| Index: chrome/browser/resources/chromeos/switch_access/automation_predicate_unittest.gtestjs
|
| diff --git a/chrome/browser/resources/chromeos/switch_access/automation_predicate_unittest.gtestjs b/chrome/browser/resources/chromeos/switch_access/automation_predicate_unittest.gtestjs
|
| index b24d637fa5b316a2ed7bac2e34d80478a4380f49..431649d2c15d7abd591d4d51b5041796e3e5c319 100644
|
| --- a/chrome/browser/resources/chromeos/switch_access/automation_predicate_unittest.gtestjs
|
| +++ b/chrome/browser/resources/chromeos/switch_access/automation_predicate_unittest.gtestjs
|
| @@ -21,17 +21,187 @@ AutomationPredicateUnitTest.prototype = {
|
|
|
| /** @override */
|
| browsePreload: DUMMY_URL,
|
| +
|
| + /** @override */
|
| + setUp: function() {
|
| + chrome.automation = {
|
| + RoleType: {
|
| + CLIENT: 'client', DESKTOP: 'desktop', ROOT_WEB_AREA: 'rootWebArea',
|
| + TAB: 'tab', TAB_LIST: 'tabList', WEB_VIEW: 'webView'
|
| + },
|
| + StateType: {FOCUSABLE: 'focusable', OFFSCREEN: 'offscreen'}
|
| + };
|
| + },
|
| +
|
| + fakeLoc: function(x) {
|
| + return {left: x, top: x, width: x, height: x};
|
| + },
|
| +
|
| + getMoreInterestingSampleTree: function() {
|
| + // - = interesting, (g) = group
|
| + // root (g)
|
| + // upper1 (g)
|
| + // lower1 (g)
|
| + // leaf1 -
|
| + // leaf2
|
| + // leaf3 -
|
| + // lower2
|
| + // leaf4
|
| + // leaf5 -
|
| + // upper2 -
|
| + // lower3 (g)
|
| + // leaf6 -
|
| + // leaf7 -
|
| + let root = {location: this.fakeLoc(0), state: {}};
|
| + let upper1 = {location: this.fakeLoc(1), state: {}};
|
| + let upper2 = {location: this.fakeLoc(2), state: {focusable: true}};
|
| + let lower1 = {location: this.fakeLoc(3), state: {}};
|
| + let lower2 = {location: this.fakeLoc(4), state: {}};
|
| + let lower3 = {location: this.fakeLoc(5), state: {}};
|
| + let leaf1 = {location: this.fakeLoc(6), state: {focusable: true}};
|
| + let leaf2 = {location: this.fakeLoc(7), state: {}};
|
| + let leaf3 = {location: this.fakeLoc(8), state: {focusable: true}};
|
| + let leaf4 = {location: this.fakeLoc(9), state: {}};
|
| + let leaf5 = {location: this.fakeLoc(10), state: {focusable: true}};
|
| + let leaf6 = {location: this.fakeLoc(11), state: {focusable: true}};
|
| + let leaf7 = {location: this.fakeLoc(12), state: {focusable: true}};
|
| +
|
| + root.children = [upper1, upper2];
|
| + upper1.children = [lower1, lower2];
|
| + upper2.children = [lower3];
|
| + lower1.children = [leaf1, leaf2, leaf3];
|
| + lower2.children = [leaf4, leaf5];
|
| + lower3.children = [leaf6, leaf7];
|
| +
|
| + return {
|
| + root: root,
|
| + upper1: upper1,
|
| + upper2: upper2,
|
| + lower1: lower1,
|
| + lower2: lower2,
|
| + lower3: lower3,
|
| + leaf1: leaf1,
|
| + leaf2: leaf2,
|
| + leaf3: leaf3,
|
| + leaf4: leaf4,
|
| + leaf5: leaf5,
|
| + leaf6: leaf6,
|
| + leaf7: leaf7,
|
| + };
|
| + },
|
| +
|
| + getLessInterestingSampleTree: function() {
|
| + // - = interesting
|
| + // root
|
| + // upper1
|
| + // lower1
|
| + // leaf1 -
|
| + // leaf2
|
| + // leaf3 -
|
| + // lower2
|
| + // leaf4
|
| + // leaf5 -
|
| + // upper2 -
|
| + // lower3
|
| + // leaf6
|
| + // leaf7
|
| + let root = {location: this.fakeLoc(0), state: {}};
|
| + let upper1 = {location: this.fakeLoc(0), state: {}};
|
| + let upper2 = {location: this.fakeLoc(0), state: {focusable: true}};
|
| + let lower1 = {location: this.fakeLoc(0), state: {}};
|
| + let lower2 = {location: this.fakeLoc(0), state: {}};
|
| + let lower3 = {location: this.fakeLoc(0), state: {}};
|
| + let leaf1 = {location: this.fakeLoc(0), state: {focusable: true}};
|
| + let leaf2 = {location: this.fakeLoc(0), state: {}};
|
| + let leaf3 = {location: this.fakeLoc(0), state: {focusable: true}};
|
| + let leaf4 = {location: this.fakeLoc(0), state: {}};
|
| + let leaf5 = {location: this.fakeLoc(0), state: {focusable: true}};
|
| + let leaf6 = {location: this.fakeLoc(0), state: {}};
|
| + let leaf7 = {location: this.fakeLoc(0), state: {}};
|
| +
|
| + root.children = [upper1, upper2];
|
| + upper1.children = [lower1, lower2];
|
| + upper2.children = [lower3];
|
| + lower1.children = [leaf1, leaf2, leaf3];
|
| + lower2.children = [leaf4, leaf5];
|
| + lower3.children = [leaf6, leaf7];
|
| +
|
| + return {
|
| + root: root,
|
| + upper1: upper1,
|
| + upper2: upper2,
|
| + lower1: lower1,
|
| + lower2: lower2,
|
| + lower3: lower3,
|
| + leaf1: leaf1,
|
| + leaf2: leaf2,
|
| + leaf3: leaf3,
|
| + leaf4: leaf4,
|
| + leaf5: leaf5,
|
| + leaf6: leaf6,
|
| + leaf7: leaf7,
|
| + };
|
| + },
|
| };
|
|
|
| -TEST_F('AutomationPredicateUnitTest', 'IsInteresting', function() {
|
| - chrome.automation = {
|
| - RoleType: {
|
| - DESKTOP: 'desktop', ROOT_WEB_AREA: 'rootWebArea', TAB: 'tab',
|
| - TAB_LIST: 'tabList', WEB_VIEW: 'webView'
|
| - },
|
| - StateType: {FOCUSABLE: 'focusable', OFFSCREEN: 'offscreen'}
|
| - };
|
| +TEST_F('AutomationPredicateUnitTest', 'IsSubtreeLeaf', function() {
|
| + let t = this.getMoreInterestingSampleTree();
|
|
|
| + assertTrue(AutomationPredicate.isSubtreeLeaf(t.root, t.root));
|
| + assertTrue(AutomationPredicate.isSubtreeLeaf(t.upper1, t.root));
|
| + assertTrue(AutomationPredicate.isSubtreeLeaf(t.upper2, t.root));
|
| + assertTrue(AutomationPredicate.isSubtreeLeaf(t.lower1, t.upper1));
|
| + assertFalse(AutomationPredicate.isSubtreeLeaf(t.lower2, t.upper1));
|
| + assertTrue(AutomationPredicate.isSubtreeLeaf(t.lower3, t.root));
|
| + assertTrue(AutomationPredicate.isSubtreeLeaf(t.leaf1, t.lower1));
|
| + assertFalse(AutomationPredicate.isSubtreeLeaf(t.leaf2, t.lower1));
|
| + assertTrue(AutomationPredicate.isSubtreeLeaf(t.leaf3, t.lower1));
|
| + assertFalse(AutomationPredicate.isSubtreeLeaf(t.leaf4, t.upper1));
|
| + assertTrue(AutomationPredicate.isSubtreeLeaf(t.leaf5, t.upper1));
|
| + assertTrue(AutomationPredicate.isSubtreeLeaf(t.leaf6, t.lower3));
|
| + assertTrue(AutomationPredicate.isSubtreeLeaf(t.leaf7, t.lower3));
|
| +});
|
| +
|
| +TEST_F('AutomationPredicateUnitTest', 'IsGroup', function() {
|
| + let t = this.getMoreInterestingSampleTree();
|
| +
|
| + assertTrue(AutomationPredicate.isGroup(t.root, t.root));
|
| + assertTrue(AutomationPredicate.isGroup(t.upper1, t.root));
|
| + assertFalse(AutomationPredicate.isGroup(t.upper2, t.root));
|
| + assertTrue(AutomationPredicate.isGroup(t.lower1, t.upper1));
|
| + assertFalse(AutomationPredicate.isGroup(t.lower2, t.upper1));
|
| + assertTrue(AutomationPredicate.isGroup(t.lower3, t.root));
|
| + assertFalse(AutomationPredicate.isGroup(t.leaf1, t.lower1));
|
| + assertFalse(AutomationPredicate.isGroup(t.leaf2, t.lower1));
|
| + assertFalse(AutomationPredicate.isGroup(t.leaf3, t.lower1));
|
| + assertFalse(AutomationPredicate.isGroup(t.leaf4, t.upper1));
|
| + assertFalse(AutomationPredicate.isGroup(t.leaf5, t.upper1));
|
| + assertFalse(AutomationPredicate.isGroup(t.leaf6, t.lower3));
|
| + assertFalse(AutomationPredicate.isGroup(t.leaf7, t.lower3));
|
| +
|
| + t.upper1.location = this.fakeLoc(0);
|
| + assertFalse(AutomationPredicate.isGroup(t.upper1, t.root));
|
| +});
|
| +
|
| +TEST_F('AutomationPredicateUnitTest', 'IsInterestingSubtree', function() {
|
| + let t = this.getLessInterestingSampleTree();
|
| +
|
| + assertTrue(AutomationPredicate.isInterestingSubtree(t.root));
|
| + assertTrue(AutomationPredicate.isInterestingSubtree(t.upper1));
|
| + assertTrue(AutomationPredicate.isInterestingSubtree(t.upper2));
|
| + assertTrue(AutomationPredicate.isInterestingSubtree(t.lower1));
|
| + assertTrue(AutomationPredicate.isInterestingSubtree(t.lower2));
|
| + assertFalse(AutomationPredicate.isInterestingSubtree(t.lower3));
|
| + assertTrue(AutomationPredicate.isInterestingSubtree(t.leaf1));
|
| + assertFalse(AutomationPredicate.isInterestingSubtree(t.leaf2));
|
| + assertTrue(AutomationPredicate.isInterestingSubtree(t.leaf3));
|
| + assertFalse(AutomationPredicate.isInterestingSubtree(t.leaf4));
|
| + assertTrue(AutomationPredicate.isInterestingSubtree(t.leaf5));
|
| + assertFalse(AutomationPredicate.isInterestingSubtree(t.leaf6));
|
| + assertFalse(AutomationPredicate.isInterestingSubtree(t.leaf7));
|
| +});
|
| +
|
| +TEST_F('AutomationPredicateUnitTest', 'IsInteresting', function() {
|
| // Testing focusable.
|
| let loc1 = {left: 0, top: 0, width: 0, height: 0};
|
| let node1 = {location: loc1, state: {}};
|
| @@ -59,4 +229,10 @@ TEST_F('AutomationPredicateUnitTest', 'IsInteresting', function() {
|
| assertFalse(AutomationPredicate.isInteresting(node7));
|
| assertFalse(AutomationPredicate.isInteresting(node8));
|
| assertTrue(AutomationPredicate.isInteresting(node9));
|
| +
|
| + // Testing if webView or rootWebArea.
|
| + let node10 = {location: loc1, role: 'webView', state: {focusable: true}};
|
| + let node11 = {location: loc1, role: 'rootWebArea', state: {focusable: true}};
|
| + assertFalse(AutomationPredicate.isInteresting(node10));
|
| + assertFalse(AutomationPredicate.isInteresting(node11));
|
| });
|
|
|