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 * Verifies that the layout matches with expectations.
9 * @param {Array.<string>} rows List of strings where each string indicates the
10 * expected sequence of characters on the corresponding row.
12 function verifyLayout(rows) {
14 rows.forEach(function(sequence) {
15 var rowId = 'row' + rowIndex++;
16 var first = sequence[0];
17 var key = findKey(first, rowId);
18 assertTrue(!!key, 'Unable to find "' + first + '" in "' + rowId + '"');
19 for (var i = 1; i < sequence.length; i++) {
20 var next = key.nextSibling;
22 'Unable to find key to right of "' + sequence[i - 1] + '"');
23 assertTrue(hasLabel(next, sequence[i]),
24 'Unexpected label: expected: "' + sequence[i] +
25 '" to follow "' + sequence[i - 1] + '"');
32 * Validates full layout for a US QWERTY keyboard.
34 function testFullQwertyLayoutAsync(testDoneCallback) {
35 var testCallback = function() {
48 verifyLayout(lowercase);
49 mockTap(findKeyById('ShiftLeft'));
50 verifyLayout(uppercase);
51 mockTap(findKeyById('ShiftRight'));
52 verifyLayout(lowercase);
61 onKeyboardReady(testCallback, config);
65 * Validates compact layout for a US QWERTY keyboard.
67 function testCompactQwertyLayoutAsync(testDoneCallback) {
68 var testCallback = function() {
86 '\u00a3\u00a2\u20ac\u00a5^\u00b0={}',
87 '\\\u00a9\u00ae\u2122\u2105[]\u00a1\u00bf'
89 verifyLayout(lowercase);
90 mockTap(findKeyById('ShiftLeft'));
91 verifyLayout(uppercase);
92 mockTap(findKey('?123'));
94 mockTap(findKey('~[<'));
96 mockTap(findKey('abc'));
97 verifyLayout(lowercase);
101 keyset: 'us.compact.qwerty',
103 passwordLayout: 'us',
106 onKeyboardReady(testCallback, config);