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

Side by Side Diff: chrome/browser/ui/ash/accessibility/ax_tree_source_aura_unittest.cc

Issue 1413423003: Move some AX attrs from AXNodeData to AXTreeData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/ui/aura/accessibility/automation_manager_aura.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <vector> 5 #include <vector>
6 6
7 #include "ash/test/ash_test_base.h" 7 #include "ash/test/ash_test_base.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/aura/accessibility/ax_tree_source_aura.h" 9 #include "chrome/browser/ui/aura/accessibility/ax_tree_source_aura.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/accessibility/ax_enums.h" 11 #include "ui/accessibility/ax_enums.h"
12 #include "ui/accessibility/ax_node.h" 12 #include "ui/accessibility/ax_node.h"
13 #include "ui/accessibility/ax_serializable_tree.h" 13 #include "ui/accessibility/ax_serializable_tree.h"
14 #include "ui/accessibility/ax_tree_serializer.h" 14 #include "ui/accessibility/ax_tree_serializer.h"
15 #include "ui/accessibility/ax_tree_update.h" 15 #include "ui/accessibility/ax_tree_update.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 #include "ui/views/accessibility/ax_aura_obj_cache.h" 17 #include "ui/views/accessibility/ax_aura_obj_cache.h"
18 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" 18 #include "ui/views/accessibility/ax_aura_obj_wrapper.h"
19 #include "ui/views/controls/textfield/textfield.h" 19 #include "ui/views/controls/textfield/textfield.h"
20 #include "ui/views/test/views_test_base.h" 20 #include "ui/views/test/views_test_base.h"
21 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
22 22
23 using views::AXAuraObjCache; 23 using views::AXAuraObjCache;
24 using views::AXAuraObjWrapper; 24 using views::AXAuraObjWrapper;
25 using views::Textfield; 25 using views::Textfield;
26 using views::View; 26 using views::View;
27 using views::Widget; 27 using views::Widget;
28 28
29 using AuraAXTreeSerializer = 29 using AuraAXTreeSerializer = ui::AXTreeSerializer<views::AXAuraObjWrapper*,
30 ui::AXTreeSerializer<views::AXAuraObjWrapper*, ui::AXNodeData>; 30 ui::AXNodeData,
31 ui::AXTreeData>;
31 32
32 // Helper to count the number of nodes in a tree. 33 // Helper to count the number of nodes in a tree.
33 size_t GetSize(AXAuraObjWrapper* tree) { 34 size_t GetSize(AXAuraObjWrapper* tree) {
34 size_t count = 1; 35 size_t count = 1;
35 36
36 std::vector<AXAuraObjWrapper*> out_children; 37 std::vector<AXAuraObjWrapper*> out_children;
37 tree->GetChildren(&out_children); 38 tree->GetChildren(&out_children);
38 39
39 for (size_t i = 0; i < out_children.size(); ++i) 40 for (size_t i = 0; i < out_children.size(); ++i)
40 count += GetSize(out_children[i]); 41 count += GetSize(out_children[i]);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 128
128 // Focus and verify. 129 // Focus and verify.
129 ASSERT_FALSE(textfield_->HasFocus()); 130 ASSERT_FALSE(textfield_->HasFocus());
130 textfield_wrapper->Focus(); 131 textfield_wrapper->Focus();
131 ASSERT_TRUE(textfield_->HasFocus()); 132 ASSERT_TRUE(textfield_->HasFocus());
132 } 133 }
133 134
134 TEST_F(AXTreeSourceAuraTest, Serialize) { 135 TEST_F(AXTreeSourceAuraTest, Serialize) {
135 AXTreeSourceAura ax_tree; 136 AXTreeSourceAura ax_tree;
136 AuraAXTreeSerializer ax_serializer(&ax_tree); 137 AuraAXTreeSerializer ax_serializer(&ax_tree);
137 ui::AXTreeUpdate<ui::AXNodeData> out_update; 138 ui::AXTreeUpdate out_update;
138 139
139 // This is the initial serialization. 140 // This is the initial serialization.
140 ax_serializer.SerializeChanges(ax_tree.GetRoot(), &out_update); 141 ax_serializer.SerializeChanges(ax_tree.GetRoot(), &out_update);
141 142
142 // The update should just be the desktop node since no events have been fired 143 // The update should just be the desktop node since no events have been fired
143 // on any controls, so no windows have been cached. 144 // on any controls, so no windows have been cached.
144 ASSERT_EQ(1U, out_update.nodes.size()); 145 ASSERT_EQ(1U, out_update.nodes.size());
145 146
146 // Try removing some child views and re-adding which should fire some events. 147 // Try removing some child views and re-adding which should fire some events.
147 content_->RemoveAllChildViews(false /* delete_children */); 148 content_->RemoveAllChildViews(false /* delete_children */);
148 content_->AddChildView(textfield_); 149 content_->AddChildView(textfield_);
149 150
150 // Grab the textfield since serialization only walks up the tree (not down 151 // Grab the textfield since serialization only walks up the tree (not down
151 // from root). 152 // from root).
152 AXAuraObjWrapper* textfield_wrapper = 153 AXAuraObjWrapper* textfield_wrapper =
153 AXAuraObjCache::GetInstance()->GetOrCreate(textfield_); 154 AXAuraObjCache::GetInstance()->GetOrCreate(textfield_);
154 155
155 // Now, re-serialize. 156 // Now, re-serialize.
156 ui::AXTreeUpdate<ui::AXNodeData> out_update2; 157 ui::AXTreeUpdate out_update2;
157 ax_serializer.SerializeChanges(textfield_wrapper, &out_update2); 158 ax_serializer.SerializeChanges(textfield_wrapper, &out_update2);
158 159
159 size_t node_count = out_update2.nodes.size(); 160 size_t node_count = out_update2.nodes.size();
160 161
161 // We should have far more updates this time around. 162 // We should have far more updates this time around.
162 ASSERT_GE(node_count, 10U); 163 ASSERT_GE(node_count, 10U);
163 164
164 ASSERT_EQ(textfield_wrapper->GetID(), out_update2.nodes[node_count - 1].id); 165 ASSERT_EQ(textfield_wrapper->GetID(), out_update2.nodes[node_count - 1].id);
165 ASSERT_EQ(ui::AX_ROLE_TEXT_FIELD, out_update2.nodes[node_count - 1].role); 166 ASSERT_EQ(ui::AX_ROLE_TEXT_FIELD, out_update2.nodes[node_count - 1].role);
166 } 167 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/aura/accessibility/automation_manager_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698