OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Include test fixture. |
| 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', |
| 7 '../../testing/assert_additions.js']); |
| 8 |
| 9 /** |
| 10 * Test fixture for recovery strategy tests. |
| 11 * @constructor |
| 12 * @extends {ChromeVoxNextE2ETest} |
| 13 */ |
| 14 function RecoveryStrategyTest() { |
| 15 ChromeVoxNextE2ETest.call(this); |
| 16 window.RoleType = chrome.automation.RoleType; |
| 17 } |
| 18 |
| 19 RecoveryStrategyTest.prototype = { |
| 20 __proto__: ChromeVoxNextE2ETest.prototype, |
| 21 }; |
| 22 |
| 23 TEST_F('RecoveryStrategyTest', 'ReparentedRecovery', function() { |
| 24 this.runWithLoadedTree(function() {/*! |
| 25 <input type="text"></input> |
| 26 <p id="p">hi</p> |
| 27 <button id="go"</button> |
| 28 <script> |
| 29 document.getElementById('go').addEventListener('click', function() { |
| 30 var p = document.getElementById('p'); |
| 31 p.remove(); |
| 32 document.body.appendChild(p); |
| 33 }); |
| 34 </script> |
| 35 */}, function(root) { |
| 36 var p = root.find({role: RoleType.PARAGRAPH}); |
| 37 var s = root.find({role: RoleType.STATIC_TEXT}); |
| 38 var b = root.find({role: RoleType.BUTTON}); |
| 39 var bAncestryRecovery = new AncestryRecoveryStrategy(b); |
| 40 var pAncestryRecovery = new AncestryRecoveryStrategy(p); |
| 41 var sAncestryRecovery = new AncestryRecoveryStrategy(s); |
| 42 var bTreePathRecovery = new TreePathRecoveryStrategy(b); |
| 43 var pTreePathRecovery = new TreePathRecoveryStrategy(p); |
| 44 var sTreePathRecovery = new TreePathRecoveryStrategy(s); |
| 45 this.listenOnce(b, 'clicked', function() { |
| 46 assertFalse(bAncestryRecovery.requiresRecovery()); |
| 47 assertTrue(pAncestryRecovery.requiresRecovery()); |
| 48 assertTrue(sAncestryRecovery.requiresRecovery()); |
| 49 assertFalse(bTreePathRecovery.requiresRecovery()); |
| 50 assertTrue(pTreePathRecovery.requiresRecovery()); |
| 51 assertTrue(sTreePathRecovery.requiresRecovery()); |
| 52 |
| 53 assertEquals(RoleType.BUTTON, bAncestryRecovery.node.role); |
| 54 assertEquals(root, pAncestryRecovery.node); |
| 55 assertEquals(root, sAncestryRecovery.node); |
| 56 |
| 57 assertEquals(b, bTreePathRecovery.node); |
| 58 assertEquals(b, pTreePathRecovery.node); |
| 59 assertEquals(b, sTreePathRecovery.node); |
| 60 |
| 61 assertFalse(bAncestryRecovery.requiresRecovery()); |
| 62 assertFalse(pAncestryRecovery.requiresRecovery()); |
| 63 assertFalse(sAncestryRecovery.requiresRecovery()); |
| 64 assertFalse(bTreePathRecovery.requiresRecovery()); |
| 65 assertFalse(pTreePathRecovery.requiresRecovery()); |
| 66 assertFalse(sTreePathRecovery.requiresRecovery()); |
| 67 }); |
| 68 // Trigger the change. |
| 69 b.doDefault(); |
| 70 }); |
| 71 }); |
OLD | NEW |