OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |