Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chrome / test / data / chromeos / virtual_keyboard / typing_test.js
blobc05264a8cd5f63eb177bc4917e1f1635ce5bf97b
1 /*
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
4 * found in the LICENSE file.
5 */
7 /**
8 * Tests that typing characters on the default lowercase keyboard triggers the
9 * correct sequence of events. The test is run asynchronously since the
10 * keyboard loads keysets dynamically.
12 function testLowercaseKeysetAsync(testDoneCallback) {
13 onKeyboardReady(function() {
14 // Keyboard defaults to lowercase.
15 mockTypeCharacter('a', 0x41, Modifier.NONE);
16 mockTypeCharacter('s', 0x53, Modifier.NONE);
17 mockTypeCharacter('.', 0, Modifier.NONE);
18 mockTypeCharacter('Enter', 0x0D, Modifier.NONE, 0x0D);
19 mockTypeCharacter('Space', 0, Modifier.NONE, 0x20);
20 testDoneCallback();
21 });
24 /**
25 * When typing quickly, one can often press a second key before releasing the
26 * first. This test confirms that both keys are typed in the correct order.
28 function testStaggeredTypingAsync(testDoneCallback) {
29 onKeyboardReady(function() {
30 var firstKey = findKey('a');
31 var secondKey = findKey('s');
32 var send = chrome.virtualKeyboardPrivate.sendKeyEvent;
33 var addExpectationsForKeyTap = function(character) {
34 var unicodeValue = character.charCodeAt(0);
35 // keyCode conversion assumes typing a lowercase alpha character.
36 var keyCode = unicodeValue - 0x20;
37 send.addExpectation({
38 type: 'keydown',
39 charValue: unicodeValue,
40 keyCode: keyCode,
41 modifiers: Modifier.NONE
42 });
43 send.addExpectation({
44 type: 'keyup',
45 charValue: unicodeValue,
46 keyCode: keyCode,
47 modifiers: Modifier.NONE
48 });
50 mockTouchEvent(firstKey, 'touchstart');
51 mockTouchEvent(secondKey, 'touchstart');
52 mockTouchEvent(firstKey, 'touchend');
53 mockTouchEvent(secondKey, 'touchend');
54 addExpectationsForKeyTap('a');
55 addExpectationsForKeyTap('s');
56 testDoneCallback();
57 });