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 "ui/views/accessibility/native_view_accessibility.h" |
10 #include "ui/views/controls/textfield/textfield.h" | 11 #include "ui/views/controls/textfield/textfield.h" |
11 #include "ui/views/test/views_test_base.h" | 12 #include "ui/views/test/views_test_base.h" |
12 | 13 |
13 namespace views { | 14 namespace views { |
14 namespace test { | 15 namespace test { |
15 | 16 |
16 typedef ViewsTestBase NativeViewAcccessibilityWinTest; | 17 typedef ViewsTestBase NativeViewAcccessibilityWinTest; |
17 | 18 |
18 TEST_F(NativeViewAcccessibilityWinTest, TextfieldAccessibility) { | 19 TEST_F(NativeViewAcccessibilityWinTest, TextfieldAccessibility) { |
19 Widget widget; | 20 Widget widget; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 ASSERT_EQ(S_OK, textfield_accessible->get_accValue( | 55 ASSERT_EQ(S_OK, textfield_accessible->get_accValue( |
55 childid_self, value.Receive())); | 56 childid_self, value.Receive())); |
56 ASSERT_STREQ(L"Value", value); | 57 ASSERT_STREQ(L"Value", value); |
57 | 58 |
58 base::win::ScopedBstr new_value(L"New value"); | 59 base::win::ScopedBstr new_value(L"New value"); |
59 ASSERT_EQ(S_OK, textfield_accessible->put_accValue(childid_self, new_value)); | 60 ASSERT_EQ(S_OK, textfield_accessible->put_accValue(childid_self, new_value)); |
60 | 61 |
61 ASSERT_STREQ(L"New value", textfield->text().c_str()); | 62 ASSERT_STREQ(L"New value", textfield->text().c_str()); |
62 } | 63 } |
63 | 64 |
| 65 TEST_F(NativeViewAcccessibilityWinTest, UnattachedWebView) { |
| 66 // This is a regression test. Calling get_accChild on the native accessible |
| 67 // object for a WebView with no attached WebContents was causing an |
| 68 // infinite loop and crash. This test simulates that with an ordinary |
| 69 // View that registers itself as a web view with NativeViewAcccessibility. |
| 70 |
| 71 Widget widget; |
| 72 Widget::InitParams init_params = |
| 73 CreateParams(Widget::InitParams::TYPE_POPUP); |
| 74 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 75 widget.Init(init_params); |
| 76 |
| 77 View* content = new View; |
| 78 widget.SetContentsView(content); |
| 79 |
| 80 View* web_view = new View; |
| 81 content->AddChildView(web_view); |
| 82 NativeViewAccessibility::RegisterWebView(web_view); |
| 83 |
| 84 base::win::ScopedComPtr<IAccessible> web_view_accessible( |
| 85 web_view->GetNativeViewAccessible()); |
| 86 base::win::ScopedComPtr<IDispatch> result_dispatch; |
| 87 base::win::ScopedVariant child_index(-999); |
| 88 ASSERT_EQ(E_FAIL, web_view_accessible->get_accChild( |
| 89 child_index, result_dispatch.Receive())); |
| 90 |
| 91 NativeViewAccessibility::UnregisterWebView(web_view); |
| 92 } |
| 93 |
64 } // namespace test | 94 } // namespace test |
65 } // namespace views | 95 } // namespace views |
OLD | NEW |