Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: chrome/test/data/chromeos/virtual_keyboard/virtual_keyboard_test_base.js

Issue 99923003: Adds unit tests for swipe flick. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@flickv2
Patch Set: Fixed the nit. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The Chromium Authors. All rights reserved. 2 * Copyright 2013 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /** 7 /**
8 * Set to true while debugging virtual keyboard tests, for verbose debug output. 8 * Set to true while debugging virtual keyboard tests, for verbose debug output.
9 */ 9 */
10 var debugging = false; 10 var debugging = false;
11 11
12 /** 12 /**
13 * Display diagnostic messages when debugging tests. 13 * Display diagnostic messages when debugging tests.
14 * @param {string} Message to conditionally display. 14 * @param {string} Message to conditionally display.
15 */ 15 */
16 function Debug(message) { 16 function Debug(message) {
17 if (debugging) 17 if (debugging)
18 console.log(message); 18 console.log(message);
19 } 19 }
20 20
21 /** 21 /**
22 * The enumeration of swipe directions.
23 * @const
24 * @enum {number}
25 */
26 var SwipeDirection = {
27 RIGHT: 0x1,
28 LEFT: 0x2,
29 UP: 0x4,
30 DOWN: 0x8
31 };
32
33 /**
22 * Layouts used in testing. 34 * Layouts used in testing.
23 * @enum {string} 35 * @enum {string}
24 */ 36 */
25 var Layout = { 37 var Layout = {
26 DEFAULT: 'qwerty', 38 DEFAULT: 'qwerty',
27 SYSTEM: 'system-qwerty', 39 SYSTEM: 'system-qwerty',
28 KEYPAD: 'numeric' 40 KEYPAD: 'numeric'
29 } 41 }
30 42
31 /** 43 /**
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 mockTimer.install(); 340 mockTimer.install();
329 341
330 mockController.createFunctionMock(chrome.virtualKeyboardPrivate, 342 mockController.createFunctionMock(chrome.virtualKeyboardPrivate,
331 'insertText'); 343 'insertText');
332 344
333 mockController.createFunctionMock(chrome.virtualKeyboardPrivate, 345 mockController.createFunctionMock(chrome.virtualKeyboardPrivate,
334 'sendKeyEvent'); 346 'sendKeyEvent');
335 347
336 mockController.createFunctionMock(chrome.virtualKeyboardPrivate, 348 mockController.createFunctionMock(chrome.virtualKeyboardPrivate,
337 'hideKeyboard'); 349 'hideKeyboard');
350 mockController.createFunctionMock(chrome.virtualKeyboardPrivate,
351 'moveCursor');
338 352
339 var validateSendCall = function(index, expected, observed) { 353 var validateSendCall = function(index, expected, observed) {
340 // Only consider the first argument (VirtualKeyEvent) for the validation of 354 // Only consider the first argument (VirtualKeyEvent) for the validation of
341 // sendKeyEvent calls. 355 // sendKeyEvent calls.
342 var expectedEvent = expected[0]; 356 var expectedEvent = expected[0];
343 var observedEvent = observed[0]; 357 var observedEvent = observed[0];
344 assertEquals(expectedEvent.type, 358 assertEquals(expectedEvent.type,
345 observedEvent.type, 359 observedEvent.type,
346 'Mismatched event types.'); 360 'Mismatched event types.');
347 assertEquals(expectedEvent.charValue, 361 assertEquals(expectedEvent.charValue,
348 observedEvent.charValue, 362 observedEvent.charValue,
349 'Mismatched unicode values for character.'); 363 'Mismatched unicode values for character.');
350 assertEquals(expectedEvent.keyCode, 364 assertEquals(expectedEvent.keyCode,
351 observedEvent.keyCode, 365 observedEvent.keyCode,
352 'Mismatched key codes.'); 366 'Mismatched key codes.');
353 assertEquals(expectedEvent.modifiers, 367 assertEquals(expectedEvent.modifiers,
354 observedEvent.modifiers, 368 observedEvent.modifiers,
355 'Mismatched states for modifiers.'); 369 'Mismatched states for modifiers.');
356 }; 370 };
357 chrome.virtualKeyboardPrivate.sendKeyEvent.validateCall = validateSendCall; 371 chrome.virtualKeyboardPrivate.sendKeyEvent.validateCall = validateSendCall;
358 372
359 chrome.virtualKeyboardPrivate.hideKeyboard.validateCall = function() { 373 chrome.virtualKeyboardPrivate.hideKeyboard.validateCall = function() {
360 // hideKeyboard has one optional argument for error logging that does not 374 // hideKeyboard has one optional argument for error logging that does not
361 // matter for the purpose of validating the call. 375 // matter for the purpose of validating the call.
362 }; 376 };
363 377
378 var validateMoveCursor = function(index, expected, observed) {
379 assertEquals(expected[0], observed[0], "Mismatched swipe directions.");
380 assertEquals(expected[1], observed[1], "Mismatched swipe flags.");
381 }
382 chrome.virtualKeyboardPrivate.moveCursor.validateCall = validateMoveCursor;
383
364 // TODO(kevers): Mock additional extension API calls as required. 384 // TODO(kevers): Mock additional extension API calls as required.
365 } 385 }
366 386
367 /** 387 /**
368 * Verify that API calls match expectations. 388 * Verify that API calls match expectations.
369 */ 389 */
370 function tearDown() { 390 function tearDown() {
371 mockController.verifyMocks(); 391 mockController.verifyMocks();
372 mockController.reset(); 392 mockController.reset();
373 mockTimer.uninstall(); 393 mockTimer.uninstall();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 * the keyboard to load a new keyset before running. 470 * the keyboard to load a new keyset before running.
451 */ 471 */
452 function waitOnKeyset(keysetName, testName, runTestCallback, testDoneCallback, 472 function waitOnKeyset(keysetName, testName, runTestCallback, testDoneCallback,
453 opt_testSubtasks) { 473 opt_testSubtasks) {
454 runTestCallback.testName = testName; 474 runTestCallback.testName = testName;
455 runTestCallback.onTestComplete = testDoneCallback; 475 runTestCallback.onTestComplete = testDoneCallback;
456 runTestCallback.subtasks = opt_testSubtasks; 476 runTestCallback.subtasks = opt_testSubtasks;
457 testRunner.scheduleTest(runTestCallback, 477 testRunner.scheduleTest(runTestCallback,
458 {state: 'keysetChanged', value: keysetName}); 478 {state: 'keysetChanged', value: keysetName});
459 } 479 }
OLDNEW
« no previous file with comments | « chrome/test/data/chromeos/virtual_keyboard/typing_test.js ('k') | ui/keyboard/resources/elements/kb-keyboard.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698