2 * Copyright 2014 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 * Test that the Control modifier key is sticky.
10 function testControlKeyStickyAsync(testDoneCallback) {
11 var testCallback = function() {
12 mockTap(findKeyById('ControlLeft'));
13 mockTypeCharacter('a', 0x41, Modifier.CONTROL, 0);
15 // Ensure that the control key is no longer sticking. i.e. Ensure that
16 // typing 'a' on its own results in only 'a'.
17 mockTypeCharacter('a', 0x41, Modifier.NONE);
27 onKeyboardReady(testCallback, config);
31 * Test that holding down a modifier key will apply it to all character keys
32 * until it is released.
34 function testChordedControlKeyAsync(testDoneCallback) {
35 var testCallback = function() {
36 var controlKey = findKeyById('ControlLeft');
37 mockTouchEvent(controlKey, 'touchstart');
39 // Expect the first chorded press of Ctrl+a to work.
40 mockTypeCharacter('a', 0x41, Modifier.CONTROL, 0);
42 // Expect following chorded presses to work as well.
43 mockTypeCharacter('a', 0x41, Modifier.CONTROL, 0);
45 // Expect a regular tap of a key after chording ends.
46 mockTouchEvent(controlKey, 'touchend');
47 mockTypeCharacter('a', 0x41, Modifier.NONE);
56 onKeyboardReady(testCallback, config);
60 * Test that multiple sticky keys stack until a character is typed.
62 function testMultipleStickyModifiersAsync(testDoneCallback) {
63 var testCallback = function() {
64 mockTap(findKeyById('ControlLeft'));
65 mockTap(findKeyById('AltLeft'));
66 mockTap(findKeyById('ShiftLeft'));
67 mockTypeCharacter('A', 0x41,
68 Modifier.CONTROL | Modifier.ALT | Modifier.SHIFT,
71 // Keys should un-stick on a subsequent press.
72 mockTypeCharacter('a', 0x41, Modifier.NONE);
81 onKeyboardReady(testCallback, config);
85 * Test that the second tap on a sticky key disables it.
87 function testDoubleTapUnstickAsync(testDoneCallback) {
88 var testCallback = function() {
89 mockTap(findKeyById('ControlLeft'));
90 mockTap(findKeyById('ControlLeft'));
91 mockTypeCharacter('a', 0x41, Modifier.NONE);
100 onKeyboardReady(testCallback, config);