OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <oleacc.h> | 5 #include <oleacc.h> |
6 | 6 |
7 #include "base/win/scoped_bstr.h" | 7 #include "base/win/scoped_bstr.h" |
8 #include "base/win/scoped_comptr.h" | 8 #include "base/win/scoped_comptr.h" |
9 #include "base/win/scoped_variant.h" | 9 #include "base/win/scoped_variant.h" |
10 #include "third_party/iaccessible2/ia2_api_all.h" | 10 #include "third_party/iaccessible2/ia2_api_all.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 class NativeViewAccessibilityWinTest : public ViewsTestBase { | 44 class NativeViewAccessibilityWinTest : public ViewsTestBase { |
45 public: | 45 public: |
46 NativeViewAccessibilityWinTest() {} | 46 NativeViewAccessibilityWinTest() {} |
47 ~NativeViewAccessibilityWinTest() override {} | 47 ~NativeViewAccessibilityWinTest() override {} |
48 | 48 |
49 protected: | 49 protected: |
50 void GetIAccessible2InterfaceForView(View* view, IAccessible2_2** result) { | 50 void GetIAccessible2InterfaceForView(View* view, IAccessible2_2** result) { |
51 ScopedComPtr<IAccessible> view_accessible( | 51 ScopedComPtr<IAccessible> view_accessible( |
52 view->GetNativeViewAccessible()); | 52 view->GetNativeViewAccessible()); |
53 ScopedComPtr<IServiceProvider> service_provider; | 53 ScopedComPtr<IServiceProvider> service_provider; |
54 ASSERT_EQ(S_OK, view_accessible.CopyTo(service_provider.Receive())); | 54 ASSERT_EQ(S_OK, view_accessible.CopyTo(service_provider.GetAddressOf())); |
55 ASSERT_EQ(S_OK, | 55 ASSERT_EQ(S_OK, |
56 service_provider->QueryService(IID_IAccessible2_2, result)); | 56 service_provider->QueryService(IID_IAccessible2_2, result)); |
57 } | 57 } |
58 }; | 58 }; |
59 | 59 |
60 TEST_F(NativeViewAccessibilityWinTest, TextfieldAccessibility) { | 60 TEST_F(NativeViewAccessibilityWinTest, TextfieldAccessibility) { |
61 Widget widget; | 61 Widget widget; |
62 Widget::InitParams init_params = | 62 Widget::InitParams init_params = |
63 CreateParams(Widget::InitParams::TYPE_POPUP); | 63 CreateParams(Widget::InitParams::TYPE_POPUP); |
64 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 64 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
(...skipping 10 matching lines...) Expand all Loading... |
75 ScopedComPtr<IAccessible> content_accessible( | 75 ScopedComPtr<IAccessible> content_accessible( |
76 content->GetNativeViewAccessible()); | 76 content->GetNativeViewAccessible()); |
77 LONG child_count = 0; | 77 LONG child_count = 0; |
78 ASSERT_EQ(S_OK, content_accessible->get_accChildCount(&child_count)); | 78 ASSERT_EQ(S_OK, content_accessible->get_accChildCount(&child_count)); |
79 ASSERT_EQ(1L, child_count); | 79 ASSERT_EQ(1L, child_count); |
80 | 80 |
81 ScopedComPtr<IDispatch> textfield_dispatch; | 81 ScopedComPtr<IDispatch> textfield_dispatch; |
82 ScopedComPtr<IAccessible> textfield_accessible; | 82 ScopedComPtr<IAccessible> textfield_accessible; |
83 ScopedVariant child_index(1); | 83 ScopedVariant child_index(1); |
84 ASSERT_EQ(S_OK, content_accessible->get_accChild( | 84 ASSERT_EQ(S_OK, content_accessible->get_accChild( |
85 child_index, textfield_dispatch.Receive())); | 85 child_index, textfield_dispatch.GetAddressOf())); |
86 ASSERT_EQ(S_OK, textfield_dispatch.CopyTo( | 86 ASSERT_EQ(S_OK, |
87 textfield_accessible.Receive())); | 87 textfield_dispatch.CopyTo(textfield_accessible.GetAddressOf())); |
88 | 88 |
89 ScopedBstr name; | 89 ScopedBstr name; |
90 ScopedVariant childid_self(CHILDID_SELF); | 90 ScopedVariant childid_self(CHILDID_SELF); |
91 ASSERT_EQ(S_OK, textfield_accessible->get_accName( | 91 ASSERT_EQ(S_OK, textfield_accessible->get_accName( |
92 childid_self, name.Receive())); | 92 childid_self, name.Receive())); |
93 ASSERT_STREQ(L"Name", name); | 93 ASSERT_STREQ(L"Name", name); |
94 | 94 |
95 ScopedBstr value; | 95 ScopedBstr value; |
96 ASSERT_EQ(S_OK, textfield_accessible->get_accValue( | 96 ASSERT_EQ(S_OK, textfield_accessible->get_accValue( |
97 childid_self, value.Receive())); | 97 childid_self, value.Receive())); |
(...skipping 16 matching lines...) Expand all Loading... |
114 widget.GetRootView()->GetNativeViewAccessible()); | 114 widget.GetRootView()->GetNativeViewAccessible()); |
115 | 115 |
116 LONG child_count = 0; | 116 LONG child_count = 0; |
117 ASSERT_EQ(S_OK, root_view_accessible->get_accChildCount(&child_count)); | 117 ASSERT_EQ(S_OK, root_view_accessible->get_accChildCount(&child_count)); |
118 ASSERT_EQ(1L, child_count); | 118 ASSERT_EQ(1L, child_count); |
119 | 119 |
120 ScopedComPtr<IDispatch> child_view_dispatch; | 120 ScopedComPtr<IDispatch> child_view_dispatch; |
121 ScopedComPtr<IAccessible> child_view_accessible; | 121 ScopedComPtr<IAccessible> child_view_accessible; |
122 ScopedVariant child_index_1(1); | 122 ScopedVariant child_index_1(1); |
123 ASSERT_EQ(S_OK, root_view_accessible->get_accChild( | 123 ASSERT_EQ(S_OK, root_view_accessible->get_accChild( |
124 child_index_1, child_view_dispatch.Receive())); | 124 child_index_1, child_view_dispatch.GetAddressOf())); |
125 ASSERT_EQ(S_OK, child_view_dispatch.CopyTo( | 125 ASSERT_EQ(S_OK, |
126 child_view_accessible.Receive())); | 126 child_view_dispatch.CopyTo(child_view_accessible.GetAddressOf())); |
127 | 127 |
128 Widget owned_widget; | 128 Widget owned_widget; |
129 Widget::InitParams owned_init_params = | 129 Widget::InitParams owned_init_params = |
130 CreateParams(Widget::InitParams::TYPE_POPUP); | 130 CreateParams(Widget::InitParams::TYPE_POPUP); |
131 owned_init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 131 owned_init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
132 owned_init_params.parent = widget.GetNativeView(); | 132 owned_init_params.parent = widget.GetNativeView(); |
133 owned_widget.Init(owned_init_params); | 133 owned_widget.Init(owned_init_params); |
134 owned_widget.Show(); | 134 owned_widget.Show(); |
135 | 135 |
136 ASSERT_EQ(S_OK, root_view_accessible->get_accChildCount(&child_count)); | 136 ASSERT_EQ(S_OK, root_view_accessible->get_accChildCount(&child_count)); |
137 ASSERT_EQ(2L, child_count); | 137 ASSERT_EQ(2L, child_count); |
138 | 138 |
139 ScopedComPtr<IDispatch> child_widget_dispatch; | 139 ScopedComPtr<IDispatch> child_widget_dispatch; |
140 ScopedComPtr<IAccessible> child_widget_accessible; | 140 ScopedComPtr<IAccessible> child_widget_accessible; |
141 ScopedVariant child_index_2(2); | 141 ScopedVariant child_index_2(2); |
142 ASSERT_EQ(S_OK, root_view_accessible->get_accChild( | 142 ASSERT_EQ(S_OK, root_view_accessible->get_accChild( |
143 child_index_2, child_widget_dispatch.Receive())); | 143 child_index_2, child_widget_dispatch.GetAddressOf())); |
144 ASSERT_EQ(S_OK, child_widget_dispatch.CopyTo( | 144 ASSERT_EQ(S_OK, child_widget_dispatch.CopyTo( |
145 child_widget_accessible.Receive())); | 145 child_widget_accessible.GetAddressOf())); |
146 | 146 |
147 ScopedComPtr<IDispatch> child_widget_sibling_dispatch; | 147 ScopedComPtr<IDispatch> child_widget_sibling_dispatch; |
148 ScopedComPtr<IAccessible> child_widget_sibling_accessible; | 148 ScopedComPtr<IAccessible> child_widget_sibling_accessible; |
149 ScopedVariant childid_self(CHILDID_SELF); | 149 ScopedVariant childid_self(CHILDID_SELF); |
150 ScopedVariant result; | 150 ScopedVariant result; |
151 ASSERT_EQ(S_OK, child_widget_accessible->accNavigate( | 151 ASSERT_EQ(S_OK, child_widget_accessible->accNavigate( |
152 NAVDIR_PREVIOUS, childid_self, result.Receive())); | 152 NAVDIR_PREVIOUS, childid_self, result.Receive())); |
153 ASSERT_EQ(VT_DISPATCH, V_VT(result.ptr())); | 153 ASSERT_EQ(VT_DISPATCH, V_VT(result.ptr())); |
154 child_widget_sibling_dispatch = V_DISPATCH(result.ptr()); | 154 child_widget_sibling_dispatch = V_DISPATCH(result.ptr()); |
155 ASSERT_EQ(S_OK, child_widget_sibling_dispatch.CopyTo( | 155 ASSERT_EQ(S_OK, child_widget_sibling_dispatch.CopyTo( |
156 child_widget_sibling_accessible.Receive())); | 156 child_widget_sibling_accessible.GetAddressOf())); |
157 ASSERT_EQ(child_view_accessible.Get(), child_widget_sibling_accessible.Get()); | 157 ASSERT_EQ(child_view_accessible.Get(), child_widget_sibling_accessible.Get()); |
158 | 158 |
159 ScopedComPtr<IDispatch> child_widget_parent_dispatch; | 159 ScopedComPtr<IDispatch> child_widget_parent_dispatch; |
160 ScopedComPtr<IAccessible> child_widget_parent_accessible; | 160 ScopedComPtr<IAccessible> child_widget_parent_accessible; |
161 ASSERT_EQ(S_OK, child_widget_accessible->get_accParent( | 161 ASSERT_EQ(S_OK, child_widget_accessible->get_accParent( |
162 child_widget_parent_dispatch.Receive())); | 162 child_widget_parent_dispatch.GetAddressOf())); |
163 ASSERT_EQ(S_OK, child_widget_parent_dispatch.CopyTo( | 163 ASSERT_EQ(S_OK, child_widget_parent_dispatch.CopyTo( |
164 child_widget_parent_accessible.Receive())); | 164 child_widget_parent_accessible.GetAddressOf())); |
165 ASSERT_EQ(root_view_accessible.Get(), child_widget_parent_accessible.Get()); | 165 ASSERT_EQ(root_view_accessible.Get(), child_widget_parent_accessible.Get()); |
166 } | 166 } |
167 | 167 |
168 // Flaky on Windows: https://crbug.com/461837. | 168 // Flaky on Windows: https://crbug.com/461837. |
169 TEST_F(NativeViewAccessibilityWinTest, DISABLED_RetrieveAllAlerts) { | 169 TEST_F(NativeViewAccessibilityWinTest, DISABLED_RetrieveAllAlerts) { |
170 Widget widget; | 170 Widget widget; |
171 Widget::InitParams init_params = | 171 Widget::InitParams init_params = |
172 CreateParams(Widget::InitParams::TYPE_POPUP); | 172 CreateParams(Widget::InitParams::TYPE_POPUP); |
173 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 173 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
174 widget.Init(init_params); | 174 widget.Init(init_params); |
175 | 175 |
176 View* content = new View; | 176 View* content = new View; |
177 widget.SetContentsView(content); | 177 widget.SetContentsView(content); |
178 | 178 |
179 View* infobar = new View; | 179 View* infobar = new View; |
180 content->AddChildView(infobar); | 180 content->AddChildView(infobar); |
181 | 181 |
182 View* infobar2 = new View; | 182 View* infobar2 = new View; |
183 content->AddChildView(infobar2); | 183 content->AddChildView(infobar2); |
184 | 184 |
185 View* root_view = content->parent(); | 185 View* root_view = content->parent(); |
186 ASSERT_EQ(NULL, root_view->parent()); | 186 ASSERT_EQ(NULL, root_view->parent()); |
187 | 187 |
188 ScopedComPtr<IAccessible2_2> root_view_accessible; | 188 ScopedComPtr<IAccessible2_2> root_view_accessible; |
189 GetIAccessible2InterfaceForView(root_view, root_view_accessible.Receive()); | 189 GetIAccessible2InterfaceForView(root_view, |
| 190 root_view_accessible.GetAddressOf()); |
190 | 191 |
191 ScopedComPtr<IAccessible2_2> infobar_accessible; | 192 ScopedComPtr<IAccessible2_2> infobar_accessible; |
192 GetIAccessible2InterfaceForView(infobar, infobar_accessible.Receive()); | 193 GetIAccessible2InterfaceForView(infobar, infobar_accessible.GetAddressOf()); |
193 | 194 |
194 ScopedComPtr<IAccessible2_2> infobar2_accessible; | 195 ScopedComPtr<IAccessible2_2> infobar2_accessible; |
195 GetIAccessible2InterfaceForView(infobar2, infobar2_accessible.Receive()); | 196 GetIAccessible2InterfaceForView(infobar2, infobar2_accessible.GetAddressOf()); |
196 | 197 |
197 // Initially, there are no alerts | 198 // Initially, there are no alerts |
198 ScopedBstr alerts_bstr(L"alerts"); | 199 ScopedBstr alerts_bstr(L"alerts"); |
199 IUnknown** targets; | 200 IUnknown** targets; |
200 long n_targets; | 201 long n_targets; |
201 ASSERT_EQ(S_FALSE, root_view_accessible->get_relationTargetsOfType( | 202 ASSERT_EQ(S_FALSE, root_view_accessible->get_relationTargetsOfType( |
202 alerts_bstr, 0, &targets, &n_targets)); | 203 alerts_bstr, 0, &targets, &n_targets)); |
203 ASSERT_EQ(0, n_targets); | 204 ASSERT_EQ(0, n_targets); |
204 | 205 |
205 // Fire alert events on the infobars. | 206 // Fire alert events on the infobars. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 242 |
242 LONG child_count = 0; | 243 LONG child_count = 0; |
243 ScopedComPtr<IAccessible> content_accessible( | 244 ScopedComPtr<IAccessible> content_accessible( |
244 widget.GetRootView()->GetNativeViewAccessible()); | 245 widget.GetRootView()->GetNativeViewAccessible()); |
245 EXPECT_EQ(S_OK, content_accessible->get_accChildCount(&child_count)); | 246 EXPECT_EQ(S_OK, content_accessible->get_accChildCount(&child_count)); |
246 EXPECT_EQ(1L, child_count); | 247 EXPECT_EQ(1L, child_count); |
247 } | 248 } |
248 | 249 |
249 } // namespace test | 250 } // namespace test |
250 } // namespace views | 251 } // namespace views |
OLD | NEW |