summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorklink@chromium.org <klink@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-17 20:41:20 +0000
committerklink@chromium.org <klink@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-17 20:41:20 +0000
commit14bac21d0b669394be472b9c2c017ff69d1d9da2 (patch)
treeadc5f464a4a81b2f1e14f1c132843d303d3cba53 /chrome/test
parentc51e0690737d3d1269cc3aa666792ab4fb0e60c0 (diff)
downloadchromium_src-14bac21d0b669394be472b9c2c017ff69d1d9da2.zip
chromium_src-14bac21d0b669394be472b9c2c017ff69d1d9da2.tar.gz
chromium_src-14bac21d0b669394be472b9c2c017ff69d1d9da2.tar.bz2
Cleans up the code style of the Accessibility Test suite.
BUG=2236 Review URL: http://codereview.chromium.org/13333 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7160 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/accessibility/accessibility_tests.cc390
-rw-r--r--chrome/test/accessibility/accessibility_util.cc491
-rw-r--r--chrome/test/accessibility/accessibility_util.h183
-rw-r--r--chrome/test/accessibility/browser_impl.cc218
-rw-r--r--chrome/test/accessibility/browser_impl.h60
-rw-r--r--chrome/test/accessibility/constants.h18
-rw-r--r--chrome/test/accessibility/keyboard_util.cc44
-rw-r--r--chrome/test/accessibility/keyboard_util.h11
-rw-r--r--chrome/test/accessibility/registry_util.cc8
-rw-r--r--chrome/test/accessibility/registry_util.h8
-rw-r--r--chrome/test/accessibility/tab_impl.cc265
-rw-r--r--chrome/test/accessibility/tab_impl.h45
12 files changed, 848 insertions, 893 deletions
diff --git a/chrome/test/accessibility/accessibility_tests.cc b/chrome/test/accessibility/accessibility_tests.cc
index 1eacede..f8e68f9 100644
--- a/chrome/test/accessibility/accessibility_tests.cc
+++ b/chrome/test/accessibility/accessibility_tests.cc
@@ -2,8 +2,8 @@
// 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 <objbase.h>
+#include <oleacc.h>
#include "base/file_util.h"
#include "base/win_util.h"
@@ -22,7 +22,7 @@
namespace {
-#define CHK_RELEASE(obj) { if (obj) { (obj)->Release(); (obj) = NULL; } }
+#define CHK_RELEASE(obj) { if (obj) { (obj)->Release(); (obj) = NULL; } }
class AccessibilityTest : public UITest {
protected:
@@ -37,162 +37,160 @@ class AccessibilityTest : public UITest {
} // Namespace.
// Check browser handle and accessibility object browser client.
-// TODO(sridharg): Alter, when accessibility objects for Chrome Window,
+// 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);
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
ASSERT_TRUE(NULL != hwnd);
- ASSERT_TRUE(NULL != p_accobj);
- CHK_RELEASE(p_accobj);
+ ASSERT_TRUE(NULL != acc_obj);
+ CHK_RELEASE(acc_obj);
}
-// Check accessibility object for toolbar and it's properties Name, Role,
+// Check accessibility object for toolbar and its 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);
- ASSERT_TRUE(NULL != p_accobj);
+ IAccessible* acc_obj = NULL;
+ GetToolbarWnd(&acc_obj);
+ ASSERT_TRUE(NULL != acc_obj);
// Check Name - IDS_ACCNAME_TOOLBAR.
- EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_TOOLBAR), GetName(p_accobj));
+ EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_TOOLBAR), GetName(acc_obj));
// Check Role - "tool bar".
- EXPECT_EQ(ROLE_SYSTEM_TOOLBAR, GetRole(p_accobj));
+ EXPECT_EQ(ROLE_SYSTEM_TOOLBAR, GetRole(acc_obj));
// Check State - "focusable"
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_accobj));
+ EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
- CHK_RELEASE(p_accobj);
+ CHK_RELEASE(acc_obj);
}
-// Check accessibility object for tabstrip and it's properties Name, Role,
+// Check accessibility object for tabstrip and its properties Name, Role,
// State. (Add other properties, if their values are fixed all the time.)
TEST_F(AccessibilityTest, TestChromeTabstripAccObject) {
- IAccessible* p_accobj = NULL;
- GetTabStripWnd(&p_accobj);
- ASSERT_TRUE(NULL != p_accobj);
+ IAccessible* acc_obj = NULL;
+ GetTabStripWnd(&acc_obj);
+ ASSERT_TRUE(NULL != acc_obj);
// Check Name - IDS_ACCNAME_TABSTRIP.
- EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_TABSTRIP), GetName(p_accobj));
+ EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_TABSTRIP), GetName(acc_obj));
// Check Role - "grouping".
- EXPECT_EQ(ROLE_SYSTEM_GROUPING, GetRole(p_accobj));
+ EXPECT_EQ(ROLE_SYSTEM_GROUPING, GetRole(acc_obj));
// Check State - "focusable"
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_accobj));
+ EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
- CHK_RELEASE(p_accobj);
+ CHK_RELEASE(acc_obj);
}
// Check Browser buttons and their Name, Role, State.
TEST_F(AccessibilityTest, TestChromeButtons) {
- HRESULT hr = S_OK;
- IAccessible* p_accobj = NULL;
- VARIANT button;
-
// Get browser accessibility object.
- IAccessible* p_browser = NULL;
- GetChromeBrowserWnd(&p_browser);
- ASSERT_TRUE(NULL != p_browser);
+ IAccessible* browser = NULL;
+ GetChromeBrowserWnd(&browser);
+ ASSERT_TRUE(NULL != browser);
- // Check Minimize button and it's Name, Role, State.
- hr = GetBrowserMinimizeButton(&p_accobj, &button);
- // It is not complete accessible object, as it is element.
+ 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 == p_accobj);
+ ASSERT_TRUE(NULL == acc_obj);
ASSERT_TRUE(VT_I4 == button.vt);
- // Read it's properties.
+ // Read properties.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_MINIMIZE),
- GetName(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.
- GetBrowserMaximizeButton(&p_accobj, &button);
- // It is an element and not complete accessible object.
+ 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 == p_accobj);
+ ASSERT_TRUE(NULL == acc_obj);
ASSERT_TRUE(VT_I4 == button.vt);
- // Read it's properties.
+ // Read properties.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_MAXIMIZE),
- GetName(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.
- GetBrowserRestoreButton(&p_accobj, &button);
- // It is an element and not complete accessible object.
+ 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 == p_accobj);
+ ASSERT_TRUE(NULL == acc_obj);
ASSERT_TRUE(VT_I4 == button.vt);
- // Read it's properties.
+ // Read properties.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_RESTORE),
- GetName(p_browser, button));
- EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(p_browser, button));
+ GetName(browser, button));
+ EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, GetRole(browser, button));
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_INVISIBLE,
- GetState(p_browser, button));
- CHK_RELEASE(p_accobj);
+ GetState(browser, button));
+ CHK_RELEASE(acc_obj);
- // Check Close button and it's Name, Role, State.
- GetBrowserCloseButton(&p_accobj, &button);
- // It is an element and not complete accessible object.
+ // 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 == p_accobj);
+ ASSERT_TRUE(NULL == acc_obj);
ASSERT_TRUE(VT_I4 == button.vt);
- // Read it's properties.
- EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_CLOSE),
- GetName(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);
+ // 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 their Name, Role, State.
+// Check Star button and its Name, Role, State.
TEST_F(AccessibilityTest, TestStarButton) {
- HRESULT hr = S_OK;
- IAccessible* p_accobj = NULL;
- VARIANT button;
-
// Get toolbar accessibility object.
- IAccessible* p_toolbar = NULL;
- GetToolbarWnd(&p_toolbar);
- ASSERT_TRUE(NULL != p_toolbar);
+ IAccessible* toolbar = NULL;
+ GetToolbarWnd(&toolbar);
+ ASSERT_TRUE(NULL != toolbar);
+
+ HRESULT hr = S_OK;
+ IAccessible* acc_obj = NULL;
+ VARIANT button;
- // Check button and it's Name, Role, State.
- hr = GetStarButton(&p_accobj, &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 == p_accobj);
+ ASSERT_TRUE(NULL == acc_obj);
ASSERT_TRUE(VT_I4 == button.vt);
- // Read it's properties.
- EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_STAR),
- GetName(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);
+ // 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 their Name, Role, State.
+// Check Star button and its Name, Role, State, upon adding a new tab.
TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) {
- HRESULT hr = S_OK;
- IAccessible* p_accobj = NULL;
- VARIANT button;
-
// Get toolbar accessibility object.
- IAccessible* p_toolbar = NULL;
- GetToolbarWnd(&p_toolbar);
- ASSERT_TRUE(NULL != p_toolbar);
+ IAccessible* toolbar = NULL;
+ GetToolbarWnd(&toolbar);
+ ASSERT_TRUE(NULL != toolbar);
+
+ HRESULT hr = S_OK;
+ IAccessible* acc_obj = NULL;
+ VARIANT button;
- // Check button and it's Name, Role, State.
- hr = GetStarButton(&p_accobj, &button);
- // It is not a complete accessible object, as it is element.
+ // 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 == p_accobj);
+ ASSERT_TRUE(NULL == acc_obj);
ASSERT_TRUE(VT_I4 == button.vt);
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button));
+ EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button));
// Now, check Star status in different situations.
scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
@@ -205,7 +203,7 @@ TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) {
file_util::AppendToPath(&test_file1, L"title1.html");
tab1->NavigateToURL(net::FilePathToFileURL(test_file1));
Sleep(kWaitForActionMsec);
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button));
+ EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button));
// Add empty new tab and check status.
int old_tab_count = -1;
@@ -218,7 +216,7 @@ TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) {
ASSERT_GE(new_tab_count, old_tab_count);
// Also, check accessibility object's children.
Sleep(1000);
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button)); // ???
+ EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button));
// Add new tab with URL and check status.
old_tab_count = new_tab_count;
@@ -230,75 +228,76 @@ 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(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button));
+ EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button));
- CHK_RELEASE(p_toolbar);
+ CHK_RELEASE(acc_obj);
+ CHK_RELEASE(toolbar);
}
-// Check Back button and their Name, Role, State.
+// Check Back button and its Name, Role, State.
TEST_F(AccessibilityTest, TestBackButton) {
- HRESULT hr = S_OK;
- IAccessible* p_accobj = NULL;
- VARIANT button;
-
// Get toolbar accessibility object.
- IAccessible* p_toolbar = NULL;
- GetToolbarWnd(&p_toolbar);
- ASSERT_TRUE(NULL != p_toolbar);
+ IAccessible* toolbar = NULL;
+ GetToolbarWnd(&toolbar);
+ ASSERT_TRUE(NULL != toolbar);
+
+ HRESULT hr = S_OK;
+ IAccessible* acc_obj = NULL;
+ VARIANT button;
- // Check button and it's Name, Role, State.
- hr = GetBackButton(&p_accobj, &button);
- // It is not a complete accessible object, as it is element.
+ // 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 == p_accobj);
+ ASSERT_TRUE(NULL == acc_obj);
ASSERT_TRUE(VT_I4 == button.vt);
- // Read it's properties.
+ // Read properties.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_BACK),
- GetName(p_toolbar, button));
- EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(p_toolbar, button));
+ GetName(toolbar, button));
+ EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(toolbar, button));
// 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(p_toolbar, button));
+ GetState(toolbar, button));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
}
- CHK_RELEASE(p_accobj);
- CHK_RELEASE(p_toolbar);
+ CHK_RELEASE(acc_obj);
+ CHK_RELEASE(toolbar);
}
-// Check Back button and their Name, Role, State.
+// Check Back button and its Name, Role, State.
// This test is disabled. See bug 1119183.
TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) {
- HRESULT hr = S_OK;
- IAccessible* p_accobj = NULL;
- VARIANT button;
-
// Get toolbar accessibility object.
- IAccessible* p_toolbar = NULL;
- GetToolbarWnd(&p_toolbar);
- ASSERT_TRUE(NULL != p_toolbar);
+ IAccessible* toolbar = NULL;
+ GetToolbarWnd(&toolbar);
+ ASSERT_TRUE(NULL != toolbar);
- // Check button and it's Name, Role, State.
- hr = GetBackButton(&p_accobj, &button);
- // It is not complete accessible object, as it is element.
+ HRESULT hr = S_OK;
+ IAccessible* acc_obj = NULL;
+ VARIANT button;
+
+ // 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 == p_accobj);
+ ASSERT_TRUE(NULL == acc_obj);
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(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
}
// Now check Back status in different situations.
@@ -316,9 +315,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(p_toolbar, button));
+ GetState(toolbar, button));
} else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button));
+ EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button));
}
// Go Back and check status.
window->ApplyAccelerator(IDC_BACK);
@@ -327,10 +326,10 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
}
// Add empty new tab and check status.
@@ -344,10 +343,10 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
}
// Add new tab with URL and check status.
@@ -364,78 +363,79 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
}
- CHK_RELEASE(p_toolbar);
+ CHK_RELEASE(acc_obj);
+ CHK_RELEASE(toolbar);
}
-// Check Forward button and their Name, Role, State.
+// Check Forward button and its Name, Role, State.
TEST_F(AccessibilityTest, TestForwardButton) {
- HRESULT hr = S_OK;
- IAccessible* p_accobj = NULL;
- VARIANT button;
-
// Get toolbar accessibility object.
- IAccessible* p_toolbar = NULL;
- GetToolbarWnd(&p_toolbar);
- ASSERT_TRUE(NULL != p_toolbar);
+ IAccessible* toolbar = NULL;
+ GetToolbarWnd(&toolbar);
+ ASSERT_TRUE(NULL != toolbar);
- // Check button and it's Name, Role, State.
- hr = GetForwardButton(&p_accobj, &button);
- // It is not complete accessible object, as it is element.
+ HRESULT hr = S_OK;
+ IAccessible* acc_obj = NULL;
+ VARIANT button;
+
+ // 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 == p_accobj);
+ ASSERT_TRUE(NULL == acc_obj);
ASSERT_TRUE(VT_I4 == button.vt);
- // Read it's properties.
+ // Read properties.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_FORWARD),
- GetName(p_toolbar, button));
- EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(p_toolbar, button));
+ GetName(toolbar, button));
+ EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(toolbar, button));
// 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(p_toolbar, button));
+ GetState(toolbar, button));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
}
- CHK_RELEASE(p_accobj);
- CHK_RELEASE(p_toolbar);
+ CHK_RELEASE(acc_obj);
+ CHK_RELEASE(toolbar);
}
-// Check Back button and their Name, Role, State.
+// Check Back button and its Name, Role, State.
// This test is disabled. See bug 1119183.
TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) {
- HRESULT hr = S_OK;
- IAccessible* p_accobj = NULL;
- VARIANT button;
-
// Get toolbar accessibility object.
- IAccessible* p_toolbar = NULL;
- GetToolbarWnd(&p_toolbar);
- ASSERT_TRUE(NULL != p_toolbar);
+ IAccessible* toolbar = NULL;
+ GetToolbarWnd(&toolbar);
+ ASSERT_TRUE(NULL != toolbar);
- // Check button and it's Name, Role, State.
- hr = GetForwardButton(&p_accobj, &button);
- // It is not complete accessible object, as it is element.
+ HRESULT hr = S_OK;
+ IAccessible* acc_obj = NULL;
+ VARIANT button;
+
+ // 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 == p_accobj);
+ ASSERT_TRUE(NULL == acc_obj);
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(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
}
// Now check Back status in different situations.
@@ -455,19 +455,19 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
}
// 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(p_toolbar, button));
+ GetState(toolbar, button));
} else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(p_toolbar, button));
+ EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(toolbar, button));
}
// Go Forward and check status.
window->ApplyAccelerator(IDC_FORWARD);
@@ -476,10 +476,10 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
}
// Add empty new tab and check status.
@@ -493,10 +493,10 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
}
// Add new tab with URL and check status.
@@ -513,11 +513,13 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
} else {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(p_toolbar, button));
+ GetState(toolbar, button));
}
- CHK_RELEASE(p_toolbar);
+ CHK_RELEASE(acc_obj);
+ CHK_RELEASE(toolbar);
}
+
diff --git a/chrome/test/accessibility/accessibility_util.cc b/chrome/test/accessibility/accessibility_util.cc
index 06b42ef..2174ad6 100644
--- a/chrome/test/accessibility/accessibility_util.cc
+++ b/chrome/test/accessibility/accessibility_util.cc
@@ -12,14 +12,14 @@
#include "chromium_strings.h"
#include "generated_resources.h"
-VARIANT g_var_self = {VT_I4, CHILDID_SELF};
+VARIANT id_self = {VT_I4, CHILDID_SELF};
// TODO(beng): clean this up
static const wchar_t* kBrowserWindowKey = L"__BROWSER_WINDOW__";
static BOOL CALLBACK WindowEnumProc(HWND hwnd, LPARAM data) {
std::wstring class_name = win_util::GetClassName(hwnd);
- if (class_name == L"Chrome_WidgetWin_0") {
+ if (class_name == CHROME_HWND_VIEW_CONTAINER) {
HANDLE window_interface = GetProp(hwnd, kBrowserWindowKey);
if (window_interface) {
HWND* out = reinterpret_cast<HWND*>(data);
@@ -30,243 +30,221 @@ static BOOL CALLBACK WindowEnumProc(HWND hwnd, LPARAM data) {
return TRUE;
}
-HWND GetChromeBrowserWnd(IAccessible** ppi_access) {
- HRESULT hr = S_OK;
- HWND hwnd = NULL;
- BSTR str_name;
- std::wstring str_role;
-
- const std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_NAME);
-
+HWND GetChromeBrowserWnd(IAccessible** acc_obj) {
+ HWND hwnd = NULL;
EnumWindows(WindowEnumProc, reinterpret_cast<LPARAM>(&hwnd));
- if (NULL == hwnd) {
- if (ppi_access)
- *ppi_access = NULL;
+ if (!hwnd) {
+ CHK_RELEASE(*acc_obj);
return hwnd;
}
// Get accessibility object for Chrome, only if requested.
- if (!ppi_access) {
+ if (!acc_obj) {
return hwnd;
}
- *ppi_access = NULL;
+ *acc_obj = NULL;
// Get accessibility object for Chrome Main Window. If failed to get it,
// return only window handle.
- IAccessible *pi_acc_root_win = NULL;
+ IAccessible* root_acc_obj = NULL;
+ HRESULT hr = S_OK;
hr = AccessibleObjectFromWindow(hwnd, OBJID_WINDOW, IID_IAccessible,
- reinterpret_cast<void**>
- (&pi_acc_root_win));
- if ((S_OK != hr) || !pi_acc_root_win) {
+ reinterpret_cast<void**>(&root_acc_obj));
+ if ((S_OK != hr) || !root_acc_obj)
return hwnd;
- }
+ const std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_NAME);
+ BSTR name;
- // Confirm if it is Chrome window using it's accessibility object's
+ // Confirm if it is Chrome window using its accessibility object's
// Name and Role property. If it's not the desired object, return only
// window handle.
- hr = pi_acc_root_win->get_accName(g_var_self, &str_name);
- if ((S_OK != hr) || (!str_name) ||
- (0 != _wcsicmp(str_name, product_name.c_str())) ) {
- CHK_RELEASE(pi_acc_root_win);
+ hr = root_acc_obj->get_accName(id_self, &name);
+ if ((S_OK != hr) || (!name) ||
+ (0 != _wcsicmp(name, product_name.c_str())) ) {
+ CHK_RELEASE(root_acc_obj);
return hwnd;
}
- if (ROLE_SYSTEM_WINDOW != GetRole(pi_acc_root_win)) {
- CHK_RELEASE(pi_acc_root_win);
+ if (ROLE_SYSTEM_WINDOW != GetRole(root_acc_obj)) {
+ CHK_RELEASE(root_acc_obj);
return hwnd;
}
// Get accessibility object for Chrome Window. If failed to get it,
// return only window handle.
- INT64 child_cnt = GetChildCount(pi_acc_root_win);
- VARIANT *var_array_child =
- reinterpret_cast<VARIANT*>(calloc(size_t(child_cnt),
- sizeof(VARIANT)));
+ INT64 child_cnt = GetChildCount(root_acc_obj);
+ VARIANT* children = reinterpret_cast<VARIANT*>(calloc(size_t(child_cnt),
+ sizeof(VARIANT)));
- if (!var_array_child) {
- CHK_RELEASE(pi_acc_root_win);
+ if (!children) {
+ CHK_RELEASE(root_acc_obj);
return hwnd;
}
- hr = GetChildrenArray(pi_acc_root_win, var_array_child);
+ hr = GetChildrenArray(root_acc_obj, children);
if (S_OK != hr) {
- CHK_RELEASE(pi_acc_root_win);
+ CHK_RELEASE(root_acc_obj);
return hwnd;
}
// Fetch desired child (Chrome window) of Chrome Main Window.
- IAccessible *pi_acc_app = NULL;
- GetChildObject(pi_acc_root_win, var_array_child[CHROME_APP_ACC_INDEX],
- &pi_acc_app);
- if (!pi_acc_app) {
- CHK_RELEASE(pi_acc_app);
+ IAccessible* app_acc_obj = NULL;
+ GetChildObject(root_acc_obj, children[CHROME_APP_ACC_INDEX], &app_acc_obj);
+ if (!app_acc_obj) {
+ CHK_RELEASE(app_acc_obj);
return hwnd;
}
// Confirm if it is Chrome application using it's accessibility object's
// Name and Role property. If it's not the desired object, return only
// window handle.
- hr = pi_acc_app->get_accName(g_var_self, &str_name);
- if ((S_OK != hr) || (!str_name) ||
- (0 != _wcsicmp(str_name, product_name.c_str())) ) {
- CHK_RELEASE(pi_acc_app);
- CHK_RELEASE(pi_acc_root_win);
+ hr = app_acc_obj->get_accName(id_self, &name);
+ if ((S_OK != hr) || (!name) ||
+ (0 != _wcsicmp(name, product_name.c_str())) ) {
+ CHK_RELEASE(app_acc_obj);
+ CHK_RELEASE(root_acc_obj);
return hwnd;
}
- if (ROLE_SYSTEM_APPLICATION != GetRole(pi_acc_app)) {
- CHK_RELEASE(pi_acc_app);
- CHK_RELEASE(pi_acc_root_win);
+ if (ROLE_SYSTEM_APPLICATION != GetRole(app_acc_obj)) {
+ CHK_RELEASE(app_acc_obj);
+ CHK_RELEASE(root_acc_obj);
return hwnd;
}
// Get accessibility object for Chrome Client. If failed, return only
// window handle.
- hr = GetChildrenArray(pi_acc_app, var_array_child);
- if (S_OK != hr) {
- CHK_RELEASE(pi_acc_app);
- CHK_RELEASE(pi_acc_root_win);
- return hwnd;
- }
+ hr = GetChildrenArray(app_acc_obj, children);
+ if (S_OK != hr) {
+ CHK_RELEASE(app_acc_obj);
+ CHK_RELEASE(root_acc_obj);
+ return hwnd;
+ }
// Chrome Window has only one child which is Chrome Client.
- GetChildObject(pi_acc_app, var_array_child[CHROME_CLIENT_ACC_INDEX],
- ppi_access);
+ GetChildObject(app_acc_obj, children[CHROME_CLIENT_ACC_INDEX], acc_obj);
// 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
// handle.
- hr = (*ppi_access)->get_accName(g_var_self, &str_name);
- if ((S_OK != hr) || (!str_name) ||
- (0 != _wcsicmp(str_name, product_name.c_str())) ) {
- CHK_RELEASE(*ppi_access);
- }
- if (ROLE_SYSTEM_CLIENT != GetRole(*ppi_access)) {
- CHK_RELEASE(*ppi_access);
+ hr = (*acc_obj)->get_accName(id_self, &name);
+ if ((S_OK != hr) || (!name) ||
+ (0 != _wcsicmp(name, product_name.c_str())) ) {
+ CHK_RELEASE(*acc_obj);
}
+ if (ROLE_SYSTEM_CLIENT != GetRole(*acc_obj))
+ CHK_RELEASE(*acc_obj);
- CHK_RELEASE(pi_acc_app);
- CHK_RELEASE(pi_acc_root_win);
+ CHK_RELEASE(app_acc_obj);
+ CHK_RELEASE(root_acc_obj);
return hwnd;
}
-HRESULT GetChildWndOf(std::wstring parent_name, unsigned int child_index,
- IAccessible** ppi_access, VARIANT* child_var_id) {
- HRESULT hr = S_OK;
-
+HRESULT GetChildWnd(std::wstring parent_name, unsigned int child_index,
+ IAccessible** acc_obj, VARIANT* child) {
// Validate input and initialize.
- if (!ppi_access && !child_var_id)
+ if (!acc_obj && !child)
return E_INVALIDARG;
- if (ppi_access)
- *ppi_access = NULL;
- if (child_var_id)
- VariantInit(child_var_id);
+ if (acc_obj)
+ *acc_obj = NULL;
+ if (child)
+ VariantInit(child);
// Get accessibility object and window handle for Chrome parent.
- IAccessible *pi_parent = NULL;
+ IAccessible* parent = NULL;
if (0 == parent_name.compare(BROWSER_STR))
- GetChromeBrowserWnd(&pi_parent);
+ GetChromeBrowserWnd(&parent);
if (0 == parent_name.compare(BROWSER_VIEW_STR))
- GetBrowserViewWnd(&pi_parent);
+ GetBrowserViewWnd(&parent);
if (0 == parent_name.compare(TOOLBAR_STR))
- GetToolbarWnd(&pi_parent);
+ GetToolbarWnd(&parent);
if (0 == parent_name.compare(TABSTRIP_STR))
- GetTabStripWnd(&pi_parent);
+ GetTabStripWnd(&parent);
- if (!pi_parent)
+ if (!parent)
return E_FAIL;
// Validate child index.
- INT64 child_cnt = GetChildCount(pi_parent);
+ INT64 child_cnt = GetChildCount(parent);
if (child_index >= child_cnt) {
- CHK_RELEASE(pi_parent);
- VariantClear(child_var_id);
+ CHK_RELEASE(parent);
+ VariantClear(child);
return E_INVALIDARG;
}
+ HRESULT hr = S_OK;
// Get array of child items of parent object.
- VARIANT *var_array_child =
- reinterpret_cast<VARIANT*>(calloc(size_t(child_cnt), sizeof(VARIANT)));
- if (var_array_child) {
- hr = GetChildrenArray(pi_parent, var_array_child);
+ 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 (ppi_access) {
- hr = GetChildObject(pi_parent, var_array_child[child_index],
- ppi_access);
+ if (acc_obj) {
+ hr = GetChildObject(parent, children[child_index], acc_obj);
}
- if (child_var_id) {
- VariantCopy(child_var_id, var_array_child+child_index);
+ if (child) {
+ VariantCopy(child, children + child_index);
}
}
- free(var_array_child);
+ free(children);
}
- CHK_RELEASE(pi_parent);
+ CHK_RELEASE(parent);
return hr;
}
-HRESULT GetTabStripWnd(IAccessible** ppi_access) {
+HRESULT GetTabStripWnd(IAccessible** acc_obj) {
#ifdef NEW_FRAMES
- return GetChildWndOf(BROWSER_VIEW_STR, TABSTRIP_ACC_INDEX, ppi_access, NULL);
+ return GetChildWnd(BROWSER_VIEW_STR, TABSTRIP_ACC_INDEX, acc_obj, NULL);
#else
- return GetChildWndOf(BROWSER_STR, TABSTRIP_ACC_INDEX, ppi_access, NULL);
+ return GetChildWnd(BROWSER_STR, TABSTRIP_ACC_INDEX, acc_obj, NULL);
#endif
}
-HRESULT GetBrowserViewWnd(IAccessible** ppi_access) {
- return GetChildWndOf(BROWSER_STR, BROWSER_VIEW_ACC_INDEX, ppi_access, NULL);
+HRESULT GetBrowserViewWnd(IAccessible** acc_obj) {
+ return GetChildWnd(BROWSER_STR, BROWSER_VIEW_ACC_INDEX, acc_obj, NULL);
}
-HRESULT GetToolbarWnd(IAccessible** ppi_access) {
- return GetChildWndOf(BROWSER_VIEW_STR, TOOLBAR_ACC_INDEX, ppi_access, NULL);
+HRESULT GetToolbarWnd(IAccessible** acc_obj) {
+ return GetChildWnd(BROWSER_VIEW_STR, TOOLBAR_ACC_INDEX, acc_obj, NULL);
}
-HRESULT GetBrowserMinimizeButton(IAccessible** ppi_access,
- VARIANT* child_var_id) {
- return GetChildWndOf(BROWSER_STR, CHROME_MIN_ACC_INDEX, ppi_access,
- child_var_id);
+HRESULT GetBrowserMinimizeButton(IAccessible** acc_obj, VARIANT* child) {
+ return GetChildWnd(BROWSER_STR, CHROME_MIN_ACC_INDEX, acc_obj, child);
}
-HRESULT GetBrowserMaximizeButton(IAccessible** ppi_access,
- VARIANT* child_var_id) {
- return GetChildWndOf(BROWSER_STR, CHROME_MAX_ACC_INDEX, ppi_access,
- child_var_id);
+HRESULT GetBrowserMaximizeButton(IAccessible** acc_obj, VARIANT* child) {
+ return GetChildWnd(BROWSER_STR, CHROME_MAX_ACC_INDEX, acc_obj, child);
}
-HRESULT GetBrowserRestoreButton(IAccessible** ppi_access,
- VARIANT* child_var_id) {
- return GetChildWndOf(BROWSER_STR, CHROME_RESTORE_ACC_INDEX, ppi_access,
- child_var_id);
+HRESULT GetBrowserRestoreButton(IAccessible** acc_obj, VARIANT* child) {
+ return GetChildWnd(BROWSER_STR, CHROME_RESTORE_ACC_INDEX, acc_obj, child);
}
-HRESULT GetBrowserCloseButton(IAccessible** ppi_access,
- VARIANT* child_var_id) {
- return GetChildWndOf(BROWSER_STR, CHROME_CLOSE_ACC_INDEX, ppi_access,
- child_var_id);
+HRESULT GetBrowserCloseButton(IAccessible** acc_obj, VARIANT* child) {
+ return GetChildWnd(BROWSER_STR, CHROME_CLOSE_ACC_INDEX, acc_obj, child);
}
-HRESULT GetStarButton(IAccessible** ppi_access, VARIANT* child_var_id) {
- return GetChildWndOf(TOOLBAR_STR, STAR_BTN_INDEX, ppi_access, child_var_id);
+HRESULT GetStarButton(IAccessible** acc_obj, VARIANT* child) {
+ return GetChildWnd(TOOLBAR_STR, STAR_BTN_INDEX, acc_obj, child);
}
-HRESULT GetBackButton(IAccessible** ppi_access, VARIANT* child_var_id) {
- return GetChildWndOf(TOOLBAR_STR, BACK_BTN_INDEX, ppi_access, child_var_id);
+HRESULT GetBackButton(IAccessible** acc_obj, VARIANT* child) {
+ return GetChildWnd(TOOLBAR_STR, BACK_BTN_INDEX, acc_obj, child);
}
-HRESULT GetForwardButton(IAccessible** ppi_access, VARIANT* child_var_id) {
- return GetChildWndOf(TOOLBAR_STR, FORWARD_BTN_INDEX, ppi_access,
- child_var_id);
+HRESULT GetForwardButton(IAccessible** acc_obj, VARIANT* child) {
+ return GetChildWnd(TOOLBAR_STR, FORWARD_BTN_INDEX, acc_obj, child);
}
-HWND GetAddressBarWnd(IAccessible** ppi_access) {
- HWND hwnd = NULL;
- HWND hwnd_addr_bar = NULL;
+HWND GetAddressBarWnd(IAccessible** acc_obj) {
+ // Initialize, if requested.
+ if (acc_obj)
+ *acc_obj = NULL;
- // // Initialize, if requested.
- if (ppi_access) {
- *ppi_access = NULL;
- }
+ HWND hwnd = NULL;
+ HWND hwnd_addr_bar = NULL;
// Get window handle for Chrome Browser.
hwnd = GetChromeBrowserWnd(NULL);
@@ -275,23 +253,22 @@ HWND GetAddressBarWnd(IAccessible** ppi_access) {
hwnd_addr_bar = FindWindowEx(hwnd, 0, CHROME_AUTOCOMPLETE_EDIT, NULL);
// Get accessibility object for address bar, if requested.
- if (ppi_access && hwnd_addr_bar) {
+ if (acc_obj && hwnd_addr_bar) {
AccessibleObjectFromWindow(hwnd_addr_bar, OBJID_WINDOW, IID_IAccessible,
- reinterpret_cast<void**>(ppi_access));
+ reinterpret_cast<void**>(acc_obj));
}
}
return hwnd_addr_bar;
}
-HWND GetFindTextWnd(IAccessible** ppi_access) {
- HWND hwnd = NULL;
- HWND hwnd_find = NULL;
-
+HWND GetFindTextWnd(IAccessible** acc_obj) {
// Initialize, if requested.
- if (ppi_access) {
- *ppi_access = NULL;
- }
+ if (acc_obj)
+ *acc_obj = NULL;
+
+ HWND hwnd = NULL;
+ HWND hwnd_find = NULL;
// Get window handle for Chrome Browser.
hwnd = GetChromeBrowserWnd(NULL);
@@ -300,28 +277,27 @@ HWND GetFindTextWnd(IAccessible** ppi_access) {
hwnd_find = FindWindowEx(hwnd, 0, CHROME_HWND_VIEW_CONTAINER, NULL);
// Get accessibility object, if requested.
- if (ppi_access && hwnd_find) {
+ if (acc_obj && hwnd_find) {
AccessibleObjectFromWindow(hwnd_find, OBJID_WINDOW, IID_IAccessible,
- reinterpret_cast<void**>(ppi_access));
+ reinterpret_cast<void**>(acc_obj));
}
}
return hwnd_find;
}
-HWND GetAuthWnd(IAccessible** ppi_access) {
- HWND hwnd = NULL;
- HWND hwnd_tab = NULL;
- HWND hwnd_auth = NULL;
-
+HWND GetAuthWnd(IAccessible** acc_obj) {
// Initialize, if requested.
- if (ppi_access) {
- *ppi_access = NULL;
- }
+ if (acc_obj)
+ *acc_obj = NULL;
+
+ HWND hwnd = NULL;
+ HWND hwnd_tab = NULL;
+ HWND hwnd_auth = NULL;
// Get window handle for Chrome Browser.
hwnd = GetChromeBrowserWnd(NULL);
- if (NULL != hwnd) {
+ if (hwnd) {
// Get window handle for tab.
hwnd_tab = FindWindowEx(hwnd, 0, CHROME_TAB_CONTENTS, NULL);
if (!hwnd_tab)
@@ -332,167 +308,150 @@ HWND GetAuthWnd(IAccessible** ppi_access) {
AUTH_TITLE);
// Get accessibility object, if requested.
- if (ppi_access && hwnd_auth) {
+ if (acc_obj && hwnd_auth) {
AccessibleObjectFromWindow(hwnd_auth, OBJID_WINDOW, IID_IAccessible,
- reinterpret_cast<void**>(ppi_access));
+ reinterpret_cast<void**>(acc_obj));
}
}
return hwnd_auth;
}
-HRESULT GetChildObject(IAccessible* pi_access, VARIANT var_child,
- IAccessible** ppi_child_access) {
- HRESULT hr = S_OK;
- IDispatch *p_dispatch = NULL;
-
+HRESULT GetChildObject(IAccessible* acc_obj, VARIANT child,
+ IAccessible** child_acc_obj) {
// Validate input.
- if ( (pi_access == NULL) ||
- (ppi_child_access == NULL) ) {
+ if (!acc_obj || !child_acc_obj)
return E_INVALIDARG;
- }
+
+ HRESULT hr = S_OK;
+ IDispatch* disp = NULL;
// Check the child type and fetch object accordingly.
- if (var_child.vt == VT_DISPATCH) {
- var_child.pdispVal->
- QueryInterface(IID_IAccessible,
- reinterpret_cast<void**>(ppi_child_access));
- } else if (var_child.vt == VT_I4) {
- hr = pi_access->get_accChild(var_child, &p_dispatch);
- if ( (hr == S_OK) &&
- (p_dispatch != NULL) ) {
- p_dispatch->QueryInterface(IID_IAccessible,
- reinterpret_cast<void**>(ppi_child_access));
- CHK_RELEASE(p_dispatch);
+ if (child.vt == VT_DISPATCH) {
+ child.pdispVal->
+ QueryInterface(IID_IAccessible,
+ reinterpret_cast<void**>(child_acc_obj));
+ } else if (child.vt == VT_I4) {
+ hr = acc_obj->get_accChild(child, &disp);
+ if ((hr == S_OK) && disp) {
+ disp->QueryInterface(IID_IAccessible,
+ reinterpret_cast<void**>(child_acc_obj));
+ CHK_RELEASE(disp);
}
}
return hr;
}
-HRESULT GetParentObject(IAccessible* pi_access,
- IAccessible** ppi_parent_access) {
- HRESULT hr = S_OK;
- IDispatch *p_dispatch = NULL;
-
+HRESULT GetParentObject(IAccessible* acc_obj, IAccessible** parent_acc_obj) {
// Validate input.
- if ( (pi_access == NULL) ||
- (ppi_parent_access == NULL) ) {
+ if (!acc_obj || !parent_acc_obj)
return E_INVALIDARG;
- }
+
+ HRESULT hr = S_OK;
+ IDispatch* disp = NULL;
// Fetch parent object.
- hr = pi_access->get_accParent(&p_dispatch);
- if ( (hr == S_OK) &&
- (p_dispatch != NULL) ) {
- p_dispatch->QueryInterface(IID_IAccessible,
- reinterpret_cast<void**>(ppi_parent_access));
- CHK_RELEASE(p_dispatch);
+ hr = acc_obj->get_accParent(&disp);
+ if ((hr == S_OK) && disp) {
+ disp->QueryInterface(IID_IAccessible,
+ reinterpret_cast<void**>(parent_acc_obj));
+ CHK_RELEASE(disp);
}
return hr;
}
-INT64 GetChildCount(IAccessible* pi_access) {
- HRESULT hr = S_OK;
- long child_cnt = 0;
+INT64 GetChildCount(IAccessible* acc_obj) {
+ HRESULT hr = S_OK;
+ LONG child_cnt = 0;
- // Validate input. Object can have 0 children. So return -1 on invalid input.
- if (pi_access == NULL) {
+ // Validate input. Object can have 0 children, so return -1 on invalid input.
+ if (!acc_obj)
return -1;
- }
// Get child count.
- pi_access->get_accChildCount(&child_cnt);
+ acc_obj->get_accChildCount(&child_cnt);
return child_cnt;
}
-HRESULT GetChildrenArray(IAccessible* pi_access, VARIANT* var_array_child) {
- HRESULT hr = S_OK;
- INT64 child_start = 0;
- long child_obtained = 0;
- INT64 child_cnt = GetChildCount(pi_access);
+HRESULT GetChildrenArray(IAccessible* acc_obj, VARIANT* children) {
+ HRESULT hr = S_OK;
+ INT64 child_start = 0;
+ LONG child_obtained = 0;
+ INT64 child_cnt = GetChildCount(acc_obj);
// Validate input.
- if ((pi_access == NULL) || (var_array_child == NULL)) {
+ if (!acc_obj || !children)
return E_INVALIDARG;
- }
// Validate every item and initialize it.
int i = 0;
- for (; (i < child_cnt) && (var_array_child+i); i++) {
- VariantInit(var_array_child+i);
+ for (; (i < child_cnt) && (children + i); i++) {
+ VariantInit(children + i);
}
// If all items in array are not initialized, return error.
- if (i != child_cnt) {
- return E_INVALIDARG;
- }
+ if (i != child_cnt)
+ return E_FAIL;
// Get IDs of child items.
- AccessibleChildren(pi_access,
- LONG(child_start),
- LONG(child_cnt),
- var_array_child,
+ AccessibleChildren(acc_obj, LONG(child_start), LONG(child_cnt), children,
&child_obtained);
return hr;
}
-HRESULT ActivateWnd(IAccessible *pi_access, HWND hwnd) {
+HRESULT ActivateWnd(IAccessible* acc_obj, HWND hwnd) {
HRESULT hr = S_OK;
// Select and focus the object, if accessibility object is specified.
- if (pi_access) {
- hr = pi_access->accSelect(SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION,
- g_var_self);
- }
+ if (acc_obj)
+ hr = acc_obj->accSelect(SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION, id_self);
// Send message to window, if window handle is specified.
- if (hwnd) {
+ if (hwnd)
SetActiveWindow(hwnd);
- }
return hr;
}
BSTR GetTabName(INT64 tab_index) {
HRESULT hr = S_OK;
- BSTR str_name;
+ BSTR name;
// Validate tab index specified.
if (tab_index < 1)
return NULL;
// Get accessibility object for Tabstrip.
- IAccessible *pi_acc_strip = NULL;
- GetTabStripWnd(&pi_acc_strip);
+ IAccessible* tab_strip_acc_obj = NULL;
+ GetTabStripWnd(&tab_strip_acc_obj);
// Get Tab from Tabstrip and return it's Name.
- if (pi_acc_strip) {
- INT64 child_cnt = GetChildCount(pi_acc_strip);
- VARIANT *var_array_child =
- reinterpret_cast<VARIANT*>(calloc(size_t(child_cnt), sizeof(VARIANT)));
- if (var_array_child) {
+ if (tab_strip_acc_obj) {
+ INT64 child_cnt = GetChildCount(tab_strip_acc_obj);
+ VARIANT* children = reinterpret_cast<VARIANT*>(calloc(size_t(child_cnt),
+ sizeof(VARIANT)));
+ if (children) {
// Get tab object. tab_index = index in child array, because first child
// in tabstrip is '+' button.
- hr = GetChildrenArray(pi_acc_strip, var_array_child);
+ hr = GetChildrenArray(tab_strip_acc_obj, children);
if (S_OK == hr) {
- IAccessible *pi_access_temp = NULL;
- hr = GetChildObject(pi_acc_strip, var_array_child[tab_index],
- &pi_access_temp);
- if ((S_OK == hr) &&
- (var_array_child[tab_index].vt == VT_DISPATCH) &&
- (pi_access_temp) ) {
- hr = pi_access_temp->get_accName(g_var_self, &str_name);
- } else if (var_array_child[tab_index].vt == VT_I4) {
- hr = pi_acc_strip->get_accName(var_array_child[1], &str_name);
+ IAccessible* temp_acc_obj = NULL;
+ hr = GetChildObject(tab_strip_acc_obj, children[tab_index],
+ &temp_acc_obj);
+ if ((S_OK == hr) && (children[tab_index].vt == VT_DISPATCH) &&
+ (temp_acc_obj)) {
+ hr = temp_acc_obj->get_accName(id_self, &name);
+ } else if (children[tab_index].vt == VT_I4) {
+ hr = tab_strip_acc_obj->get_accName(children[1], &name);
}
- CHK_RELEASE(pi_acc_strip);
- return str_name;
+ CHK_RELEASE(temp_acc_obj);
+ CHK_RELEASE(tab_strip_acc_obj);
+ return name;
}
}
-
- CHK_RELEASE(pi_acc_strip);
+ CHK_RELEASE(tab_strip_acc_obj);
}
return NULL;
@@ -500,81 +459,75 @@ BSTR GetTabName(INT64 tab_index) {
INT64 GetTabCnt() {
// Get accessibility object for Tabstrip.
- IAccessible *pi_acc_strip = NULL;
- GetTabStripWnd(&pi_acc_strip);
+ IAccessible* tab_strip_acc_obj = NULL;
+ GetTabStripWnd(&tab_strip_acc_obj);
- // If Tabstrip is invalid, return -1, to indicate error.
- if (!pi_acc_strip) {
+ // If Tabstrip is invalid, return -1 to indicate error.
+ if (!tab_strip_acc_obj)
return -1;
- }
// Get child count.
- INT64 child_cnt = 0;
- if (pi_acc_strip) {
- child_cnt = GetChildCount(pi_acc_strip);
- CHK_RELEASE(pi_acc_strip);
- }
+ INT64 child_cnt = 0;
+ child_cnt = GetChildCount(tab_strip_acc_obj);
+ CHK_RELEASE(tab_strip_acc_obj);
// Don't count 1st child as it is '+' button.
- return (child_cnt-1);
+ return (child_cnt - 1);
}
-std::wstring GetName(IAccessible* pi_access, VARIANT child) {
+std::wstring GetName(IAccessible* acc_obj, VARIANT child) {
HRESULT hr = S_OK;
// Validate input.
- if (NULL == pi_access) {
+ if (!acc_obj)
return std::wstring();
- }
// Get Name.
BSTR name;
- hr = pi_access->get_accName(child, &name);
+ hr = acc_obj->get_accName(child, &name);
if (S_OK != hr)
return std::wstring();
return std::wstring(name);
}
-DWORD GetRole(IAccessible* pi_access, VARIANT child) {
- HRESULT hr = S_OK;
- LPTSTR role_str = NULL;
+LONG GetRole(IAccessible* acc_obj, VARIANT child) {
+ HRESULT hr = S_OK;
+ LPTSTR role_str = NULL;
// Validate input.
- if (NULL == pi_access) {
- return ROLE_ERROR;
- }
+ if (!acc_obj)
+ return -1;
// Get Role.
VARIANT role;
VariantInit(&role);
- hr = pi_access->get_accRole(child, &role);
+ hr = acc_obj->get_accRole(child, &role);
if (S_OK != hr || VT_I4 != role.vt) {
VariantClear(&role);
- return ROLE_ERROR;
+ return -1;
}
// Return the role value
return role.lVal;
}
-DWORD GetState(IAccessible* pi_access, VARIANT child) {
- HRESULT hr = S_OK;
- LPTSTR state_str = NULL;
+LONG GetState(IAccessible* acc_obj, VARIANT child) {
+ HRESULT hr = S_OK;
+ LPTSTR state_str = NULL;
std::wstring complete_state;
// Validate input.
- if (NULL == pi_access) {
- return STATE_ERROR;
- }
+ if (!acc_obj)
+ return -1;
// Get State.
VARIANT state;
VariantInit(&state);
- hr = pi_access->get_accState(child, &state);
+ hr = acc_obj->get_accState(child, &state);
if (S_OK != hr || VT_I4 != state.vt) {
VariantClear(&state);
- return STATE_ERROR;
+ return -1;
}
VariantClear(&state);
diff --git a/chrome/test/accessibility/accessibility_util.h b/chrome/test/accessibility/accessibility_util.h
index 182f733..ec63956 100644
--- a/chrome/test/accessibility/accessibility_util.h
+++ b/chrome/test/accessibility/accessibility_util.h
@@ -2,114 +2,131 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_TEST_ACCISSIBILITY_ACCISSIBILITY_UTIL_H__
-#define CHROME_TEST_ACCISSIBILITY_ACCISSIBILITY_UTIL_H__
+#ifndef CHROME_TEST_ACCESSIBILITY_ACCESSIBILITY_UTIL_H_
+#define CHROME_TEST_ACCESSIBILITY_ACCESSIBILITY_UTIL_H_
-#include <Oleacc.h>
-#include <iostream>
+#include <oleacc.h>
+
+#include "base/string_util.h"
///////////////////////////////////////////////////////////////////////////////
-// Functions and Globals which are using IAccessible interface.
+// Functions and Globals that use the IAccessible interface.
// These are the wrappers to fetch accessible object interface and properties.
///////////////////////////////////////////////////////////////////////////////
// Variant ID pointing to object itself.
-extern VARIANT g_var_self;
-
-// Returns window handle to Chrome Browser. Retrives it's(having role as
-// client) IAccessible pointer, if requested.
-HWND GetChromeBrowserWnd(IAccessible** ppi_access);
-
-// Returns IAccessible pointer of object's child window, provided parent's name
-// and it's 0 based child index. If child is element and not complete object,
-// it's variant id is returned with S_FALSE.
-HRESULT GetChildWndOf(std::wstring parent_name, unsigned int child_index,
- IAccessible** ppi_access, VARIANT* child_var_id);
-
-// Returns IAccessible pointer for Tabstrip. It does not have window handle.
-HRESULT GetTabStripWnd(IAccessible** ppi_access);
-
-// Returns IAccessible pointer for BrowserView. It does not have window handle.
-HRESULT GetBrowserViewWnd(IAccessible** ppi_access);
-
-// Returns IAccessible pointer for Toolbar. It does not have window handle.
-HRESULT GetToolbarWnd(IAccessible** ppi_access);
-
-// Returns handle to OmniBox(AddressBar) and IAccessible pointer, if requested.
-HWND GetAddressBarWnd(IAccessible** ppi_access);
-
-// Returns handle to Find box and IAccessible pointer, if requested.
-HWND GetFindTextWnd(IAccessible** ppi_access);
-
-// Returns handle to authentication dialog and IAccessible pointer, if
-// requested.
-HWND GetAuthWnd(IAccessible** ppi_access);
-
-// Fetches IAccessible pointer for a child of given the IAccessible pointer
-// and desired child id.
-HRESULT GetChildObject(IAccessible* pi_access, VARIANT var_child,
- IAccessible** ppi_child_access);
-
-// Fetches IAccessible pointer for a parent of specified IAccessible pointer.
-HRESULT GetParentObject(IAccessible* pi_access,
- IAccessible** ppi_parent_access);
-
-// Returns no. of child items of specified IAccessible pointer. If input
+extern VARIANT id_self;
+
+// Returns window handle to Chrome Browser, along with (if requested) its
+// IAccessible implementation, by calling AccessibleObjectFromWindow on the
+// window handle. The IAccessible hierarchy (root->app->client) is also verified
+// in terms of accessible name and role. If [acc_obj] is NULL, only the window
+// handle is returned.
+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);
+
+// 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);
+
+// 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);
+
+// 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);
+
+// Returns window handle to OmniBox(AddressBar) and IAccessible pointer (if
+// requested), by calling AccessibleObjectFromWindow on the window handle. If
+// [acc_obj] is NULL, only the window handle is returned.
+HWND GetAddressBarWnd(IAccessible** acc_obj);
+
+// Returns window handle to Find edit box and IAccessible pointer (if
+// requested), by calling AccessibleObjectFromWindow on the window handle. If
+// [acc_obj] is NULL, only the window handle is returned.
+HWND GetFindTextWnd(IAccessible** acc_obj);
+
+// Returns window handle to Authentication dialog and IAccessible pointer (if
+// requested), by calling AccessibleObjectFromWindow on the window handle. If
+// [acc_obj] is NULL, only the window handle is returned.
+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);
+
+// 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);
+
+// Returns number of children for the specified IAccessible. If [acc_obj]
// parameter is NULL, -1 is returned.
-INT64 GetChildCount(IAccessible* pi_access);
+INT64 GetChildCount(IAccessible* acc_obj);
-// Extracts (VARIANT)array of child items of specified IAccessible pointer.
-HRESULT GetChildrenArray(IAccessible* pi_access, VARIANT* var_array_child);
+// Extracts (VARIANT)array of child items of specified IAccessible pointer,
+// by calling the AccessibleChildren function in MSAA.
+HRESULT GetChildrenArray(IAccessible* acc_obj, VARIANT* children);
// Activates specified window using IAccessible pointer and/or window handle.
-HRESULT ActivateWnd(IAccessible *pi_access, HWND hwnd);
+// Also calls accSelect on [acc_obj] to set accessibility focus and selection.
+HRESULT ActivateWnd(IAccessible* acc_obj, HWND hwnd);
// Returns title of tab whose index is specified. Tab index starts from 1.
BSTR GetTabName(INT64 tab_index);
-// Returns no. of tabs in tabstrip. If processing fails, it returns -1.
+// Returns number of tabs in tabstrip. If processing fails, it returns -1.
INT64 GetTabCnt();
-// Returns Name of specified IAccessible pointer or it's child specified by
-// variant.
-std::wstring GetName(IAccessible* pi_access, VARIANT child = g_var_self);
+// Returns Name of specified [acc_obj] or its [child], by calling get_accName.
+// If input is invalid, an empty std::wstring is returned.
+std::wstring GetName(IAccessible* acc_obj, VARIANT child = id_self);
-// Returns the role of specified IAccessible pointer or it's child specified by
-// variant.
-DWORD GetRole(IAccessible* pi_access, VARIANT child = g_var_self);
+// Returns Role of specified [acc_obj] or its [child], by calling get_accRole. A
+// returned value of -1 indicates error.
+LONG GetRole(IAccessible* acc_obj, VARIANT child = id_self);
-// Returns state of specified IAccessible pointer or it's child specified by
-// variant.
-DWORD GetState(IAccessible* pi_access, VARIANT child = g_var_self);
+// Returns State of specified [acc_obj] or its [child], by calling get_accState.
+// A returned value of -1 indicates error.
+LONG GetState(IAccessible* acc_obj, VARIANT child = id_self);
-// Returns IAccessible pointer for Chrome Minimize Button. It does not have
-// window handle.
-HRESULT GetBrowserMinimizeButton(IAccessible** ppi_access,
- VARIANT* child_var_id);
+// Returns IAccessible pointer for Chrome Minimize Button, by calling
+// GetChildWnd. It does not have window handle.
+HRESULT GetBrowserMinimizeButton(IAccessible** acc_obj, VARIANT* child);
-// Returns IAccessible pointer for Chrome Maximize Button. It does not have
-// window handle.
-HRESULT GetBrowserMaximizeButton(IAccessible** ppi_access,
- VARIANT* child_var_id);
+// Returns IAccessible pointer for Chrome Maximize Button, by calling
+// GetChildWnd. It does not have window handle.
+HRESULT GetBrowserMaximizeButton(IAccessible** acc_obj, VARIANT* child);
-// Returns IAccessible pointer for Chrome Restore Button. It does not have
-// window handle.
-HRESULT GetBrowserRestoreButton(IAccessible** ppi_access,
- VARIANT* child_var_id);
+// Returns IAccessible pointer for Chrome Restore Button, by calling
+// GetChildWnd. It does not have window handle.
+HRESULT GetBrowserRestoreButton(IAccessible** acc_obj, VARIANT* child);
-// Returns IAccessible pointer for Chrome Close Button. It does not have
-// window handle.
-HRESULT GetBrowserCloseButton(IAccessible** ppi_access, VARIANT* child_var_id);
+// Returns IAccessible pointer for Chrome Close Button, by calling
+// GetChildWnd. It does not have window handle.
+HRESULT GetBrowserCloseButton(IAccessible** acc_obj, VARIANT* child);
-// Returns IAccessible pointer for Star Button. It does not have window handle.
-HRESULT GetStarButton(IAccessible** ppi_access, VARIANT* child_var_id);
+// 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 Back Button. It does not have window handle.
-HRESULT GetBackButton(IAccessible** ppi_access, VARIANT* child_var_id);
+// 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 Forward Button. It does not have window
-// handle.
-HRESULT GetForwardButton(IAccessible** ppi_access, VARIANT* child_var_id);
+// Returns IAccessible pointer for Chrome Forward Button, by calling
+// GetChildWnd. It does not have window handle.
+HRESULT GetForwardButton(IAccessible** acc_obj, VARIANT* child);
-#endif // CHROME_TEST_ACCISSIBILITY_ACCISSIBILITY_UTIL_H__
+#endif // CHROME_TEST_ACCESSIBILITY_ACCESSIBILITY_UTIL_H_
diff --git a/chrome/test/accessibility/browser_impl.cc b/chrome/test/accessibility/browser_impl.cc
index 94db7a7..36b3c1f 100644
--- a/chrome/test/accessibility/browser_impl.cc
+++ b/chrome/test/accessibility/browser_impl.cc
@@ -10,18 +10,18 @@
#include "chrome/test/accessibility/keyboard_util.h"
#include "chrome/test/accessibility/registry_util.h"
-bool CBrowserImpl::Launch(void) {
- // TODO: Check if chrome already running.
- BSTR chrome_path = SysAllocString(GetChromeExePath());
- BOOL bool_return = FALSE;
+bool BrowserImpl::Launch(void) {
+ // TODO(klink): Check if chrome already running.
+ BSTR chrome_path = SysAllocString(GetChromeExePath());
+ BOOL success = FALSE;
// Initialize and fill up structure.
SHELLEXECUTEINFO shell_execute_info;
memset(&shell_execute_info, 0, sizeof(SHELLEXECUTEINFO));
shell_execute_info.cbSize = sizeof(SHELLEXECUTEINFO);
// To get Process handle.
- shell_execute_info.fMask = SEE_MASK_NOCLOSEPROCESS;
- shell_execute_info.nShow = SW_SHOW;
+ shell_execute_info.fMask = SEE_MASK_NOCLOSEPROCESS;
+ shell_execute_info.nShow = SW_SHOW;
shell_execute_info.lpFile =
reinterpret_cast<TCHAR*>(malloc(sizeof(TCHAR) *
SysStringLen(chrome_path)));
@@ -29,11 +29,10 @@ bool CBrowserImpl::Launch(void) {
chrome_path);
// Execute.
- bool_return = ShellExecuteEx(&shell_execute_info);
+ success = ShellExecuteEx(&shell_execute_info);
- if (bool_return &&
- (INT64(shell_execute_info.hInstApp) > 32) ) {
- // TODO: Maintain instance and process handle.
+ if (success && (INT64(shell_execute_info.hInstApp) > 32)) {
+ // TODO(klink): Maintain instance and process handle.
// Maintain active tab index.
SetActiveTabIndex(1);
@@ -42,13 +41,15 @@ bool CBrowserImpl::Launch(void) {
UpdateTabCollection();
// Chrome launched.
+ SysFreeString(chrome_path);
return true;
}
+ SysFreeString(chrome_path);
return false;
}
-bool CBrowserImpl::Quit(void) {
+bool BrowserImpl::Quit(void) {
// Cleanup.
EraseTabCollection();
@@ -60,39 +61,35 @@ bool CBrowserImpl::Quit(void) {
return true;
}
-bool CBrowserImpl::ActivateTab(const INT64 index) {
+bool BrowserImpl::ActivateTab(const INT64 index) {
// Validate index specified.
- if (index < 1) {
+ if (index < 1)
return false;
- }
// Goto next tab till focused at desired tab.
- // TODO: Change implementation when DoDefaultAction() for Tab is exported.
while (active_tab_index_ != index) {
GoToNextTab(NULL);
}
return true;
}
-bool CBrowserImpl::GetActiveTabURL(BSTR* url) {
+bool BrowserImpl::GetActiveTabURL(BSTR* url) {
// Validate input.
if (!url)
return false;
- // TODO: Implement.
return true;
}
-bool CBrowserImpl::GetActiveTabTitle(BSTR* title) {
+bool BrowserImpl::GetActiveTabTitle(BSTR* title) {
if (!title)
return false;
- BSTR tab_title = SysAllocString(GetTabName(active_tab_index_));
- *title = SysAllocString(tab_title);
+ *title = SysAllocString(GetTabName(active_tab_index_));
return true;
}
-bool CBrowserImpl::GetActiveTabIndex(INT64* index) {
+bool BrowserImpl::GetActiveTabIndex(INT64* index) {
if (!index)
return false;
@@ -100,17 +97,17 @@ bool CBrowserImpl::GetActiveTabIndex(INT64* index) {
return true;
}
-void CBrowserImpl::SetActiveTabIndex(INT64 index) {
+void BrowserImpl::SetActiveTabIndex(INT64 index) {
if ((index >= MIN_TAB_INDEX_DIGIT) && (index <= GetTabCnt()))
active_tab_index_ = index;
return;
}
-bool CBrowserImpl::GetActiveTab(CTabImpl** tab) {
+bool BrowserImpl::GetActiveTab(TabImpl** tab) {
return GetTab(active_tab_index_, tab);
}
-bool CBrowserImpl::GetTabCount(INT64* count) {
+bool BrowserImpl::GetTabCount(INT64* count) {
if (!count)
return false;
@@ -118,16 +115,14 @@ bool CBrowserImpl::GetTabCount(INT64* count) {
return true;
}
-bool CBrowserImpl::GetBrowserProcessCount(INT64* count) {
+bool BrowserImpl::GetBrowserProcessCount(INT64* count) {
if (!count)
return false;
- // TODO: Add your implementation code here
-
return true;
}
-bool CBrowserImpl::GetBrowserTitle(BSTR* title) {
+bool BrowserImpl::GetBrowserTitle(BSTR* title) {
if (!title)
return false;
@@ -141,7 +136,7 @@ bool CBrowserImpl::GetBrowserTitle(BSTR* title) {
return true;
}
-bool CBrowserImpl::AddTab(CTabImpl** tab) {
+bool BrowserImpl::AddTab(TabImpl** tab) {
// Add new tab.
HWND hwnd = GetChromeBrowserWnd(NULL);
if (!hwnd)
@@ -155,16 +150,20 @@ bool CBrowserImpl::AddTab(CTabImpl** tab) {
SetActiveTabIndex(new_tab_index);
// Fill object.
- CTabImpl *new_tab = new CTabImpl();
+ TabImpl* new_tab = new TabImpl();
if (!new_tab)
return false;
ChromeTab* tab_data = new_tab->InitTabData();
- new_tab->PutIndex(new_tab_index);
- new_tab->PutTitle(GetTabName(new_tab_index));
- new_tab->SetBrowser(this);
+ new_tab->set_index(new_tab_index);
+ new_tab->set_title(GetTabName(new_tab_index));
+ new_tab->set_browser(this);
+
+ // Create a copy for storage, in case the caller deletes this newly created
+ // TabImpl before [tab_collection_] is done using [tab_data].
+ ChromeTab* tab_data_copy = tab_data;
// Update tab collection.
- tab_collection_.push_back(tab_data);
+ tab_collection_.push_back(linked_ptr<ChromeTab>(tab_data_copy));
// Create tab object, if requested.
if (tab)
@@ -173,7 +172,7 @@ bool CBrowserImpl::AddTab(CTabImpl** tab) {
return true;
}
-bool CBrowserImpl::GetTab(const INT64 index, CTabImpl** tab) {
+bool BrowserImpl::GetTab(const INT64 index, TabImpl** tab) {
// Create tab object, if requested.
if (!tab)
return false;
@@ -181,20 +180,20 @@ bool CBrowserImpl::GetTab(const INT64 index, CTabImpl** tab) {
if (index > GetTabCnt())
return false;
- *tab = new CTabImpl();
+ *tab = new TabImpl();
if (!*tab)
return false;
// Fill object.
ChromeTab* tab_data = (*tab)->InitTabData();
- (*tab)->PutIndex(index);
- (*tab)->PutTitle(GetTabName(index));
- (*tab)->SetBrowser(this);
+ (*tab)->set_index(index);
+ (*tab)->set_title(GetTabName(index));
+ (*tab)->set_browser(this);
return true;
}
-bool CBrowserImpl::GoToTab(const INT64 index, CTabImpl** tab) {
+bool BrowserImpl::GoToTab(const INT64 index, TabImpl** tab) {
// Validate input.
if (index > MAX_TAB_INDEX_DIGIT)
return false;
@@ -204,13 +203,13 @@ bool CBrowserImpl::GoToTab(const INT64 index, CTabImpl** tab) {
return true;
// Move to a tab (indexed 1 to 9).
- IAccessible *pi_access = NULL;
- HWND hwnd = GetChromeBrowserWnd(&pi_access);
- if (pi_access && hwnd) {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
+ if (acc_obj && hwnd) {
// Activate main window and operate key Ctrl+digit.
- ActivateWnd(pi_access, hwnd);
+ ActivateWnd(acc_obj, hwnd);
ClickKey(hwnd, VK_CONTROL, WORD('0'+index));
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
// Set focused tab index.
active_tab_index_ = index;
@@ -223,14 +222,14 @@ bool CBrowserImpl::GoToTab(const INT64 index, CTabImpl** tab) {
return false;
}
-bool CBrowserImpl::GoToNextTab(CTabImpl** tab) {
- IAccessible *pi_access = NULL;
- HWND hwnd = GetChromeBrowserWnd(&pi_access);
- if (pi_access && hwnd) {
+bool BrowserImpl::GoToNextTab(TabImpl** tab) {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
+ if (acc_obj && hwnd) {
// Activate main window and operate key Ctrl+Tab.
- ActivateWnd(pi_access, hwnd);
+ ActivateWnd(acc_obj, hwnd);
ClickKey(hwnd, VK_CONTROL, VK_TAB);
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
// Set focused tab index.
if (active_tab_index_ == GetTabCnt()) {
@@ -248,14 +247,14 @@ bool CBrowserImpl::GoToNextTab(CTabImpl** tab) {
return false;
}
-bool CBrowserImpl::GoToPrevTab(CTabImpl** tab) {
- IAccessible *pi_access = NULL;
- HWND hwnd = GetChromeBrowserWnd(&pi_access);
- if (pi_access && hwnd) {
+bool BrowserImpl::GoToPrevTab(TabImpl** tab) {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
+ if (acc_obj && hwnd) {
// Activate main window and operate key Ctrl+Tab.
- ActivateWnd(pi_access, hwnd);
+ ActivateWnd(acc_obj, hwnd);
ClickKey(hwnd, VK_SHIFT, VK_CONTROL, VK_TAB);
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
// Set focused tab index.
if (active_tab_index_ == 1) {
@@ -273,19 +272,18 @@ bool CBrowserImpl::GoToPrevTab(CTabImpl** tab) {
return false;
}
-bool CBrowserImpl::WaitForChromeToBeVisible(const INT64 interval,
- const INT64 timeout,
- bool* visible) {
- IAccessible *pi_access = NULL;
+bool BrowserImpl::WaitForChromeToBeVisible(const INT64 interval,
+ const INT64 timeout, bool* visible) {
+ IAccessible* acc_obj = NULL;
INT64 time_elapsed = 0;
*visible = false;
// Check and wait.
while (timeout >= time_elapsed) {
- GetTabStripWnd(&pi_access);
- if (pi_access) {
+ GetTabStripWnd(&acc_obj);
+ if (acc_obj) {
*visible = true;
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return true;
}
Sleep(DWORD(interval));
@@ -295,26 +293,21 @@ bool CBrowserImpl::WaitForChromeToBeVisible(const INT64 interval,
return false;
}
-bool CBrowserImpl::WaitForTabCountToChange(const INT64 interval,
- const INT64 timeout,
- bool* changed) {
- // TODO: Add your implementation code here
-
+bool BrowserImpl::WaitForTabCountToChange(const INT64 interval,
+ const INT64 timeout, bool* changed) {
return true;
}
-bool CBrowserImpl::WaitForTabToBecomeActive(const INT64 index,
- const INT64 interval,
- const INT64 timeout,
- bool* activated) {
- // TODO: Add your implementation code here
-
+bool BrowserImpl::WaitForTabToBecomeActive(const INT64 index,
+ const INT64 interval,
+ const INT64 timeout,
+ bool* activated) {
return true;
}
-bool CBrowserImpl::ApplyAccelerator(VARIANT keys) {
- // Input should be -array of enum or strings
- // or -IDispatch (jscript array object).
+bool BrowserImpl::ApplyAccelerator(VARIANT keys) {
+ // Input should be -array of enum or strings or -IDispatch (jscript array
+ // object).
if ((keys.vt != (VT_ARRAY|VT_BSTR)) && // Array of string values.
(keys.vt != (VT_ARRAY|VT_I4)) && // Array of enum values.
(!(keys.vt & VT_DISPATCH)) ) { // Object.
@@ -323,11 +316,11 @@ bool CBrowserImpl::ApplyAccelerator(VARIANT keys) {
// Array to store keys in a single combination. Currently, valid keyboard
// -input combination can constitute of at the most 3 keys.
- KEYBD_KEYS key_value[3];
+ KEYBD_KEYS key_value[3];
// Initialize key count.
int key_cnt = 0;
// Get variant array from object.
- IDispatch *disp = NULL;
+ IDispatch* disp = NULL;
// Not array of string values or integers.
if ((keys.vt != (VT_ARRAY|VT_BSTR)) &&
@@ -394,60 +387,59 @@ bool CBrowserImpl::ApplyAccelerator(VARIANT keys) {
VariantClear(&len);
} else {
// Directly fetch array.
- SAFEARRAY *key_safe = NULL;
+ SAFEARRAY* key_safe = NULL;
key_safe = V_ARRAY(&keys);
// Operate on Variant Array.
HRESULT hr = S_OK;
- LONG cElements, lLBound, lUBound;
+ LONG num_elements, lower_bound, upper_bound;
// Array is not 1-dimentional.
if (SafeArrayGetDim(key_safe) != 1)
return false;
// Get array bounds.
- hr = SafeArrayGetLBound(key_safe, 1, &lLBound);
+ hr = SafeArrayGetLBound(key_safe, 1, &lower_bound);
if (S_OK !=hr)
return false;
- hr = SafeArrayGetUBound(key_safe, 1, &lUBound);
+ hr = SafeArrayGetUBound(key_safe, 1, &upper_bound);
if (S_OK !=hr)
return false;
// Key combination can be of maximum 3 keys.
- cElements = lUBound-lLBound+1;
- if (cElements > 3)
+ num_elements = upper_bound - lower_bound + 1;
+ if (num_elements > 3)
return false;
- key_cnt = cElements;
+ key_cnt = num_elements;
// Read the data in array.
if (keys.vt == (VT_ARRAY|VT_I4)) {
- KEYBD_KEYS *read_keys;
- hr = SafeArrayAccessData(key_safe,
- reinterpret_cast<void **>(&read_keys));
- if (S_OK !=hr)
+ KEYBD_KEYS* read_keys;
+ hr = SafeArrayAccessData(key_safe, reinterpret_cast<void **>(&read_keys));
+ if (S_OK != hr)
return false;
- for (int i = 0; i < cElements; i++) {
+ for (int i = 0; i < num_elements; i++) {
key_value[i] = read_keys[i];
}
} else if (keys.vt == (VT_ARRAY|VT_BSTR)) {
- BSTR *key_str_value;
+ BSTR* key_str_value;
hr = SafeArrayAccessData(key_safe,
reinterpret_cast<void **>(&key_str_value));
- if (S_OK !=hr)
+ if (S_OK != hr)
return false;
// Translate and add key to array.
- for (int i = 0; i < cElements; i++) {
+ for (int i = 0; i < num_elements; i++) {
key_value[i] = GetKeybdKeysVal(key_str_value[i]);
}
}
}
// Focus on main window and operate keys.
- IAccessible *pi_access = NULL;
- HWND hwnd = GetChromeBrowserWnd(&pi_access);
- if (pi_access || hwnd)
- ActivateWnd(pi_access, hwnd);
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
+ if (acc_obj || hwnd)
+ ActivateWnd(acc_obj, hwnd);
if (1 == key_cnt)
ClickKey(hwnd, key_value[0]);
@@ -456,21 +448,20 @@ bool CBrowserImpl::ApplyAccelerator(VARIANT keys) {
else if (3 == key_cnt)
ClickKey(hwnd, key_value[0], key_value[1], key_value[2]);
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return true;
}
-void CBrowserImpl::UpdateTabCollection(void) {
+void BrowserImpl::UpdateTabCollection(void) {
// Get tab count and browser title.
INT64 tab_cnt = GetTabCnt();
BSTR browser_title;
GetBrowserTitle(&browser_title);
- // Check tab-collection size and no. of existing tabs,
- // work accordingly.
+ // Check tab-collection size and number of existing tabs, work accordingly.
- // First time creation
+ // First time creation.
if (0 == tab_collection_.size()) {
EraseTabCollection();
for (int i = 0; i < tab_cnt; i++) {
@@ -482,28 +473,23 @@ void CBrowserImpl::UpdateTabCollection(void) {
}
}
}
+ SysFreeString(browser_title);
- // TODO: If tabs are swapped.
- // Add implementation here.
+ // TODO(klink): Add implementation here to handle if tabs are reordered,
+ // rather than created.
}
-void CBrowserImpl::EraseTabCollection(void) {
- std::vector<ChromeTab*>::iterator tab_iterator;
- for (tab_iterator = tab_collection_.begin();
- tab_iterator != tab_collection_.end();
- tab_iterator++) {
- // Relese memory used for data.
- CHK_DELETE(*tab_iterator);
- }
+void BrowserImpl::EraseTabCollection(void) {
tab_collection_.clear();
}
-void CBrowserImpl::CloseTabFromCollection(INT64 index) {
+void BrowserImpl::CloseTabFromCollection(INT64 index) {
std::vector <ChromeTab*>::size_type collection_size = tab_collection_.size();
// Validate tab index.
if ((index < MIN_TAB_INDEX_DIGIT) ||
- (static_cast<unsigned int>(index) > collection_size) )
+ (static_cast<unsigned int>(index) > collection_size)) {
return;
+ }
// Index starts from 1.
tab_collection_.erase(tab_collection_.begin() + static_cast<int>(index) - 1);
diff --git a/chrome/test/accessibility/browser_impl.h b/chrome/test/accessibility/browser_impl.h
index 226c77f..42facf0 100644
--- a/chrome/test/accessibility/browser_impl.h
+++ b/chrome/test/accessibility/browser_impl.h
@@ -2,15 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_TEST_ACCISSIBILITY_BROWSER_IMPL_H__
-#define CHROME_TEST_ACCISSIBILITY_BROWSER_IMPL_H__
+#ifndef CHROME_TEST_ACCESSIBILITY_BROWSER_IMPL_H_
+#define CHROME_TEST_ACCESSIBILITY_BROWSER_IMPL_H_
+#include <oleacc.h>
#include <vector>
-#include "tab_impl.h"
+#include "base/linked_ptr.h"
+#include "chrome/test/accessibility/tab_impl.h"
/////////////////////////////////////////////////////////////////////
-// CBrowserImpl
+// BrowserImpl
// It is a wrapper to Browser specific functionalities.
// Note:
// In most of the tasks, keyboard messages are used for now.
@@ -19,9 +21,9 @@
// And keyboard messages will be tested using ApplyAccelerator().
/////////////////////////////////////////////////////////////////////
-class CBrowserImpl {
+class BrowserImpl {
public:
- CBrowserImpl() {
+ BrowserImpl() {
active_tab_index_ = 0;
}
@@ -37,41 +39,46 @@ class CBrowserImpl {
// Returns URL of the active tab.
bool GetActiveTabURL(BSTR* url);
- // Gets active tab's title.
+ // Gets active tab's title. Note that it is the caller's responsibility to
+ // call SysFreeString on [title].
bool GetActiveTabTitle(BSTR* title);
// Gets active tab index.
bool GetActiveTabIndex(INT64* index);
// Returns active tab object.
- bool GetActiveTab(CTabImpl** tab);
+ bool GetActiveTab(TabImpl** tab);
// Returns no. of tabs in tabstrip.
bool GetTabCount(INT64* count);
bool GetBrowserProcessCount(INT64* count);
- // Reads browser title, which is also a active tab's title
+ // Reads browser title, which is also a active tab's title. Note that it is
+ // the caller's responsibility to call SysFreeString on [title].
bool GetBrowserTitle(BSTR* title);
- // Adds new tab. Maintain current active tab index.
- // Returns created tab, if requested.
- bool AddTab(CTabImpl** tab);
+ // Adds new tab. Maintain current active tab index. Returns created tab, if
+ // requested. Note that it is the caller's responsibility to delete [tab].
+ bool AddTab(TabImpl** tab);
- // Returns tab object of specified index.
- bool GetTab(const INT64 index, CTabImpl** tab);
+ // Returns tab object of specified index. Note that it is the caller's
+ // responsibility to delete [tab].
+ bool GetTab(const INT64 index, TabImpl** tab);
- // Activate tab of specified index. Maintain current active tab index.
- // Returns created tab, if requested.
- bool GoToTab(const INT64 index, CTabImpl** tab);
+ // Activate tab of specified index. Maintain current active tab index. Returns
+ // created tab, if requested. Note that it is the caller's responsibility to
+ // delete [tab].
+ bool GoToTab(const INT64 index, TabImpl** tab);
- // Move to next tab. Maintain current active tab index.
- // Returns created tab, if requested.
- bool GoToNextTab(CTabImpl** tab);
+ // Move to next tab. Maintain current active tab index. Returns created tab,
+ // if requested. Note that it is the caller's responsibility to delete [tab].
+ bool GoToNextTab(TabImpl** tab);
- // Move to previous tab. Maintain current active tab index.
- // Returns created tab, if requested.
- bool GoToPrevTab(CTabImpl** tab);
+ // Move to previous tab. Maintain current active tab index. Returns created
+ // tab, if requested. Note that it is the caller's responsibility to delete
+ // [tab].
+ bool GoToPrevTab(TabImpl** tab);
// Wait for chrome window to be visible. It checks for accessibility object
// for tabstrip after every 'interval' for the specified 'timeout'.
@@ -91,7 +98,7 @@ class CBrowserImpl {
// Removed tab from tab collection vector.
void CloseTabFromCollection(INT64 index);
- // Updates tab collection vector
+ // Updates tab collection vector.
void UpdateTabCollection(void);
// Removes tab from tab collection vector.
@@ -102,9 +109,8 @@ class CBrowserImpl {
INT64 active_tab_index_;
// Collection of tab data.
- std::vector<ChromeTab*> tab_collection_;
+ std::vector<linked_ptr<ChromeTab> > tab_collection_;
};
-
-#endif // CHROME_TEST_ACCISSIBILITY_BROWSER_IMPL_H__
+#endif // CHROME_TEST_ACCESSIBILITY_BROWSER_IMPL_H_
diff --git a/chrome/test/accessibility/constants.h b/chrome/test/accessibility/constants.h
index dfba0f5..5fad4b7 100644
--- a/chrome/test/accessibility/constants.h
+++ b/chrome/test/accessibility/constants.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_TEST_ACCISSIBILITY_CONSTANTS_H__
-#define CHROME_TEST_ACCISSIBILITY_CONSTANTS_H__
+#ifndef CHROME_TEST_ACCESSIBILITY_CONSTANTS_H_
+#define CHROME_TEST_ACCESSIBILITY_CONSTANTS_H_
#include <windows.h>
#include <tchar.h>
@@ -15,8 +15,8 @@
///////////////////////////////////////////////////////////////////
// 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; } }
+#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.
@@ -29,16 +29,9 @@
#define AUTH_TITLE _T("Authentication Required - Chrome")
#define CHROME_TAB_CONTENTS _T("Chrome_TabContents")
-#define BROWSER_WIN_ROLE _T("window")
-#define BROWSER_APP_ROLE _T("application")
-#define BROWSER_CLIENT_ROLE _T("client")
-
#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)
@@ -134,6 +127,5 @@ enum KEYBD_KEYS {
KEY_INVALID = -1
};
-
-#endif // CHROME_TEST_ACCISSIBILITY_CONSTANTS_H__
+#endif // CHROME_TEST_ACCESSIBILITY_CONSTANTS_H_
diff --git a/chrome/test/accessibility/keyboard_util.cc b/chrome/test/accessibility/keyboard_util.cc
index 7133991..8201927 100644
--- a/chrome/test/accessibility/keyboard_util.cc
+++ b/chrome/test/accessibility/keyboard_util.cc
@@ -9,13 +9,13 @@ void ClickKey(HWND hwnd, WORD key) {
memset(&input, 0, sizeof(INPUT)*2);
// Press key.
- input[0].type = INPUT_KEYBOARD;
- input[0].ki.wVk = key;
+ input[0].type = INPUT_KEYBOARD;
+ input[0].ki.wVk = key;
input[0].ki.dwFlags = 0;
// Release key.
- input[1].type = INPUT_KEYBOARD;
- input[1].ki.wVk = key;
+ input[1].type = INPUT_KEYBOARD;
+ input[1].ki.wVk = key;
input[1].ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(2, input, sizeof(INPUT));
@@ -26,23 +26,23 @@ void ClickKey(HWND hwnd, WORD extended_key, WORD key) {
memset(&input, 0, sizeof(INPUT)*4);
// Press extended key.
- input[0].type = INPUT_KEYBOARD;
- input[0].ki.wVk = extended_key;
+ input[0].type = INPUT_KEYBOARD;
+ input[0].ki.wVk = extended_key;
input[0].ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
// Press key.
- input[1].type = INPUT_KEYBOARD;
- input[1].ki.wVk = key;
+ input[1].type = INPUT_KEYBOARD;
+ input[1].ki.wVk = key;
input[1].ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
// Release key.
- input[2].type = INPUT_KEYBOARD;
- input[2].ki.wVk = key;
+ input[2].type = INPUT_KEYBOARD;
+ input[2].ki.wVk = key;
input[2].ki.dwFlags = KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP;
// Release key.
- input[3].type = INPUT_KEYBOARD;
- input[3].ki.wVk = extended_key;
+ input[3].type = INPUT_KEYBOARD;
+ input[3].ki.wVk = extended_key;
input[3].ki.dwFlags = KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP;
SendInput(4, input, sizeof(INPUT));
@@ -53,23 +53,23 @@ void ClickKey(HWND hwnd, WORD extended_key1, WORD extended_key2, WORD key) {
memset(&input, 0, sizeof(INPUT)*6);
// Press extended key1.
- input[0].type = INPUT_KEYBOARD;
- input[0].ki.wVk = extended_key1;
+ input[0].type = INPUT_KEYBOARD;
+ input[0].ki.wVk = extended_key1;
input[0].ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
// Press extended key2.
- input[1].type = INPUT_KEYBOARD;
- input[1].ki.wVk = extended_key2;
+ input[1].type = INPUT_KEYBOARD;
+ input[1].ki.wVk = extended_key2;
input[1].ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
// Press key.
- input[2].type = INPUT_KEYBOARD;
- input[2].ki.wVk = key;
+ input[2].type = INPUT_KEYBOARD;
+ input[2].ki.wVk = key;
input[2].ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
// Release key.
- input[3].type = INPUT_KEYBOARD;
- input[3].ki.wVk = key;
+ input[3].type = INPUT_KEYBOARD;
+ input[3].ki.wVk = key;
input[3].ki.dwFlags = KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP;
// Release extended key2.
@@ -78,8 +78,8 @@ void ClickKey(HWND hwnd, WORD extended_key1, WORD extended_key2, WORD key) {
input[4].ki.dwFlags = KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP;
// Release extended key1.
- input[5].type = INPUT_KEYBOARD;
- input[5].ki.wVk = extended_key1;
+ input[5].type = INPUT_KEYBOARD;
+ input[5].ki.wVk = extended_key1;
input[5].ki.dwFlags = KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP;
SendInput(6, input, sizeof(INPUT));
diff --git a/chrome/test/accessibility/keyboard_util.h b/chrome/test/accessibility/keyboard_util.h
index 43ee9c9..af15a240 100644
--- a/chrome/test/accessibility/keyboard_util.h
+++ b/chrome/test/accessibility/keyboard_util.h
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_TEST_ACCISSIBILITY_KEYBOARD_UTIL_H__
-#define CHROME_TEST_ACCISSIBILITY_KEYBOARD_UTIL_H__
+#ifndef CHROME_TEST_ACCESSIBILITY_KEYBOARD_UTIL_H_
+#define CHROME_TEST_ACCESSIBILITY_KEYBOARD_UTIL_H_
-#include "constants.h"
+#include <wtypes.h>
-#include <oleauto.h>
+#include "chrome/test/accessibility/constants.h"
//////////////////////////////////////////////////////
// Function declarations to automate keyboard events.
@@ -33,6 +33,5 @@ void ReleaseKey(HWND hwnd, WORD key);
// Returns native enum values for a key-string specified.
KEYBD_KEYS GetKeybdKeysVal(BSTR str);
-
-#endif // CHROME_TEST_ACCISSIBILITY_KEYBOARD_UTIL_H__
+#endif // CHROME_TEST_ACCESSIBILITY_KEYBOARD_UTIL_H_
diff --git a/chrome/test/accessibility/registry_util.cc b/chrome/test/accessibility/registry_util.cc
index 1597090..8c5984d 100644
--- a/chrome/test/accessibility/registry_util.cc
+++ b/chrome/test/accessibility/registry_util.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "registry_util.h"
-#include "constants.h"
+#include "chrome/test/accessibility/registry_util.h"
+
+#include <ocidl.h>
+
+#include "chrome/test/accessibility/constants.h"
BSTR GetChromeExePath() {
- // TODO: once registry contains chrome exe path.
BSTR chrome_exe_path = SysAllocString(CHROME_PATH);
return chrome_exe_path;
}
diff --git a/chrome/test/accessibility/registry_util.h b/chrome/test/accessibility/registry_util.h
index 3b33ebd..a37b66c 100644
--- a/chrome/test/accessibility/registry_util.h
+++ b/chrome/test/accessibility/registry_util.h
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_TEST_ACCISSIBILITY_REGISTRY_UTIL_H__
-#define CHROME_TEST_ACCISSIBILITY_REGISTRY_UTIL_H__
+#ifndef CHROME_TEST_ACCESSIBILITY_REGISTRY_UTIL_H_
+#define CHROME_TEST_ACCESSIBILITY_REGISTRY_UTIL_H_
//////////////////////////////////////////////////
// Functions for registry operations.
//////////////////////////////////////////////////
-#include <ocidl.h>
+#include <wtypes.h>
// Reads chrome installation path from registry.
BSTR GetChromeExePath();
-#endif // CHROME_TEST_ACCISSIBILITY_REGISTRY_UTIL_H__
+#endif // CHROME_TEST_ACCESSIBILITY_REGISTRY_UTIL_H_
diff --git a/chrome/test/accessibility/tab_impl.cc b/chrome/test/accessibility/tab_impl.cc
index cf4d288..d116760 100644
--- a/chrome/test/accessibility/tab_impl.cc
+++ b/chrome/test/accessibility/tab_impl.cc
@@ -2,29 +2,39 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "browser_impl.h"
-#include "tab_impl.h"
-#include "accessibility_util.h"
-#include "keyboard_util.h"
-#include "constants.h"
-
-bool CTabImpl::Close(void) {
- IAccessible *pi_access = NULL;
- HWND hwnd = GetChromeBrowserWnd(&pi_access);
- if (!pi_access || !hwnd)
+#include "chrome/test/accessibility/tab_impl.h"
+
+#include <oleacc.h>
+
+#include "chrome/test/accessibility/accessibility_util.h"
+#include "chrome/test/accessibility/browser_impl.h"
+#include "chrome/test/accessibility/keyboard_util.h"
+
+
+TabImpl::~TabImpl() {
+ if (tab_) {
+ SysFreeString(tab_->title_);
+ delete tab_;
+ }
+}
+
+bool TabImpl::Close(void) {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
+ if (!acc_obj || !hwnd)
return false;
// Activate main window and operate key Ctrl+F4.
- ActivateWnd(pi_access, hwnd);
+ ActivateWnd(acc_obj, hwnd);
ClickKey(hwnd, VK_CONTROL, VK_F4);
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
// Update tab information in browser object.
- my_browser_->CloseTabFromCollection(tab_->index_);
+ browser_->CloseTabFromCollection(tab_->index_);
return true;
}
-bool CTabImpl::GetTitle(BSTR* title) {
+bool TabImpl::GetTitle(BSTR* title) {
// Validation.
if (!title)
return false;
@@ -36,62 +46,62 @@ bool CTabImpl::GetTitle(BSTR* title) {
return true;
}
-bool CTabImpl::SetAddressBarText(const BSTR text) {
- IAccessible *pi_access = NULL;
- HWND hwnd_addr_bar = GetAddressBarWnd(&pi_access);
- if (!pi_access || !hwnd_addr_bar)
+bool TabImpl::SetAddressBarText(const BSTR text) {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd_addr_bar = GetAddressBarWnd(&acc_obj);
+ if (!acc_obj || !hwnd_addr_bar)
return false;
// Activate address bar.
- ActivateWnd(pi_access, hwnd_addr_bar);
+ ActivateWnd(acc_obj, hwnd_addr_bar);
// Set text to address bar.
SendMessage(hwnd_addr_bar, WM_SETTEXT, 0, LPARAM(text));
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return true;
}
-bool CTabImpl::NavigateToURL(const BSTR url) {
- IAccessible *pi_access = NULL;
- HWND hwnd_addr_bar = GetAddressBarWnd(&pi_access);
+bool TabImpl::NavigateToURL(const BSTR url) {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd_addr_bar = GetAddressBarWnd(&acc_obj);
- if (!pi_access || !hwnd_addr_bar)
+ if (!acc_obj || !hwnd_addr_bar)
return false;
// Activate address bar.
- ActivateWnd(pi_access, hwnd_addr_bar);
+ ActivateWnd(acc_obj, hwnd_addr_bar);
// Set text to address bar.
SendMessage(hwnd_addr_bar, WM_SETTEXT, 0, LPARAM(url));
// Click Enter. Window is activated above for this.
ClickKey(hwnd_addr_bar, VK_RETURN);
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return true;
}
-bool CTabImpl::FindInPage(const BSTR find_text) {
- IAccessible *pi_access = NULL;
- HWND hwnd = GetChromeBrowserWnd(&pi_access);
- if (!pi_access || !hwnd)
+bool TabImpl::FindInPage(const BSTR find_text) {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
+ if (!acc_obj || !hwnd)
return false;
// Activate main window and operate key 'F3' to invoke Find window.
- ActivateWnd(pi_access, hwnd);
+ ActivateWnd(acc_obj, hwnd);
ClickKey(hwnd, VK_F3);
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
// If no text is to be searched, return.
if (find_text != NULL) {
- // TODO: Once FindWindow is exported through Accessibility.
+ // TODO(klink): Once FindWindow is exported through Accessibility.
// Instead of sleep, check if FindWindows exists or not.
Sleep(50);
// Get Find window.
- pi_access = NULL;
- hwnd = GetFindTextWnd(&pi_access);
+ acc_obj = NULL;
+ hwnd = GetFindTextWnd(&acc_obj);
if (hwnd) {
- HWND hwnd_find_edit = FindWindowEx(hwnd, 0,
- CHROME_VIEWS_TEXT_FIELD_EDIT, 0);
+ HWND hwnd_find_edit = FindWindowEx(hwnd, 0, CHROME_VIEWS_TEXT_FIELD_EDIT,
+ 0);
if (hwnd_find_edit) {
- ActivateWnd(pi_access, hwnd);
+ ActivateWnd(acc_obj, hwnd);
ActivateWnd(NULL, hwnd_find_edit);
// Set text in Find window edit box.
WCHAR* strTemp =
@@ -99,77 +109,77 @@ bool CTabImpl::FindInPage(const BSTR find_text) {
wcscpy_s(strTemp, wcslen(find_text), find_text);
for (size_t i = 0; i < wcslen(strTemp); i++) {
SendMessage(hwnd_find_edit, WM_KEYDOWN, strTemp[i], 0);
- SendMessage(hwnd_find_edit, WM_CHAR, strTemp[i], 0);
- SendMessage(hwnd_find_edit, WM_KEYUP, strTemp[i], 0);
+ SendMessage(hwnd_find_edit, WM_CHAR, strTemp[i], 0);
+ SendMessage(hwnd_find_edit, WM_KEYUP, strTemp[i], 0);
}
}
}
}
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return true;
}
-bool CTabImpl::Reload(void) {
- IAccessible *pi_access = NULL;
- HWND hwnd = GetChromeBrowserWnd(&pi_access);
- if (!pi_access || !hwnd)
+bool TabImpl::Reload(void) {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
+ if (!acc_obj || !hwnd)
return false;
// Operate key F5.
- ActivateWnd(pi_access, hwnd);
+ ActivateWnd(acc_obj, hwnd);
ClickKey(hwnd, VK_F5);
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return true;
}
-bool CTabImpl::Duplicate(CTabImpl** tab) {
- // TODO: Add your implementation code here
+bool TabImpl::Duplicate(TabImpl** tab) {
return true;
}
-bool CTabImpl::IsAuthDialogVisible() {
- IAccessible *pi_access = NULL;
- HWND hwnd = GetChromeBrowserWnd(&pi_access);
- if (!pi_access || !hwnd)
+bool TabImpl::IsAuthDialogVisible() {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
+ if (!acc_obj || !hwnd)
return false;
// Activate main window.
- ActivateWnd(pi_access, hwnd);
- CHK_RELEASE(pi_access);
+ ActivateWnd(acc_obj, hwnd);
+ CHK_RELEASE(acc_obj);
// Check for Authentication Window.
- pi_access = NULL;
- hwnd = GetAuthWnd(&pi_access);
- if (!hwnd || !pi_access) {
- CHK_RELEASE(pi_access);
+ acc_obj = NULL;
+ hwnd = GetAuthWnd(&acc_obj);
+ if (!hwnd || !acc_obj) {
+ CHK_RELEASE(acc_obj);
return false;
- }
+ }
+ CHK_RELEASE(acc_obj);
return true;
}
-bool CTabImpl::SetAuthDialog(const BSTR user_name, const BSTR password) {
- IAccessible *pi_access = NULL;
- HWND hwnd = GetChromeBrowserWnd(&pi_access);
- if (!pi_access || !hwnd)
+bool TabImpl::SetAuthDialog(const BSTR user_name, const BSTR password) {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
+ if (!acc_obj || !hwnd)
return false;
// Activate main window.
- ActivateWnd(pi_access, hwnd);
- CHK_RELEASE(pi_access);
+ ActivateWnd(acc_obj, hwnd);
+ CHK_RELEASE(acc_obj);
// Get editbox for user name and password.
- pi_access = NULL;
- hwnd = GetAuthWnd(&pi_access);
+ acc_obj = NULL;
+ hwnd = GetAuthWnd(&acc_obj);
if (!hwnd) {
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return false;
}
// Get handle to password edit box.
HWND hwnd_auth_pwd = FindWindowEx(hwnd, 0, CHROME_VIEWS_TEXT_FIELD_EDIT, 0);
if (!hwnd_auth_pwd) {
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return false;
}
@@ -177,14 +187,14 @@ bool CTabImpl::SetAuthDialog(const BSTR user_name, const BSTR password) {
HWND hwnd_auth_name = FindWindowEx(hwnd, hwnd_auth_pwd,
CHROME_VIEWS_TEXT_FIELD_EDIT, 0);
if (!hwnd_auth_name) {
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return false;
}
// Activate Tab.
SetActiveWindow(GetParent(hwnd));
// Activate Authentication window.
- ActivateWnd(pi_access, hwnd);
+ ActivateWnd(acc_obj, hwnd);
// Activate edit box for name.
ActivateWnd(NULL, hwnd_auth_name);
@@ -196,8 +206,8 @@ bool CTabImpl::SetAuthDialog(const BSTR user_name, const BSTR password) {
wcscpy_s(strTemp, wcslen(user_name), user_name);
for (size_t i = 0; i < wcslen(strTemp); i++) {
SendMessage(hwnd_auth_name, WM_KEYDOWN, strTemp[i], 0);
- SendMessage(hwnd_auth_name, WM_CHAR, strTemp[i], 0);
- SendMessage(hwnd_auth_name, WM_KEYUP, strTemp[i], 0);
+ SendMessage(hwnd_auth_name, WM_CHAR, strTemp[i], 0);
+ SendMessage(hwnd_auth_name, WM_KEYUP, strTemp[i], 0);
}
}
@@ -207,8 +217,8 @@ bool CTabImpl::SetAuthDialog(const BSTR user_name, const BSTR password) {
// Set password.
if (password != NULL) {
// set text
- WCHAR* strTemp =
- reinterpret_cast<WCHAR*>(calloc(wcslen(password), sizeof(WCHAR)));
+ WCHAR* strTemp = reinterpret_cast<WCHAR*>(calloc(wcslen(password),
+ sizeof(WCHAR)));
wcscpy_s(strTemp, wcslen(password), password);
for (size_t i = 0; i < wcslen(strTemp); i++) {
SendMessage(hwnd_auth_pwd, WM_KEYDOWN, strTemp[i], 0);
@@ -217,38 +227,39 @@ bool CTabImpl::SetAuthDialog(const BSTR user_name, const BSTR password) {
}
}
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return true;
}
-bool CTabImpl::CancelAuthDialog(void) {
- IAccessible *pi_access = NULL;
- HWND hwnd = GetChromeBrowserWnd(&pi_access);
- if (!pi_access || !hwnd)
+bool TabImpl::CancelAuthDialog(void) {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
+ if (!acc_obj || !hwnd)
return false;
// Activate main window.
- ActivateWnd(pi_access, hwnd);
- CHK_RELEASE(pi_access);
+ ActivateWnd(acc_obj, hwnd);
+ CHK_RELEASE(acc_obj);
// Get editbox for user name which is after password.
- pi_access = NULL;
- hwnd = GetAuthWnd(&pi_access);
+ acc_obj = NULL;
+ hwnd = GetAuthWnd(&acc_obj);
if (!hwnd) {
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return false;
}
// Get Cancel button.
- HWND cancel_button_container =
- FindWindowEx(hwnd, 0, CHROME_VIEWS_NATIVE_CTRL_CONTNR, 0);
+ HWND cancel_button_container = FindWindowEx(hwnd, 0,
+ CHROME_VIEWS_NATIVE_CTRL_CONTNR,
+ 0);
if (!cancel_button_container) {
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return false;
}
HWND cancel_button = FindWindowEx(cancel_button_container, 0, STD_BUTTON, 0);
if (!cancel_button) {
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return false;
}
@@ -257,32 +268,34 @@ bool CTabImpl::CancelAuthDialog(void) {
SetActiveWindow(cancel_button);
SendMessage(cancel_button, BM_CLICK, 0, 0);
+ CHK_RELEASE(acc_obj);
return true;
}
-bool CTabImpl::UseAuthDialog(void) {
- IAccessible *pi_access = NULL;
- HWND hwnd = GetChromeBrowserWnd(&pi_access);
- if (!pi_access || !hwnd)
+bool TabImpl::UseAuthDialog(void) {
+ IAccessible* acc_obj = NULL;
+ HWND hwnd = GetChromeBrowserWnd(&acc_obj);
+ if (!acc_obj || !hwnd)
return false;
// Activate main window.
- ActivateWnd(pi_access, hwnd);
- CHK_RELEASE(pi_access);
+ ActivateWnd(acc_obj, hwnd);
+ CHK_RELEASE(acc_obj);
// Get editbox for user name which is after password.
- pi_access = NULL;
- hwnd = GetAuthWnd(&pi_access);
+ acc_obj = NULL;
+ hwnd = GetAuthWnd(&acc_obj);
if (!hwnd) {
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return false;
}
// Get Ok button.
- HWND cancel_button_container =
- FindWindowEx(hwnd, 0, CHROME_VIEWS_NATIVE_CTRL_CONTNR, 0);
+ HWND cancel_button_container = FindWindowEx(hwnd, 0,
+ CHROME_VIEWS_NATIVE_CTRL_CONTNR,
+ 0);
if (!cancel_button_container) {
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return false;
}
@@ -290,12 +303,12 @@ bool CTabImpl::UseAuthDialog(void) {
HWND ok_button_container = FindWindowEx(hwnd, cancel_button_container,
CHROME_VIEWS_NATIVE_CTRL_CONTNR, 0);
if (!ok_button_container) {
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return false;
}
HWND ok_button = FindWindowEx(ok_button_container, 0, STD_BUTTON, 0);
if (!ok_button) {
- CHK_RELEASE(pi_access);
+ CHK_RELEASE(acc_obj);
return false;
}
@@ -304,62 +317,50 @@ bool CTabImpl::UseAuthDialog(void) {
SetActiveWindow(ok_button);
SendMessage(ok_button, BM_CLICK, 0, 0);
+ CHK_RELEASE(acc_obj);
return true;
}
-bool CTabImpl::Activate(void) {
- // TODO: Add your implementation code here
+void TabImpl::set_title(BSTR title) {
+ if (!tab_)
+ InitTabData();
+ tab_->title_ = SysAllocString(title);
+}
+bool TabImpl::Activate(void) {
return true;
}
-bool CTabImpl::WaitForTabToBecomeActive(const INT64 interval,
- const INT64 timeout) {
- // TODO: Add your implementation code here
-
+bool TabImpl::WaitForTabToBecomeActive(const INT64 interval,
+ const INT64 timeout) {
return true;
}
-bool CTabImpl::WaitForTabToGetLoaded(const INT64 interval,
- const INT64 timeout) {
- // TODO: Add your implementation code here
-
+bool TabImpl::WaitForTabToGetLoaded(const INT64 interval, const INT64 timeout) {
return true;
}
-bool CTabImpl::IsSSLLockPresent(bool* present) {
- // TODO: Add your implementation code here
-
+bool TabImpl::IsSSLLockPresent(bool* present) {
return true;
}
-bool CTabImpl::IsSSLSoftError(bool* soft_err) {
- // TODO: Add your implementation code here
-
+bool TabImpl::IsSSLSoftError(bool* soft_err) {
return true;
}
-bool CTabImpl::OpenPageCertificateDialog(void) {
- // TODO: Add your implementation code here
-
+bool TabImpl::OpenPageCertificateDialog(void) {
return true;
}
-bool CTabImpl::ClosePageCertificateDialog(void) {
- // TODO: Add your implementation code here
-
+bool TabImpl::ClosePageCertificateDialog(void) {
return true;
}
-bool CTabImpl::GoBack(void) {
- // TODO: Add your implementation code here
-
+bool TabImpl::GoBack(void) {
return true;
}
-bool CTabImpl::GoForward(void) {
- // TODO: Add your implementation code here
-
+bool TabImpl::GoForward(void) {
return true;
}
diff --git a/chrome/test/accessibility/tab_impl.h b/chrome/test/accessibility/tab_impl.h
index c0ba7c3..3155222 100644
--- a/chrome/test/accessibility/tab_impl.h
+++ b/chrome/test/accessibility/tab_impl.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_TEST_ACCISSIBILITY_TAB_IMPL_H__
-#define CHROME_TEST_ACCISSIBILITY_TAB_IMPL_H__
+#ifndef CHROME_TEST_ACCESSIBILITY_TAB_IMPL_H_
+#define CHROME_TEST_ACCESSIBILITY_TAB_IMPL_H_
-#include "constants.h"
+#include <wtypes.h>
-#include <oleauto.h>
+#include "constants.h"
/////////////////////////////////////////////////////////////////////
-// CTabImpl
+// TabImpl
// It is a wrapper to Tab specific functionalities.
// Note:
// In most of the tasks, keyboard messages are used for now.
@@ -20,7 +20,7 @@
/////////////////////////////////////////////////////////////////////
// Forward declaration.
-class CBrowserImpl;
+class BrowserImpl;
// Structure storing Tab parameters.
struct ChromeTab {
@@ -28,10 +28,11 @@ struct ChromeTab {
BSTR title_;
};
-class CTabImpl {
+class TabImpl {
public:
- CTabImpl(): tab_(NULL), my_browser_(NULL) {
- }
+ TabImpl(): tab_(NULL), browser_(NULL) {}
+
+ ~TabImpl();
public:
// Close this tab.
@@ -53,7 +54,7 @@ class CTabImpl {
bool Reload(void);
// Duplicates this tab.
- bool Duplicate(CTabImpl** tab);
+ bool Duplicate(TabImpl** tab);
// Returns true of Authentication dialog is opena nd visible.
bool IsAuthDialogVisible();
@@ -79,8 +80,11 @@ class CTabImpl {
// loaded with URL.
bool WaitForTabToGetLoaded(const INT64 interval, const INT64 timeout);
+ // Sets title of this tab.
+ void set_title(BSTR title);
+
// Sets index of this tab.
- void PutIndex(INT64 index) {
+ void set_index(INT64 index) {
if (index < 0)
return;
if (!tab_)
@@ -88,17 +92,10 @@ class CTabImpl {
tab_->index_ = index;
}
- // Sets title of this tab.
- void PutTitle(BSTR title) {
- if (!tab_)
- InitTabData();
- tab_->title_ = SysAllocString(title);
- }
-
// Sets browser to which tab belongs.
- bool SetBrowser(CBrowserImpl *browser) {
+ bool set_browser(BrowserImpl* browser) {
if (browser)
- my_browser_ = browser;
+ browser_ = browser;
else
return false;
@@ -118,7 +115,7 @@ class CTabImpl {
return tab_;
}
- // TODO
+ // To be implemeted.
bool IsSSLLockPresent(bool* present);
bool IsSSLSoftError(bool* soft_err);
bool OpenPageCertificateDialog(void);
@@ -128,12 +125,12 @@ class CTabImpl {
private:
// Structure to store tab data.
- ChromeTab *tab_;
+ ChromeTab* tab_;
// Pointer to browser to which this tab belongs.
- CBrowserImpl *my_browser_;
+ BrowserImpl* browser_;
};
-#endif // CHROME_TEST_ACCISSIBILITY_TAB_IMPL_H__
+#endif // CHROME_TEST_ACCISSIBILITY_TAB_IMPL_H_