diff options
author | klink@chromium.org <klink@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-08 00:39:43 +0000 |
---|---|---|
committer | klink@chromium.org <klink@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-08 00:39:43 +0000 |
commit | bd04abd493a296e9309fca99d23530b3493ddc93 (patch) | |
tree | c15673ce5084056b6063473a6ef75e9798ebf160 /chrome/test/accessibility | |
parent | ba1100d658069bcc3ed69a736cd45a1f2b81c8f3 (diff) | |
download | chromium_src-bd04abd493a296e9309fca99d23530b3493ddc93.zip chromium_src-bd04abd493a296e9309fca99d23530b3493ddc93.tar.gz chromium_src-bd04abd493a296e9309fca99d23530b3493ddc93.tar.bz2 |
Adds some more cleanup and test coverage to the Accessibility tests.
Review URL: http://codereview.chromium.org/15097
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7708 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/accessibility')
-rw-r--r-- | chrome/test/accessibility/accessibility_tests.cc | 465 | ||||
-rw-r--r-- | chrome/test/accessibility/accessibility_util.cc | 159 | ||||
-rw-r--r-- | chrome/test/accessibility/accessibility_util.h | 74 | ||||
-rw-r--r-- | chrome/test/accessibility/browser_impl.cc | 2 | ||||
-rw-r--r-- | chrome/test/accessibility/constants.h | 46 |
5 files changed, 354 insertions, 392 deletions
diff --git a/chrome/test/accessibility/accessibility_tests.cc b/chrome/test/accessibility/accessibility_tests.cc index f8e68f9..bff3296 100644 --- a/chrome/test/accessibility/accessibility_tests.cc +++ b/chrome/test/accessibility/accessibility_tests.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <objbase.h> #include <oleacc.h> #include "base/file_util.h" @@ -14,7 +13,6 @@ #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/window_proxy.h" #include "chrome/test/automation/tab_proxy.h" -#include "googleurl/src/gurl.h" #include "net/base/net_util.h" #include "chromium_strings.h" @@ -37,21 +35,22 @@ class AccessibilityTest : public UITest { } // Namespace. // Check browser handle and accessibility object browser client. -// TODO(sridharg): Alter, when accessibility objects for Chrome Window, -// Application and Client are corrected. TEST_F(AccessibilityTest, TestChromeBrowserAccObject) { IAccessible* acc_obj = NULL; HWND hwnd = GetChromeBrowserWnd(&acc_obj); + ASSERT_TRUE(NULL != hwnd); ASSERT_TRUE(NULL != acc_obj); + CHK_RELEASE(acc_obj); } -// Check accessibility object for toolbar and its properties Name, Role, -// State. (Add other properties, if their values are fixed all the time.) +// Check accessibility object for toolbar and its properties Name, Role, State. TEST_F(AccessibilityTest, TestChromeToolbarAccObject) { + HRESULT hr = S_OK; IAccessible* acc_obj = NULL; - GetToolbarWnd(&acc_obj); + hr = GetToolbarAccessible(&acc_obj); + ASSERT_TRUE(S_OK == hr); ASSERT_TRUE(NULL != acc_obj); // Check Name - IDS_ACCNAME_TOOLBAR. @@ -65,10 +64,12 @@ TEST_F(AccessibilityTest, TestChromeToolbarAccObject) { } // Check accessibility object for tabstrip and its properties Name, Role, -// State. (Add other properties, if their values are fixed all the time.) +// State. TEST_F(AccessibilityTest, TestChromeTabstripAccObject) { + HRESULT hr = S_OK; IAccessible* acc_obj = NULL; - GetTabStripWnd(&acc_obj); + hr = GetTabStripAccessible(&acc_obj); + ASSERT_TRUE(S_OK == hr); ASSERT_TRUE(NULL != acc_obj); // Check Name - IDS_ACCNAME_TABSTRIP. @@ -81,223 +82,61 @@ TEST_F(AccessibilityTest, TestChromeTabstripAccObject) { CHK_RELEASE(acc_obj); } +// This test is disabled for now, see issue 2243. // Check Browser buttons and their Name, Role, State. -TEST_F(AccessibilityTest, TestChromeButtons) { - // Get browser accessibility object. - IAccessible* browser = NULL; - GetChromeBrowserWnd(&browser); - ASSERT_TRUE(NULL != browser); - - HRESULT hr = S_OK; - IAccessible* acc_obj = NULL; - VARIANT button; - - // Check Minimize button and its Name, Role, State. - hr = GetBrowserMinimizeButton(&acc_obj, &button); - // Not a complete accessible object, as Minimize is an element leaf. - ASSERT_TRUE(S_FALSE == hr); - ASSERT_TRUE(NULL == acc_obj); - ASSERT_TRUE(VT_I4 == button.vt); - // Read properties. - EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_MINIMIZE), - GetName(browser, button)); - EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(browser, button)); - EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(browser, button)); - CHK_RELEASE(acc_obj); - - // Check Maximize button and its Name, Role, State. - GetBrowserMaximizeButton(&acc_obj, &button); - // Not a complete accessible object, as Maximize is an element leaf. - ASSERT_TRUE(S_FALSE == hr); - ASSERT_TRUE(NULL == acc_obj); - ASSERT_TRUE(VT_I4 == button.vt); - // Read properties. - EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_MAXIMIZE), - GetName(browser, button)); - EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(browser, button)); - EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(browser, button)); - CHK_RELEASE(acc_obj); - - // Check Restore button and its Name, Role, State. - GetBrowserRestoreButton(&acc_obj, &button); - // Not a complete accessible object, as Restore is an element leaf. - ASSERT_TRUE(S_FALSE == hr); - ASSERT_TRUE(NULL == acc_obj); - ASSERT_TRUE(VT_I4 == button.vt); - // Read properties. - EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_RESTORE), - GetName(browser, button)); - EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(browser, button)); - EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_INVISIBLE, - GetState(browser, button)); - CHK_RELEASE(acc_obj); - - // Check Close button and its Name, Role, State. - GetBrowserCloseButton(&acc_obj, &button); - // Not a complete accessible object, as Close is an element leaf. - ASSERT_TRUE(S_FALSE == hr); - ASSERT_TRUE(NULL == acc_obj); - ASSERT_TRUE(VT_I4 == button.vt); - // Read properties. - EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_CLOSE), GetName(browser, button)); - EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(browser, button)); - EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(browser, button)); - - CHK_RELEASE(acc_obj); - CHK_RELEASE(browser); -} - -// Check Star button and its Name, Role, State. -TEST_F(AccessibilityTest, TestStarButton) { - // Get toolbar accessibility object. - IAccessible* toolbar = NULL; - GetToolbarWnd(&toolbar); - ASSERT_TRUE(NULL != toolbar); - - HRESULT hr = S_OK; - IAccessible* acc_obj = NULL; - VARIANT button; - - // Check button and its Name, Role, State. - hr = GetStarButton(&acc_obj, &button); - // It is not complete accessible object, as it is element. - ASSERT_TRUE(S_FALSE == hr); - ASSERT_TRUE(NULL == acc_obj); - ASSERT_TRUE(VT_I4 == button.vt); - // Read properties. - EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_STAR), GetName(toolbar, button)); - EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(toolbar, button)); - EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button)); - - CHK_RELEASE(acc_obj); - CHK_RELEASE(toolbar); -} - -// Check Star button and its Name, Role, State, upon adding a new tab. -TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) { - // Get toolbar accessibility object. - IAccessible* toolbar = NULL; - GetToolbarWnd(&toolbar); - ASSERT_TRUE(NULL != toolbar); - - HRESULT hr = S_OK; - IAccessible* acc_obj = NULL; - VARIANT button; - - // Check button and its Name, Role, State. - hr = GetStarButton(&acc_obj, &button); - // Not a complete accessible object, as Star is an element leaf. - ASSERT_TRUE(S_FALSE == hr); - ASSERT_TRUE(NULL == acc_obj); - ASSERT_TRUE(VT_I4 == button.vt); - EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button)); - - // Now, check Star status in different situations. - scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); - ASSERT_TRUE(window.get()); - - // Set URL and check button status. - scoped_ptr<TabProxy> tab1(window->GetTab(0)); - ASSERT_TRUE(tab1.get()); - std::wstring test_file1 = test_data_directory_; - file_util::AppendToPath(&test_file1, L"title1.html"); - tab1->NavigateToURL(net::FilePathToFileURL(test_file1)); - Sleep(kWaitForActionMsec); - EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button)); - - // Add empty new tab and check status. - int old_tab_count = -1; - ASSERT_TRUE(window->GetTabCount(&old_tab_count)); - ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB)); - int new_tab_count; - ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count, - 5000)); - // Check tab count. - ASSERT_GE(new_tab_count, old_tab_count); - // Also, check accessibility object's children. - Sleep(1000); - EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button)); - - // Add new tab with URL and check status. - old_tab_count = new_tab_count; - std::wstring test_file2 = test_data_directory_; - file_util::AppendToPath(&test_file2, L"title1.html"); - ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2))); - ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count, - 5000)); - // Check tab count. Also, check accessibility object's children. - ASSERT_GE(new_tab_count, old_tab_count); - Sleep(kWaitForActionMsec); - EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button)); - - CHK_RELEASE(acc_obj); - CHK_RELEASE(toolbar); +TEST_F(AccessibilityTest, DISABLED_TestChromeButtons) { + // TODO(klink): Implement with indexing from ViewIDs. } // Check Back button and its Name, Role, State. TEST_F(AccessibilityTest, TestBackButton) { - // Get toolbar accessibility object. - IAccessible* toolbar = NULL; - GetToolbarWnd(&toolbar); - ASSERT_TRUE(NULL != toolbar); - HRESULT hr = S_OK; IAccessible* acc_obj = NULL; - VARIANT button; + + // Retrieve IAccessible for Back button. + hr = GetBackButton(&acc_obj); + ASSERT_TRUE(S_OK == hr); + ASSERT_TRUE(NULL != acc_obj); // Check button and its Name, Role, State. - hr = GetBackButton(&acc_obj, &button); - // Not a complete accessible object, as Back is an element leaf. - ASSERT_TRUE(S_FALSE == hr); - ASSERT_TRUE(NULL == acc_obj); - ASSERT_TRUE(VT_I4 == button.vt); - - // Read properties. - EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_BACK), - GetName(toolbar, button)); - EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(toolbar, button)); + EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_BACK), GetName(acc_obj)); + EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj)); // State "has popup" only supported in XP and higher. if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } CHK_RELEASE(acc_obj); - CHK_RELEASE(toolbar); } -// Check Back button and its Name, Role, State. -// This test is disabled. See bug 1119183. -TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) { - // Get toolbar accessibility object. - IAccessible* toolbar = NULL; - GetToolbarWnd(&toolbar); - ASSERT_TRUE(NULL != toolbar); - +// Check Back button and its Name, Role, State, upon adding a new tab. +TEST_F(AccessibilityTest, TestBackBtnStatusOnNewTab) { HRESULT hr = S_OK; IAccessible* acc_obj = NULL; - VARIANT button; + + // Retrieve IAccessible for Back button. + hr = GetBackButton(&acc_obj); + ASSERT_TRUE(S_OK == hr); + ASSERT_TRUE(NULL != acc_obj); // Check button and its Name, Role, State. - hr = GetBackButton(&acc_obj, &button); - // Not a complete accessible object, as Back is an element leaf. - ASSERT_TRUE(S_FALSE == hr); - ASSERT_TRUE(NULL == acc_obj); - ASSERT_TRUE(VT_I4 == button.vt); + EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_BACK), GetName(acc_obj)); + EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj)); // State "has popup" only supported in XP and higher. if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } // Now check Back status in different situations. @@ -315,9 +154,9 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) { Sleep(kWaitForActionMsec); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { - EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj)); } // Go Back and check status. window->ApplyAccelerator(IDC_BACK); @@ -326,27 +165,27 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } // Add empty new tab and check status. ASSERT_TRUE(window->GetTabCount(&old_tab_count)); ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB)); ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count, - 5000)); + kWaitForActionMsec * 5)); // Check tab count. Also, check accessibility object's children. ASSERT_GE(new_tab_count, old_tab_count); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } // Add new tab with URL and check status. @@ -355,7 +194,7 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) { file_util::AppendToPath(&test_file2, L"title1.html"); ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2))); ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count, - 5000)); + kWaitForActionMsec * 5)); // Check tab count. Also, check accessibility object's children. ASSERT_GE(new_tab_count, old_tab_count); Sleep(kWaitForActionMsec); @@ -363,79 +202,66 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } CHK_RELEASE(acc_obj); - CHK_RELEASE(toolbar); } // Check Forward button and its Name, Role, State. TEST_F(AccessibilityTest, TestForwardButton) { - // Get toolbar accessibility object. - IAccessible* toolbar = NULL; - GetToolbarWnd(&toolbar); - ASSERT_TRUE(NULL != toolbar); - HRESULT hr = S_OK; IAccessible* acc_obj = NULL; - VARIANT button; + + // Retrieve IAccessible for Forward button. + hr = GetForwardButton(&acc_obj); + ASSERT_TRUE(S_OK == hr); + ASSERT_TRUE(NULL != acc_obj); // Check button and its Name, Role, State. - hr = GetForwardButton(&acc_obj, &button); - // Not a complete accessible object, as Forward is an element leaf. - ASSERT_TRUE(S_FALSE == hr); - ASSERT_TRUE(NULL == acc_obj); - ASSERT_TRUE(VT_I4 == button.vt); - // Read properties. EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_FORWARD), - GetName(toolbar, button)); - EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(toolbar, button)); + GetName(acc_obj)); + EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj)); // State "has popup" only supported in XP and higher. if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } CHK_RELEASE(acc_obj); - CHK_RELEASE(toolbar); } -// Check Back button and its Name, Role, State. -// This test is disabled. See bug 1119183. -TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) { - // Get toolbar accessibility object. - IAccessible* toolbar = NULL; - GetToolbarWnd(&toolbar); - ASSERT_TRUE(NULL != toolbar); - +// Check Forward button and its Name, Role, State, upon adding a new tab. +TEST_F(AccessibilityTest, TestForwardBtnStatusOnNewTab) { HRESULT hr = S_OK; IAccessible* acc_obj = NULL; - VARIANT button; + + // Retrieve IAccessible for Forward button. + hr = GetForwardButton(&acc_obj); + ASSERT_TRUE(S_OK == hr); + ASSERT_TRUE(NULL != acc_obj); // Check button and its Name, Role, State. - hr = GetForwardButton(&acc_obj, &button); - // Not a complete accessible object, as Forward is an element leaf. - ASSERT_TRUE(S_FALSE == hr); - ASSERT_TRUE(NULL == acc_obj); - ASSERT_TRUE(VT_I4 == button.vt); + EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_FORWARD), + GetName(acc_obj)); + EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj)); // State "has popup" only supported in XP and higher. if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } // Now check Back status in different situations. @@ -455,19 +281,19 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } // Go Back and check status. window->ApplyAccelerator(IDC_BACK); Sleep(kWaitForActionMsec); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { - EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj)); } // Go Forward and check status. window->ApplyAccelerator(IDC_FORWARD); @@ -476,27 +302,27 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } // Add empty new tab and check status. ASSERT_TRUE(window->GetTabCount(&old_tab_count)); ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB)); ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count, - 5000)); + kWaitForActionMsec * 5)); // Check tab count. ASSERT_GE(new_tab_count, old_tab_count); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } // Add new tab with URL and check status. @@ -505,7 +331,7 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) { file_util::AppendToPath(&test_file2, L"title1.html"); ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2))); ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count, - 5000)); + kWaitForActionMsec * 5)); // Check tab count. ASSERT_GE(new_tab_count, old_tab_count); Sleep(kWaitForActionMsec); @@ -513,13 +339,150 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) { EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); } else { EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, - GetState(toolbar, button)); + GetState(acc_obj)); + } + + CHK_RELEASE(acc_obj); +} + +// Check Star button and its Name, Role, State. +TEST_F(AccessibilityTest, TestStarButton) { + HRESULT hr = S_OK; + IAccessible* acc_obj = NULL; + + // Retrieve IAccessible for Star button. + hr = GetStarButton(&acc_obj); + ASSERT_TRUE(S_OK == hr); + ASSERT_TRUE(NULL != acc_obj); + + // Check button and its Name, Role, State. + EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_STAR), GetName(acc_obj)); + EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(acc_obj)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj)); + + CHK_RELEASE(acc_obj); +} + +// Check Star button and its Name, Role, State, upon adding a new tab. +TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) { + HRESULT hr = S_OK; + IAccessible* acc_obj = NULL; + + // Retrieve IAccessible for Star button. + hr = GetStarButton(&acc_obj); + ASSERT_TRUE(S_OK == hr); + ASSERT_TRUE(NULL != acc_obj); + + // Check button and its Name, Role, State. + EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_STAR), GetName(acc_obj)); + EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(acc_obj)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj)); + + // Now, check Star status in different situations. + scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(window.get()); + + // Set URL and check button status. + scoped_ptr<TabProxy> tab1(window->GetTab(0)); + ASSERT_TRUE(tab1.get()); + std::wstring test_file1 = test_data_directory_; + file_util::AppendToPath(&test_file1, L"title1.html"); + tab1->NavigateToURL(net::FilePathToFileURL(test_file1)); + Sleep(kWaitForActionMsec); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj)); + + // Add empty new tab and check status. + int old_tab_count = -1; + ASSERT_TRUE(window->GetTabCount(&old_tab_count)); + ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB)); + int new_tab_count; + ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count, + kWaitForActionMsec * 5)); + // Check tab count. Also, check accessibility object's state. + ASSERT_GE(new_tab_count, old_tab_count); + Sleep(kWaitForActionMsec); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj)); + + // Add new tab with URL and check status. + old_tab_count = new_tab_count; + std::wstring test_file2 = test_data_directory_; + file_util::AppendToPath(&test_file2, L"title1.html"); + ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2))); + ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count, + kWaitForActionMsec * 5)); + // Check tab count. Also, check accessibility object's state. + ASSERT_GE(new_tab_count, old_tab_count); + Sleep(kWaitForActionMsec); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj)); + + CHK_RELEASE(acc_obj); +} + +// Check Go button and its Name, Role, State. +TEST_F(AccessibilityTest, TestGoButton) { + HRESULT hr = S_OK; + IAccessible* acc_obj = NULL; + + // Retrieve IAccessible for Go button. + hr = GetGoButton(&acc_obj); + ASSERT_TRUE(S_OK == hr); + ASSERT_TRUE(NULL != acc_obj); + + // Check button and its Name, Role, State. + EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_GO), GetName(acc_obj)); + EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(acc_obj)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj)); + + CHK_RELEASE(acc_obj); +} + +// Check Page menu button and its Name, Role, State. +TEST_F(AccessibilityTest, TestPageMenuButton) { + HRESULT hr = S_OK; + IAccessible* acc_obj = NULL; + + // Retrieve IAccessible for Page menu button. + hr = GetPageMenuButton(&acc_obj); + ASSERT_TRUE(S_OK == hr); + ASSERT_TRUE(NULL != acc_obj); + + // Check button and its Name, Role, State. + EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_PAGE), GetName(acc_obj)); + EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj)); + // State "has popup" only supported in XP and higher. + if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE, + GetState(acc_obj)); + } else { + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj)); } CHK_RELEASE(acc_obj); - CHK_RELEASE(toolbar); } +// Check App (wrench) menu button and its Name, Role, State. +TEST_F(AccessibilityTest, TestAppMenuButton) { + HRESULT hr = S_OK; + IAccessible* acc_obj = NULL; + + // Retrieve IAccessible for App menu button. + hr = GetAppMenuButton(&acc_obj); + ASSERT_TRUE(S_OK == hr); + ASSERT_TRUE(NULL != acc_obj); + + // Check button and its Name, Role, State. + EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_APP), GetName(acc_obj)); + EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj)); + // State "has popup" only supported in XP and higher. + if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE, + GetState(acc_obj)); + } else { + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj)); + } + + CHK_RELEASE(acc_obj); +} diff --git a/chrome/test/accessibility/accessibility_util.cc b/chrome/test/accessibility/accessibility_util.cc index 2174ad6..9d4afbb 100644 --- a/chrome/test/accessibility/accessibility_util.cc +++ b/chrome/test/accessibility/accessibility_util.cc @@ -5,7 +5,7 @@ #include "chrome/test/accessibility/accessibility_util.h" #include "base/win_util.h" -#include "chrome/common/win_util.h" +#include "chrome/browser/view_ids.h" #include "chrome/common/l10n_util.h" #include "chrome/test/accessibility/constants.h" @@ -32,17 +32,18 @@ static BOOL CALLBACK WindowEnumProc(HWND hwnd, LPARAM data) { HWND GetChromeBrowserWnd(IAccessible** acc_obj) { HWND hwnd = NULL; + EnumWindows(WindowEnumProc, reinterpret_cast<LPARAM>(&hwnd)); if (!hwnd) { CHK_RELEASE(*acc_obj); - return hwnd; + return NULL; } - // Get accessibility object for Chrome, only if requested. - if (!acc_obj) { + // Get accessibility object for Chrome, only if requested (not NULL). + if (!acc_obj) return hwnd; - } + *acc_obj = NULL; // Get accessibility object for Chrome Main Window. If failed to get it, @@ -57,7 +58,7 @@ HWND GetChromeBrowserWnd(IAccessible** acc_obj) { const std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_NAME); BSTR name; - // Confirm if it is Chrome window using its accessibility object's + // Confirm if it is Chrome Main Window using its accessibility object's // Name and Role property. If it's not the desired object, return only // window handle. hr = root_acc_obj->get_accName(id_self, &name); @@ -71,8 +72,8 @@ HWND GetChromeBrowserWnd(IAccessible** acc_obj) { return hwnd; } - // Get accessibility object for Chrome Window. If failed to get it, - // return only window handle. + // Get accessibility child objects for Chrome Main Window. If failed, return + // only window handle. INT64 child_cnt = GetChildCount(root_acc_obj); VARIANT* children = reinterpret_cast<VARIANT*>(calloc(size_t(child_cnt), sizeof(VARIANT))); @@ -85,18 +86,20 @@ HWND GetChromeBrowserWnd(IAccessible** acc_obj) { hr = GetChildrenArray(root_acc_obj, children); if (S_OK != hr) { CHK_RELEASE(root_acc_obj); + free(children); return hwnd; } - // Fetch desired child (Chrome window) of Chrome Main Window. + // Fetch desired child (Chrome App Window) of Chrome Main Window. IAccessible* app_acc_obj = NULL; - GetChildObject(root_acc_obj, children[CHROME_APP_ACC_INDEX], &app_acc_obj); + GetChildAccObject(root_acc_obj, children[CHROME_APP_ACC_INDEX], &app_acc_obj); if (!app_acc_obj) { CHK_RELEASE(app_acc_obj); + free(children); return hwnd; } - // Confirm if it is Chrome application using it's accessibility object's + // Confirm if it is Chrome App Window by using it's accessibility object's // Name and Role property. If it's not the desired object, return only // window handle. hr = app_acc_obj->get_accName(id_self, &name); @@ -104,11 +107,13 @@ HWND GetChromeBrowserWnd(IAccessible** acc_obj) { (0 != _wcsicmp(name, product_name.c_str())) ) { CHK_RELEASE(app_acc_obj); CHK_RELEASE(root_acc_obj); + free(children); return hwnd; } if (ROLE_SYSTEM_APPLICATION != GetRole(app_acc_obj)) { CHK_RELEASE(app_acc_obj); CHK_RELEASE(root_acc_obj); + free(children); return hwnd; } @@ -118,11 +123,15 @@ HWND GetChromeBrowserWnd(IAccessible** acc_obj) { if (S_OK != hr) { CHK_RELEASE(app_acc_obj); CHK_RELEASE(root_acc_obj); + free(children); return hwnd; } // Chrome Window has only one child which is Chrome Client. - GetChildObject(app_acc_obj, children[CHROME_CLIENT_ACC_INDEX], acc_obj); + GetChildAccObject(app_acc_obj, children[CHROME_CLIENT_ACC_INDEX], acc_obj); + + // Done using [children] array. + free(children); // Confirm if it is Chrome client using it's accessibility object's Name // and Role property. If it's not the desired object, return only window @@ -140,102 +149,112 @@ HWND GetChromeBrowserWnd(IAccessible** acc_obj) { return hwnd; } -HRESULT GetChildWnd(std::wstring parent_name, unsigned int child_index, - IAccessible** acc_obj, VARIANT* child) { +HRESULT GetChildAccessible(std::wstring parent_name, unsigned int child_index, + IAccessible** acc_obj) { // Validate input and initialize. - if (!acc_obj && !child) + if (!acc_obj) return E_INVALIDARG; - if (acc_obj) - *acc_obj = NULL; - if (child) - VariantInit(child); + + *acc_obj = NULL; // Get accessibility object and window handle for Chrome parent. IAccessible* parent = NULL; if (0 == parent_name.compare(BROWSER_STR)) GetChromeBrowserWnd(&parent); if (0 == parent_name.compare(BROWSER_VIEW_STR)) - GetBrowserViewWnd(&parent); + GetBrowserViewAccessible(&parent); if (0 == parent_name.compare(TOOLBAR_STR)) - GetToolbarWnd(&parent); + GetToolbarAccessible(&parent); if (0 == parent_name.compare(TABSTRIP_STR)) - GetTabStripWnd(&parent); + GetTabStripAccessible(&parent); if (!parent) return E_FAIL; + bool get_iaccessible = false; + // Validate child index. INT64 child_cnt = GetChildCount(parent); - if (child_index >= child_cnt) { - CHK_RELEASE(parent); - VariantClear(child); - return E_INVALIDARG; - } + if (child_index >= child_cnt) + get_iaccessible = true; HRESULT hr = S_OK; - // Get array of child items of parent object. - VARIANT* children = reinterpret_cast<VARIANT*>(calloc(size_t(child_cnt), - sizeof(VARIANT))); - if (children) { - hr = GetChildrenArray(parent, children); - if (S_OK == hr) { - // Fetch Tabstrip which is child_index'th child of parent object. - if (acc_obj) { - hr = GetChildObject(parent, children[child_index], acc_obj); - } - if (child) { - VariantCopy(child, children + child_index); + + if (get_iaccessible) { + // Child retrieved by child index, potentially further down the hierarchy. + VARIANT child_var; + child_var.vt = VT_I4; + child_var.lVal = child_index; + hr = GetChildAccObject(parent, child_var, acc_obj); + } else { + // Get array of child items of parent object. + VARIANT* children = reinterpret_cast<VARIANT*>(calloc(size_t(child_cnt), + sizeof(VARIANT))); + if (children) { + hr = GetChildrenArray(parent, children); + if (S_OK == hr) { + // Fetch child IAccessible. + if (acc_obj) + hr = GetChildAccObject(parent, children[child_index], acc_obj); } + free(children); } - free(children); } CHK_RELEASE(parent); return hr; } -HRESULT GetTabStripWnd(IAccessible** acc_obj) { -#ifdef NEW_FRAMES - return GetChildWnd(BROWSER_VIEW_STR, TABSTRIP_ACC_INDEX, acc_obj, NULL); -#else - return GetChildWnd(BROWSER_STR, TABSTRIP_ACC_INDEX, acc_obj, NULL); -#endif +HRESULT GetTabStripAccessible(IAccessible** acc_obj) { + return GetChildAccessible(BROWSER_VIEW_STR, TABSTRIP_ACC_INDEX, acc_obj); +} + +HRESULT GetBrowserViewAccessible(IAccessible** acc_obj) { + return GetChildAccessible(BROWSER_STR, BROWSER_VIEW_ACC_INDEX, acc_obj); +} + +HRESULT GetToolbarAccessible(IAccessible** acc_obj) { + return GetChildAccessible(BROWSER_VIEW_STR, VIEW_ID_TOOLBAR, acc_obj); +} + +HRESULT GetBrowserMinimizeButton(IAccessible** acc_obj) { + return GetChildAccessible(BROWSER_STR, CHROME_MIN_ACC_INDEX, acc_obj); } -HRESULT GetBrowserViewWnd(IAccessible** acc_obj) { - return GetChildWnd(BROWSER_STR, BROWSER_VIEW_ACC_INDEX, acc_obj, NULL); +HRESULT GetBrowserMaximizeButton(IAccessible** acc_obj) { + return GetChildAccessible(BROWSER_STR, CHROME_MAX_ACC_INDEX, acc_obj); } -HRESULT GetToolbarWnd(IAccessible** acc_obj) { - return GetChildWnd(BROWSER_VIEW_STR, TOOLBAR_ACC_INDEX, acc_obj, NULL); +HRESULT GetBrowserRestoreButton(IAccessible** acc_obj) { + return GetChildAccessible(BROWSER_STR, CHROME_RESTORE_ACC_INDEX, acc_obj); } -HRESULT GetBrowserMinimizeButton(IAccessible** acc_obj, VARIANT* child) { - return GetChildWnd(BROWSER_STR, CHROME_MIN_ACC_INDEX, acc_obj, child); +HRESULT GetBrowserCloseButton(IAccessible** acc_obj) { + return GetChildAccessible(BROWSER_STR, CHROME_CLOSE_ACC_INDEX, acc_obj); } -HRESULT GetBrowserMaximizeButton(IAccessible** acc_obj, VARIANT* child) { - return GetChildWnd(BROWSER_STR, CHROME_MAX_ACC_INDEX, acc_obj, child); +HRESULT GetBackButton(IAccessible** acc_obj) { + return GetChildAccessible(TOOLBAR_STR, VIEW_ID_BACK_BUTTON, acc_obj); } -HRESULT GetBrowserRestoreButton(IAccessible** acc_obj, VARIANT* child) { - return GetChildWnd(BROWSER_STR, CHROME_RESTORE_ACC_INDEX, acc_obj, child); +HRESULT GetForwardButton(IAccessible** acc_obj) { + return GetChildAccessible(TOOLBAR_STR, VIEW_ID_FORWARD_BUTTON, acc_obj); } -HRESULT GetBrowserCloseButton(IAccessible** acc_obj, VARIANT* child) { - return GetChildWnd(BROWSER_STR, CHROME_CLOSE_ACC_INDEX, acc_obj, child); +HRESULT GetStarButton(IAccessible** acc_obj) { + return GetChildAccessible(TOOLBAR_STR, VIEW_ID_STAR_BUTTON, acc_obj); } -HRESULT GetStarButton(IAccessible** acc_obj, VARIANT* child) { - return GetChildWnd(TOOLBAR_STR, STAR_BTN_INDEX, acc_obj, child); +HRESULT GetGoButton(IAccessible** acc_obj) { + return GetChildAccessible(TOOLBAR_STR, VIEW_ID_GO_BUTTON, acc_obj); } -HRESULT GetBackButton(IAccessible** acc_obj, VARIANT* child) { - return GetChildWnd(TOOLBAR_STR, BACK_BTN_INDEX, acc_obj, child); +HRESULT GetPageMenuButton(IAccessible** acc_obj) { + return GetChildAccessible(TOOLBAR_STR, VIEW_ID_PAGE_MENU, acc_obj); } -HRESULT GetForwardButton(IAccessible** acc_obj, VARIANT* child) { - return GetChildWnd(TOOLBAR_STR, FORWARD_BTN_INDEX, acc_obj, child); +HRESULT GetAppMenuButton(IAccessible** acc_obj) { + return GetChildAccessible(TOOLBAR_STR, VIEW_ID_APP_MENU, acc_obj); } HWND GetAddressBarWnd(IAccessible** acc_obj) { @@ -317,8 +336,8 @@ HWND GetAuthWnd(IAccessible** acc_obj) { return hwnd_auth; } -HRESULT GetChildObject(IAccessible* acc_obj, VARIANT child, - IAccessible** child_acc_obj) { +HRESULT GetChildAccObject(IAccessible* acc_obj, VARIANT child, + IAccessible** child_acc_obj) { // Validate input. if (!acc_obj || !child_acc_obj) return E_INVALIDARG; @@ -343,7 +362,7 @@ HRESULT GetChildObject(IAccessible* acc_obj, VARIANT child, return hr; } -HRESULT GetParentObject(IAccessible* acc_obj, IAccessible** parent_acc_obj) { +HRESULT GetParentAccObject(IAccessible* acc_obj, IAccessible** parent_acc_obj) { // Validate input. if (!acc_obj || !parent_acc_obj) return E_INVALIDARG; @@ -425,7 +444,7 @@ BSTR GetTabName(INT64 tab_index) { // Get accessibility object for Tabstrip. IAccessible* tab_strip_acc_obj = NULL; - GetTabStripWnd(&tab_strip_acc_obj); + GetTabStripAccessible(&tab_strip_acc_obj); // Get Tab from Tabstrip and return it's Name. if (tab_strip_acc_obj) { @@ -438,7 +457,7 @@ BSTR GetTabName(INT64 tab_index) { hr = GetChildrenArray(tab_strip_acc_obj, children); if (S_OK == hr) { IAccessible* temp_acc_obj = NULL; - hr = GetChildObject(tab_strip_acc_obj, children[tab_index], + hr = GetChildAccObject(tab_strip_acc_obj, children[tab_index], &temp_acc_obj); if ((S_OK == hr) && (children[tab_index].vt == VT_DISPATCH) && (temp_acc_obj)) { @@ -460,7 +479,7 @@ BSTR GetTabName(INT64 tab_index) { INT64 GetTabCnt() { // Get accessibility object for Tabstrip. IAccessible* tab_strip_acc_obj = NULL; - GetTabStripWnd(&tab_strip_acc_obj); + GetTabStripAccessible(&tab_strip_acc_obj); // If Tabstrip is invalid, return -1 to indicate error. if (!tab_strip_acc_obj) diff --git a/chrome/test/accessibility/accessibility_util.h b/chrome/test/accessibility/accessibility_util.h index ec63956..738a0de 100644 --- a/chrome/test/accessibility/accessibility_util.h +++ b/chrome/test/accessibility/accessibility_util.h @@ -27,23 +27,23 @@ HWND GetChromeBrowserWnd(IAccessible** acc_obj); // Returns IAccessible pointer of object's child window, provided [parent_name] // and its (0-based) [child_index]. If child is a leaf element (has no children) // its variant id is returned with S_FALSE. -HRESULT GetChildWnd(std::wstring parent_name, unsigned int child_index, - IAccessible** acc_obj, VARIANT* child); +HRESULT GetChildAccessible(std::wstring parent_name, unsigned int child_index, + IAccessible** acc_obj); // Returns IAccessible pointer for Tabstrip (does not have a window handle), by -// calling upon GetChildWnd. Will never be a leaf element, as it always has at -// least one child. -HRESULT GetTabStripWnd(IAccessible** acc_obj); +// calling upon GetChildAccessible. Will never be a leaf element, as it always +// has at least one child. +HRESULT GetTabStripAccessible(IAccessible** acc_obj); // Returns IAccessible pointer for BrowserView (does not have a window handle), -// by calling upon GetChildWnd. Will never be a leaf element, as it always has -// at least one child. -HRESULT GetBrowserViewWnd(IAccessible** acc_obj); +// by calling upon GetChildAccessible. Will never be a leaf element, as it +// always has at least one child. +HRESULT GetBrowserViewAccessible(IAccessible** acc_obj); // Returns IAccessible pointer for Toolbar (does not have a window handle), by -// calling upon GetChildWnd. Will never be a leaf element, as it always has at -// least one child. -HRESULT GetToolbarWnd(IAccessible** acc_obj); +// calling upon GetChildAccessible. Will never be a leaf element, as it always +// has at least one child. +HRESULT GetToolbarAccessible(IAccessible** acc_obj); // Returns window handle to OmniBox(AddressBar) and IAccessible pointer (if // requested), by calling AccessibleObjectFromWindow on the window handle. If @@ -63,12 +63,12 @@ HWND GetAuthWnd(IAccessible** acc_obj); // Fetches IAccessible pointer for a child, given the IAccessible for the parent // ([acc_obj]) and a child id (passed in with the [child] VARIANT). Retrieves // the child by calling get_accChild on [acc_obj]. -HRESULT GetChildObject(IAccessible* acc_obj, VARIANT child, - IAccessible** child_acc_obj); +HRESULT GetChildAccObject(IAccessible* acc_obj, VARIANT child, + IAccessible** child_acc_obj); // Fetches IAccessible pointer for the parent of specified IAccessible object // (by calling get_accParent on [acc_obj]). -HRESULT GetParentObject(IAccessible* acc_obj, IAccessible** parent_acc_obj); +HRESULT GetParentAccObject(IAccessible* acc_obj, IAccessible** parent_acc_obj); // Returns number of children for the specified IAccessible. If [acc_obj] // parameter is NULL, -1 is returned. @@ -101,32 +101,44 @@ LONG GetRole(IAccessible* acc_obj, VARIANT child = id_self); LONG GetState(IAccessible* acc_obj, VARIANT child = id_self); // Returns IAccessible pointer for Chrome Minimize Button, by calling -// GetChildWnd. It does not have window handle. -HRESULT GetBrowserMinimizeButton(IAccessible** acc_obj, VARIANT* child); +// GetChildAccessible. It does not have window handle. +HRESULT GetBrowserMinimizeButton(IAccessible** acc_obj); // Returns IAccessible pointer for Chrome Maximize Button, by calling -// GetChildWnd. It does not have window handle. -HRESULT GetBrowserMaximizeButton(IAccessible** acc_obj, VARIANT* child); +// GetChildAccessible. It does not have window handle. +HRESULT GetBrowserMaximizeButton(IAccessible** acc_obj); // Returns IAccessible pointer for Chrome Restore Button, by calling -// GetChildWnd. It does not have window handle. -HRESULT GetBrowserRestoreButton(IAccessible** acc_obj, VARIANT* child); +// GetChildAccessible. It does not have window handle. +HRESULT GetBrowserRestoreButton(IAccessible** acc_obj); // Returns IAccessible pointer for Chrome Close Button, by calling -// GetChildWnd. It does not have window handle. -HRESULT GetBrowserCloseButton(IAccessible** acc_obj, VARIANT* child); +// GetChildAccessible. It does not have window handle. +HRESULT GetBrowserCloseButton(IAccessible** acc_obj); -// Returns IAccessible pointer for Chrome Star Button, by calling GetChildWnd. -// It does not have window handle. -HRESULT GetStarButton(IAccessible** acc_obj, VARIANT* child); - -// Returns IAccessible pointer for Chrome Back Button, by calling GetChildWnd. -// It does not have window handle. -HRESULT GetBackButton(IAccessible** acc_obj, VARIANT* child); +// Returns IAccessible pointer for Chrome Back Button, by calling +// GetChildAccessible. It does not have window handle. +HRESULT GetBackButton(IAccessible** acc_obj); // Returns IAccessible pointer for Chrome Forward Button, by calling -// GetChildWnd. It does not have window handle. -HRESULT GetForwardButton(IAccessible** acc_obj, VARIANT* child); +// GetChildAccessible. It does not have window handle. +HRESULT GetForwardButton(IAccessible** acc_obj); + +// Returns IAccessible pointer for Chrome Star Button, by calling +// GetChildAccessible. It does not have window handle. +HRESULT GetStarButton(IAccessible** acc_obj); + +// Returns IAccessible pointer for Chrome Go Button, by calling +// GetChildAccessible. It does not have window handle. +HRESULT GetGoButton(IAccessible** acc_obj); + +// Returns IAccessible pointer for Chrome Page Menu Button, by calling +// GetChildAccessible. It does not have window handle. +HRESULT GetPageMenuButton(IAccessible** acc_obj); + +// Returns IAccessible pointer for Chrome App Menu Button, by calling +// GetChildAccessible. It does not have window handle. +HRESULT GetAppMenuButton(IAccessible** acc_obj); #endif // CHROME_TEST_ACCESSIBILITY_ACCESSIBILITY_UTIL_H_ diff --git a/chrome/test/accessibility/browser_impl.cc b/chrome/test/accessibility/browser_impl.cc index 36b3c1f..10785b1 100644 --- a/chrome/test/accessibility/browser_impl.cc +++ b/chrome/test/accessibility/browser_impl.cc @@ -280,7 +280,7 @@ bool BrowserImpl::WaitForChromeToBeVisible(const INT64 interval, // Check and wait. while (timeout >= time_elapsed) { - GetTabStripWnd(&acc_obj); + GetTabStripAccessible(&acc_obj); if (acc_obj) { *visible = true; CHK_RELEASE(acc_obj); diff --git a/chrome/test/accessibility/constants.h b/chrome/test/accessibility/constants.h index 5fad4b7..43091795 100644 --- a/chrome/test/accessibility/constants.h +++ b/chrome/test/accessibility/constants.h @@ -8,17 +8,14 @@ #include <windows.h> #include <tchar.h> -#define NEW_FRAMES - /////////////////////////////////////////////////////////////////// -// Constant Definitations specific to Chrome Accessibility Tests. +// Constants definitions specific to Chrome Accessibility Tests. /////////////////////////////////////////////////////////////////// // Safe delete and release operations. #define CHK_RELEASE(obj) { if (obj) { (obj)->Release(); (obj) = NULL; } } #define CHK_DELETE(obj) { if (obj) { delete (obj); (obj) = NULL; } } - // Chrome Accessibility Tests specific strings. #define CHROME_PATH _T("C:\\Program Files\\Google\\Chrome\\Chrome.exe") #define CHROME_VIEWS_TEXT_FIELD_EDIT _T("ChromeViewsTextFieldEdit") @@ -29,50 +26,21 @@ #define AUTH_TITLE _T("Authentication Required - Chrome") #define CHROME_TAB_CONTENTS _T("Chrome_TabContents") +// Index for accessing specific children in the MSAA hierarchy. +// TODO(klink): Remove the need for these. #define CHROME_APP_ACC_INDEX (3) #define CHROME_CLIENT_ACC_INDEX (0) - -// Chrome Client chidren. -#ifdef NEW_FRAMES #define BROWSER_VIEW_ACC_INDEX (4) + +// Chrome Client chidren. These UI elements cannot take MSAA focus, and +// therefore have no ViewID associated. #define TABSTRIP_ACC_INDEX (0) #define CHROME_MIN_ACC_INDEX (0) #define CHROME_MAX_ACC_INDEX (1) #define CHROME_RESTORE_ACC_INDEX (2) #define CHROME_CLOSE_ACC_INDEX (3) -#else -#define BROWSER_VIEW_ACC_INDEX (0) -#define TABSTRIP_ACC_INDEX (1) -#if defined(GOOGLE_CHROME_BUILD) -#define CHROME_MIN_ACC_INDEX (4) -#define CHROME_MAX_ACC_INDEX (5) -#define CHROME_RESTORE_ACC_INDEX (6) -#define CHROME_CLOSE_ACC_INDEX (7) -#else -#define CHROME_MIN_ACC_INDEX (3) -#define CHROME_MAX_ACC_INDEX (4) -#define CHROME_RESTORE_ACC_INDEX (5) -#define CHROME_CLOSE_ACC_INDEX (6) -#endif -#endif - -// Browser View children. -#ifdef NEW_FRAMES -#define TOOLBAR_ACC_INDEX (1) -#else -#define TOOLBAR_ACC_INDEX (0) -#endif - -// Toolbar children. -#define BACK_BTN_INDEX (0) -#define FORWARD_BTN_INDEX (1) -#define RELOAD_BTN_INDEX (2) -#define STAR_BTN_INDEX (4) -#define GO_BTN_INDEX (6) -#define PAGE_BTN_INDEX (7) -#define MENU_BTN_INDEX (8) -// Digit limits for tab index which can be used in accelerator. +// Tab index limits for bounds checking in Accessibility Tests. #define MAX_TAB_INDEX_DIGIT (9) #define MIN_TAB_INDEX_DIGIT (1) |