| Index: content/browser/accessibility/browser_accessibility_win_unittest.cc
|
| diff --git a/content/browser/accessibility/browser_accessibility_win_unittest.cc b/content/browser/accessibility/browser_accessibility_win_unittest.cc
|
| index 7f23dd92be02feba919eca27f7dc83254244330f..5fab5b61344b6bf948045d4363b1b84b1820f809 100644
|
| --- a/content/browser/accessibility/browser_accessibility_win_unittest.cc
|
| +++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc
|
| @@ -11,7 +11,6 @@
|
| #include "content/browser/accessibility/browser_accessibility_manager_win.h"
|
| #include "content/browser/accessibility/browser_accessibility_state_impl.h"
|
| #include "content/browser/accessibility/browser_accessibility_win.h"
|
| -#include "content/browser/renderer_host/legacy_render_widget_host_win.h"
|
| #include "content/common/accessibility_messages.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "ui/base/win/atl_module.h"
|
| @@ -79,34 +78,6 @@ BrowserAccessibility* CountedBrowserAccessibilityFactory::Create() {
|
| return instance;
|
| }
|
|
|
| -// Provides functionality for creating the accessible hwnd and ensures that
|
| -// the hwnd along with the LegacyRenderWidgetHostHWND instance is destroyed
|
| -// when this instance is destroyed.
|
| -class TestLegacyRenderWidgetHostHWND {
|
| - public:
|
| - TestLegacyRenderWidgetHostHWND()
|
| - : accessible_hwnd_(NULL) {}
|
| -
|
| - ~TestLegacyRenderWidgetHostHWND() {
|
| - if (accessible_hwnd())
|
| - ::DestroyWindow(accessible_hwnd()->hwnd());
|
| - }
|
| -
|
| - bool Initialize(HWND parent) {
|
| - accessible_hwnd_ = LegacyRenderWidgetHostHWND::Create(parent);
|
| - EXPECT_NE(accessible_hwnd_,
|
| - static_cast<LegacyRenderWidgetHostHWND*>(NULL));
|
| - return accessible_hwnd_ != NULL;
|
| - }
|
| -
|
| - LegacyRenderWidgetHostHWND* accessible_hwnd() {
|
| - return accessible_hwnd_;
|
| - }
|
| -
|
| - private:
|
| - LegacyRenderWidgetHostHWND* accessible_hwnd_;
|
| -};
|
| -
|
| } // namespace
|
|
|
|
|
| @@ -633,13 +604,8 @@ TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) {
|
| const int32 busy_state = 1 << ui::AX_STATE_BUSY;
|
| const int32 readonly_state = 1 << ui::AX_STATE_READ_ONLY;
|
| const int32 enabled_state = 1 << ui::AX_STATE_ENABLED;
|
| - scoped_ptr<TestLegacyRenderWidgetHostHWND> accessibility_test
|
| - (new TestLegacyRenderWidgetHostHWND);
|
| - EXPECT_EQ(accessibility_test->Initialize(GetDesktopWindow()), true);
|
| scoped_ptr<BrowserAccessibilityManager> manager(
|
| - new BrowserAccessibilityManagerWin(
|
| - accessibility_test->accessible_hwnd(),
|
| - NULL,
|
| + BrowserAccessibilityManager::Create(
|
| BrowserAccessibilityManagerWin::GetEmptyDocument(),
|
| NULL,
|
| new CountedBrowserAccessibilityFactory()));
|
| @@ -720,52 +686,24 @@ TEST(BrowserAccessibilityManagerWinTest, TestAccessibleHWND) {
|
| IID_IAccessible,
|
| reinterpret_cast<void**>(desktop_hwnd_iaccessible.Receive())));
|
|
|
| - scoped_ptr<TestLegacyRenderWidgetHostHWND> accessibility_test
|
| - (new TestLegacyRenderWidgetHostHWND);
|
| - EXPECT_EQ(accessibility_test->Initialize(GetDesktopWindow()), true);
|
| -
|
| scoped_ptr<BrowserAccessibilityManagerWin> manager(
|
| - new BrowserAccessibilityManagerWin(
|
| - accessibility_test->accessible_hwnd(),
|
| - desktop_hwnd_iaccessible,
|
| - BrowserAccessibilityManagerWin::GetEmptyDocument(),
|
| - NULL));
|
| - ASSERT_EQ(desktop_hwnd, manager->parent_hwnd());
|
| + static_cast<BrowserAccessibilityManagerWin*>(
|
| + BrowserAccessibilityManager::Create(
|
| + BrowserAccessibilityManagerWin::GetEmptyDocument(), NULL)));
|
| + ASSERT_EQ(NULL, manager->parent_iaccessible());
|
|
|
| // Enabling screen reader support and calling MaybeCallNotifyWinEvent
|
| - // should trigger creating the AccessibleHWND, and we should now get a
|
| + // should trigger using the AccessibleHWND, and we should now get a
|
| // new parent_hwnd with the right window class to fool older screen
|
| // readers.
|
| BrowserAccessibilityStateImpl::GetInstance()->OnScreenReaderDetected();
|
| manager->MaybeCallNotifyWinEvent(0, 0);
|
| HWND new_parent_hwnd = manager->parent_hwnd();
|
| ASSERT_NE(desktop_hwnd, new_parent_hwnd);
|
| + ASSERT_TRUE(manager->parent_iaccessible());
|
| WCHAR hwnd_class_name[256];
|
| ASSERT_NE(0, GetClassName(new_parent_hwnd, hwnd_class_name, 256));
|
| ASSERT_STREQ(L"Chrome_RenderWidgetHostHWND", hwnd_class_name);
|
| -
|
| - // Destroy the TestLegacyRenderWidgetHostHWND instance. That should in turn
|
| - // destroy the hwnd, which should clear the parent_hwnd().
|
| - accessibility_test.reset(NULL);
|
| - ASSERT_EQ(FALSE, ::IsWindow(new_parent_hwnd));
|
| - ASSERT_EQ(NULL, manager->parent_hwnd());
|
| -
|
| - // Now create it again.
|
| - accessibility_test.reset(new TestLegacyRenderWidgetHostHWND);
|
| - EXPECT_EQ(accessibility_test->Initialize(::GetDesktopWindow()), true);
|
| - manager.reset(
|
| - new BrowserAccessibilityManagerWin(
|
| - accessibility_test->accessible_hwnd(),
|
| - desktop_hwnd_iaccessible,
|
| - BrowserAccessibilityManagerWin::GetEmptyDocument(),
|
| - NULL));
|
| - manager->MaybeCallNotifyWinEvent(0, 0);
|
| - new_parent_hwnd = manager->parent_hwnd();
|
| - ASSERT_FALSE(NULL == new_parent_hwnd);
|
| -
|
| - // This time, destroy the manager first, make sure the AccessibleHWND doesn't
|
| - // crash on destruction (to be caught by SyzyASAN or other tools).
|
| - manager.reset(NULL);
|
| }
|
|
|
| } // namespace content
|
|
|