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

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

Issue 2942413003: Forward BrowserAccessibility::get_accSelection to AXPlatformNode. (Closed)
Patch Set: Add impl and tests Created 3 years, 5 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 | « ui/accessibility/platform/ax_platform_node_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 EXPECT_EQ(S_OK, root_obj->get_accKeyboardShortcut(SELF, shortcut.Receive())); 186 EXPECT_EQ(S_OK, root_obj->get_accKeyboardShortcut(SELF, shortcut.Receive()));
187 EXPECT_STREQ(L"Shortcut", shortcut); 187 EXPECT_STREQ(L"Shortcut", shortcut);
188 188
189 EXPECT_EQ(E_INVALIDARG, root_obj->get_accKeyboardShortcut(SELF, nullptr)); 189 EXPECT_EQ(E_INVALIDARG, root_obj->get_accKeyboardShortcut(SELF, nullptr));
190 ScopedVariant bad_id(999); 190 ScopedVariant bad_id(999);
191 ScopedBstr k2; 191 ScopedBstr k2;
192 EXPECT_EQ(E_INVALIDARG, 192 EXPECT_EQ(E_INVALIDARG,
193 root_obj->get_accKeyboardShortcut(bad_id, k2.Receive())); 193 root_obj->get_accKeyboardShortcut(bad_id, k2.Receive()));
194 } 194 }
195 195
196 TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelection) {
197 {
198 // We only support AX_ROLE_LIST_BOX as this point, so, this should return
dmazzoni 2017/06/23 18:58:36 I'd prefer splitting this into a bunch of separate
dougt 2017/06/23 22:24:06 Done.
199 // not implemented. We're choosing AX_ROLE_ALERT, but it could be anything
200 // but AX_ROLE_LIST_BOX_OPTION.
201
202 AXNodeData not_supported;
203 not_supported.id = 0;
204 not_supported.role = AX_ROLE_ALERT;
205
206 Init(not_supported);
207 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
208
209 ScopedVariant selection;
210 EXPECT_EQ(E_NOTIMPL, root_obj->get_accSelection(selection.Receive()));
211 }
212
213 // We're going to set up a AX_ROLE_LIST_BOX_OPTION with 2 options. The initial
214 // tree will have nothing selected. Later on we will change the state so that
215 // we can test selection.
216 AXNodeData list;
217 list.id = 0;
218 list.role = AX_ROLE_LIST_BOX;
219
220 list.child_ids.push_back(2);
221 list.child_ids.push_back(3);
222
223 AXNodeData list_item_2;
224 list_item_2.id = 2;
225 list_item_2.role = AX_ROLE_LIST_BOX_OPTION;
226 list_item_2.AddStringAttribute(AX_ATTR_NAME, "Name2");
227
228 AXNodeData list_item_3;
229 list_item_3.id = 3;
230 list_item_3.role = AX_ROLE_LIST_BOX_OPTION;
231 list_item_3.AddStringAttribute(AX_ATTR_NAME, "Name3");
232
233 {
234 // Nothing is selected. This should return S_OK and the selection should be
235 // VT_EMPTY.
236
237 Init(list, list_item_2, list_item_3);
238 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
239
240 ScopedVariant selection;
241 EXPECT_EQ(S_OK, root_obj->get_accSelection(selection.Receive()));
242 EXPECT_EQ(VT_EMPTY, selection.type());
243 }
244
245 // Set one of the items to be selected:
dmazzoni 2017/06/23 18:58:36 One last test with multiple selections
dougt 2017/06/23 22:24:06 Done.
246 list_item_2.state = 1 << ui::AX_STATE_SELECTED;
247
248 {
249 // Test that one of the list items is return from accSelection.
250 Init(list, list_item_2, list_item_3);
251
252 ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
253
254 ScopedVariant selection;
255 EXPECT_EQ(S_OK, root_obj->get_accSelection(selection.Receive()));
256 ASSERT_NE(nullptr, selection.ptr());
257
258 // We got something back, make sure that it has the corrent name.
dmazzoni 2017/06/23 18:58:36 corrent -> correct
dougt 2017/06/23 22:24:06 Done.
259 base::win::ScopedComPtr<IAccessible> accessible;
260 HRESULT hr =
261 V_DISPATCH(selection.ptr())->QueryInterface(IID_PPV_ARGS(&accessible));
262 EXPECT_EQ(S_OK, hr);
263 ScopedBstr name;
264 EXPECT_EQ(S_OK, accessible->get_accName(SELF, name.Receive()));
265 EXPECT_STREQ(L"Name2", name);
266 }
267 }
268
196 TEST_F(AXPlatformNodeWinTest, TestIAccessibleRole) { 269 TEST_F(AXPlatformNodeWinTest, TestIAccessibleRole) {
197 AXNodeData root; 270 AXNodeData root;
198 root.id = 1; 271 root.id = 1;
199 root.child_ids.push_back(2); 272 root.child_ids.push_back(2);
200 273
201 AXNodeData child; 274 AXNodeData child;
202 child.id = 2; 275 child.id = 2;
203 276
204 Init(root, child); 277 Init(root, child);
205 AXNode* child_node = GetRootNode()->children()[0]; 278 AXNode* child_node = GetRootNode()->children()[0];
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 1, 0)); 586 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 1, 0));
514 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 2, 2)); 587 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 2, 2));
515 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, IA2_TEXT_OFFSET_CARET, 588 EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, IA2_TEXT_OFFSET_CARET,
516 IA2_TEXT_OFFSET_LENGTH)); 589 IA2_TEXT_OFFSET_LENGTH));
517 590
518 EXPECT_HRESULT_FAILED(text_field->setSelection(1, 0, 0)); 591 EXPECT_HRESULT_FAILED(text_field->setSelection(1, 0, 0));
519 EXPECT_HRESULT_FAILED(text_field->setSelection(0, 0, 5)); 592 EXPECT_HRESULT_FAILED(text_field->setSelection(0, 0, 5));
520 } 593 }
521 594
522 } // namespace ui 595 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698