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

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

Issue 2514583002: Ensure fake alert window attached to AXAura tree and refine alert dialog output (Closed)
Patch Set: Fix test. Created 4 years, 1 month 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 TEST_F(AXTreeSourceAuraTest, Serialize) { 139 TEST_F(AXTreeSourceAuraTest, Serialize) {
140 AXTreeSourceAura ax_tree; 140 AXTreeSourceAura ax_tree;
141 AuraAXTreeSerializer ax_serializer(&ax_tree); 141 AuraAXTreeSerializer ax_serializer(&ax_tree);
142 ui::AXTreeUpdate out_update; 142 ui::AXTreeUpdate out_update;
143 143
144 // This is the initial serialization. 144 // This is the initial serialization.
145 ax_serializer.SerializeChanges(ax_tree.GetRoot(), &out_update); 145 ax_serializer.SerializeChanges(ax_tree.GetRoot(), &out_update);
146 146
147 // The update should just be the desktop node since no events have been fired 147 // The update should just be the desktop node and the fake alert window we use
148 // on any controls, so no windows have been cached. 148 // to handle posting text alerts.
149 ASSERT_EQ(1U, out_update.nodes.size()); 149 ASSERT_EQ(2U, out_update.nodes.size());
150 150
151 // Try removing some child views and re-adding which should fire some events. 151 // Try removing some child views and re-adding which should fire some events.
152 content_->RemoveAllChildViews(false /* delete_children */); 152 content_->RemoveAllChildViews(false /* delete_children */);
153 content_->AddChildView(textfield_); 153 content_->AddChildView(textfield_);
154 154
155 // Grab the textfield since serialization only walks up the tree (not down 155 // Grab the textfield since serialization only walks up the tree (not down
156 // from root). 156 // from root).
157 AXAuraObjWrapper* textfield_wrapper = 157 AXAuraObjWrapper* textfield_wrapper =
158 AXAuraObjCache::GetInstance()->GetOrCreate(textfield_); 158 AXAuraObjCache::GetInstance()->GetOrCreate(textfield_);
159 159
160 // Now, re-serialize. 160 // Now, re-serialize.
161 ui::AXTreeUpdate out_update2; 161 ui::AXTreeUpdate out_update2;
162 ax_serializer.SerializeChanges(textfield_wrapper, &out_update2); 162 ax_serializer.SerializeChanges(textfield_wrapper, &out_update2);
163 163
164 size_t node_count = out_update2.nodes.size(); 164 size_t node_count = out_update2.nodes.size();
165 165
166 // We should have far more updates this time around. 166 // We should have far more updates this time around.
167 ASSERT_GE(node_count, 10U); 167 ASSERT_GE(node_count, 10U);
168 168
169 int text_field_update_index = -1; 169 int text_field_update_index = -1;
170 for (size_t i = 0; i < node_count; ++i) { 170 for (size_t i = 0; i < node_count; ++i) {
171 if (textfield_wrapper->GetID() == out_update2.nodes[i].id) 171 if (textfield_wrapper->GetID() == out_update2.nodes[i].id)
172 text_field_update_index = i; 172 text_field_update_index = i;
173 } 173 }
174 174
175 ASSERT_NE(-1, text_field_update_index); 175 ASSERT_NE(-1, text_field_update_index);
176 ASSERT_EQ(ui::AX_ROLE_TEXT_FIELD, 176 ASSERT_EQ(ui::AX_ROLE_TEXT_FIELD,
177 out_update2.nodes[text_field_update_index].role); 177 out_update2.nodes[text_field_update_index].role);
178 } 178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698