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 "ui/accessibility/ax_tree.h" | 5 #include "ui/accessibility/ax_tree.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/stl_util.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "ui/accessibility/ax_node.h" | 17 #include "ui/accessibility/ax_node.h" |
17 #include "ui/accessibility/ax_serializable_tree.h" | 18 #include "ui/accessibility/ax_serializable_tree.h" |
18 #include "ui/accessibility/ax_tree_serializer.h" | 19 #include "ui/accessibility/ax_tree_serializer.h" |
19 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
20 | 21 |
21 using base::DoubleToString; | 22 using base::DoubleToString; |
22 using base::IntToString; | 23 using base::IntToString; |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 update.root_id = 1; | 517 update.root_id = 1; |
517 update.nodes[0].id = 1; | 518 update.nodes[0].id = 1; |
518 update.nodes[0].child_ids.push_back(3); | 519 update.nodes[0].child_ids.push_back(3); |
519 update.nodes[1].id = 3; | 520 update.nodes[1].id = 3; |
520 EXPECT_TRUE(tree.Unserialize(update)) << tree.error(); | 521 EXPECT_TRUE(tree.Unserialize(update)) << tree.error(); |
521 std::vector<int> created = fake_delegate.node_creation_finished_ids(); | 522 std::vector<int> created = fake_delegate.node_creation_finished_ids(); |
522 std::vector<int> subtree_reparented = | 523 std::vector<int> subtree_reparented = |
523 fake_delegate.subtree_reparented_finished_ids(); | 524 fake_delegate.subtree_reparented_finished_ids(); |
524 std::vector<int> node_reparented = | 525 std::vector<int> node_reparented = |
525 fake_delegate.node_reparented_finished_ids(); | 526 fake_delegate.node_reparented_finished_ids(); |
526 ASSERT_EQ(std::find(created.begin(), created.end(), 3), created.end()); | 527 ASSERT_FALSE(base::ContainsValue(created, 3)); |
527 ASSERT_NE(std::find(subtree_reparented.begin(), subtree_reparented.end(), 3), | 528 ASSERT_TRUE(base::ContainsValue(subtree_reparented, 3)); |
528 subtree_reparented.end()); | 529 ASSERT_FALSE(base::ContainsValue(node_reparented, 3)); |
529 ASSERT_EQ(std::find(node_reparented.begin(), node_reparented.end(), 3), | |
530 node_reparented.end()); | |
531 } | 530 } |
532 | 531 |
533 TEST(AXTreeTest, TreeDelegateIsNotCalledForReparenting) { | 532 TEST(AXTreeTest, TreeDelegateIsNotCalledForReparenting) { |
534 AXTreeUpdate initial_state; | 533 AXTreeUpdate initial_state; |
535 initial_state.root_id = 1; | 534 initial_state.root_id = 1; |
536 initial_state.nodes.resize(2); | 535 initial_state.nodes.resize(2); |
537 initial_state.nodes[0].id = 1; | 536 initial_state.nodes[0].id = 1; |
538 initial_state.nodes[0].child_ids.push_back(2); | 537 initial_state.nodes[0].child_ids.push_back(2); |
539 initial_state.nodes[1].id = 2; | 538 initial_state.nodes[1].id = 2; |
540 | 539 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 tree_update.nodes[1].child_ids.push_back(3); | 895 tree_update.nodes[1].child_ids.push_back(3); |
897 tree_update.nodes[2].id = 3; | 896 tree_update.nodes[2].id = 3; |
898 tree_update.nodes[2].offset_container_id = 2; | 897 tree_update.nodes[2].offset_container_id = 2; |
899 tree_update.nodes[2].location = gfx::RectF(20, 30, 50, 5); | 898 tree_update.nodes[2].location = gfx::RectF(20, 30, 50, 5); |
900 | 899 |
901 AXTree tree(tree_update); | 900 AXTree tree(tree_update); |
902 EXPECT_EQ("(115, 70) size (50 x 5)", GetBoundsAsString(tree, 3)); | 901 EXPECT_EQ("(115, 70) size (50 x 5)", GetBoundsAsString(tree, 3)); |
903 } | 902 } |
904 | 903 |
905 } // namespace ui | 904 } // namespace ui |
OLD | NEW |