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

Side by Side Diff: chrome/browser/resources/chromeos/switch_access/automation_predicate.js

Issue 2866123002: Added unit tests for tree_walker and automation_predicate. (Closed)
Patch Set: Combined getSampleTree functions into one Created 3 years, 7 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 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 * Class containing predicates for the chrome automation API. Each predicate 6 * Class containing predicates for the chrome automation API. Each predicate
7 * can be run on one or more AutomationNodes and returns a boolean value. 7 * can be run on one or more AutomationNodes and returns a boolean value.
8 * 8 *
9 * @constructor 9 * @constructor
10 */ 10 */
(...skipping 29 matching lines...) Expand all
40 return false; 40 return false;
41 41
42 // Work around for client nested in client. No need to have user select both 42 // Work around for client nested in client. No need to have user select both
43 // clients for a window. Once locations for outer client updates correctly, 43 // clients for a window. Once locations for outer client updates correctly,
44 // this won't be needed. 44 // this won't be needed.
45 if (node.role === chrome.automation.RoleType.CLIENT 45 if (node.role === chrome.automation.RoleType.CLIENT
46 && node.role === scope.role && node !== scope) 46 && node.role === scope.role && node !== scope)
47 return false; 47 return false;
48 48
49 let interestingBranches = 0; 49 let interestingBranches = 0;
50 for (let child of node.children) { 50 let children = node.children || [];
51 for (let child of children) {
51 if (AutomationPredicate.isInterestingSubtree(child)) 52 if (AutomationPredicate.isInterestingSubtree(child))
52 interestingBranches += 1; 53 interestingBranches += 1;
53 if (interestingBranches > 1) 54 if (interestingBranches > 1)
54 return true; 55 return true;
55 } 56 }
56 return false; 57 return false;
57 }; 58 };
58 59
59 /** 60 /**
60 * Returns true if the two nodes have the same location. 61 * Returns true if the two nodes have the same location.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // Work around for browser tabs 116 // Work around for browser tabs
116 if (role === chrome.automation.RoleType.TAB 117 if (role === chrome.automation.RoleType.TAB
117 && parent.role === chrome.automation.RoleType.TAB_LIST 118 && parent.role === chrome.automation.RoleType.TAB_LIST
118 && root.role === chrome.automation.RoleType.DESKTOP) 119 && root.role === chrome.automation.RoleType.DESKTOP)
119 return true; 120 return true;
120 } 121 }
121 122
122 // The general rule that applies to everything. 123 // The general rule that applies to everything.
123 return state[chrome.automation.StateType.FOCUSABLE] === true; 124 return state[chrome.automation.StateType.FOCUSABLE] === true;
124 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698