diff options
author | niranjan@google.com <niranjan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-21 08:15:38 +0000 |
---|---|---|
committer | niranjan@google.com <niranjan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-21 08:15:38 +0000 |
commit | acfab0510bc977a795578a560e16aecb2cb2e552 (patch) | |
tree | 098a79e00b4c6e1383f97803ce77ab8cea024646 /chrome | |
parent | 11e020fcd65c415dc46d10ae9dbe6ba63600ee4c (diff) | |
download | chromium_src-acfab0510bc977a795578a560e16aecb2cb2e552.zip chromium_src-acfab0510bc977a795578a560e16aecb2cb2e552.tar.gz chromium_src-acfab0510bc977a795578a560e16aecb2cb2e552.tar.bz2 |
Fixed all the remaining hardcoded strings in AccessibilityTests
Changed the GetRole() and GetState() methods to return DWORD constants instead of strings. We didn't really need the string values of Roles and States and this led us to compare strings in the test cases when we should have been just comparing constants. This change fixes all that.
All the accessibility tests should now run on locales other than en-us and as a nice side effect, the tests should run very very marginally faster.
TEST=ui_tests.exe --gtest_filter=AccessibilityTest*
Review URL: http://codereview.chromium.org/11558
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5821 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/test/accessibility/accessibility_tests.cc | 139 | ||||
-rw-r--r-- | chrome/test/accessibility/accessibility_util.cc | 60 | ||||
-rw-r--r-- | chrome/test/accessibility/accessibility_util.h | 8 | ||||
-rw-r--r-- | chrome/test/accessibility/constants.h | 3 |
4 files changed, 103 insertions, 107 deletions
diff --git a/chrome/test/accessibility/accessibility_tests.cc b/chrome/test/accessibility/accessibility_tests.cc index 6ca4902..42c087a 100644 --- a/chrome/test/accessibility/accessibility_tests.cc +++ b/chrome/test/accessibility/accessibility_tests.cc @@ -5,11 +5,9 @@ #include <Objbase.h> #include <Oleacc.h> -#include "base/command_line.h" #include "base/file_util.h" #include "base/win_util.h" #include "chrome/app/chrome_dll_resource.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/l10n_util.h" #include "chrome/test/accessibility/accessibility_util.h" #include "chrome/test/ui/ui_test.h" @@ -31,9 +29,6 @@ class AccessibilityTest : public UITest { AccessibilityTest() { show_window_ = true; CoInitialize(NULL); - CommandLine::AppendSwitchWithValue(&launch_arguments_, - switches::kLang, - L"en-us"); } ~AccessibilityTest() { CoUninitialize(); @@ -42,8 +37,8 @@ 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. +// TODO(sridharg): Alter, when accessibility objects for Chrome Window, +// Application and Client are corrected. TEST_F(AccessibilityTest, TestChromeBrowserAccObject) { IAccessible* p_accobj = NULL; HWND hwnd = GetChromeBrowserWnd(&p_accobj); @@ -52,8 +47,8 @@ TEST_F(AccessibilityTest, TestChromeBrowserAccObject) { CHK_RELEASE(p_accobj); } -// Check accessibility object for toolbar and it's properties Name, Role, State. -// (Add other properties, if their values are fixed all the time.) +// Check accessibility object for toolbar and it's properties Name, Role, +// State. (Add other properties, if their values are fixed all the time.) TEST_F(AccessibilityTest, TestChromeToolbarAccObject) { IAccessible* p_accobj = NULL; GetToolbarWnd(&p_accobj); @@ -62,9 +57,9 @@ TEST_F(AccessibilityTest, TestChromeToolbarAccObject) { // Check Name - IDS_ACCNAME_TOOLBAR. EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_TOOLBAR), GetName(p_accobj)); // Check Role - "tool bar". - EXPECT_EQ(L"tool bar", GetRole(p_accobj)); + EXPECT_EQ(ROLE_SYSTEM_TOOLBAR, GetRole(p_accobj)); // Check State - "focusable" - EXPECT_EQ(L"focusable", GetState(p_accobj)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_accobj)); CHK_RELEASE(p_accobj); } @@ -79,9 +74,9 @@ TEST_F(AccessibilityTest, TestChromeTabstripAccObject) { // Check Name - IDS_ACCNAME_TABSTRIP. EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_TABSTRIP), GetName(p_accobj)); // Check Role - "grouping". - EXPECT_EQ(L"grouping", GetRole(p_accobj)); + EXPECT_EQ(ROLE_SYSTEM_GROUPING, GetRole(p_accobj)); // Check State - "focusable" - EXPECT_EQ(L"focusable", GetState(p_accobj)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_accobj)); CHK_RELEASE(p_accobj); } @@ -106,8 +101,8 @@ TEST_F(AccessibilityTest, TestChromeButtons) { // Read it's properties. EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_MINIMIZE), GetName(p_browser, button)); - EXPECT_EQ(L"push button", GetRole(p_browser, button)); - EXPECT_EQ(L"focusable", GetState(p_browser, button)); + EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(p_browser, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_browser, button)); CHK_RELEASE(p_accobj); // Check Maximize button and it's Name, Role, State. @@ -119,8 +114,8 @@ TEST_F(AccessibilityTest, TestChromeButtons) { // Read it's properties. EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_MAXIMIZE), GetName(p_browser, button)); - EXPECT_EQ(L"push button", GetRole(p_browser, button)); - EXPECT_EQ(L"focusable", GetState(p_browser, button)); + EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(p_browser, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_browser, button)); CHK_RELEASE(p_accobj); // Check Restore button and it's Name, Role, State. @@ -132,8 +127,9 @@ TEST_F(AccessibilityTest, TestChromeButtons) { // Read it's properties. EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_RESTORE), GetName(p_browser, button)); - EXPECT_EQ(L"push button", GetRole(p_browser, button)); - EXPECT_EQ(L"focusable, invisible", GetState(p_browser, button)); + EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(p_browser, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_INVISIBLE, + GetState(p_browser, button)); CHK_RELEASE(p_accobj); // Check Close button and it's Name, Role, State. @@ -145,8 +141,8 @@ TEST_F(AccessibilityTest, TestChromeButtons) { // Read it's properties. EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_CLOSE), GetName(p_browser, button)); - EXPECT_EQ(L"push button", GetRole(p_browser, button)); - EXPECT_EQ(L"focusable", GetState(p_browser, button)); + EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(p_browser, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_browser, button)); CHK_RELEASE(p_accobj); CHK_RELEASE(p_browser); @@ -172,8 +168,8 @@ TEST_F(AccessibilityTest, TestStarButton) { // Read it's properties. EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_STAR), GetName(p_toolbar, button)); - EXPECT_EQ(L"push button", GetRole(p_toolbar, button)); - EXPECT_EQ(L"focusable", GetState(p_toolbar, button)); + EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button)); CHK_RELEASE(p_accobj); CHK_RELEASE(p_toolbar); @@ -196,7 +192,7 @@ TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) { ASSERT_TRUE(S_FALSE == hr); ASSERT_TRUE(NULL == p_accobj); ASSERT_TRUE(VT_I4 == button.vt); - EXPECT_EQ(L"focusable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button)); // Now, check Star status in different situations. scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); @@ -209,7 +205,7 @@ TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) { file_util::AppendToPath(&test_file1, L"title1.html"); tab1->NavigateToURL(net::FilePathToFileURL(test_file1)); Sleep(kWaitForActionMsec); - EXPECT_EQ(L"focusable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button)); // Add empty new tab and check status. int old_tab_count = -1; @@ -222,7 +218,7 @@ TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) { ASSERT_GE(new_tab_count, old_tab_count); // Also, check accessibility object's children. Sleep(1000); - EXPECT_EQ(L"focusable", GetState(p_toolbar, button)); // ??? + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button)); // ??? // Add new tab with URL and check status. old_tab_count = new_tab_count; @@ -234,7 +230,7 @@ TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) { // Check tab count. Also, check accessibility object's children. ASSERT_GE(new_tab_count, old_tab_count); Sleep(kWaitForActionMsec); - EXPECT_EQ(L"focusable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button)); CHK_RELEASE(p_toolbar); } @@ -260,13 +256,16 @@ TEST_F(AccessibilityTest, TestBackButton) { // Read it's properties. EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_BACK), GetName(p_toolbar, button)); - EXPECT_EQ(L"drop down button", GetRole(p_toolbar, button)); + EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(p_toolbar, button)); // State "has popup" only supported in XP and higher. if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable, unavailable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | + STATE_SYSTEM_FOCUSABLE | + STATE_SYSTEM_UNAVAILABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable, unavailable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, + GetState(p_toolbar, button)); } CHK_RELEASE(p_accobj); @@ -293,10 +292,13 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) { ASSERT_TRUE(VT_I4 == button.vt); // State "has popup" only supported in XP and higher. if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable, unavailable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | + STATE_SYSTEM_FOCUSABLE | + STATE_SYSTEM_UNAVAILABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable, unavailable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, + GetState(p_toolbar, button)); } // Now check Back status in different situations. @@ -313,19 +315,22 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) { tab1->NavigateToURL(net::FilePathToFileURL(test_file1)); Sleep(kWaitForActionMsec); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button)); } // Go Back and check status. window->ApplyAccelerator(IDC_BACK); Sleep(kWaitForActionMsec); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable, unavailable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | + STATE_SYSTEM_FOCUSABLE | + STATE_SYSTEM_UNAVAILABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable, unavailable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, + GetState(p_toolbar, button)); } // Add empty new tab and check status. @@ -336,10 +341,13 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) { // 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(L"has popup, focusable, unavailable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | + STATE_SYSTEM_FOCUSABLE | + STATE_SYSTEM_UNAVAILABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable, unavailable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, + GetState(p_toolbar, button)); } // Add new tab with URL and check status. @@ -353,10 +361,13 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) { ASSERT_GE(new_tab_count, old_tab_count); Sleep(kWaitForActionMsec); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable, unavailable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | + STATE_SYSTEM_FOCUSABLE | + STATE_SYSTEM_UNAVAILABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable, unavailable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, + GetState(p_toolbar, button)); } CHK_RELEASE(p_toolbar); @@ -382,13 +393,16 @@ TEST_F(AccessibilityTest, TestForwardButton) { // Read it's properties. EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_FORWARD), GetName(p_toolbar, button)); - EXPECT_EQ(L"drop down button", GetRole(p_toolbar, button)); + EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(p_toolbar, button)); // State "has popup" only supported in XP and higher. if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable, unavailable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | + STATE_SYSTEM_FOCUSABLE | + STATE_SYSTEM_UNAVAILABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable, unavailable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, + GetState(p_toolbar, button)); } CHK_RELEASE(p_accobj); @@ -415,10 +429,13 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) { ASSERT_TRUE(VT_I4 == button.vt); // State "has popup" only supported in XP and higher. if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable, unavailable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | + STATE_SYSTEM_FOCUSABLE | + STATE_SYSTEM_UNAVAILABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable, unavailable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, + GetState(p_toolbar, button)); } // Now check Back status in different situations. @@ -435,28 +452,34 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) { tab1->NavigateToURL(net::FilePathToFileURL(test_file1)); Sleep(kWaitForActionMsec); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable, unavailable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | + STATE_SYSTEM_FOCUSABLE | + STATE_SYSTEM_UNAVAILABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable, unavailable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, + GetState(p_toolbar, button)); } // Go Back and check status. window->ApplyAccelerator(IDC_BACK); Sleep(kWaitForActionMsec); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button)); } // Go Forward and check status. window->ApplyAccelerator(IDC_FORWARD); Sleep(kWaitForActionMsec); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable, unavailable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | + STATE_SYSTEM_FOCUSABLE | + STATE_SYSTEM_UNAVAILABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable, unavailable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, + GetState(p_toolbar, button)); } // Add empty new tab and check status. @@ -467,10 +490,13 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) { // Check tab count. ASSERT_GE(new_tab_count, old_tab_count); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable, unavailable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | + STATE_SYSTEM_FOCUSABLE | + STATE_SYSTEM_UNAVAILABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable, unavailable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, + GetState(p_toolbar, button)); } // Add new tab with URL and check status. @@ -484,10 +510,13 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) { ASSERT_GE(new_tab_count, old_tab_count); Sleep(kWaitForActionMsec); if (win_util::GetWinVersion() > win_util::WINVERSION_2000) { - EXPECT_EQ(L"has popup, focusable, unavailable", + EXPECT_EQ(STATE_SYSTEM_HASPOPUP | + STATE_SYSTEM_FOCUSABLE | + STATE_SYSTEM_UNAVAILABLE, GetState(p_toolbar, button)); } else { - EXPECT_EQ(L"focusable, unavailable", GetState(p_toolbar, button)); + EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE, + GetState(p_toolbar, button)); } CHK_RELEASE(p_toolbar); diff --git a/chrome/test/accessibility/accessibility_util.cc b/chrome/test/accessibility/accessibility_util.cc index 36089cd..d52d57e 100644 --- a/chrome/test/accessibility/accessibility_util.cc +++ b/chrome/test/accessibility/accessibility_util.cc @@ -72,8 +72,7 @@ HWND GetChromeBrowserWnd(IAccessible** ppi_access) { CHK_RELEASE(pi_acc_root_win); return hwnd; } - str_role = GetRole(pi_acc_root_win); - if (0 != str_role.compare(BROWSER_WIN_ROLE)) { + if (ROLE_SYSTEM_WINDOW != GetRole(pi_acc_root_win)) { CHK_RELEASE(pi_acc_root_win); return hwnd; } @@ -115,8 +114,7 @@ HWND GetChromeBrowserWnd(IAccessible** ppi_access) { CHK_RELEASE(pi_acc_root_win); return hwnd; } - str_role = GetRole(pi_acc_app); - if (0 != str_role.compare(BROWSER_APP_ROLE)) { + if (ROLE_SYSTEM_APPLICATION != GetRole(pi_acc_app)) { CHK_RELEASE(pi_acc_app); CHK_RELEASE(pi_acc_root_win); return hwnd; @@ -143,8 +141,7 @@ HWND GetChromeBrowserWnd(IAccessible** ppi_access) { (0 != _wcsicmp(str_name, product_name.c_str())) ) { CHK_RELEASE(*ppi_access); } - str_role = GetRole(*ppi_access); - if (0 != str_role.compare(BROWSER_CLIENT_ROLE)) { + if (ROLE_SYSTEM_CLIENT != GetRole(*ppi_access)) { CHK_RELEASE(*ppi_access); } @@ -539,13 +536,13 @@ std::wstring GetName(IAccessible* pi_access, VARIANT child) { return std::wstring(name); } -std::wstring GetRole(IAccessible* pi_access, VARIANT child) { +DWORD GetRole(IAccessible* pi_access, VARIANT child) { HRESULT hr = S_OK; LPTSTR role_str = NULL; // Validate input. if (NULL == pi_access) { - return std::wstring(); + return ROLE_ERROR; } // Get Role. @@ -554,27 +551,21 @@ std::wstring GetRole(IAccessible* pi_access, VARIANT child) { hr = pi_access->get_accRole(child, &role); if (S_OK != hr || VT_I4 != role.vt) { VariantClear(&role); - return std::wstring(); + return ROLE_ERROR; } - // Get Role string. - unsigned int role_length = GetRoleText(role.lVal, NULL, 0); - role_str = (LPTSTR)calloc(role_length + 1, sizeof(TCHAR)); - if (role_str) - GetRoleText(role.lVal, role_str, role_length + 1); - - VariantClear(&role); - return std::wstring(role_str); + // Return the role value + return role.lVal; } -std::wstring GetState(IAccessible* pi_access, VARIANT child) { +DWORD GetState(IAccessible* pi_access, VARIANT child) { HRESULT hr = S_OK; LPTSTR state_str = NULL; std::wstring complete_state; // Validate input. if (NULL == pi_access) { - return std::wstring(); + return STATE_ERROR; } // Get State. @@ -583,37 +574,10 @@ std::wstring GetState(IAccessible* pi_access, VARIANT child) { hr = pi_access->get_accState(child, &state); if (S_OK != hr || VT_I4 != state.vt) { VariantClear(&state); - return std::wstring(); - } - - // Treat the "normal" state separately. - if (state.vt == 0) { - unsigned int state_length = GetStateText(state.lVal, NULL, 0); - state_str = (LPTSTR)calloc(state_length + 1, sizeof(TCHAR)); - if (state_str) { - GetStateText(state.lVal, state_str, state_length + 1); - complete_state = std::wstring(state_str); - } - } else { - // Number of bits. - UINT bit_cnt = 32; - // Convert state flags to comma separated list. - for (DWORD dwStateBit = 0x80000000; bit_cnt; bit_cnt--, dwStateBit >>= 1) { - if (state.lVal & dwStateBit) { - unsigned int state_length = GetStateText(dwStateBit, NULL, 0); - state_str = (LPTSTR)calloc(state_length + 1, sizeof(TCHAR)); - if (state_str) { - GetStateText(dwStateBit, state_str, state_length + 1); - if (complete_state.length() > 0) - complete_state.append(L", "); - complete_state.append(state_str); - free(state_str); - } - } - } + return STATE_ERROR; } VariantClear(&state); - return complete_state; + return state.lVal; } diff --git a/chrome/test/accessibility/accessibility_util.h b/chrome/test/accessibility/accessibility_util.h index 15f49f1..182f733 100644 --- a/chrome/test/accessibility/accessibility_util.h +++ b/chrome/test/accessibility/accessibility_util.h @@ -74,13 +74,13 @@ INT64 GetTabCnt(); // variant. std::wstring GetName(IAccessible* pi_access, VARIANT child = g_var_self); -// Returns Role of specified IAccessible pointer or it's child specified by +// Returns the role of specified IAccessible pointer or it's child specified by // variant. -std::wstring GetRole(IAccessible* pi_access, VARIANT child = g_var_self); +DWORD GetRole(IAccessible* pi_access, VARIANT child = g_var_self); -// Returns State of specified IAccessible pointer or it's child specified by +// Returns state of specified IAccessible pointer or it's child specified by // variant. -std::wstring GetState(IAccessible* pi_access, VARIANT child = g_var_self); +DWORD GetState(IAccessible* pi_access, VARIANT child = g_var_self); // Returns IAccessible pointer for Chrome Minimize Button. It does not have // window handle. diff --git a/chrome/test/accessibility/constants.h b/chrome/test/accessibility/constants.h index 967de0c..a3d6060 100644 --- a/chrome/test/accessibility/constants.h +++ b/chrome/test/accessibility/constants.h @@ -36,6 +36,9 @@ #define CHROME_APP_ACC_INDEX (3) #define CHROME_CLIENT_ACC_INDEX (0) +#define ROLE_ERROR (-1) +#define STATE_ERROR (-1) + // Chrome Client chidren. #ifdef NEW_FRAMES #define BROWSER_VIEW_ACC_INDEX (4) |