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

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

Issue 1151393006: An accessibility tree update with two roots should be rejected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « ui/accessibility/ax_tree.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/accessibility/ax_node.h" 8 #include "ui/accessibility/ax_node.h"
9 #include "ui/accessibility/ax_serializable_tree.h" 9 #include "ui/accessibility/ax_serializable_tree.h"
10 #include "ui/accessibility/ax_tree.h" 10 #include "ui/accessibility/ax_tree.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 update.nodes[0].id = 1; 276 update.nodes[0].id = 1;
277 update.nodes[0].role = AX_ROLE_ROOT_WEB_AREA; 277 update.nodes[0].role = AX_ROLE_ROOT_WEB_AREA;
278 update.nodes[0].child_ids.push_back(3); 278 update.nodes[0].child_ids.push_back(3);
279 update.nodes[0].child_ids.push_back(2); 279 update.nodes[0].child_ids.push_back(2);
280 update.nodes[1].id = 2; 280 update.nodes[1].id = 2;
281 update.nodes[2].id = 3; 281 update.nodes[2].id = 3;
282 EXPECT_FALSE(tree.Unserialize(update)); 282 EXPECT_FALSE(tree.Unserialize(update));
283 ASSERT_EQ("Node 3 reparented from 2 to 1", tree.error()); 283 ASSERT_EQ("Node 3 reparented from 2 to 1", tree.error());
284 } 284 }
285 285
286 TEST(AXTreeTest, TwoRootsFails) {
287 AXTreeUpdate initial_state;
288 initial_state.nodes.resize(1);
289 initial_state.nodes[0].id = 1;
290 initial_state.nodes[0].role = AX_ROLE_ROOT_WEB_AREA;
291 AXTree tree(initial_state);
292
293 // This should fail because there are two new roots.
294 AXTreeUpdate update;
295 update.nodes.resize(2);
296 update.nodes[0].id = 2;
297 update.nodes[0].role = AX_ROLE_ROOT_WEB_AREA;
298 update.nodes[1].id = 3;
299 update.nodes[1].role = AX_ROLE_ROOT_WEB_AREA;
300 EXPECT_FALSE(tree.Unserialize(update));
301 ASSERT_EQ("Tree update contains two new roots", tree.error());
302 }
303
286 TEST(AXTreeTest, TreeDelegateIsCalled) { 304 TEST(AXTreeTest, TreeDelegateIsCalled) {
287 AXTreeUpdate initial_state; 305 AXTreeUpdate initial_state;
288 initial_state.nodes.resize(2); 306 initial_state.nodes.resize(2);
289 initial_state.nodes[0].id = 1; 307 initial_state.nodes[0].id = 1;
290 initial_state.nodes[0].role = AX_ROLE_ROOT_WEB_AREA; 308 initial_state.nodes[0].role = AX_ROLE_ROOT_WEB_AREA;
291 initial_state.nodes[0].child_ids.push_back(2); 309 initial_state.nodes[0].child_ids.push_back(2);
292 initial_state.nodes[1].id = 2; 310 initial_state.nodes[1].id = 2;
293 311
294 AXTree tree(initial_state); 312 AXTree tree(initial_state);
295 AXTreeUpdate update; 313 AXTreeUpdate update;
(...skipping 25 matching lines...) Expand all
321 339
322 ASSERT_EQ(1U, fake_delegate.node_creation_finished_ids().size()); 340 ASSERT_EQ(1U, fake_delegate.node_creation_finished_ids().size());
323 EXPECT_EQ(4, fake_delegate.node_creation_finished_ids()[0]); 341 EXPECT_EQ(4, fake_delegate.node_creation_finished_ids()[0]);
324 342
325 ASSERT_EQ(true, fake_delegate.root_changed()); 343 ASSERT_EQ(true, fake_delegate.root_changed());
326 344
327 tree.SetDelegate(NULL); 345 tree.SetDelegate(NULL);
328 } 346 }
329 347
330 } // namespace ui 348 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/ax_tree.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698