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

Side by Side Diff: ui/accessibility/ax_tree_combiner_unittest.cc

Issue 2572923002: AXTreeCombiner no longer needs to convert to global coordinates. (Closed)
Patch Set: Fixed unittests Created 4 years 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
« no previous file with comments | « ui/accessibility/ax_tree_combiner.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "ui/accessibility/ax_tree_combiner.h" 6 #include "ui/accessibility/ax_tree_combiner.h"
7 7
8 namespace ui { 8 namespace ui {
9 9
10 TEST(CombineAXTreesTest, RenumberOneTree) { 10 TEST(CombineAXTreesTest, RenumberOneTree) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute( 142 EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute(
143 AX_ATTR_FLOWTO_IDS)[0]); 143 AX_ATTR_FLOWTO_IDS)[0]);
144 EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute( 144 EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute(
145 AX_ATTR_LABELLEDBY_IDS)[0]); 145 AX_ATTR_LABELLEDBY_IDS)[0]);
146 EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute( 146 EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute(
147 AX_ATTR_CELL_IDS)[0]); 147 AX_ATTR_CELL_IDS)[0]);
148 EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute( 148 EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute(
149 AX_ATTR_UNIQUE_CELL_IDS)[0]); 149 AX_ATTR_UNIQUE_CELL_IDS)[0]);
150 } 150 }
151 151
152 TEST(CombineAXTreesTest, Coordinates) {
153 AXTreeUpdate parent_tree;
154 parent_tree.has_tree_data = true;
155 parent_tree.tree_data.tree_id = 1;
156 parent_tree.root_id = 1;
157 parent_tree.nodes.resize(3);
158 parent_tree.nodes[0].id = 1;
159 parent_tree.nodes[0].child_ids.push_back(2);
160 parent_tree.nodes[0].child_ids.push_back(3);
161 parent_tree.nodes[1].id = 2;
162 parent_tree.nodes[1].role = AX_ROLE_BUTTON;
163 parent_tree.nodes[1].location = gfx::RectF(50, 10, 200, 100);
164 parent_tree.nodes[2].id = 3;
165 parent_tree.nodes[2].role = AX_ROLE_IFRAME;
166 parent_tree.nodes[2].AddIntAttribute(AX_ATTR_CHILD_TREE_ID, 2);
167
168 AXTreeUpdate child_tree;
169 child_tree.has_tree_data = true;
170 child_tree.tree_data.parent_tree_id = 1;
171 child_tree.tree_data.tree_id = 2;
172 child_tree.root_id = 1;
173 child_tree.nodes.resize(2);
174 child_tree.nodes[0].id = 1;
175 child_tree.nodes[0].child_ids.push_back(2);
176
177 child_tree.nodes[0].transform.reset(new gfx::Transform());
178 child_tree.nodes[0].transform->Translate(0, 300);
179 child_tree.nodes[0].transform->Scale(2.0, 2.0);
180
181 child_tree.nodes[1].id = 2;
182 child_tree.nodes[1].role = AX_ROLE_BUTTON;
183 child_tree.nodes[1].location = gfx::RectF(50, 10, 200, 100);
184
185 AXTreeCombiner combiner;
186 combiner.AddTree(parent_tree, true);
187 combiner.AddTree(child_tree, false);
188 combiner.Combine();
189
190 const AXTreeUpdate& combined = combiner.combined();
191
192 ASSERT_EQ(5U, combined.nodes.size());
193 EXPECT_EQ(50, combined.nodes[1].location.x());
194 EXPECT_EQ(10, combined.nodes[1].location.y());
195 EXPECT_EQ(200, combined.nodes[1].location.width());
196 EXPECT_EQ(100, combined.nodes[1].location.height());
197 EXPECT_EQ(100, combined.nodes[4].location.x());
198 EXPECT_EQ(320, combined.nodes[4].location.y());
199 EXPECT_EQ(400, combined.nodes[4].location.width());
200 EXPECT_EQ(200, combined.nodes[4].location.height());
201 }
202
203 TEST(CombineAXTreesTest, FocusedTree) { 152 TEST(CombineAXTreesTest, FocusedTree) {
204 AXTreeUpdate parent_tree; 153 AXTreeUpdate parent_tree;
205 parent_tree.has_tree_data = true; 154 parent_tree.has_tree_data = true;
206 parent_tree.tree_data.tree_id = 1; 155 parent_tree.tree_data.tree_id = 1;
207 parent_tree.tree_data.focused_tree_id = 2; 156 parent_tree.tree_data.focused_tree_id = 2;
208 parent_tree.tree_data.focus_id = 2; 157 parent_tree.tree_data.focus_id = 2;
209 parent_tree.root_id = 1; 158 parent_tree.root_id = 1;
210 parent_tree.nodes.resize(3); 159 parent_tree.nodes.resize(3);
211 parent_tree.nodes[0].id = 1; 160 parent_tree.nodes[0].id = 1;
212 parent_tree.nodes[0].child_ids.push_back(2); 161 parent_tree.nodes[0].child_ids.push_back(2);
(...skipping 24 matching lines...) Expand all
237 combiner.AddTree(child_tree, false); 186 combiner.AddTree(child_tree, false);
238 combiner.Combine(); 187 combiner.Combine();
239 188
240 const AXTreeUpdate& combined = combiner.combined(); 189 const AXTreeUpdate& combined = combiner.combined();
241 190
242 ASSERT_EQ(6U, combined.nodes.size()); 191 ASSERT_EQ(6U, combined.nodes.size());
243 EXPECT_EQ(6, combined.tree_data.focus_id); 192 EXPECT_EQ(6, combined.tree_data.focus_id);
244 } 193 }
245 194
246 } // namespace ui 195 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/ax_tree_combiner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698