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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 std::vector<int32_t> subtree_creation_finished_ids_; | 92 std::vector<int32_t> subtree_creation_finished_ids_; |
93 std::vector<int32_t> change_finished_ids_; | 93 std::vector<int32_t> change_finished_ids_; |
94 }; | 94 }; |
95 | 95 |
96 } // namespace | 96 } // namespace |
97 | 97 |
98 TEST(AXTreeTest, SerializeSimpleAXTree) { | 98 TEST(AXTreeTest, SerializeSimpleAXTree) { |
99 AXNodeData root; | 99 AXNodeData root; |
100 root.id = 1; | 100 root.id = 1; |
101 root.role = AX_ROLE_ROOT_WEB_AREA; | 101 root.role = AX_ROLE_ROOT_WEB_AREA; |
102 root.state = (1 << AX_STATE_FOCUSABLE) | (1 << AX_STATE_FOCUSED); | 102 root.state = 1 << AX_STATE_FOCUSABLE; |
103 root.location = gfx::Rect(0, 0, 800, 600); | 103 root.location = gfx::Rect(0, 0, 800, 600); |
104 root.child_ids.push_back(2); | 104 root.child_ids.push_back(2); |
105 root.child_ids.push_back(3); | 105 root.child_ids.push_back(3); |
106 | 106 |
107 AXNodeData button; | 107 AXNodeData button; |
108 button.id = 2; | 108 button.id = 2; |
109 button.role = AX_ROLE_BUTTON; | 109 button.role = AX_ROLE_BUTTON; |
110 button.state = 0; | 110 button.state = 0; |
111 button.location = gfx::Rect(20, 20, 200, 30); | 111 button.location = gfx::Rect(20, 20, 200, 30); |
112 | 112 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 const AXNode* button_node = root_node->ChildAtIndex(0); | 144 const AXNode* button_node = root_node->ChildAtIndex(0); |
145 EXPECT_EQ(button.id, button_node->id()); | 145 EXPECT_EQ(button.id, button_node->id()); |
146 EXPECT_EQ(button.role, button_node->data().role); | 146 EXPECT_EQ(button.role, button_node->data().role); |
147 | 147 |
148 const AXNode* checkbox_node = root_node->ChildAtIndex(1); | 148 const AXNode* checkbox_node = root_node->ChildAtIndex(1); |
149 EXPECT_EQ(checkbox.id, checkbox_node->id()); | 149 EXPECT_EQ(checkbox.id, checkbox_node->id()); |
150 EXPECT_EQ(checkbox.role, checkbox_node->data().role); | 150 EXPECT_EQ(checkbox.role, checkbox_node->data().role); |
151 | 151 |
152 EXPECT_EQ( | 152 EXPECT_EQ( |
153 "AXTree title=Title\n" | 153 "AXTree title=Title\n" |
154 "id=1 rootWebArea FOCUSABLE FOCUSED (0, 0)-(800, 600) child_ids=2,3\n" | 154 "id=1 rootWebArea FOCUSABLE (0, 0)-(800, 600) child_ids=2,3\n" |
155 " id=2 button (20, 20)-(200, 30)\n" | 155 " id=2 button (20, 20)-(200, 30)\n" |
156 " id=3 checkBox (20, 50)-(200, 30)\n", | 156 " id=3 checkBox (20, 50)-(200, 30)\n", |
157 dst_tree.ToString()); | 157 dst_tree.ToString()); |
158 } | 158 } |
159 | 159 |
160 TEST(AXTreeTest, SerializeAXTreeUpdate) { | 160 TEST(AXTreeTest, SerializeAXTreeUpdate) { |
161 AXNodeData list; | 161 AXNodeData list; |
162 list.id = 3; | 162 list.id = 3; |
163 list.role = AX_ROLE_LIST; | 163 list.role = AX_ROLE_LIST; |
164 list.state = 0; | 164 list.state = 0; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 tree_data_update.has_tree_data = true; | 392 tree_data_update.has_tree_data = true; |
393 tree_data_update.tree_data.title = "New Title"; | 393 tree_data_update.tree_data.title = "New Title"; |
394 EXPECT_TRUE(tree.Unserialize(tree_data_update)); | 394 EXPECT_TRUE(tree.Unserialize(tree_data_update)); |
395 EXPECT_TRUE(fake_delegate.tree_data_changed()); | 395 EXPECT_TRUE(fake_delegate.tree_data_changed()); |
396 EXPECT_EQ("New Title", tree.data().title); | 396 EXPECT_EQ("New Title", tree.data().title); |
397 | 397 |
398 tree.SetDelegate(NULL); | 398 tree.SetDelegate(NULL); |
399 } | 399 } |
400 | 400 |
401 } // namespace ui | 401 } // namespace ui |
OLD | NEW |