Chromium Code Reviews| 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 /** | 5 /** |
| 6 * @fileoverview Tests for cr-action-menu element. Runs as an interactive UI | 6 * @fileoverview Tests for cr-action-menu element. Runs as an interactive UI |
| 7 * test, since many of these tests check focus behavior. | 7 * test, since many of these tests check focus behavior. |
| 8 */ | 8 */ |
| 9 suite('CrActionMenu', function() { | 9 suite('CrActionMenu', function() { |
| 10 /** @type {?CrActionMenuElement} */ | 10 /** @type {?CrActionMenuElement} */ |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 dots.addEventListener('focus', resolve); | 120 dots.addEventListener('focus', resolve); |
| 121 MockInteractions.keyDownOn(menu, key, [], key); | 121 MockInteractions.keyDownOn(menu, key, [], key); |
| 122 assertFalse(menu.open); | 122 assertFalse(menu.open); |
| 123 }); | 123 }); |
| 124 } | 124 } |
| 125 | 125 |
| 126 test('close on Tab', function() { return testFocusAfterClosing('Tab'); }); | 126 test('close on Tab', function() { return testFocusAfterClosing('Tab'); }); |
| 127 test('close on Escape', function() { | 127 test('close on Escape', function() { |
| 128 return testFocusAfterClosing('Escape'); | 128 return testFocusAfterClosing('Escape'); |
| 129 }); | 129 }); |
| 130 | |
| 131 test('mouse movement focus options', function() { | |
| 132 menu.showAt(document.querySelector('#dots')); | |
| 133 | |
| 134 // Moving mouse on option 1 should focus it | |
| 135 assertNotEquals(items[0], menu.root.activeElement); | |
| 136 MockInteractions.move(items[0], {x: 0, y: 0}, {x: 1, y: 1}); | |
|
scottchen
2017/04/04 23:07:27
BTW, I'm aware .move is not exposed in MockInterac
| |
| 137 menu.flushDebouncer('cr-action-menu-mousemove'); | |
| 138 assertEquals(items[0], menu.root.activeElement); | |
| 139 | |
| 140 // Moving mouse on the menu (not on option) should focus the menu | |
| 141 MockInteractions.move(menu, {x: 0, y: 0}, {x: 1, y: 1}); | |
| 142 menu.flushDebouncer('cr-action-menu-mousemove'); | |
| 143 assertNotEquals(items[0], menu.root.activeElement); | |
| 144 assertEquals(menu, document.activeElement); | |
| 145 | |
| 146 // Mouse movements should override keyboard focus | |
| 147 down(); | |
| 148 down(); | |
| 149 assertEquals(items[1], menu.root.activeElement); | |
| 150 MockInteractions.move(items[0], {x: 0, y: 0}, {x: 1, y: 1}); | |
| 151 menu.flushDebouncer('cr-action-menu-mousemove'); | |
| 152 assertEquals(items[0], menu.root.activeElement); | |
| 153 }); | |
| 130 }); | 154 }); |
| OLD | NEW |