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.
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);
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;
39 charValue: unicodeValue,
41 modifiers: Modifier.NONE
45 charValue: unicodeValue,
47 modifiers: Modifier.NONE
50 mockTouchEvent(firstKey, 'touchstart');
51 mockTouchEvent(secondKey, 'touchstart');
52 mockTouchEvent(firstKey, 'touchend');
53 mockTouchEvent(secondKey, 'touchend');
54 addExpectationsForKeyTap('a');
55 addExpectationsForKeyTap('s');