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

Side by Side Diff: content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc

Issue 2860883003: A11y: Add/refactor methods for manipulating bitfields on AXNodeData. (Closed)
Patch Set: Delete AXNodeData::Init() and clear bitfields in AXNodeData() instead. 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 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 private: 45 private:
46 DISALLOW_COPY_AND_ASSIGN(MAYBE_OneShotAccessibilityTreeSearchTest); 46 DISALLOW_COPY_AND_ASSIGN(MAYBE_OneShotAccessibilityTreeSearchTest);
47 }; 47 };
48 48
49 void MAYBE_OneShotAccessibilityTreeSearchTest::SetUp() { 49 void MAYBE_OneShotAccessibilityTreeSearchTest::SetUp() {
50 ui::AXNodeData root; 50 ui::AXNodeData root;
51 root.id = 1; 51 root.id = 1;
52 root.SetName("Document"); 52 root.SetName("Document");
53 root.role = ui::AX_ROLE_ROOT_WEB_AREA; 53 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
54 root.state = 0;
55 root.child_ids.push_back(2); 54 root.child_ids.push_back(2);
56 root.child_ids.push_back(3); 55 root.child_ids.push_back(3);
57 root.child_ids.push_back(6); 56 root.child_ids.push_back(6);
58 57
59 ui::AXNodeData heading; 58 ui::AXNodeData heading;
60 heading.id = 2; 59 heading.id = 2;
61 heading.SetName("Heading"); 60 heading.SetName("Heading");
62 heading.role = ui::AX_ROLE_HEADING; 61 heading.role = ui::AX_ROLE_HEADING;
63 heading.state = 0;
64 62
65 ui::AXNodeData list; 63 ui::AXNodeData list;
66 list.id = 3; 64 list.id = 3;
67 list.role = ui::AX_ROLE_LIST; 65 list.role = ui::AX_ROLE_LIST;
68 list.state = 0;
69 list.child_ids.push_back(4); 66 list.child_ids.push_back(4);
70 list.child_ids.push_back(5); 67 list.child_ids.push_back(5);
71 68
72 ui::AXNodeData list_item_1; 69 ui::AXNodeData list_item_1;
73 list_item_1.id = 4; 70 list_item_1.id = 4;
74 list_item_1.SetName("Autobots"); 71 list_item_1.SetName("Autobots");
75 list_item_1.role = ui::AX_ROLE_LIST_ITEM; 72 list_item_1.role = ui::AX_ROLE_LIST_ITEM;
76 list_item_1.state = 0;
77 73
78 ui::AXNodeData list_item_2; 74 ui::AXNodeData list_item_2;
79 list_item_2.id = 5; 75 list_item_2.id = 5;
80 list_item_2.SetName("Decepticons"); 76 list_item_2.SetName("Decepticons");
81 list_item_2.role = ui::AX_ROLE_LIST_ITEM; 77 list_item_2.role = ui::AX_ROLE_LIST_ITEM;
82 list_item_2.state = 0;
83 78
84 ui::AXNodeData footer; 79 ui::AXNodeData footer;
85 footer.id = 6; 80 footer.id = 6;
86 footer.SetName("Footer"); 81 footer.SetName("Footer");
87 footer.role = ui::AX_ROLE_FOOTER; 82 footer.role = ui::AX_ROLE_FOOTER;
88 footer.state = 1 << ui::AX_STATE_OFFSCREEN; 83 footer.AddState(ui::AX_STATE_OFFSCREEN);
89 84
90 tree_.reset(new TestBrowserAccessibilityManager( 85 tree_.reset(new TestBrowserAccessibilityManager(
91 MakeAXTreeUpdate(root, heading, list, list_item_1, list_item_2, footer))); 86 MakeAXTreeUpdate(root, heading, list, list_item_1, list_item_2, footer)));
92 } 87 }
93 88
94 TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, GetAll) { 89 TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, GetAll) {
95 OneShotAccessibilityTreeSearch search(tree_->GetRoot()); 90 OneShotAccessibilityTreeSearch search(tree_->GetRoot());
96 ASSERT_EQ(6U, search.CountMatches()); 91 ASSERT_EQ(6U, search.CountMatches());
97 } 92 }
98 93
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 search.AddPredicate([](BrowserAccessibility* start, 222 search.AddPredicate([](BrowserAccessibility* start,
228 BrowserAccessibility* current) { 223 BrowserAccessibility* current) {
229 return (current->GetId() % 2 == 1); 224 return (current->GetId() % 2 == 1);
230 }); 225 });
231 ASSERT_EQ(2U, search.CountMatches()); 226 ASSERT_EQ(2U, search.CountMatches());
232 EXPECT_EQ(3, search.GetMatchAtIndex(0)->GetId()); 227 EXPECT_EQ(3, search.GetMatchAtIndex(0)->GetId());
233 EXPECT_EQ(5, search.GetMatchAtIndex(1)->GetId()); 228 EXPECT_EQ(5, search.GetMatchAtIndex(1)->GetId());
234 } 229 }
235 230
236 } // namespace content 231 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698