| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Include test fixture. | 5 // Include test fixture. |
| 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); | 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Test fixture for automation_util.js. | 9 * Test fixture for automation_util.js. |
| 10 * @constructor | 10 * @constructor |
| 11 * @extends {ChromeVoxE2ETestBase} | 11 * @extends {ChromeVoxE2ETestBase} |
| 12 */ | 12 */ |
| 13 function AutomationUtilE2ETest() {} | 13 function AutomationUtilE2ETest() {} |
| 14 | 14 |
| 15 AutomationUtilE2ETest.prototype = { | 15 AutomationUtilE2ETest.prototype = { |
| 16 __proto__: ChromeVoxNextE2ETest.prototype, | 16 __proto__: ChromeVoxNextE2ETest.prototype, |
| 17 | 17 |
| 18 /** @override */ | 18 /** @override */ |
| 19 setUp: function() { | 19 setUp: function() { |
| 20 window.Dir = AutomationUtil.Dir; | 20 window.Dir = AutomationUtil.Dir; |
| 21 }, | 21 }, |
| 22 | 22 |
| 23 basicDoc: function() {/*! | 23 basicDoc: function() {/*! |
| 24 <p><a href='#'></a>hello</p> | 24 <p><a href='#'></a>hello</p> |
| 25 <h1><ul><li>a</ul><button></h1> | 25 <h1><ul><li>a</ul><button></h1> |
| 26 */} | 26 */} |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 TEST_F('AutomationUtilE2ETest', 'GetAncestors', function() { | 29 TEST_F('AutomationUtilE2ETest', 'GetAncestors', function() { |
| 30 this.runWithLoadedTree(this.basicDoc, | 30 this.runWithAutomation(this.basicDoc, |
| 31 function(root) { | 31 function(root) { |
| 32 var expectedLength = 1; | 32 var expectedLength = 1; |
| 33 while (root) { | 33 while (root) { |
| 34 var ancestors = AutomationUtil.getAncestors(root); | 34 var ancestors = AutomationUtil.getAncestors(root); |
| 35 assertEquals(expectedLength++, ancestors.length); | 35 assertEquals(expectedLength++, ancestors.length); |
| 36 root = root.firstChild; | 36 root = root.firstChild; |
| 37 } | 37 } |
| 38 testDone(); | 38 testDone(); |
| 39 }.bind(this)); | 39 }.bind(this)); |
| 40 }); | 40 }); |
| 41 | 41 |
| 42 TEST_F('AutomationUtilE2ETest', 'GetUniqueAncestors', function() { | 42 TEST_F('AutomationUtilE2ETest', 'GetUniqueAncestors', function() { |
| 43 this.runWithLoadedTree(this.basicDoc, function(root) { | 43 this.runWithAutomation(this.basicDoc, function(root) { |
| 44 var leftmost = root, rightmost = root; | 44 var leftmost = root, rightmost = root; |
| 45 while (leftmost.firstChild) | 45 while (leftmost.firstChild) |
| 46 leftmost = leftmost.firstChild; | 46 leftmost = leftmost.firstChild; |
| 47 while (rightmost.lastChild) | 47 while (rightmost.lastChild) |
| 48 rightmost = rightmost.lastChild; | 48 rightmost = rightmost.lastChild; |
| 49 | 49 |
| 50 var leftAncestors = AutomationUtil.getAncestors(leftmost); | 50 var leftAncestors = AutomationUtil.getAncestors(leftmost); |
| 51 var rightAncestors = AutomationUtil.getAncestors(rightmost); | 51 var rightAncestors = AutomationUtil.getAncestors(rightmost); |
| 52 assertEquals(chrome.automation.RoleType.link, leftmost.role); | 52 assertEquals(chrome.automation.RoleType.link, leftmost.role); |
| 53 assertEquals(chrome.automation.RoleType.button, rightmost.role); | 53 assertEquals(chrome.automation.RoleType.button, rightmost.role); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 76 uniqueAncestorsRight[2].role); | 76 uniqueAncestorsRight[2].role); |
| 77 | 77 |
| 78 assertEquals( | 78 assertEquals( |
| 79 1, AutomationUtil.getUniqueAncestors(leftmost, leftmost).length); | 79 1, AutomationUtil.getUniqueAncestors(leftmost, leftmost).length); |
| 80 | 80 |
| 81 testDone(); | 81 testDone(); |
| 82 }.bind(this)); | 82 }.bind(this)); |
| 83 }); | 83 }); |
| 84 | 84 |
| 85 TEST_F('AutomationUtilE2ETest', 'GetDirection', function() { | 85 TEST_F('AutomationUtilE2ETest', 'GetDirection', function() { |
| 86 this.runWithLoadedTree(this.basicDoc, function(root) { | 86 this.runWithAutomation(this.basicDoc, function(root) { |
| 87 var left = root, right = root; | 87 var left = root, right = root; |
| 88 | 88 |
| 89 // Same node. | 89 // Same node. |
| 90 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right)); | 90 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right)); |
| 91 | 91 |
| 92 // Ancestor. | 92 // Ancestor. |
| 93 left = left.firstChild; | 93 left = left.firstChild; |
| 94 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right)); | 94 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right)); |
| 95 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(right, left)); | 95 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(right, left)); |
| 96 | 96 |
| 97 // Ordered. | 97 // Ordered. |
| 98 right = right.lastChild; | 98 right = right.lastChild; |
| 99 assertEquals(Dir.BACKWARD, AutomationUtil.getDirection(right, left)); | 99 assertEquals(Dir.BACKWARD, AutomationUtil.getDirection(right, left)); |
| 100 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right)); | 100 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right)); |
| 101 | 101 |
| 102 testDone(); | 102 testDone(); |
| 103 }.bind(this)); | 103 }.bind(this)); |
| 104 }); | 104 }); |
| OLD | NEW |