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

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

Issue 236203015: Add ToString to AXTreeUpdate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nicer indent Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/accessibility/ax_tree.cc ('k') | ui/accessibility/ax_tree_update.h » ('j') | 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 EXPECT_EQ(checkbox.id, checkbox_node->id()); 96 EXPECT_EQ(checkbox.id, checkbox_node->id());
97 EXPECT_EQ(checkbox.role, checkbox_node->data().role); 97 EXPECT_EQ(checkbox.role, checkbox_node->data().role);
98 98
99 EXPECT_EQ( 99 EXPECT_EQ(
100 "id=1 root_web_area FOCUSABLE FOCUSED (0, 0)-(800, 600) child_ids=2,3\n" 100 "id=1 root_web_area FOCUSABLE FOCUSED (0, 0)-(800, 600) child_ids=2,3\n"
101 " id=2 button (20, 20)-(200, 30)\n" 101 " id=2 button (20, 20)-(200, 30)\n"
102 " id=3 check_box (20, 50)-(200, 30)\n", 102 " id=3 check_box (20, 50)-(200, 30)\n",
103 dst_tree.ToString()); 103 dst_tree.ToString());
104 } 104 }
105 105
106 TEST(AXTreeTest, SerializeAXTreeUpdate) {
107 AXNodeData list;
108 list.id = 3;
109 list.role = AX_ROLE_LIST;
110 list.state = 0;
111 list.child_ids.push_back(4);
112 list.child_ids.push_back(5);
113 list.child_ids.push_back(6);
114
115 AXNodeData list_item_2;
116 list_item_2.id = 5;
117 list_item_2.role = AX_ROLE_LIST_ITEM;
118 list_item_2.state = 0;
119
120 AXNodeData list_item_3;
121 list_item_3.id = 6;
122 list_item_3.role = AX_ROLE_LIST_ITEM;
123 list_item_3.state = 0;
124
125 AXNodeData button;
126 button.id = 7;
127 button.role = AX_ROLE_BUTTON;
128 button.state = 0;
129
130 AXTreeUpdate update;
131 update.nodes.push_back(list);
132 update.nodes.push_back(list_item_2);
133 update.nodes.push_back(list_item_3);
134 update.nodes.push_back(button);
135
136 EXPECT_EQ(
137 "id=3 list (0, 0)-(0, 0) child_ids=4,5,6\n"
138 " id=5 list_item (0, 0)-(0, 0)\n"
139 " id=6 list_item (0, 0)-(0, 0)\n"
140 "id=7 button (0, 0)-(0, 0)\n",
141 update.ToString());
142 }
143
106 TEST(AXTreeTest, DeleteUnknownSubtreeFails) { 144 TEST(AXTreeTest, DeleteUnknownSubtreeFails) {
107 AXNodeData root; 145 AXNodeData root;
108 root.id = 1; 146 root.id = 1;
109 root.role = AX_ROLE_ROOT_WEB_AREA; 147 root.role = AX_ROLE_ROOT_WEB_AREA;
110 148
111 AXTreeUpdate initial_state; 149 AXTreeUpdate initial_state;
112 initial_state.nodes.push_back(root); 150 initial_state.nodes.push_back(root);
113 AXTree tree(initial_state); 151 AXTree tree(initial_state);
114 152
115 // This should fail because we're asking it to delete 153 // This should fail because we're asking it to delete
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 EXPECT_EQ(2, fake_delegate.created_ids()[0]); 272 EXPECT_EQ(2, fake_delegate.created_ids()[0]);
235 EXPECT_EQ(3, fake_delegate.created_ids()[1]); 273 EXPECT_EQ(3, fake_delegate.created_ids()[1]);
236 274
237 ASSERT_EQ(1U, fake_delegate.new_root_ids().size()); 275 ASSERT_EQ(1U, fake_delegate.new_root_ids().size());
238 EXPECT_EQ(2, fake_delegate.new_root_ids()[0]); 276 EXPECT_EQ(2, fake_delegate.new_root_ids()[0]);
239 277
240 tree.SetDelegate(NULL); 278 tree.SetDelegate(NULL);
241 } 279 }
242 280
243 } // namespace ui 281 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/ax_tree.cc ('k') | ui/accessibility/ax_tree_update.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698