Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/recovery_strategy_test.extjs |
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/recovery_strategy_test.extjs b/chrome/browser/resources/chromeos/chromevox/cvox2/background/recovery_strategy_test.extjs |
new file mode 100644 |
index 0000000000000000000000000000000000000000..41d70a1377628993ccf908d506ee8a9fb489d5a6 |
--- /dev/null |
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/recovery_strategy_test.extjs |
@@ -0,0 +1,71 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Include test fixture. |
+GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', |
+ '../../testing/assert_additions.js']); |
+ |
+/** |
+ * Test fixture for recovery strategy tests. |
+ * @constructor |
+ * @extends {ChromeVoxNextE2ETest} |
+ */ |
+function RecoveryStrategyTest() { |
+ ChromeVoxNextE2ETest.call(this); |
+ window.RoleType = chrome.automation.RoleType; |
+} |
+ |
+RecoveryStrategyTest.prototype = { |
+ __proto__: ChromeVoxNextE2ETest.prototype, |
+}; |
+ |
+TEST_F('RecoveryStrategyTest', 'ReparentedRecovery', function() { |
+ this.runWithLoadedTree(function() {/*! |
+ <input type="text"></input> |
+ <p id="p">hi</p> |
+ <button id="go"</button> |
+ <script> |
+ document.getElementById('go').addEventListener('click', function() { |
+ var p = document.getElementById('p'); |
+ p.remove(); |
+ document.body.appendChild(p); |
+ }); |
+ </script> |
+ */}, function(root) { |
+ var p = root.find({role: RoleType.PARAGRAPH}); |
+ var s = root.find({role: RoleType.STATIC_TEXT}); |
+ var b = root.find({role: RoleType.BUTTON}); |
+ var bAncestryRecovery = new AncestryRecoveryStrategy(b); |
+ var pAncestryRecovery = new AncestryRecoveryStrategy(p); |
+ var sAncestryRecovery = new AncestryRecoveryStrategy(s); |
+ var bTreePathRecovery = new TreePathRecoveryStrategy(b); |
+ var pTreePathRecovery = new TreePathRecoveryStrategy(p); |
+ var sTreePathRecovery = new TreePathRecoveryStrategy(s); |
+ this.listenOnce(b, 'clicked', function() { |
+ assertFalse(bAncestryRecovery.requiresRecovery()); |
+ assertTrue(pAncestryRecovery.requiresRecovery()); |
+ assertTrue(sAncestryRecovery.requiresRecovery()); |
+ assertFalse(bTreePathRecovery.requiresRecovery()); |
+ assertTrue(pTreePathRecovery.requiresRecovery()); |
+ assertTrue(sTreePathRecovery.requiresRecovery()); |
+ |
+ assertEquals(RoleType.BUTTON, bAncestryRecovery.node.role); |
+ assertEquals(root, pAncestryRecovery.node); |
+ assertEquals(root, sAncestryRecovery.node); |
+ |
+ assertEquals(b, bTreePathRecovery.node); |
+ assertEquals(b, pTreePathRecovery.node); |
+ assertEquals(b, sTreePathRecovery.node); |
+ |
+ assertFalse(bAncestryRecovery.requiresRecovery()); |
+ assertFalse(pAncestryRecovery.requiresRecovery()); |
+ assertFalse(sAncestryRecovery.requiresRecovery()); |
+ assertFalse(bTreePathRecovery.requiresRecovery()); |
+ assertFalse(pTreePathRecovery.requiresRecovery()); |
+ assertFalse(sTreePathRecovery.requiresRecovery()); |
+ }); |
+ // Trigger the change. |
+ b.doDefault(); |
+ }); |
+}); |