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> |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 two.push_back(2); | 742 two.push_back(2); |
743 | 743 |
744 std::vector<int32_t> three; | 744 std::vector<int32_t> three; |
745 three.push_back(3); | 745 three.push_back(3); |
746 | 746 |
747 AXTreeUpdate initial_state; | 747 AXTreeUpdate initial_state; |
748 initial_state.root_id = 1; | 748 initial_state.root_id = 1; |
749 initial_state.nodes.resize(1); | 749 initial_state.nodes.resize(1); |
750 initial_state.nodes[0].id = 1; | 750 initial_state.nodes[0].id = 1; |
751 initial_state.nodes[0].AddIntListAttribute(AX_ATTR_CONTROLS_IDS, one); | 751 initial_state.nodes[0].AddIntListAttribute(AX_ATTR_CONTROLS_IDS, one); |
752 initial_state.nodes[0].AddIntListAttribute(AX_ATTR_DETAILS_IDS, two); | 752 initial_state.nodes[0].AddIntListAttribute(AX_ATTR_RADIO_GROUP_IDS, two); |
753 AXTree tree(initial_state); | 753 AXTree tree(initial_state); |
754 | 754 |
755 FakeAXTreeDelegate fake_delegate; | 755 FakeAXTreeDelegate fake_delegate; |
756 tree.SetDelegate(&fake_delegate); | 756 tree.SetDelegate(&fake_delegate); |
757 | 757 |
758 // Change existing attributes. | 758 // Change existing attributes. |
759 AXTreeUpdate update0; | 759 AXTreeUpdate update0; |
760 update0.root_id = 1; | 760 update0.root_id = 1; |
761 update0.nodes.resize(1); | 761 update0.nodes.resize(1); |
762 update0.nodes[0].id = 1; | 762 update0.nodes[0].id = 1; |
763 update0.nodes[0].AddIntListAttribute(AX_ATTR_CONTROLS_IDS, two); | 763 update0.nodes[0].AddIntListAttribute(AX_ATTR_CONTROLS_IDS, two); |
764 update0.nodes[0].AddIntListAttribute(AX_ATTR_DETAILS_IDS, three); | 764 update0.nodes[0].AddIntListAttribute(AX_ATTR_RADIO_GROUP_IDS, three); |
765 EXPECT_TRUE(tree.Unserialize(update0)); | 765 EXPECT_TRUE(tree.Unserialize(update0)); |
766 | 766 |
767 const std::vector<std::string>& change_log = | 767 const std::vector<std::string>& change_log = |
768 fake_delegate.attribute_change_log(); | 768 fake_delegate.attribute_change_log(); |
769 ASSERT_EQ(2U, change_log.size()); | 769 ASSERT_EQ(2U, change_log.size()); |
770 EXPECT_EQ("controlsIds changed from 1 to 2,2", change_log[0]); | 770 EXPECT_EQ("controlsIds changed from 1 to 2,2", change_log[0]); |
771 EXPECT_EQ("detailsIds changed from 2,2 to 3", change_log[1]); | 771 EXPECT_EQ("radioGroupIds changed from 2,2 to 3", change_log[1]); |
772 | 772 |
773 FakeAXTreeDelegate fake_delegate2; | 773 FakeAXTreeDelegate fake_delegate2; |
774 tree.SetDelegate(&fake_delegate2); | 774 tree.SetDelegate(&fake_delegate2); |
775 | 775 |
776 // Add and remove attributes. | 776 // Add and remove attributes. |
777 AXTreeUpdate update1; | 777 AXTreeUpdate update1; |
778 update1.root_id = 1; | 778 update1.root_id = 1; |
779 update1.nodes.resize(1); | 779 update1.nodes.resize(1); |
780 update1.nodes[0].id = 1; | 780 update1.nodes[0].id = 1; |
781 update1.nodes[0].AddIntListAttribute(AX_ATTR_DETAILS_IDS, two); | 781 update1.nodes[0].AddIntListAttribute(AX_ATTR_RADIO_GROUP_IDS, two); |
782 update1.nodes[0].AddIntListAttribute(AX_ATTR_FLOWTO_IDS, three); | 782 update1.nodes[0].AddIntListAttribute(AX_ATTR_FLOWTO_IDS, three); |
783 EXPECT_TRUE(tree.Unserialize(update1)); | 783 EXPECT_TRUE(tree.Unserialize(update1)); |
784 | 784 |
785 const std::vector<std::string>& change_log2 = | 785 const std::vector<std::string>& change_log2 = |
786 fake_delegate2.attribute_change_log(); | 786 fake_delegate2.attribute_change_log(); |
787 ASSERT_EQ(3U, change_log2.size()); | 787 ASSERT_EQ(3U, change_log2.size()); |
788 EXPECT_EQ("controlsIds changed from 2,2 to ", change_log2[0]); | 788 EXPECT_EQ("controlsIds changed from 2,2 to ", change_log2[0]); |
789 EXPECT_EQ("detailsIds changed from 3 to 2,2", change_log2[1]); | 789 EXPECT_EQ("radioGroupIds changed from 3 to 2,2", change_log2[1]); |
790 EXPECT_EQ("flowtoIds changed from to 3", change_log2[2]); | 790 EXPECT_EQ("flowtoIds changed from to 3", change_log2[2]); |
791 | 791 |
792 tree.SetDelegate(NULL); | 792 tree.SetDelegate(NULL); |
793 } | 793 } |
794 | 794 |
795 // Create a very simple tree and make sure that we can get the bounds of | 795 // Create a very simple tree and make sure that we can get the bounds of |
796 // any node. | 796 // any node. |
797 TEST(AXTreeTest, GetBoundsBasic) { | 797 TEST(AXTreeTest, GetBoundsBasic) { |
798 AXTreeUpdate tree_update; | 798 AXTreeUpdate tree_update; |
799 tree_update.root_id = 1; | 799 tree_update.root_id = 1; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 tree_update.nodes[1].child_ids.push_back(3); | 895 tree_update.nodes[1].child_ids.push_back(3); |
896 tree_update.nodes[2].id = 3; | 896 tree_update.nodes[2].id = 3; |
897 tree_update.nodes[2].offset_container_id = 2; | 897 tree_update.nodes[2].offset_container_id = 2; |
898 tree_update.nodes[2].location = gfx::RectF(20, 30, 50, 5); | 898 tree_update.nodes[2].location = gfx::RectF(20, 30, 50, 5); |
899 | 899 |
900 AXTree tree(tree_update); | 900 AXTree tree(tree_update); |
901 EXPECT_EQ("(115, 70) size (50 x 5)", GetBoundsAsString(tree, 3)); | 901 EXPECT_EQ("(115, 70) size (50 x 5)", GetBoundsAsString(tree, 3)); |
902 } | 902 } |
903 | 903 |
904 } // namespace ui | 904 } // namespace ui |
OLD | NEW |