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

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

Issue 2795843002: Move implementation of accessibility actions to views::View (Closed)
Patch Set: Fix win compile Created 3 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
« no previous file with comments | « no previous file | chrome/browser/ui/aura/accessibility/automation_manager_aura.cc » ('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 <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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/ui/aura/accessibility/ax_tree_source_aura.h" 12 #include "chrome/browser/ui/aura/accessibility/ax_tree_source_aura.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/accessibility/ax_action_data.h"
14 #include "ui/accessibility/ax_enums.h" 15 #include "ui/accessibility/ax_enums.h"
15 #include "ui/accessibility/ax_node.h" 16 #include "ui/accessibility/ax_node.h"
16 #include "ui/accessibility/ax_serializable_tree.h" 17 #include "ui/accessibility/ax_serializable_tree.h"
17 #include "ui/accessibility/ax_tree_serializer.h" 18 #include "ui/accessibility/ax_tree_serializer.h"
18 #include "ui/accessibility/ax_tree_update.h" 19 #include "ui/accessibility/ax_tree_update.h"
19 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
20 #include "ui/views/accessibility/ax_aura_obj_cache.h" 21 #include "ui/views/accessibility/ax_aura_obj_cache.h"
21 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" 22 #include "ui/views/accessibility/ax_aura_obj_wrapper.h"
22 #include "ui/views/controls/textfield/textfield.h" 23 #include "ui/views/controls/textfield/textfield.h"
23 #include "ui/views/test/views_test_base.h" 24 #include "ui/views/test/views_test_base.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 113
113 TEST_F(AXTreeSourceAuraTest, DoDefault) { 114 TEST_F(AXTreeSourceAuraTest, DoDefault) {
114 AXTreeSourceAura ax_tree; 115 AXTreeSourceAura ax_tree;
115 116
116 // Grab a wrapper to |DoDefault| (click). 117 // Grab a wrapper to |DoDefault| (click).
117 AXAuraObjWrapper* textfield_wrapper = 118 AXAuraObjWrapper* textfield_wrapper =
118 AXAuraObjCache::GetInstance()->GetOrCreate(textfield_); 119 AXAuraObjCache::GetInstance()->GetOrCreate(textfield_);
119 120
120 // Click and verify focus. 121 // Click and verify focus.
121 ASSERT_FALSE(textfield_->HasFocus()); 122 ASSERT_FALSE(textfield_->HasFocus());
122 textfield_wrapper->DoDefault(); 123 ui::AXActionData action_data;
124 action_data.action = ui::AX_ACTION_DO_DEFAULT;
125 action_data.target_node_id = textfield_wrapper->GetID();
126 textfield_wrapper->HandleAccessibleAction(action_data);
123 ASSERT_TRUE(textfield_->HasFocus()); 127 ASSERT_TRUE(textfield_->HasFocus());
124 } 128 }
125 129
126 TEST_F(AXTreeSourceAuraTest, Focus) { 130 TEST_F(AXTreeSourceAuraTest, Focus) {
127 AXTreeSourceAura ax_tree; 131 AXTreeSourceAura ax_tree;
128 132
129 // Grab a wrapper to focus. 133 // Grab a wrapper to focus.
130 AXAuraObjWrapper* textfield_wrapper = 134 AXAuraObjWrapper* textfield_wrapper =
131 AXAuraObjCache::GetInstance()->GetOrCreate(textfield_); 135 AXAuraObjCache::GetInstance()->GetOrCreate(textfield_);
132 136
133 // Focus and verify. 137 // Focus and verify.
134 ASSERT_FALSE(textfield_->HasFocus()); 138 ASSERT_FALSE(textfield_->HasFocus());
135 textfield_wrapper->Focus(); 139 ui::AXActionData action_data;
140 action_data.action = ui::AX_ACTION_FOCUS;
141 action_data.target_node_id = textfield_wrapper->GetID();
142 textfield_wrapper->HandleAccessibleAction(action_data);
136 ASSERT_TRUE(textfield_->HasFocus()); 143 ASSERT_TRUE(textfield_->HasFocus());
137 } 144 }
138 145
139 TEST_F(AXTreeSourceAuraTest, Serialize) { 146 TEST_F(AXTreeSourceAuraTest, Serialize) {
140 AXTreeSourceAura ax_tree; 147 AXTreeSourceAura ax_tree;
141 AuraAXTreeSerializer ax_serializer(&ax_tree); 148 AuraAXTreeSerializer ax_serializer(&ax_tree);
142 ui::AXTreeUpdate out_update; 149 ui::AXTreeUpdate out_update;
143 150
144 // This is the initial serialization. 151 // This is the initial serialization.
145 ax_serializer.SerializeChanges(ax_tree.GetRoot(), &out_update); 152 ax_serializer.SerializeChanges(ax_tree.GetRoot(), &out_update);
(...skipping 23 matching lines...) Expand all
169 int text_field_update_index = -1; 176 int text_field_update_index = -1;
170 for (size_t i = 0; i < node_count; ++i) { 177 for (size_t i = 0; i < node_count; ++i) {
171 if (textfield_wrapper->GetID() == out_update2.nodes[i].id) 178 if (textfield_wrapper->GetID() == out_update2.nodes[i].id)
172 text_field_update_index = i; 179 text_field_update_index = i;
173 } 180 }
174 181
175 ASSERT_NE(-1, text_field_update_index); 182 ASSERT_NE(-1, text_field_update_index);
176 ASSERT_EQ(ui::AX_ROLE_TEXT_FIELD, 183 ASSERT_EQ(ui::AX_ROLE_TEXT_FIELD,
177 out_update2.nodes[text_field_update_index].role); 184 out_update2.nodes[text_field_update_index].role);
178 } 185 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/aura/accessibility/automation_manager_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698