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 /** @fileoverview Tests for settings-action-menu element. */ | 5 /** @fileoverview Tests for cr-action-menu element. */ |
| 6 suite('SettingsActionMenu', function() { | 6 suite('CrActionMenu', function() { |
| 7 /** @type {?SettingsActionMenuElement} */ | 7 /** @type {?CrActionMenuElement} */ |
| 8 var menu = null; | 8 var menu = null; |
| 9 | 9 |
| 10 /** @type {?NodeList<HTMLElement>} */ | 10 /** @type {?NodeList<HTMLElement>} */ |
| 11 var items = null; | 11 var items = null; |
| 12 | 12 |
| 13 setup(function() { | 13 setup(function() { |
| 14 PolymerTest.clearBody(); | 14 PolymerTest.clearBody(); |
| 15 | 15 |
| 16 document.body.innerHTML = ` | 16 document.body.innerHTML = ` |
| 17 <button id="dots">...</button> | 17 <button id="dots">...</button> |
| 18 <dialog is="settings-action-menu"> | 18 <dialog is="cr-action-menu"> |
| 19 <button class="dropdown-item">Un</button> | 19 <button class="dropdown-item">Un</button> |
| 20 <hr> | 20 <hr> |
| 21 <button class="dropdown-item">Dos</button> | 21 <button class="dropdown-item">Dos</button> |
| 22 <button class="dropdown-item">Tres</button> | 22 <button class="dropdown-item">Tres</button> |
| 23 </dialog> | 23 </dialog> |
| 24 `; | 24 `; |
| 25 | 25 |
| 26 menu = document.querySelector('dialog[is=settings-action-menu]'); | 26 menu = document.querySelector('dialog[is=cr-action-menu]'); |
| 27 items = menu.querySelectorAll('.dropdown-item'); | 27 items = menu.querySelectorAll('.dropdown-item'); |
| 28 assertEquals(3, items.length); | 28 assertEquals(3, items.length); |
| 29 }); | 29 }); |
| 30 | 30 |
| 31 teardown(function() { | 31 teardown(function() { |
| 32 if (menu.open) | 32 if (menu.open) |
| 33 menu.close(); | 33 menu.close(); |
| 34 }); | 34 }); |
| 35 | 35 |
| 36 test('focus after showing', function() { | 36 test('focus after showing', function() { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 window.dispatchEvent(new CustomEvent('resize')); | 92 window.dispatchEvent(new CustomEvent('resize')); |
| 93 assertFalse(menu.open); | 93 assertFalse(menu.open); |
| 94 }); | 94 }); |
| 95 | 95 |
| 96 test('close on Tab', function() { | 96 test('close on Tab', function() { |
| 97 menu.showAt(document.querySelector('#dots')); | 97 menu.showAt(document.querySelector('#dots')); |
| 98 assertTrue(menu.open); | 98 assertTrue(menu.open); |
| 99 | 99 |
| 100 MockInteractions.keyDownOn(menu, 'Tab', [], 'Tab'); | 100 MockInteractions.keyDownOn(menu, 'Tab', [], 'Tab'); |
| 101 assertFalse(menu.open); | 101 assertFalse(menu.open); |
| 102 }); | 102 }); |
|
Dan Beam
2016/11/01 18:13:00
how do you plan to test RTL now that you're using
dpapad
2016/11/01 18:31:03
My thinking was the following:
Currently we don't
| |
| 103 }); | 103 }); |
| OLD | NEW |