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

Side by Side Diff: ui/views/accessibility/native_view_accessibility_win_unittest.cc

Issue 2864523002: Rename ScopedComPtr::QueryInterface to ScopedComPtr::CopyTo (Closed)
Patch Set: Created 3 years, 7 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/gl/gl_angle_util_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 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 11 matching lines...) Expand all
22 class NativeViewAccessibilityWinTest : public ViewsTestBase { 22 class NativeViewAccessibilityWinTest : public ViewsTestBase {
23 public: 23 public:
24 NativeViewAccessibilityWinTest() {} 24 NativeViewAccessibilityWinTest() {}
25 ~NativeViewAccessibilityWinTest() override {} 25 ~NativeViewAccessibilityWinTest() override {}
26 26
27 protected: 27 protected:
28 void GetIAccessible2InterfaceForView(View* view, IAccessible2_2** result) { 28 void GetIAccessible2InterfaceForView(View* view, IAccessible2_2** result) {
29 ScopedComPtr<IAccessible> view_accessible( 29 ScopedComPtr<IAccessible> view_accessible(
30 view->GetNativeViewAccessible()); 30 view->GetNativeViewAccessible());
31 ScopedComPtr<IServiceProvider> service_provider; 31 ScopedComPtr<IServiceProvider> service_provider;
32 ASSERT_EQ(S_OK, view_accessible.QueryInterface(service_provider.Receive())); 32 ASSERT_EQ(S_OK, view_accessible.CopyTo(service_provider.Receive()));
33 ASSERT_EQ(S_OK, 33 ASSERT_EQ(S_OK,
34 service_provider->QueryService(IID_IAccessible2_2, result)); 34 service_provider->QueryService(IID_IAccessible2_2, result));
35 } 35 }
36 }; 36 };
37 37
38 TEST_F(NativeViewAccessibilityWinTest, TextfieldAccessibility) { 38 TEST_F(NativeViewAccessibilityWinTest, TextfieldAccessibility) {
39 Widget widget; 39 Widget widget;
40 Widget::InitParams init_params = 40 Widget::InitParams init_params =
41 CreateParams(Widget::InitParams::TYPE_POPUP); 41 CreateParams(Widget::InitParams::TYPE_POPUP);
42 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 42 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
(...skipping 11 matching lines...) Expand all
54 content->GetNativeViewAccessible()); 54 content->GetNativeViewAccessible());
55 LONG child_count = 0; 55 LONG child_count = 0;
56 ASSERT_EQ(S_OK, content_accessible->get_accChildCount(&child_count)); 56 ASSERT_EQ(S_OK, content_accessible->get_accChildCount(&child_count));
57 ASSERT_EQ(1L, child_count); 57 ASSERT_EQ(1L, child_count);
58 58
59 ScopedComPtr<IDispatch> textfield_dispatch; 59 ScopedComPtr<IDispatch> textfield_dispatch;
60 ScopedComPtr<IAccessible> textfield_accessible; 60 ScopedComPtr<IAccessible> textfield_accessible;
61 ScopedVariant child_index(1); 61 ScopedVariant child_index(1);
62 ASSERT_EQ(S_OK, content_accessible->get_accChild( 62 ASSERT_EQ(S_OK, content_accessible->get_accChild(
63 child_index, textfield_dispatch.Receive())); 63 child_index, textfield_dispatch.Receive()));
64 ASSERT_EQ(S_OK, textfield_dispatch.QueryInterface( 64 ASSERT_EQ(S_OK, textfield_dispatch.CopyTo(
65 textfield_accessible.Receive())); 65 textfield_accessible.Receive()));
66 66
67 ScopedBstr name; 67 ScopedBstr name;
68 ScopedVariant childid_self(CHILDID_SELF); 68 ScopedVariant childid_self(CHILDID_SELF);
69 ASSERT_EQ(S_OK, textfield_accessible->get_accName( 69 ASSERT_EQ(S_OK, textfield_accessible->get_accName(
70 childid_self, name.Receive())); 70 childid_self, name.Receive()));
71 ASSERT_STREQ(L"Name", name); 71 ASSERT_STREQ(L"Name", name);
72 72
73 ScopedBstr value; 73 ScopedBstr value;
74 ASSERT_EQ(S_OK, textfield_accessible->get_accValue( 74 ASSERT_EQ(S_OK, textfield_accessible->get_accValue(
(...skipping 18 matching lines...) Expand all
93 93
94 LONG child_count = 0; 94 LONG child_count = 0;
95 ASSERT_EQ(S_OK, root_view_accessible->get_accChildCount(&child_count)); 95 ASSERT_EQ(S_OK, root_view_accessible->get_accChildCount(&child_count));
96 ASSERT_EQ(1L, child_count); 96 ASSERT_EQ(1L, child_count);
97 97
98 ScopedComPtr<IDispatch> child_view_dispatch; 98 ScopedComPtr<IDispatch> child_view_dispatch;
99 ScopedComPtr<IAccessible> child_view_accessible; 99 ScopedComPtr<IAccessible> child_view_accessible;
100 ScopedVariant child_index_1(1); 100 ScopedVariant child_index_1(1);
101 ASSERT_EQ(S_OK, root_view_accessible->get_accChild( 101 ASSERT_EQ(S_OK, root_view_accessible->get_accChild(
102 child_index_1, child_view_dispatch.Receive())); 102 child_index_1, child_view_dispatch.Receive()));
103 ASSERT_EQ(S_OK, child_view_dispatch.QueryInterface( 103 ASSERT_EQ(S_OK, child_view_dispatch.CopyTo(
104 child_view_accessible.Receive())); 104 child_view_accessible.Receive()));
105 105
106 Widget owned_widget; 106 Widget owned_widget;
107 Widget::InitParams owned_init_params = 107 Widget::InitParams owned_init_params =
108 CreateParams(Widget::InitParams::TYPE_POPUP); 108 CreateParams(Widget::InitParams::TYPE_POPUP);
109 owned_init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 109 owned_init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
110 owned_init_params.parent = widget.GetNativeView(); 110 owned_init_params.parent = widget.GetNativeView();
111 owned_widget.Init(owned_init_params); 111 owned_widget.Init(owned_init_params);
112 owned_widget.Show(); 112 owned_widget.Show();
113 113
114 ASSERT_EQ(S_OK, root_view_accessible->get_accChildCount(&child_count)); 114 ASSERT_EQ(S_OK, root_view_accessible->get_accChildCount(&child_count));
115 ASSERT_EQ(2L, child_count); 115 ASSERT_EQ(2L, child_count);
116 116
117 ScopedComPtr<IDispatch> child_widget_dispatch; 117 ScopedComPtr<IDispatch> child_widget_dispatch;
118 ScopedComPtr<IAccessible> child_widget_accessible; 118 ScopedComPtr<IAccessible> child_widget_accessible;
119 ScopedVariant child_index_2(2); 119 ScopedVariant child_index_2(2);
120 ASSERT_EQ(S_OK, root_view_accessible->get_accChild( 120 ASSERT_EQ(S_OK, root_view_accessible->get_accChild(
121 child_index_2, child_widget_dispatch.Receive())); 121 child_index_2, child_widget_dispatch.Receive()));
122 ASSERT_EQ(S_OK, child_widget_dispatch.QueryInterface( 122 ASSERT_EQ(S_OK, child_widget_dispatch.CopyTo(
123 child_widget_accessible.Receive())); 123 child_widget_accessible.Receive()));
124 124
125 ScopedComPtr<IDispatch> child_widget_sibling_dispatch; 125 ScopedComPtr<IDispatch> child_widget_sibling_dispatch;
126 ScopedComPtr<IAccessible> child_widget_sibling_accessible; 126 ScopedComPtr<IAccessible> child_widget_sibling_accessible;
127 ScopedVariant childid_self(CHILDID_SELF); 127 ScopedVariant childid_self(CHILDID_SELF);
128 ScopedVariant result; 128 ScopedVariant result;
129 ASSERT_EQ(S_OK, child_widget_accessible->accNavigate( 129 ASSERT_EQ(S_OK, child_widget_accessible->accNavigate(
130 NAVDIR_PREVIOUS, childid_self, result.Receive())); 130 NAVDIR_PREVIOUS, childid_self, result.Receive()));
131 ASSERT_EQ(VT_DISPATCH, V_VT(result.ptr())); 131 ASSERT_EQ(VT_DISPATCH, V_VT(result.ptr()));
132 child_widget_sibling_dispatch = V_DISPATCH(result.ptr()); 132 child_widget_sibling_dispatch = V_DISPATCH(result.ptr());
133 ASSERT_EQ(S_OK, child_widget_sibling_dispatch.QueryInterface( 133 ASSERT_EQ(S_OK, child_widget_sibling_dispatch.CopyTo(
134 child_widget_sibling_accessible.Receive())); 134 child_widget_sibling_accessible.Receive()));
135 ASSERT_EQ(child_view_accessible.Get(), child_widget_sibling_accessible.Get()); 135 ASSERT_EQ(child_view_accessible.Get(), child_widget_sibling_accessible.Get());
136 136
137 ScopedComPtr<IDispatch> child_widget_parent_dispatch; 137 ScopedComPtr<IDispatch> child_widget_parent_dispatch;
138 ScopedComPtr<IAccessible> child_widget_parent_accessible; 138 ScopedComPtr<IAccessible> child_widget_parent_accessible;
139 ASSERT_EQ(S_OK, child_widget_accessible->get_accParent( 139 ASSERT_EQ(S_OK, child_widget_accessible->get_accParent(
140 child_widget_parent_dispatch.Receive())); 140 child_widget_parent_dispatch.Receive()));
141 ASSERT_EQ(S_OK, child_widget_parent_dispatch.QueryInterface( 141 ASSERT_EQ(S_OK, child_widget_parent_dispatch.CopyTo(
142 child_widget_parent_accessible.Receive())); 142 child_widget_parent_accessible.Receive()));
143 ASSERT_EQ(root_view_accessible.Get(), child_widget_parent_accessible.Get()); 143 ASSERT_EQ(root_view_accessible.Get(), child_widget_parent_accessible.Get());
144 } 144 }
145 145
146 // Flaky on Windows: https://crbug.com/461837. 146 // Flaky on Windows: https://crbug.com/461837.
147 TEST_F(NativeViewAccessibilityWinTest, DISABLED_RetrieveAllAlerts) { 147 TEST_F(NativeViewAccessibilityWinTest, DISABLED_RetrieveAllAlerts) {
148 Widget widget; 148 Widget widget;
149 Widget::InitParams init_params = 149 Widget::InitParams init_params =
150 CreateParams(Widget::InitParams::TYPE_POPUP); 150 CreateParams(Widget::InitParams::TYPE_POPUP);
151 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 151 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 LONG child_count = 0; 220 LONG child_count = 0;
221 ScopedComPtr<IAccessible> content_accessible( 221 ScopedComPtr<IAccessible> content_accessible(
222 widget.GetRootView()->GetNativeViewAccessible()); 222 widget.GetRootView()->GetNativeViewAccessible());
223 EXPECT_EQ(S_OK, content_accessible->get_accChildCount(&child_count)); 223 EXPECT_EQ(S_OK, content_accessible->get_accChildCount(&child_count));
224 EXPECT_EQ(1L, child_count); 224 EXPECT_EQ(1L, child_count);
225 } 225 }
226 226
227 } // namespace test 227 } // namespace test
228 } // namespace views 228 } // namespace views
OLDNEW
« no previous file with comments | « ui/gl/gl_angle_util_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698