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

Side by Side Diff: chrome/browser/resources/chromeos/switch_access/tree_walker_unittest.gtestjs

Issue 2777203006: Added auto-scan, made some small changes to how prefs are stored, refactored. (Closed)
Patch Set: Responding to comments. Refactored tree_walker. Removed testable_tree_walker. Created 3 years, 8 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
« no previous file with comments | « chrome/browser/resources/chromeos/switch_access/tree_walker.js ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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 /** 5 /**
6 * Test fixture for switch_access.js. 6 * Test fixture for tree_walker.js.
7 * @constructor 7 * @constructor
8 * @extends {testing.Test} 8 * @extends {testing.Test}
9 */ 9 */
10 function SwitchAccessUnitTest () { 10 function AutomationTreeWalkerUnitTest () {
11 testing.Test.call(this); 11 testing.Test.call(this);
12 }; 12 };
13 13
14 SwitchAccessUnitTest.prototype = { 14 AutomationTreeWalkerUnitTest.prototype = {
15 __proto__: testing.Test.prototype, 15 __proto__: testing.Test.prototype,
16 16
17 /** @override */ 17 /** @override */
18 extraLibraries: [ 18 extraLibraries: [
19 'test_support.js', 19 'tree_walker.js',
20 'prefs.js',
21 'switch_access.js',
22 'testable_switch_access.js',
23 ], 20 ],
24 21
25 getSampleTree: function() { 22 getSampleTree: function() {
26 // root 23 // root
27 // middle1 24 // middle1
28 // leaf1 25 // leaf1
29 // leaf2 26 // leaf2
30 // leaf3 27 // leaf3
31 // middle2 28 // middle2
32 // leaf4 29 // leaf4
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 middle2: middle2, 68 middle2: middle2,
72 leaf1: leaf1, 69 leaf1: leaf1,
73 leaf2: leaf2, 70 leaf2: leaf2,
74 leaf3: leaf3, 71 leaf3: leaf3,
75 leaf4: leaf4, 72 leaf4: leaf4,
76 leaf5: leaf5 73 leaf5: leaf5
77 }; 74 };
78 } 75 }
79 }; 76 };
80 77
81 TEST_F('SwitchAccessUnitTest', 'GetNextNode', function() { 78 TEST_F('AutomationTreeWalkerUnitTest', 'GetNextNode', function() {
82 let tree = this.getSampleTree(); 79 let tree = this.getSampleTree();
83 let tsa = new TestableSwitchAccess(); 80 let treeWalker = new AutomationTreeWalker();
84 81
85 let order = 82 let order =
86 [tree.root, tree.middle1, tree.leaf1, tree.leaf2, tree.leaf3, 83 [tree.root, tree.middle1, tree.leaf1, tree.leaf2, tree.leaf3,
87 tree.middle2, tree.leaf4, tree.leaf5]; 84 tree.middle2, tree.leaf4, tree.leaf5];
88 let node = tree.root; 85 let node = tree.root;
89 for (let i = 0; i < order.length; i++) { 86 for (let i = 0; i < order.length; i++) {
90 assertEquals(order[i], node); 87 assertEquals(order[i], node);
91 node = tsa.getNextNode(node); 88 node = treeWalker.getNextNode_(node);
92 } 89 }
93 assertEquals(null, node); 90 assertEquals(undefined, node);
94 }); 91 });
95 92
96 TEST_F('SwitchAccessUnitTest', 'GetPreviousNode', function() { 93 TEST_F('AutomationTreeWalkerUnitTest', 'GetPreviousNode', function() {
97 let tree = this.getSampleTree(); 94 let tree = this.getSampleTree();
98 let tsa = new TestableSwitchAccess(); 95 let treeWalker = new AutomationTreeWalker();
99 96
100 let order = 97 let order =
101 [tree.leaf5, tree.leaf4, tree.middle2, tree.leaf3, tree.leaf2, 98 [tree.leaf5, tree.leaf4, tree.middle2, tree.leaf3, tree.leaf2,
102 tree.leaf1, tree.middle1, tree.root]; 99 tree.leaf1, tree.middle1, tree.root];
103 let node = tree.leaf5; 100 let node = tree.leaf5;
104 for (let i = 0; i < order.length; i++) { 101 for (let i = 0; i < order.length; i++) {
105 assertEquals(order[i], node); 102 assertEquals(order[i], node);
106 node = tsa.getPreviousNode(node); 103 node = treeWalker.getPreviousNode_(node);
107 } 104 }
108 assertEquals(null, node); 105 assertEquals(undefined, node);
109 }); 106 });
110 107
111 TEST_F('SwitchAccessUnitTest', 'GetYoungestDescendant', function() { 108 TEST_F('AutomationTreeWalkerUnitTest', 'GetYoungestDescendant', function() {
112 let tree = this.getSampleTree(); 109 let tree = this.getSampleTree();
113 let tsa = new TestableSwitchAccess(); 110 let treeWalker = new AutomationTreeWalker();
114 111
115 assertEquals(tree.leaf5, tsa.getYoungestDescendant(tree.root)); 112 assertEquals(tree.leaf5, treeWalker.getYoungestDescendant_(tree.root));
116 assertEquals(tree.leaf3, tsa.getYoungestDescendant(tree.middle1)); 113 assertEquals(tree.leaf3, treeWalker.getYoungestDescendant_(tree.middle1));
117 assertEquals(tree.leaf5, tsa.getYoungestDescendant(tree.middle2)); 114 assertEquals(tree.leaf5, treeWalker.getYoungestDescendant_(tree.middle2));
118 assertEquals(null, tsa.getYoungestDescendant(tree.leaf1)); 115 assertEquals(undefined, treeWalker.getYoungestDescendant_(tree.leaf1));
119 assertEquals(null, tsa.getYoungestDescendant(tree.leaf2)); 116 assertEquals(undefined, treeWalker.getYoungestDescendant_(tree.leaf2));
120 assertEquals(null, tsa.getYoungestDescendant(tree.leaf3)); 117 assertEquals(undefined, treeWalker.getYoungestDescendant_(tree.leaf3));
121 assertEquals(null, tsa.getYoungestDescendant(tree.leaf4)); 118 assertEquals(undefined, treeWalker.getYoungestDescendant_(tree.leaf4));
122 assertEquals(null, tsa.getYoungestDescendant(tree.leaf5)); 119 assertEquals(undefined, treeWalker.getYoungestDescendant_(tree.leaf5));
123 }); 120 });
124 121
125 TEST_F('SwitchAccessUnitTest', 'IsInteresting', function() { 122 TEST_F('AutomationTreeWalkerUnitTest', 'IsInteresting', function() {
126 let node1 = {}; 123 let node1 = {};
127 let node2 = {state: {}}; 124 let node2 = {state: {}};
128 let node3 = {state: {focusable: false}}; 125 let node3 = {state: {focusable: false}};
129 let node4 = {state: {focusable: true}}; 126 let node4 = {state: {focusable: true}};
130 let tsa = new TestableSwitchAccess(); 127 let treeWalker = new AutomationTreeWalker();
131 128
132 assertTrue(tsa.isInteresting(node1) === undefined); 129 assertTrue(treeWalker.isInteresting_(node1) === undefined);
133 assertTrue(tsa.isInteresting(node2) === undefined); 130 assertTrue(treeWalker.isInteresting_(node2) === undefined);
134 assertFalse(tsa.isInteresting(node3)); 131 assertFalse(treeWalker.isInteresting_(node3));
135 assertTrue(tsa.isInteresting(node4)); 132 assertTrue(treeWalker.isInteresting_(node4));
136 }); 133 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/switch_access/tree_walker.js ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698