Chromium Code Reviews| Index: chrome/browser/ui/views/accessibility/browser_views_accessibility_browsertest.cc |
| =================================================================== |
| --- chrome/browser/ui/views/accessibility/browser_views_accessibility_browsertest.cc (revision 158860) |
| +++ chrome/browser/ui/views/accessibility/browser_views_accessibility_browsertest.cc (working copy) |
| @@ -31,83 +31,93 @@ |
| class BrowserViewsAccessibilityTest : public InProcessBrowserTest { |
| public: |
| - BrowserViewsAccessibilityTest() { |
| - ui::win::CreateATLModuleIfNeeded(); |
| - ::CoInitialize(NULL); |
| - } |
| + BrowserViewsAccessibilityTest(); |
| + ~BrowserViewsAccessibilityTest(); |
| - ~BrowserViewsAccessibilityTest() { |
| - ::CoUninitialize(); |
| - } |
| + // Retrieves an instance of BrowserWindowTesting. |
| + BrowserWindowTesting* GetBrowserWindowTesting(); |
| - // Retrieves an instance of BrowserWindowTesting |
| - BrowserWindowTesting* GetBrowserWindowTesting() { |
| - BrowserWindow* browser_window = browser()->window(); |
| + // Retrieve an instance of BrowserView. |
| + BrowserView* GetBrowserView(); |
| - if (!browser_window) |
| - return NULL; |
| + // Retrieves and initializes an instance of ToolbarView. |
| + ToolbarView* GetToolbarView(); |
| - return browser_window->GetBrowserWindowTesting(); |
| - } |
| + // Retrieves and initializes an instance of BookmarkBarView. |
| + BookmarkBarView* GetBookmarkBarView(); |
| - // Retrieve an instance of BrowserView |
| - BrowserView* GetBrowserView() { |
| - return BrowserView::GetBrowserViewForBrowser(browser()); |
| - } |
| + // Retrieves and verifies the accessibility object for the given View. |
| + void TestViewAccessibilityObject(views::View* view, |
| + std::wstring name, |
| + int32 role); |
| - // Retrieves and initializes an instance of ToolbarView. |
| - ToolbarView* GetToolbarView() { |
| - BrowserWindowTesting* browser_window_testing = GetBrowserWindowTesting(); |
| + // Verifies MSAA Name and Role properties of the given IAccessible. |
| + void TestAccessibilityInfo(IAccessible* acc_obj, |
| + std::wstring name, |
| + int32 role); |
| +}; |
| - if (!browser_window_testing) |
| - return NULL; |
| +BrowserViewsAccessibilityTest::BrowserViewsAccessibilityTest() { |
| + ui::win::CreateATLModuleIfNeeded(); |
| + ::CoInitialize(NULL); |
|
dmazzoni
2012/09/27 06:22:39
Should this be using ScopedComInitializer as long
Peter Kasting
2012/09/27 06:25:15
This is precisely why I said: "...done while conve
|
| +} |
| - return browser_window_testing->GetToolbarView(); |
| - } |
| +BrowserViewsAccessibilityTest~BrowserViewsAccessibilityTest() { |
|
dmazzoni
2012/09/27 06:22:39
Typo here?
Peter Kasting
2012/09/27 06:25:15
Indeed. Good catch.
|
| + ::CoUninitialize(); |
| +} |
| - // Retrieves and initializes an instance of BookmarkBarView. |
| - BookmarkBarView* GetBookmarkBarView() { |
| - BrowserWindowTesting* browser_window_testing = GetBrowserWindowTesting(); |
| +BrowserWindowTesting* BrowserViewsAccessibilityTest::GetBrowserWindowTesting() { |
| + BrowserWindow* browser_window = browser()->window(); |
| + return browser_window ? browser_window->GetBrowserWindowTesting() : NULL; |
| +} |
| - if (!browser_window_testing) |
| - return NULL; |
| +BrowserView* BrowserViewsAccessibilityTest::GetBrowserView() { |
| + return BrowserView::GetBrowserViewForBrowser(browser()); |
| +} |
| - return browser_window_testing->GetBookmarkBarView(); |
| - } |
| +ToolbarView* BrowserViewsAccessibilityTest::GetToolbarView() { |
| + BrowserWindowTesting* browser_window_testing = GetBrowserWindowTesting(); |
| + return browser_window_testing ? |
| + browser_window_testing->GetToolbarView() : NULL; |
| +} |
| - // Retrieves and verifies the accessibility object for the given View. |
| - void TestViewAccessibilityObject(views::View* view, std::wstring name, |
| - int32 role) { |
| - ASSERT_TRUE(NULL != view); |
| +BookmarkBarView* BrowserViewsAccessibilityTest::GetBookmarkBarView() { |
| + BrowserWindowTesting* browser_window_testing = GetBrowserWindowTesting(); |
| + return browser_window_testing ? |
| + browser_window_testing->GetBookmarkBarView() : NULL; |
| +} |
| - TestAccessibilityInfo(view->GetNativeViewAccessible(), name, role); |
| - } |
| +void BrowserViewsAccessibilityTest::TestViewAccessibilityObject( |
| + views::View* view, |
| + std::wstring name, |
| + int32 role) { |
| + ASSERT_TRUE(view != NULL); |
| + TestAccessibilityInfo(view->GetNativeViewAccessible(), name, role); |
| +} |
| +void BrowserViewsAccessibilityTest::TestAccessibilityInfo(IAccessible* acc_obj, |
| + std::wstring name, |
| + int32 role) { |
| + // Verify MSAA Name property. |
| + BSTR acc_name; |
| - // Verifies MSAA Name and Role properties of the given IAccessible. |
| - void TestAccessibilityInfo(IAccessible* acc_obj, std::wstring name, |
| - int32 role) { |
| - // Verify MSAA Name property. |
| - BSTR acc_name; |
| + HRESULT hr = acc_obj->get_accName(id_self, &acc_name); |
| + ASSERT_EQ(S_OK, hr); |
| + EXPECT_STREQ(acc_name, name.c_str()); |
| - HRESULT hr = acc_obj->get_accName(id_self, &acc_name); |
| - ASSERT_EQ(S_OK, hr); |
| - EXPECT_STREQ(acc_name, name.c_str()); |
| + // Verify MSAA Role property. |
| + VARIANT acc_role; |
| + ::VariantInit(&acc_role); |
| - // Verify MSAA Role property. |
| - VARIANT acc_role; |
| - ::VariantInit(&acc_role); |
| + hr = acc_obj->get_accRole(id_self, &acc_role); |
| + ASSERT_EQ(S_OK, hr); |
| + EXPECT_EQ(VT_I4, acc_role.vt); |
| + EXPECT_EQ(role, acc_role.lVal); |
| - hr = acc_obj->get_accRole(id_self, &acc_role); |
| - ASSERT_EQ(S_OK, hr); |
| - EXPECT_EQ(VT_I4, acc_role.vt); |
| - EXPECT_EQ(role, acc_role.lVal); |
| + ::VariantClear(&acc_role); |
| + ::SysFreeString(acc_name); |
| +} |
| - ::VariantClear(&acc_role); |
| - ::SysFreeString(acc_name); |
| - } |
| -}; |
| - |
| // Retrieve accessibility object for main window and verify accessibility info. |
| IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, |
| TestChromeWindowAccObj) { |