OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/accessibility/one_shot_accessibility_tree_search.h" | 5 #include "content/browser/accessibility/one_shot_accessibility_tree_search.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "content/browser/accessibility/browser_accessibility.h" | 10 #include "content/browser/accessibility/browser_accessibility.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 tree_.reset(new TestBrowserAccessibilityManager( | 90 tree_.reset(new TestBrowserAccessibilityManager( |
91 MakeAXTreeUpdate(root, heading, list, list_item_1, list_item_2, footer))); | 91 MakeAXTreeUpdate(root, heading, list, list_item_1, list_item_2, footer))); |
92 } | 92 } |
93 | 93 |
94 TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, GetAll) { | 94 TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, GetAll) { |
95 OneShotAccessibilityTreeSearch search(tree_->GetRoot()); | 95 OneShotAccessibilityTreeSearch search(tree_->GetRoot()); |
96 ASSERT_EQ(6U, search.CountMatches()); | 96 ASSERT_EQ(6U, search.CountMatches()); |
97 } | 97 } |
98 | 98 |
| 99 TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, NoCycle) { |
| 100 // If you set a result limit of 1, you won't get the root node back as |
| 101 // the first match. |
| 102 OneShotAccessibilityTreeSearch search(tree_->GetRoot()); |
| 103 search.SetResultLimit(1); |
| 104 ASSERT_EQ(1U, search.CountMatches()); |
| 105 EXPECT_NE(1, search.GetMatchAtIndex(0)->GetId()); |
| 106 } |
| 107 |
99 TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, ForwardsWithStartNode) { | 108 TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, ForwardsWithStartNode) { |
100 OneShotAccessibilityTreeSearch search(tree_->GetRoot()); | 109 OneShotAccessibilityTreeSearch search(tree_->GetRoot()); |
101 search.SetStartNode(tree_->GetFromID(4)); | 110 search.SetStartNode(tree_->GetFromID(4)); |
102 ASSERT_EQ(2U, search.CountMatches()); | 111 ASSERT_EQ(2U, search.CountMatches()); |
103 EXPECT_EQ(5, search.GetMatchAtIndex(0)->GetId()); | 112 EXPECT_EQ(5, search.GetMatchAtIndex(0)->GetId()); |
104 EXPECT_EQ(6, search.GetMatchAtIndex(1)->GetId()); | 113 EXPECT_EQ(6, search.GetMatchAtIndex(1)->GetId()); |
105 } | 114 } |
106 | 115 |
107 TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, BackwardsWithStartNode) { | 116 TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, BackwardsWithStartNode) { |
108 OneShotAccessibilityTreeSearch search(tree_->GetRoot()); | 117 OneShotAccessibilityTreeSearch search(tree_->GetRoot()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 search.AddPredicate([](BrowserAccessibility* start, | 227 search.AddPredicate([](BrowserAccessibility* start, |
219 BrowserAccessibility* current) { | 228 BrowserAccessibility* current) { |
220 return (current->GetId() % 2 == 1); | 229 return (current->GetId() % 2 == 1); |
221 }); | 230 }); |
222 ASSERT_EQ(2U, search.CountMatches()); | 231 ASSERT_EQ(2U, search.CountMatches()); |
223 EXPECT_EQ(3, search.GetMatchAtIndex(0)->GetId()); | 232 EXPECT_EQ(3, search.GetMatchAtIndex(0)->GetId()); |
224 EXPECT_EQ(5, search.GetMatchAtIndex(1)->GetId()); | 233 EXPECT_EQ(5, search.GetMatchAtIndex(1)->GetId()); |
225 } | 234 } |
226 | 235 |
227 } // namespace content | 236 } // namespace content |
OLD | NEW |