Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util_test.extjs

Issue 938623003: Fix ChromeVox next tests to fail instead of timing out where applicable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify async callback handling in the tests. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 ChromeVoxNextE2ETest.call(this);
15 }
14 16
15 AutomationUtilE2ETest.prototype = { 17 AutomationUtilE2ETest.prototype = {
16 __proto__: ChromeVoxNextE2ETest.prototype, 18 __proto__: ChromeVoxNextE2ETest.prototype,
17 19
18 /** @override */ 20 /** @override */
19 setUp: function() { 21 setUp: function() {
20 window.Dir = AutomationUtil.Dir; 22 window.Dir = AutomationUtil.Dir;
21 }, 23 },
22 24
23 basicDoc: function() {/*! 25 basicDoc: function() {/*!
24 <p><a href='#'></a>hello</p> 26 <p><a href='#'></a>hello</p>
25 <h1><ul><li>a</ul><button></h1> 27 <h1><ul><li>a</ul><button></h1>
26 */} 28 */}
27 }; 29 };
28 30
29 TEST_F('AutomationUtilE2ETest', 'GetAncestors', function() { 31 TEST_F('AutomationUtilE2ETest', 'GetAncestors', function() {
30 this.runWithLoadedTree(this.basicDoc, 32 this.runWithLoadedTree(this.basicDoc, function(root) {
31 function(root) { 33 var expectedLength = 1;
32 var expectedLength = 1; 34 while (root) {
33 while (root) { 35 var ancestors = AutomationUtil.getAncestors(root);
34 var ancestors = AutomationUtil.getAncestors(root); 36 assertEquals(expectedLength++, ancestors.length);
35 assertEquals(expectedLength++, ancestors.length); 37 root = root.firstChild;
36 root = root.firstChild; 38 }
37 } 39 });
38 testDone();
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.runWithLoadedTree(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
(...skipping 21 matching lines...) Expand all
71 assertEquals(chrome.automation.RoleType.heading, 71 assertEquals(chrome.automation.RoleType.heading,
72 uniqueAncestorsRight[0].role); 72 uniqueAncestorsRight[0].role);
73 assertEquals(chrome.automation.RoleType.group, 73 assertEquals(chrome.automation.RoleType.group,
74 uniqueAncestorsRight[1].role); 74 uniqueAncestorsRight[1].role);
75 assertEquals(chrome.automation.RoleType.button, 75 assertEquals(chrome.automation.RoleType.button,
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 });
82 }.bind(this));
83 }); 82 });
84 83
85 TEST_F('AutomationUtilE2ETest', 'GetDirection', function() { 84 TEST_F('AutomationUtilE2ETest', 'GetDirection', function() {
86 this.runWithLoadedTree(this.basicDoc, function(root) { 85 this.runWithLoadedTree(this.basicDoc, function(root) {
87 var left = root, right = root; 86 var left = root, right = root;
88 87
89 // Same node. 88 // Same node.
90 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right)); 89 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right));
91 90
92 // Ancestor. 91 // Ancestor.
93 left = left.firstChild; 92 left = left.firstChild;
94 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right)); 93 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right));
95 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(right, left)); 94 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(right, left));
96 95
97 // Ordered. 96 // Ordered.
98 right = right.lastChild; 97 right = right.lastChild;
99 assertEquals(Dir.BACKWARD, AutomationUtil.getDirection(right, left)); 98 assertEquals(Dir.BACKWARD, AutomationUtil.getDirection(right, left));
100 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right)); 99 assertEquals(Dir.FORWARD, AutomationUtil.getDirection(left, right));
101 100
102 testDone(); 101 });
103 }.bind(this));
104 }); 102 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698