OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** @fileoverview Suite of tests for extension-keyboard-shortcuts. */ | 5 /** @fileoverview Suite of tests for extension-keyboard-shortcuts. */ |
6 cr.define('extension_keyboard_shortcut_tests', function() { | 6 cr.define('extension_keyboard_shortcut_tests', function() { |
7 /** @enum {string} */ | 7 /** @enum {string} */ |
8 var TestNames = { | 8 var TestNames = { |
9 Layout: 'Layout', | 9 Layout: 'Layout', |
10 // The ShortcutUtil test suite is all js-based (no UI), so we can execute | 10 // The ShortcutUtil test suite is all js-based (no UI), so we can execute |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 var cards = | 75 var cards = |
76 keyboardShortcuts.$$('#main').querySelectorAll('.shortcut-card'); | 76 keyboardShortcuts.$$('#main').querySelectorAll('.shortcut-card'); |
77 assertEquals(2, cards.length); | 77 assertEquals(2, cards.length); |
78 | 78 |
79 var card1 = cards[0]; | 79 var card1 = cards[0]; |
80 expectEquals(oneCommand.name, | 80 expectEquals(oneCommand.name, |
81 card1.querySelector('.card-title span').textContent); | 81 card1.querySelector('.card-title span').textContent); |
82 var commands = card1.querySelectorAll('.command-entry'); | 82 var commands = card1.querySelectorAll('.command-entry'); |
83 assertEquals(1, commands.length); | 83 assertEquals(1, commands.length); |
84 expectTrue(isVisibleOnCard(commands[0], '.command-name')); | 84 expectTrue(isVisibleOnCard(commands[0], '.command-name')); |
85 expectTrue(isVisibleOnCard(commands[0], 'paper-dropdown-menu')); | 85 expectTrue(isVisibleOnCard(commands[0], 'select.md-select')); |
86 | 86 |
87 var card2 = cards[1]; | 87 var card2 = cards[1]; |
88 commands = card2.querySelectorAll('.command-entry'); | 88 commands = card2.querySelectorAll('.command-entry'); |
89 assertEquals(2, commands.length); | 89 assertEquals(2, commands.length); |
90 | |
91 expectEquals( | |
92 1, | |
93 keyboardShortcuts.computeSelectedScope_(twoCommands.commands[0])); | |
94 expectEquals( | |
95 0, | |
96 keyboardShortcuts.computeSelectedScope_(twoCommands.commands[1])); | |
97 }); | 90 }); |
98 }); | 91 }); |
99 suite(assert(TestNames.ShortcutUtil), function() { | 92 suite(assert(TestNames.ShortcutUtil), function() { |
100 test('isValidKeyCode test', function() { | 93 test('isValidKeyCode test', function() { |
101 expectTrue(extensions.isValidKeyCode('A'.charCodeAt(0))); | 94 expectTrue(extensions.isValidKeyCode('A'.charCodeAt(0))); |
102 expectTrue(extensions.isValidKeyCode('F'.charCodeAt(0))); | 95 expectTrue(extensions.isValidKeyCode('F'.charCodeAt(0))); |
103 expectTrue(extensions.isValidKeyCode('Z'.charCodeAt(0))); | 96 expectTrue(extensions.isValidKeyCode('Z'.charCodeAt(0))); |
104 expectTrue(extensions.isValidKeyCode('4'.charCodeAt(0))); | 97 expectTrue(extensions.isValidKeyCode('4'.charCodeAt(0))); |
105 expectTrue(extensions.isValidKeyCode(extensions.Key.PageUp)); | 98 expectTrue(extensions.isValidKeyCode(extensions.Key.PageUp)); |
106 expectTrue(extensions.isValidKeyCode(extensions.Key.MediaPlayPause)); | 99 expectTrue(extensions.isValidKeyCode(extensions.Key.MediaPlayPause)); |
(...skipping 17 matching lines...) Expand all Loading... |
124 expectEquals('Ctrl+Shift+A', extensions.keystrokeToString(e)); | 117 expectEquals('Ctrl+Shift+A', extensions.keystrokeToString(e)); |
125 }); | 118 }); |
126 }); | 119 }); |
127 } | 120 } |
128 | 121 |
129 return { | 122 return { |
130 registerTests: registerTests, | 123 registerTests: registerTests, |
131 TestNames: TestNames, | 124 TestNames: TestNames, |
132 }; | 125 }; |
133 }); | 126 }); |
OLD | NEW |