Chromium Code Reviews| Index: ui/accessibility/platform/ax_platform_node_win_unittest.cc |
| diff --git a/ui/accessibility/platform/ax_platform_node_win_unittest.cc b/ui/accessibility/platform/ax_platform_node_win_unittest.cc |
| index 506267ccaa1d5e4eb0a917282f8ec2259c51be91..2604a7d1680f14c71f38e55e94480b72a1c49030 100644 |
| --- a/ui/accessibility/platform/ax_platform_node_win_unittest.cc |
| +++ b/ui/accessibility/platform/ax_platform_node_win_unittest.cc |
| @@ -193,6 +193,79 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleShortcut) { |
| root_obj->get_accKeyboardShortcut(bad_id, k2.Receive())); |
| } |
| +TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelection) { |
| + { |
| + // 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.
|
| + // not implemented. We're choosing AX_ROLE_ALERT, but it could be anything |
| + // but AX_ROLE_LIST_BOX_OPTION. |
| + |
| + AXNodeData not_supported; |
| + not_supported.id = 0; |
| + not_supported.role = AX_ROLE_ALERT; |
| + |
| + Init(not_supported); |
| + ScopedComPtr<IAccessible> root_obj(GetRootIAccessible()); |
| + |
| + ScopedVariant selection; |
| + EXPECT_EQ(E_NOTIMPL, root_obj->get_accSelection(selection.Receive())); |
| + } |
| + |
| + // We're going to set up a AX_ROLE_LIST_BOX_OPTION with 2 options. The initial |
| + // tree will have nothing selected. Later on we will change the state so that |
| + // we can test selection. |
| + AXNodeData list; |
| + list.id = 0; |
| + list.role = AX_ROLE_LIST_BOX; |
| + |
| + list.child_ids.push_back(2); |
| + list.child_ids.push_back(3); |
| + |
| + AXNodeData list_item_2; |
| + list_item_2.id = 2; |
| + list_item_2.role = AX_ROLE_LIST_BOX_OPTION; |
| + list_item_2.AddStringAttribute(AX_ATTR_NAME, "Name2"); |
| + |
| + AXNodeData list_item_3; |
| + list_item_3.id = 3; |
| + list_item_3.role = AX_ROLE_LIST_BOX_OPTION; |
| + list_item_3.AddStringAttribute(AX_ATTR_NAME, "Name3"); |
| + |
| + { |
| + // Nothing is selected. This should return S_OK and the selection should be |
| + // VT_EMPTY. |
| + |
| + Init(list, list_item_2, list_item_3); |
| + ScopedComPtr<IAccessible> root_obj(GetRootIAccessible()); |
| + |
| + ScopedVariant selection; |
| + EXPECT_EQ(S_OK, root_obj->get_accSelection(selection.Receive())); |
| + EXPECT_EQ(VT_EMPTY, selection.type()); |
| + } |
| + |
| + // 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.
|
| + list_item_2.state = 1 << ui::AX_STATE_SELECTED; |
| + |
| + { |
| + // Test that one of the list items is return from accSelection. |
| + Init(list, list_item_2, list_item_3); |
| + |
| + ScopedComPtr<IAccessible> root_obj(GetRootIAccessible()); |
| + |
| + ScopedVariant selection; |
| + EXPECT_EQ(S_OK, root_obj->get_accSelection(selection.Receive())); |
| + ASSERT_NE(nullptr, selection.ptr()); |
| + |
| + // 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.
|
| + base::win::ScopedComPtr<IAccessible> accessible; |
| + HRESULT hr = |
| + V_DISPATCH(selection.ptr())->QueryInterface(IID_PPV_ARGS(&accessible)); |
| + EXPECT_EQ(S_OK, hr); |
| + ScopedBstr name; |
| + EXPECT_EQ(S_OK, accessible->get_accName(SELF, name.Receive())); |
| + EXPECT_STREQ(L"Name2", name); |
| + } |
| +} |
| + |
| TEST_F(AXPlatformNodeWinTest, TestIAccessibleRole) { |
| AXNodeData root; |
| root.id = 1; |