Chromium Code Reviews| 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" |
| 11 #include "ui/views/accessibility/native_view_accessibility.h" | 11 #include "ui/views/accessibility/native_view_accessibility.h" |
| 12 #include "ui/views/controls/textfield/textfield.h" | 12 #include "ui/views/controls/textfield/textfield.h" |
| 13 #include "ui/views/test/views_test_base.h" | 13 #include "ui/views/test/views_test_base.h" |
| 14 | 14 |
| 15 using base::win::ScopedBstr; | 15 using base::win::ScopedBstr; |
| 16 using base::win::ScopedComPtr; | 16 using base::win::ScopedComPtr; |
| 17 using base::win::ScopedVariant; | 17 using base::win::ScopedVariant; |
| 18 | 18 |
| 19 namespace views { | 19 namespace views { |
| 20 namespace test { | 20 namespace test { |
| 21 | 21 |
| 22 class NativeViewAcccessibilityWinTest : public ViewsTestBase { | 22 class NativeViewAccessibilityWinTest : public ViewsTestBase { |
|
tapted
2016/12/22 02:56:37
this can be a separate patch I think :)
Patti Lor
2017/01/11 02:01:48
Oops - thanks, I think I needed to edit stuff in h
| |
| 23 public: | 23 public: |
| 24 NativeViewAcccessibilityWinTest() {} | 24 NativeViewAccessibilityWinTest() {} |
| 25 ~NativeViewAcccessibilityWinTest() 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.QueryInterface(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(NativeViewAcccessibilityWinTest, 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; |
| 43 widget.Init(init_params); | 43 widget.Init(init_params); |
| 44 | 44 |
| 45 View* content = new View; | 45 View* content = new View; |
| 46 widget.SetContentsView(content); | 46 widget.SetContentsView(content); |
| 47 | 47 |
| 48 Textfield* textfield = new Textfield; | 48 Textfield* textfield = new Textfield; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 74 ASSERT_EQ(S_OK, textfield_accessible->get_accValue( | 74 ASSERT_EQ(S_OK, textfield_accessible->get_accValue( |
| 75 childid_self, value.Receive())); | 75 childid_self, value.Receive())); |
| 76 ASSERT_STREQ(L"Value", value); | 76 ASSERT_STREQ(L"Value", value); |
| 77 | 77 |
| 78 ScopedBstr new_value(L"New value"); | 78 ScopedBstr new_value(L"New value"); |
| 79 ASSERT_EQ(S_OK, textfield_accessible->put_accValue(childid_self, new_value)); | 79 ASSERT_EQ(S_OK, textfield_accessible->put_accValue(childid_self, new_value)); |
| 80 | 80 |
| 81 ASSERT_STREQ(L"New value", textfield->text().c_str()); | 81 ASSERT_STREQ(L"New value", textfield->text().c_str()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 TEST_F(NativeViewAcccessibilityWinTest, AuraOwnedWidgets) { | 84 TEST_F(NativeViewAccessibilityWinTest, AuraOwnedWidgets) { |
| 85 Widget widget; | 85 Widget widget; |
| 86 Widget::InitParams init_params = | 86 Widget::InitParams init_params = |
| 87 CreateParams(Widget::InitParams::TYPE_WINDOW); | 87 CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 88 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 88 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 89 widget.Init(init_params); | 89 widget.Init(init_params); |
| 90 | 90 |
| 91 ScopedComPtr<IAccessible> root_view_accessible( | 91 ScopedComPtr<IAccessible> root_view_accessible( |
| 92 widget.GetRootView()->GetNativeViewAccessible()); | 92 widget.GetRootView()->GetNativeViewAccessible()); |
| 93 | 93 |
| 94 LONG child_count = 0; | 94 LONG child_count = 0; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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.QueryInterface( |
| 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(NativeViewAcccessibilityWinTest, 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; |
| 152 widget.Init(init_params); | 152 widget.Init(init_params); |
| 153 | 153 |
| 154 View* content = new View; | 154 View* content = new View; |
| 155 widget.SetContentsView(content); | 155 widget.SetContentsView(content); |
| 156 | 156 |
| 157 View* infobar = new View; | 157 View* infobar = new View; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 delete infobar; | 203 delete infobar; |
| 204 ASSERT_EQ(S_OK, root_view_accessible->get_relationTargetsOfType( | 204 ASSERT_EQ(S_OK, root_view_accessible->get_relationTargetsOfType( |
| 205 alerts_bstr, 0, &targets, &n_targets)); | 205 alerts_bstr, 0, &targets, &n_targets)); |
| 206 ASSERT_EQ(1, n_targets); | 206 ASSERT_EQ(1, n_targets); |
| 207 ASSERT_TRUE(infobar2_accessible.IsSameObject(targets[0])); | 207 ASSERT_TRUE(infobar2_accessible.IsSameObject(targets[0])); |
| 208 CoTaskMemFree(targets); | 208 CoTaskMemFree(targets); |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace test | 211 } // namespace test |
| 212 } // namespace views | 212 } // namespace views |
| OLD | NEW |