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

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

Issue 98073012: Add unit test for lock and unlock virtual keyboard feature (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months 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 | Annotate | Revision Log
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;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 270 }
271 var waitCondition = this.queue[0].waitCondition; 271 var waitCondition = this.queue[0].waitCondition;
272 var keyset = $('keyboard').activeKeyset; 272 var keyset = $('keyboard').activeKeyset;
273 var id = keyset.id; 273 var id = keyset.id;
274 var continueWaiting = true; 274 var continueWaiting = true;
275 if (waitCondition.state == 'keysetChanged') { 275 if (waitCondition.state == 'keysetChanged') {
276 if (id == waitCondition.value) { 276 if (id == waitCondition.value) {
277 continueWaiting = false; 277 continueWaiting = false;
278 this.runNextTest(); 278 this.runNextTest();
279 } 279 }
280 } else if (waitCondition.state = 'candidatePopupVisibility') { 280 } else if (waitCondition.state == 'candidatePopupVisibility') {
281 var popup = keyset.querySelector('kb-altkey-container'); 281 var popup = keyset.querySelector('kb-altkey-container');
282 if (popup && popup.hidden == !waitCondition.value) { 282 if (popup && popup.hidden == !waitCondition.value) {
283 continueWaiting = false; 283 continueWaiting = false;
284 this.runNextTest(); 284 this.runNextTest();
285 } 285 }
286 } else if (waitCondition.state == 'overlayVisibility') {
287 var popup =
288 $('keyboard').shadowRoot.querySelector('kb-keyboard-overlay');
289 if (popup && popup.hidden == !waitCondition.value) {
290 continueWaiting = false;
291 this.runNextTest();
292 }
286 } 293 }
287 if (continueWaiting) { 294 if (continueWaiting) {
288 Debug('waiting on ' + waitCondition.state + ' = ' + 295 Debug('waiting on ' + waitCondition.state + ' = ' +
289 waitCondition.value); 296 waitCondition.value);
290 } 297 }
291 }, 298 },
292 299
293 runNextTest: function() { 300 runNextTest: function() {
294 var testFailure = false; 301 var testFailure = false;
295 var callback = this.queue[0].testCallback; 302 var callback = this.queue[0].testCallback;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 346
340 mockTimer.install(); 347 mockTimer.install();
341 348
342 mockController.createFunctionMock(chrome.virtualKeyboardPrivate, 349 mockController.createFunctionMock(chrome.virtualKeyboardPrivate,
343 'insertText'); 350 'insertText');
344 351
345 mockController.createFunctionMock(chrome.virtualKeyboardPrivate, 352 mockController.createFunctionMock(chrome.virtualKeyboardPrivate,
346 'sendKeyEvent'); 353 'sendKeyEvent');
347 354
348 mockController.createFunctionMock(chrome.virtualKeyboardPrivate, 355 mockController.createFunctionMock(chrome.virtualKeyboardPrivate,
356 'lockKeyboard');
357 mockController.createFunctionMock(chrome.virtualKeyboardPrivate,
349 'hideKeyboard'); 358 'hideKeyboard');
350 mockController.createFunctionMock(chrome.virtualKeyboardPrivate, 359 mockController.createFunctionMock(chrome.virtualKeyboardPrivate,
351 'moveCursor'); 360 'moveCursor');
352 361
353 var validateSendCall = function(index, expected, observed) { 362 var validateSendCall = function(index, expected, observed) {
354 // Only consider the first argument (VirtualKeyEvent) for the validation of 363 // Only consider the first argument (VirtualKeyEvent) for the validation of
355 // sendKeyEvent calls. 364 // sendKeyEvent calls.
356 var expectedEvent = expected[0]; 365 var expectedEvent = expected[0];
357 var observedEvent = observed[0]; 366 var observedEvent = observed[0];
358 assertEquals(expectedEvent.type, 367 assertEquals(expectedEvent.type,
359 observedEvent.type, 368 observedEvent.type,
360 'Mismatched event types.'); 369 'Mismatched event types.');
361 assertEquals(expectedEvent.charValue, 370 assertEquals(expectedEvent.charValue,
362 observedEvent.charValue, 371 observedEvent.charValue,
363 'Mismatched unicode values for character.'); 372 'Mismatched unicode values for character.');
364 assertEquals(expectedEvent.keyCode, 373 assertEquals(expectedEvent.keyCode,
365 observedEvent.keyCode, 374 observedEvent.keyCode,
366 'Mismatched key codes.'); 375 'Mismatched key codes.');
367 assertEquals(expectedEvent.modifiers, 376 assertEquals(expectedEvent.modifiers,
368 observedEvent.modifiers, 377 observedEvent.modifiers,
369 'Mismatched states for modifiers.'); 378 'Mismatched states for modifiers.');
370 }; 379 };
371 chrome.virtualKeyboardPrivate.sendKeyEvent.validateCall = validateSendCall; 380 chrome.virtualKeyboardPrivate.sendKeyEvent.validateCall = validateSendCall;
372 381
382 var validateLockKeyboard = function(index, expected, observed) {
383 assertEquals(expected[0],
384 observed[0],
385 'Mismatched keyboard lock/unlock state.');
386 };
387 chrome.virtualKeyboardPrivate.lockKeyboard.validateCall =
388 validateLockKeyboard;
389
373 chrome.virtualKeyboardPrivate.hideKeyboard.validateCall = function() { 390 chrome.virtualKeyboardPrivate.hideKeyboard.validateCall = function() {
374 // hideKeyboard has one optional argument for error logging that does not 391 // hideKeyboard has one optional argument for error logging that does not
375 // matter for the purpose of validating the call. 392 // matter for the purpose of validating the call.
376 }; 393 };
377 394
378 var validateMoveCursor = function(index, expected, observed) { 395 var validateMoveCursor = function(index, expected, observed) {
379 assertEquals(expected[0], observed[0], "Mismatched swipe directions."); 396 assertEquals(expected[0], observed[0], 'Mismatched swipe directions.');
380 assertEquals(expected[1], observed[1], "Mismatched swipe flags."); 397 assertEquals(expected[1], observed[1], 'Mismatched swipe flags.');
381 } 398 };
382 chrome.virtualKeyboardPrivate.moveCursor.validateCall = validateMoveCursor; 399 chrome.virtualKeyboardPrivate.moveCursor.validateCall = validateMoveCursor;
383 400
384 // TODO(kevers): Mock additional extension API calls as required. 401 // TODO(kevers): Mock additional extension API calls as required.
385 } 402 }
386 403
387 /** 404 /**
388 * Verify that API calls match expectations. 405 * Verify that API calls match expectations.
389 */ 406 */
390 function tearDown() { 407 function tearDown() {
391 mockController.verifyMocks(); 408 mockController.verifyMocks();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 * the keyboard to load a new keyset before running. 487 * the keyboard to load a new keyset before running.
471 */ 488 */
472 function waitOnKeyset(keysetName, testName, runTestCallback, testDoneCallback, 489 function waitOnKeyset(keysetName, testName, runTestCallback, testDoneCallback,
473 opt_testSubtasks) { 490 opt_testSubtasks) {
474 runTestCallback.testName = testName; 491 runTestCallback.testName = testName;
475 runTestCallback.onTestComplete = testDoneCallback; 492 runTestCallback.onTestComplete = testDoneCallback;
476 runTestCallback.subtasks = opt_testSubtasks; 493 runTestCallback.subtasks = opt_testSubtasks;
477 testRunner.scheduleTest(runTestCallback, 494 testRunner.scheduleTest(runTestCallback,
478 {state: 'keysetChanged', value: keysetName}); 495 {state: 'keysetChanged', value: keysetName});
479 } 496 }
OLDNEW
« no previous file with comments | « chrome/test/data/chromeos/virtual_keyboard/typing_test.js ('k') | ui/keyboard/resources/elements/kb-key.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698