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

Side by Side Diff: ui/accessibility/platform/ax_platform_node_win_unittest.cc

Issue 2679313003: Implemented IA2::setSelection and related methods on text fields in Views. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/accessibility/platform/ax_platform_node.h" 5 #include "ui/accessibility/platform/ax_platform_node.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlcom.h> 8 #include <atlcom.h>
9 #include <oleacc.h> 9 #include <oleacc.h>
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 iaccessible->AddRef(); 88 iaccessible->AddRef();
89 return ScopedComPtr<IAccessible>(iaccessible); 89 return ScopedComPtr<IAccessible>(iaccessible);
90 } 90 }
91 91
92 ScopedComPtr<IAccessible> GetRootIAccessible() { 92 ScopedComPtr<IAccessible> GetRootIAccessible() {
93 return IAccessibleFromNode(GetRootNode()); 93 return IAccessibleFromNode(GetRootNode());
94 } 94 }
95 95
96 ScopedComPtr<IAccessible2> ToIAccessible2( 96 ScopedComPtr<IAccessible2> ToIAccessible2(
97 ScopedComPtr<IAccessible> accessible) { 97 ScopedComPtr<IAccessible> accessible) {
98 CHECK(accessible.get());
98 ScopedComPtr<IServiceProvider> service_provider; 99 ScopedComPtr<IServiceProvider> service_provider;
99 service_provider.QueryFrom(accessible.get()); 100 service_provider.QueryFrom(accessible.get());
100 ScopedComPtr<IAccessible2> result; 101 ScopedComPtr<IAccessible2> result;
101 CHECK(SUCCEEDED( 102 CHECK(SUCCEEDED(
102 service_provider->QueryService(IID_IAccessible2, result.Receive()))); 103 service_provider->QueryService(IID_IAccessible2, result.Receive())));
103 return result; 104 return result;
104 } 105 }
105 106
106 std::unique_ptr<AXTree> tree_; 107 std::unique_ptr<AXTree> tree_;
107 }; 108 };
108 109
109 TEST_F(AXPlatformNodeWinTest, TestIAccessibleDetachedObject) { 110 TEST_F(AXPlatformNodeWinTest, TestIAccessibleDetachedObject) {
110 AXNodeData root; 111 AXNodeData root;
111 root.id = 1; 112 root.id = 1;
112 root.AddStringAttribute(AX_ATTR_NAME, "Name"); 113 root.AddStringAttribute(AX_ATTR_NAME, "Name");
113 Init(root); 114 Init(root);
114 115
115 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible()); 116 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
116 ScopedBstr name; 117 ScopedBstr name;
117 ASSERT_EQ(S_OK, root_obj->get_accName(SELF, name.Receive())); 118 EXPECT_EQ(S_OK, root_obj->get_accName(SELF, name.Receive()));
dmazzoni 2017/02/08 00:41:14 I think I made this an assert and not an expect be
118 EXPECT_EQ(L"Name", base::string16(name)); 119 EXPECT_EQ(L"Name", base::string16(name));
119 120
120 tree_.reset(new AXTree()); 121 tree_.reset(new AXTree());
121 ScopedBstr name2; 122 ScopedBstr name2;
122 ASSERT_EQ(E_FAIL, root_obj->get_accName(SELF, name2.Receive())); 123 EXPECT_EQ(E_FAIL, root_obj->get_accName(SELF, name2.Receive()));
123 } 124 }
124 125
125 TEST_F(AXPlatformNodeWinTest, TestIAccessibleName) { 126 TEST_F(AXPlatformNodeWinTest, TestIAccessibleName) {
126 AXNodeData root; 127 AXNodeData root;
127 root.id = 1; 128 root.id = 1;
128 root.AddStringAttribute(AX_ATTR_NAME, "Name"); 129 root.AddStringAttribute(AX_ATTR_NAME, "Name");
129 Init(root); 130 Init(root);
130 131
131 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible()); 132 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
132 ScopedBstr name; 133 ScopedBstr name;
133 ASSERT_EQ(S_OK, root_obj->get_accName(SELF, name.Receive())); 134 EXPECT_EQ(S_OK, root_obj->get_accName(SELF, name.Receive()));
134 EXPECT_EQ(L"Name", base::string16(name)); 135 EXPECT_EQ(L"Name", base::string16(name));
135 136
136 ASSERT_EQ(E_INVALIDARG, root_obj->get_accName(SELF, nullptr)); 137 EXPECT_EQ(E_INVALIDARG, root_obj->get_accName(SELF, nullptr));
137 ScopedVariant bad_id(999); 138 ScopedVariant bad_id(999);
138 ScopedBstr name2; 139 ScopedBstr name2;
139 ASSERT_EQ(E_INVALIDARG, root_obj->get_accName(bad_id, name2.Receive())); 140 EXPECT_EQ(E_INVALIDARG, root_obj->get_accName(bad_id, name2.Receive()));
140 } 141 }
141 142
142 TEST_F(AXPlatformNodeWinTest, TestIAccessibleDescription) { 143 TEST_F(AXPlatformNodeWinTest, TestIAccessibleDescription) {
143 AXNodeData root; 144 AXNodeData root;
144 root.id = 1; 145 root.id = 1;
145 root.AddStringAttribute(AX_ATTR_DESCRIPTION, "Description"); 146 root.AddStringAttribute(AX_ATTR_DESCRIPTION, "Description");
146 Init(root); 147 Init(root);
147 148
148 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible()); 149 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
149 ScopedBstr description; 150 ScopedBstr description;
150 ASSERT_EQ(S_OK, root_obj->get_accDescription(SELF, description.Receive())); 151 EXPECT_EQ(S_OK, root_obj->get_accDescription(SELF, description.Receive()));
151 EXPECT_EQ(L"Description", base::string16(description)); 152 EXPECT_EQ(L"Description", base::string16(description));
152 153
153 ASSERT_EQ(E_INVALIDARG, root_obj->get_accDescription(SELF, nullptr)); 154 EXPECT_EQ(E_INVALIDARG, root_obj->get_accDescription(SELF, nullptr));
154 ScopedVariant bad_id(999); 155 ScopedVariant bad_id(999);
155 ScopedBstr d2; 156 ScopedBstr d2;
156 ASSERT_EQ(E_INVALIDARG, root_obj->get_accDescription(bad_id, d2.Receive())); 157 EXPECT_EQ(E_INVALIDARG, root_obj->get_accDescription(bad_id, d2.Receive()));
157 } 158 }
158 159
159 TEST_F(AXPlatformNodeWinTest, TestIAccessibleValue) { 160 TEST_F(AXPlatformNodeWinTest, TestIAccessibleValue) {
160 AXNodeData root; 161 AXNodeData root;
161 root.id = 1; 162 root.id = 1;
162 root.AddStringAttribute(AX_ATTR_VALUE, "Value"); 163 root.AddStringAttribute(AX_ATTR_VALUE, "Value");
163 Init(root); 164 Init(root);
164 165
165 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible()); 166 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
166 ScopedBstr value; 167 ScopedBstr value;
167 ASSERT_EQ(S_OK, root_obj->get_accValue(SELF, value.Receive())); 168 EXPECT_EQ(S_OK, root_obj->get_accValue(SELF, value.Receive()));
168 EXPECT_EQ(L"Value", base::string16(value)); 169 EXPECT_EQ(L"Value", base::string16(value));
169 170
170 ASSERT_EQ(E_INVALIDARG, root_obj->get_accValue(SELF, nullptr)); 171 EXPECT_EQ(E_INVALIDARG, root_obj->get_accValue(SELF, nullptr));
171 ScopedVariant bad_id(999); 172 ScopedVariant bad_id(999);
172 ScopedBstr v2; 173 ScopedBstr v2;
173 ASSERT_EQ(E_INVALIDARG, root_obj->get_accValue(bad_id, v2.Receive())); 174 EXPECT_EQ(E_INVALIDARG, root_obj->get_accValue(bad_id, v2.Receive()));
174 } 175 }
175 176
176 TEST_F(AXPlatformNodeWinTest, TestIAccessibleShortcut) { 177 TEST_F(AXPlatformNodeWinTest, TestIAccessibleShortcut) {
177 AXNodeData root; 178 AXNodeData root;
178 root.id = 1; 179 root.id = 1;
179 root.AddStringAttribute(AX_ATTR_SHORTCUT, "Shortcut"); 180 root.AddStringAttribute(AX_ATTR_SHORTCUT, "Shortcut");
180 Init(root); 181 Init(root);
181 182
182 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible()); 183 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
183 ScopedBstr shortcut; 184 ScopedBstr shortcut;
184 ASSERT_EQ(S_OK, root_obj->get_accKeyboardShortcut( 185 EXPECT_EQ(S_OK, root_obj->get_accKeyboardShortcut(SELF, shortcut.Receive()));
185 SELF, shortcut.Receive()));
186 EXPECT_EQ(L"Shortcut", base::string16(shortcut)); 186 EXPECT_EQ(L"Shortcut", base::string16(shortcut));
187 187
188 ASSERT_EQ(E_INVALIDARG, root_obj->get_accKeyboardShortcut(SELF, nullptr)); 188 EXPECT_EQ(E_INVALIDARG, root_obj->get_accKeyboardShortcut(SELF, nullptr));
189 ScopedVariant bad_id(999); 189 ScopedVariant bad_id(999);
190 ScopedBstr k2; 190 ScopedBstr k2;
191 ASSERT_EQ(E_INVALIDARG, root_obj->get_accKeyboardShortcut( 191 EXPECT_EQ(E_INVALIDARG,
192 bad_id, k2.Receive())); 192 root_obj->get_accKeyboardShortcut(bad_id, k2.Receive()));
193 } 193 }
194 194
195 TEST_F(AXPlatformNodeWinTest, TestIAccessibleRole) { 195 TEST_F(AXPlatformNodeWinTest, TestIAccessibleRole) {
196 AXNodeData root; 196 AXNodeData root;
197 root.id = 1; 197 root.id = 1;
198 root.child_ids.push_back(2); 198 root.child_ids.push_back(2);
199 199
200 AXNodeData child; 200 AXNodeData child;
201 child.id = 2; 201 child.id = 2;
202 202
203 Init(root, child); 203 Init(root, child);
204 AXNode* child_node = GetRootNode()->children()[0]; 204 AXNode* child_node = GetRootNode()->children()[0];
205 ScopedComPtr<IAccessible> child_iaccessible( 205 ScopedComPtr<IAccessible> child_iaccessible(
206 IAccessibleFromNode(child_node)); 206 IAccessibleFromNode(child_node));
207 207
208 ScopedVariant role; 208 ScopedVariant role;
209 209
210 child.role = AX_ROLE_ALERT; 210 child.role = AX_ROLE_ALERT;
211 child_node->SetData(child); 211 child_node->SetData(child);
212 ASSERT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive())); 212 EXPECT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive()));
213 EXPECT_EQ(ROLE_SYSTEM_ALERT, V_I4(role.ptr())); 213 EXPECT_EQ(ROLE_SYSTEM_ALERT, V_I4(role.ptr()));
214 214
215 child.role = AX_ROLE_BUTTON; 215 child.role = AX_ROLE_BUTTON;
216 child_node->SetData(child); 216 child_node->SetData(child);
217 ASSERT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive())); 217 EXPECT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive()));
218 EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, V_I4(role.ptr())); 218 EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, V_I4(role.ptr()));
219 219
220 child.role = AX_ROLE_POP_UP_BUTTON; 220 child.role = AX_ROLE_POP_UP_BUTTON;
221 child_node->SetData(child); 221 child_node->SetData(child);
222 ASSERT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive())); 222 EXPECT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive()));
223 EXPECT_EQ(ROLE_SYSTEM_BUTTONMENU, V_I4(role.ptr())); 223 EXPECT_EQ(ROLE_SYSTEM_BUTTONMENU, V_I4(role.ptr()));
224 224
225 ASSERT_EQ(E_INVALIDARG, child_iaccessible->get_accRole(SELF, nullptr)); 225 EXPECT_EQ(E_INVALIDARG, child_iaccessible->get_accRole(SELF, nullptr));
226 ScopedVariant bad_id(999); 226 ScopedVariant bad_id(999);
227 ASSERT_EQ(E_INVALIDARG, child_iaccessible->get_accRole( 227 EXPECT_EQ(E_INVALIDARG,
228 bad_id, role.Receive())); 228 child_iaccessible->get_accRole(bad_id, role.Receive()));
229 } 229 }
230 230
231 TEST_F(AXPlatformNodeWinTest, TestIAccessibleLocation) { 231 TEST_F(AXPlatformNodeWinTest, TestIAccessibleLocation) {
232 AXNodeData root; 232 AXNodeData root;
233 root.id = 1; 233 root.id = 1;
234 root.location = gfx::RectF(10, 40, 800, 600); 234 root.location = gfx::RectF(10, 40, 800, 600);
235 Init(root); 235 Init(root);
236 236
237 TestAXNodeWrapper::SetGlobalCoordinateOffset(gfx::Vector2d(100, 200)); 237 TestAXNodeWrapper::SetGlobalCoordinateOffset(gfx::Vector2d(100, 200));
238 238
239 LONG x_left, y_top, width, height; 239 LONG x_left, y_top, width, height;
240 ASSERT_EQ(S_OK, GetRootIAccessible()->accLocation( 240 EXPECT_EQ(S_OK, GetRootIAccessible()->accLocation(&x_left, &y_top, &width,
241 &x_left, &y_top, &width, &height, SELF)); 241 &height, SELF));
242 EXPECT_EQ(110, x_left); 242 EXPECT_EQ(110, x_left);
243 EXPECT_EQ(240, y_top); 243 EXPECT_EQ(240, y_top);
244 EXPECT_EQ(800, width); 244 EXPECT_EQ(800, width);
245 EXPECT_EQ(600, height); 245 EXPECT_EQ(600, height);
246 246
247 ASSERT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation( 247 EXPECT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation(
248 nullptr, &y_top, &width, &height, SELF)); 248 nullptr, &y_top, &width, &height, SELF));
249 ASSERT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation( 249 EXPECT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation(
250 &x_left, nullptr, &width, &height, SELF)); 250 &x_left, nullptr, &width, &height, SELF));
251 ASSERT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation( 251 EXPECT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation(
252 &x_left, &y_top, nullptr, &height, SELF)); 252 &x_left, &y_top, nullptr, &height, SELF));
253 ASSERT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation( 253 EXPECT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation(
254 &x_left, &y_top, &width, nullptr, SELF)); 254 &x_left, &y_top, &width, nullptr, SELF));
255 ScopedVariant bad_id(999); 255 ScopedVariant bad_id(999);
256 ASSERT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation( 256 EXPECT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation(
257 &x_left, &y_top, &width, &height, bad_id)); 257 &x_left, &y_top, &width, &height, bad_id));
258 } 258 }
259 259
260 TEST_F(AXPlatformNodeWinTest, TestIAccessibleChildAndParent) { 260 TEST_F(AXPlatformNodeWinTest, TestIAccessibleChildAndParent) {
261 AXNodeData root; 261 AXNodeData root;
262 root.id = 1; 262 root.id = 1;
263 root.child_ids.push_back(2); 263 root.child_ids.push_back(2);
264 root.child_ids.push_back(3); 264 root.child_ids.push_back(3);
265 265
266 AXNodeData button; 266 AXNodeData button;
267 button.role = AX_ROLE_BUTTON; 267 button.role = AX_ROLE_BUTTON;
268 button.id = 2; 268 button.id = 2;
269 269
270 AXNodeData checkbox; 270 AXNodeData checkbox;
271 checkbox.role = AX_ROLE_CHECK_BOX; 271 checkbox.role = AX_ROLE_CHECK_BOX;
272 checkbox.id = 3; 272 checkbox.id = 3;
273 273
274 Init(root, button, checkbox); 274 Init(root, button, checkbox);
275 AXNode* button_node = GetRootNode()->children()[0]; 275 AXNode* button_node = GetRootNode()->children()[0];
276 AXNode* checkbox_node = GetRootNode()->children()[1]; 276 AXNode* checkbox_node = GetRootNode()->children()[1];
277 ScopedComPtr<IAccessible> root_iaccessible(GetRootIAccessible()); 277 ScopedComPtr<IAccessible> root_iaccessible(GetRootIAccessible());
278 ScopedComPtr<IAccessible> button_iaccessible( 278 ScopedComPtr<IAccessible> button_iaccessible(
279 IAccessibleFromNode(button_node)); 279 IAccessibleFromNode(button_node));
280 ScopedComPtr<IAccessible> checkbox_iaccessible( 280 ScopedComPtr<IAccessible> checkbox_iaccessible(
281 IAccessibleFromNode(checkbox_node)); 281 IAccessibleFromNode(checkbox_node));
282 282
283 LONG child_count; 283 LONG child_count;
284 ASSERT_EQ(S_OK, root_iaccessible->get_accChildCount(&child_count)); 284 EXPECT_EQ(S_OK, root_iaccessible->get_accChildCount(&child_count));
285 ASSERT_EQ(2L, child_count); 285 EXPECT_EQ(2L, child_count);
286 ASSERT_EQ(S_OK, button_iaccessible->get_accChildCount(&child_count)); 286 EXPECT_EQ(S_OK, button_iaccessible->get_accChildCount(&child_count));
287 ASSERT_EQ(0L, child_count); 287 EXPECT_EQ(0L, child_count);
288 ASSERT_EQ(S_OK, checkbox_iaccessible->get_accChildCount(&child_count)); 288 EXPECT_EQ(S_OK, checkbox_iaccessible->get_accChildCount(&child_count));
289 ASSERT_EQ(0L, child_count); 289 EXPECT_EQ(0L, child_count);
290 290
291 { 291 {
292 ScopedComPtr<IDispatch> result; 292 ScopedComPtr<IDispatch> result;
293 ASSERT_EQ(S_OK, root_iaccessible->get_accChild(SELF, result.Receive())); 293 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(SELF, result.Receive()));
294 ASSERT_EQ(result.get(), root_iaccessible); 294 EXPECT_EQ(result.get(), root_iaccessible);
295 } 295 }
296 296
297 { 297 {
298 ScopedComPtr<IDispatch> result; 298 ScopedComPtr<IDispatch> result;
299 ScopedVariant child1(1); 299 ScopedVariant child1(1);
300 ASSERT_EQ(S_OK, root_iaccessible->get_accChild(child1, result.Receive())); 300 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(child1, result.Receive()));
301 ASSERT_EQ(result.get(), button_iaccessible); 301 EXPECT_EQ(result.get(), button_iaccessible);
302 } 302 }
303 303
304 { 304 {
305 ScopedComPtr<IDispatch> result; 305 ScopedComPtr<IDispatch> result;
306 ScopedVariant child2(2); 306 ScopedVariant child2(2);
307 ASSERT_EQ(S_OK, root_iaccessible->get_accChild(child2, result.Receive())); 307 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(child2, result.Receive()));
308 ASSERT_EQ(result.get(), checkbox_iaccessible); 308 EXPECT_EQ(result.get(), checkbox_iaccessible);
309 } 309 }
310 310
311 { 311 {
312 // Asking for child id 3 should fail. 312 // Asking for child id 3 should fail.
313 ScopedComPtr<IDispatch> result; 313 ScopedComPtr<IDispatch> result;
314 ScopedVariant child3(3); 314 ScopedVariant child3(3);
315 ASSERT_EQ(E_INVALIDARG, 315 EXPECT_EQ(E_INVALIDARG,
316 root_iaccessible->get_accChild(child3, result.Receive())); 316 root_iaccessible->get_accChild(child3, result.Receive()));
317 } 317 }
318 318
319 // We should be able to ask for the button by its unique id too. 319 // We should be able to ask for the button by its unique id too.
320 LONG button_unique_id; 320 LONG button_unique_id;
321 ScopedComPtr<IAccessible2> button_iaccessible2 = 321 ScopedComPtr<IAccessible2> button_iaccessible2 =
322 ToIAccessible2(button_iaccessible); 322 ToIAccessible2(button_iaccessible);
323 button_iaccessible2->get_uniqueID(&button_unique_id); 323 button_iaccessible2->get_uniqueID(&button_unique_id);
324 ASSERT_LT(button_unique_id, 0); 324 ASSERT_LT(button_unique_id, 0);
325 { 325 {
326 ScopedComPtr<IDispatch> result; 326 ScopedComPtr<IDispatch> result;
327 ScopedVariant button_id_variant(button_unique_id); 327 ScopedVariant button_id_variant(button_unique_id);
328 ASSERT_EQ(S_OK, root_iaccessible->get_accChild(button_id_variant, 328 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(button_id_variant,
329 result.Receive())); 329 result.Receive()));
330 ASSERT_EQ(result.get(), button_iaccessible); 330 EXPECT_EQ(result.get(), button_iaccessible);
331 } 331 }
332 332
333 // We shouldn't be able to ask for the root node by its unique ID 333 // We shouldn't be able to ask for the root node by its unique ID
334 // from one of its children, though. 334 // from one of its children, though.
335 LONG root_unique_id; 335 LONG root_unique_id;
336 ScopedComPtr<IAccessible2> root_iaccessible2 = 336 ScopedComPtr<IAccessible2> root_iaccessible2 =
337 ToIAccessible2(root_iaccessible); 337 ToIAccessible2(root_iaccessible);
338 root_iaccessible2->get_uniqueID(&root_unique_id); 338 root_iaccessible2->get_uniqueID(&root_unique_id);
339 ASSERT_LT(root_unique_id, 0); 339 ASSERT_LT(root_unique_id, 0);
340 { 340 {
341 ScopedComPtr<IDispatch> result; 341 ScopedComPtr<IDispatch> result;
342 ScopedVariant root_id_variant(root_unique_id); 342 ScopedVariant root_id_variant(root_unique_id);
343 ASSERT_EQ(E_INVALIDARG, button_iaccessible->get_accChild(root_id_variant, 343 EXPECT_EQ(E_INVALIDARG, button_iaccessible->get_accChild(root_id_variant,
344 result.Receive())); 344 result.Receive()));
345 } 345 }
346 346
347 // Now check parents. 347 // Now check parents.
348 { 348 {
349 ScopedComPtr<IDispatch> result; 349 ScopedComPtr<IDispatch> result;
350 ASSERT_EQ(S_OK, button_iaccessible->get_accParent(result.Receive())); 350 EXPECT_EQ(S_OK, button_iaccessible->get_accParent(result.Receive()));
351 ASSERT_EQ(result.get(), root_iaccessible); 351 EXPECT_EQ(result.get(), root_iaccessible);
352 } 352 }
353 353
354 { 354 {
355 ScopedComPtr<IDispatch> result; 355 ScopedComPtr<IDispatch> result;
356 ASSERT_EQ(S_OK, checkbox_iaccessible->get_accParent(result.Receive())); 356 EXPECT_EQ(S_OK, checkbox_iaccessible->get_accParent(result.Receive()));
357 ASSERT_EQ(result.get(), root_iaccessible); 357 EXPECT_EQ(result.get(), root_iaccessible);
358 } 358 }
359 359
360 { 360 {
361 ScopedComPtr<IDispatch> result; 361 ScopedComPtr<IDispatch> result;
362 ASSERT_EQ(S_FALSE, root_iaccessible->get_accParent(result.Receive())); 362 EXPECT_EQ(S_FALSE, root_iaccessible->get_accParent(result.Receive()));
363 } 363 }
364 } 364 }
365 365
366 TEST_F(AXPlatformNodeWinTest, TestIAccessible2IndexInParent) { 366 TEST_F(AXPlatformNodeWinTest, TestIAccessible2IndexInParent) {
367 AXNodeData root; 367 AXNodeData root;
368 root.id = 1; 368 root.id = 1;
369 root.child_ids.push_back(2); 369 root.child_ids.push_back(2);
370 root.child_ids.push_back(3); 370 root.child_ids.push_back(3);
371 371
372 AXNodeData left; 372 AXNodeData left;
373 left.id = 2; 373 left.id = 2;
374 374
375 AXNodeData right; 375 AXNodeData right;
376 right.id = 3; 376 right.id = 3;
377 377
378 Init(root, left, right); 378 Init(root, left, right);
379 ScopedComPtr<IAccessible> root_iaccessible(GetRootIAccessible()); 379 ScopedComPtr<IAccessible> root_iaccessible(GetRootIAccessible());
380 ScopedComPtr<IAccessible2> root_iaccessible2 = 380 ScopedComPtr<IAccessible2> root_iaccessible2 =
381 ToIAccessible2(root_iaccessible); 381 ToIAccessible2(root_iaccessible);
382 ScopedComPtr<IAccessible> left_iaccessible( 382 ScopedComPtr<IAccessible> left_iaccessible(
383 IAccessibleFromNode(GetRootNode()->children()[0])); 383 IAccessibleFromNode(GetRootNode()->children()[0]));
384 ScopedComPtr<IAccessible2> left_iaccessible2 = 384 ScopedComPtr<IAccessible2> left_iaccessible2 =
385 ToIAccessible2(left_iaccessible); 385 ToIAccessible2(left_iaccessible);
386 ScopedComPtr<IAccessible> right_iaccessible( 386 ScopedComPtr<IAccessible> right_iaccessible(
387 IAccessibleFromNode(GetRootNode()->children()[1])); 387 IAccessibleFromNode(GetRootNode()->children()[1]));
388 ScopedComPtr<IAccessible2> right_iaccessible2 = 388 ScopedComPtr<IAccessible2> right_iaccessible2 =
389 ToIAccessible2(right_iaccessible); 389 ToIAccessible2(right_iaccessible);
390 390
391 LONG index; 391 LONG index;
392 ASSERT_EQ(E_FAIL, root_iaccessible2->get_indexInParent(&index)); 392 EXPECT_EQ(E_FAIL, root_iaccessible2->get_indexInParent(&index));
393 393
394 ASSERT_EQ(S_OK, left_iaccessible2->get_indexInParent(&index)); 394 EXPECT_EQ(S_OK, left_iaccessible2->get_indexInParent(&index));
395 EXPECT_EQ(0, index); 395 EXPECT_EQ(0, index);
396 396
397 ASSERT_EQ(S_OK, right_iaccessible2->get_indexInParent(&index)); 397 EXPECT_EQ(S_OK, right_iaccessible2->get_indexInParent(&index));
398 EXPECT_EQ(1, index); 398 EXPECT_EQ(1, index);
399 } 399 }
400 400
401 TEST_F(AXPlatformNodeWinTest, TestIAccessible2SetSelection) {
402 AXNodeData text_field_node;
403 text_field_node.id = 1;
404 text_field_node.role = ui::AX_ROLE_TEXT_FIELD;
405 text_field_node.state = 1 << ui::AX_STATE_EDITABLE;
406 text_field_node.SetValue("Hi");
407
408 Init(text_field_node);
409 ScopedComPtr<IAccessible2> ia2_text_field =
410 ToIAccessible2(GetRootIAccessible());
411 ScopedComPtr<IAccessibleText> text_field;
412 text_field.QueryFrom(ia2_text_field.get());
413 ASSERT_NE(nullptr, text_field);
414
415 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 0, 1));
416 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 1, 0));
417 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 2, 2));
418 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, IA2_TEXT_OFFSET_CARET,
419 IA2_TEXT_OFFSET_LENGTH));
420
421 EXPECT_HRESULT_FAILED(text_field->setSelection(1, 0, 0));
422 EXPECT_HRESULT_FAILED(text_field->setSelection(0, 0, 5));
423 }
424
401 } // namespace ui 425 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_win.cc ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698