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

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: Revert comment. 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 30 matching lines...) Expand all
41 void SetUp() override; 41 void SetUp() override;
42 42
43 std::unique_ptr<BrowserAccessibilityManager> tree_; 43 std::unique_ptr<BrowserAccessibilityManager> tree_;
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.ClearBitfields();
51 root.id = 1; 52 root.id = 1;
52 root.SetName("Document"); 53 root.SetName("Document");
53 root.role = ui::AX_ROLE_ROOT_WEB_AREA; 54 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
54 root.state = 0;
55 root.child_ids.push_back(2); 55 root.child_ids.push_back(2);
56 root.child_ids.push_back(3); 56 root.child_ids.push_back(3);
57 root.child_ids.push_back(6); 57 root.child_ids.push_back(6);
58 58
59 ui::AXNodeData heading; 59 ui::AXNodeData heading;
60 heading.ClearBitfields();
60 heading.id = 2; 61 heading.id = 2;
61 heading.SetName("Heading"); 62 heading.SetName("Heading");
62 heading.role = ui::AX_ROLE_HEADING; 63 heading.role = ui::AX_ROLE_HEADING;
63 heading.state = 0;
64 64
65 ui::AXNodeData list; 65 ui::AXNodeData list;
66 list.ClearBitfields();
66 list.id = 3; 67 list.id = 3;
67 list.role = ui::AX_ROLE_LIST; 68 list.role = ui::AX_ROLE_LIST;
68 list.state = 0;
69 list.child_ids.push_back(4); 69 list.child_ids.push_back(4);
70 list.child_ids.push_back(5); 70 list.child_ids.push_back(5);
71 71
72 ui::AXNodeData list_item_1; 72 ui::AXNodeData list_item_1;
73 list_item_1.ClearBitfields();
73 list_item_1.id = 4; 74 list_item_1.id = 4;
74 list_item_1.SetName("Autobots"); 75 list_item_1.SetName("Autobots");
75 list_item_1.role = ui::AX_ROLE_LIST_ITEM; 76 list_item_1.role = ui::AX_ROLE_LIST_ITEM;
76 list_item_1.state = 0;
77 77
78 ui::AXNodeData list_item_2; 78 ui::AXNodeData list_item_2;
79 list_item_2.ClearBitfields();
79 list_item_2.id = 5; 80 list_item_2.id = 5;
80 list_item_2.SetName("Decepticons"); 81 list_item_2.SetName("Decepticons");
81 list_item_2.role = ui::AX_ROLE_LIST_ITEM; 82 list_item_2.role = ui::AX_ROLE_LIST_ITEM;
82 list_item_2.state = 0;
83 83
84 ui::AXNodeData footer; 84 ui::AXNodeData footer;
85 footer.id = 6; 85 footer.id = 6;
86 footer.SetName("Footer"); 86 footer.SetName("Footer");
87 footer.role = ui::AX_ROLE_FOOTER; 87 footer.role = ui::AX_ROLE_FOOTER;
88 footer.state = 1 << ui::AX_STATE_OFFSCREEN; 88 footer.AddState(ui::AX_STATE_OFFSCREEN);
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
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 search.AddPredicate([](BrowserAccessibility* start, 227 search.AddPredicate([](BrowserAccessibility* start,
228 BrowserAccessibility* current) { 228 BrowserAccessibility* current) {
229 return (current->GetId() % 2 == 1); 229 return (current->GetId() % 2 == 1);
230 }); 230 });
231 ASSERT_EQ(2U, search.CountMatches()); 231 ASSERT_EQ(2U, search.CountMatches());
232 EXPECT_EQ(3, search.GetMatchAtIndex(0)->GetId()); 232 EXPECT_EQ(3, search.GetMatchAtIndex(0)->GetId());
233 EXPECT_EQ(5, search.GetMatchAtIndex(1)->GetId()); 233 EXPECT_EQ(5, search.GetMatchAtIndex(1)->GetId());
234 } 234 }
235 235
236 } // namespace content 236 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698