| 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 GEN_INCLUDE(['../../testing/snippets.js']); | 8 GEN_INCLUDE(['../../testing/snippets.js']); |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 | 36 |
| 37 window.getNonDesktopUniqueAncestors = function(node1, node2) { | 37 window.getNonDesktopUniqueAncestors = function(node1, node2) { |
| 38 return AutomationUtil.getUniqueAncestors(node1, node2) | 38 return AutomationUtil.getUniqueAncestors(node1, node2) |
| 39 .filter(filterNonDesktopRoot); | 39 .filter(filterNonDesktopRoot); |
| 40 } | 40 } |
| 41 }, | 41 }, |
| 42 | 42 |
| 43 basicDoc: function() {/*! | 43 basicDoc: function() {/*! |
| 44 <p><a href='#'></a>hello</p> | 44 <p><a href='#'></a>hello</p> |
| 45 <h1><ul><li>a</ul><button></h1> | 45 <h1><ul><li>a</ul><div role="group"><button></button></div></h1> |
| 46 */}, | 46 */}, |
| 47 | 47 |
| 48 secondDoc: function() {/*! | 48 secondDoc: function() {/*! |
| 49 <html> | 49 <html> |
| 50 <head><title>Second doc</title></head> | 50 <head><title>Second doc</title></head> |
| 51 <body><div>Second</div></body> | 51 <body><div>Second</div></body> |
| 52 </html> | 52 </html> |
| 53 */}, | 53 */}, |
| 54 | 54 |
| 55 iframeDoc: function() {/*! | 55 iframeDoc: function() {/*! |
| 56 <html> | 56 <html> |
| 57 <head><title>Second doc</title></head> | 57 <head><title>Second doc</title></head> |
| 58 <body> | 58 <body> |
| 59 <iframe src="data:text/html,<p>Inside</p>"></iframe> | 59 <iframe src="data:text/html,<p>Inside</p>"></iframe> |
| 60 </body> | 60 </body> |
| 61 </html> | 61 </html> |
| 62 */} | 62 */} |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 TEST_F('AutomationUtilE2ETest', 'GetAncestors', function() { | 65 TEST_F('AutomationUtilE2ETest', 'GetAncestors', function() { |
| 66 this.runWithLoadedTree(this.basicDoc, function(root) { | 66 this.runWithLoadedTree(this.basicDoc, function(root) { |
| 67 var expectedLength = 1; | 67 var expectedLength = 1; |
| 68 while (root) { | 68 while (root) { |
| 69 var ancestors = getNonDesktopAncestors(root); | 69 var ancestors = getNonDesktopAncestors(root); |
| 70 assertEquals(expectedLength++, ancestors.length); | 70 assertEquals(expectedLength++, ancestors.length); |
| 71 root = root.firstChild; | 71 root = root.firstChild; |
| 72 } | 72 } |
| 73 }); | 73 }); |
| 74 }); | 74 }); |
| 75 | 75 |
| 76 TEST_F('AutomationUtilE2ETest', 'GetUniqueAncestors', function() { | 76 TEST_F('AutomationUtilE2ETest', 'GetUniqueAncestors', function() { |
| 77 this.runWithLoadedTree(this.basicDoc, function(root) { | 77 this.runWithLoadedTree(this.basicDoc, function(root) { |
| 78 var leftmost = root, rightmost = root; | 78 var leftmost = root, rightmost = root; |
| 79 while (leftmost.firstChild) | 79 while (leftmost.firstChild) |
| 80 leftmost = leftmost.firstChild; | 80 leftmost = leftmost.firstChild; |
| 81 while (rightmost.lastChild) | 81 while (rightmost.lastChild) |
| 82 rightmost = rightmost.lastChild; | 82 rightmost = rightmost.lastChild; |
| 83 | 83 |
| 84 var leftAncestors = getNonDesktopAncestors(leftmost); | 84 var leftAncestors = getNonDesktopAncestors(leftmost); |
| 85 var rightAncestors = getNonDesktopAncestors(rightmost); | 85 var rightAncestors = getNonDesktopAncestors(rightmost); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1.parent))); | 170 assertEquals(h1, AutomationUtil.hitTest(r, getCP(h1.parent))); |
| 171 assertEquals(h1.parent.parent, | 171 assertEquals(h1.parent.parent, |
| 172 AutomationUtil.hitTest(r, getCP(h1.parent.parent))); | 172 AutomationUtil.hitTest(r, getCP(h1.parent.parent))); |
| 173 | 173 |
| 174 assertEquals(a, AutomationUtil.hitTest(r, getCP(a))); | 174 assertEquals(a, AutomationUtil.hitTest(r, getCP(a))); |
| 175 assertEquals(a, AutomationUtil.hitTest(r, getCP(a.parent))); | 175 assertEquals(a, AutomationUtil.hitTest(r, getCP(a.parent))); |
| 176 assertEquals(a.parent.parent, | 176 assertEquals(a.parent.parent, |
| 177 AutomationUtil.hitTest(r, getCP(a.parent.parent))); | 177 AutomationUtil.hitTest(r, getCP(a.parent.parent))); |
| 178 }); | 178 }); |
| 179 }); | 179 }); |
| OLD | NEW |