summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 15:22:45 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 15:22:45 +0000
commit076bf500c06a2ec9ce9f5accc0eaad7c0b0b2666 (patch)
tree90c75e38f905641cda5eff21273c76e9f80b4ca5 /chrome
parent09247ce046ae7fa18a868d7f07ad292899b3798c (diff)
downloadchromium_src-076bf500c06a2ec9ce9f5accc0eaad7c0b0b2666.zip
chromium_src-076bf500c06a2ec9ce9f5accc0eaad7c0b0b2666.tar.gz
chromium_src-076bf500c06a2ec9ce9f5accc0eaad7c0b0b2666.tar.bz2
Cleanup in automation. Remove WaitForTabCountToChange.
WaitForTabCountToBecome is easier to use and more reliable. Also removed Windows2000-specific code from accessibility unit tests. Review URL: http://codereview.chromium.org/45070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12774 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/sessions/session_restore_uitest.cc22
-rw-r--r--chrome/browser/tab_restore_uitest.cc45
-rw-r--r--chrome/browser/views/tabs/tab_dragging_test.cc26
-rw-r--r--chrome/test/accessibility/accessibility_tests.cc168
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.cc4
-rw-r--r--chrome/test/automation/automation_proxy_uitest.cc15
-rw-r--r--chrome/test/automation/browser_proxy.cc18
-rw-r--r--chrome/test/automation/browser_proxy.h9
-rw-r--r--chrome/test/startup/feature_startup_test.cc17
-rw-r--r--chrome/test/tab_switching/tab_switching_test.cc9
10 files changed, 109 insertions, 224 deletions
diff --git a/chrome/browser/sessions/session_restore_uitest.cc b/chrome/browser/sessions/session_restore_uitest.cc
index 431b66e..58bee39 100644
--- a/chrome/browser/sessions/session_restore_uitest.cc
+++ b/chrome/browser/sessions/session_restore_uitest.cc
@@ -377,23 +377,24 @@ TEST_F(SessionRestoreUITest, DISABLED_ShareProcessesOnRestore) {
ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
// Create two new tabs.
- int new_tab_count;
ASSERT_TRUE(browser_proxy->ApplyAccelerator(IDC_NEW_TAB));
- ASSERT_TRUE(browser_proxy->WaitForTabCountToChange(tab_count, &new_tab_count,
+ ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(tab_count + 1,
action_timeout_ms()));
- scoped_ptr<TabProxy> last_tab(browser_proxy->GetTab(new_tab_count - 1));
+ ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
+ scoped_ptr<TabProxy> last_tab(browser_proxy->GetTab(tab_count - 1));
ASSERT_TRUE(last_tab.get() != NULL);
// Do a reload to ensure new tab page has loaded.
ASSERT_TRUE(last_tab->Reload());
- tab_count = new_tab_count;
ASSERT_TRUE(browser_proxy->ApplyAccelerator(IDC_NEW_TAB));
- ASSERT_TRUE(browser_proxy->WaitForTabCountToChange(tab_count, &new_tab_count,
+ ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(tab_count + 1,
action_timeout_ms()));
- last_tab.reset(browser_proxy->GetTab(new_tab_count - 1));
+ ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
+ last_tab.reset(browser_proxy->GetTab(tab_count - 1));
ASSERT_TRUE(last_tab.get() != NULL);
// Do a reload to ensure new tab page has loaded.
ASSERT_TRUE(last_tab->Reload());
int expected_process_count = GetBrowserProcessCount();
+ int expected_tab_count = tab_count;
// Restart.
browser_proxy.reset();
@@ -404,14 +405,13 @@ TEST_F(SessionRestoreUITest, DISABLED_ShareProcessesOnRestore) {
// count matches.
browser_proxy.reset(automation()->GetBrowserWindow(0));
ASSERT_TRUE(browser_proxy.get() != NULL);
- int restored_tab_count;
- ASSERT_TRUE(browser_proxy->GetTabCount(&restored_tab_count));
- ASSERT_EQ(new_tab_count, restored_tab_count);
+ ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
+ ASSERT_EQ(expected_tab_count, tab_count);
- scoped_ptr<TabProxy> tab_proxy(browser_proxy->GetTab(restored_tab_count - 2));
+ scoped_ptr<TabProxy> tab_proxy(browser_proxy->GetTab(tab_count - 2));
ASSERT_TRUE(tab_proxy.get() != NULL);
ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms()));
- tab_proxy.reset(browser_proxy->GetTab(restored_tab_count - 1));
+ tab_proxy.reset(browser_proxy->GetTab(tab_count - 1));
ASSERT_TRUE(tab_proxy.get() != NULL);
ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms()));
diff --git a/chrome/browser/tab_restore_uitest.cc b/chrome/browser/tab_restore_uitest.cc
index 88bf499..34922e6 100644
--- a/chrome/browser/tab_restore_uitest.cc
+++ b/chrome/browser/tab_restore_uitest.cc
@@ -37,16 +37,14 @@ class TabRestoreUITest : public UITest {
// Restore the tab.
ASSERT_TRUE(browser_proxy->ApplyAccelerator(IDC_RESTORE_TAB));
+ ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(
+ tab_count + 1, action_max_timeout_ms()));
// Get a handle to the restored tab.
- int restored_tab_count;
- ASSERT_TRUE(browser_proxy->WaitForTabCountToChange(
- tab_count, &restored_tab_count, action_max_timeout_ms()));
- ASSERT_EQ(tab_count + 1, restored_tab_count);
-
- // Wait for the restored tab to finish loading.
+ ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
scoped_ptr<TabProxy> restored_tab_proxy(
- browser_proxy->GetTab(restored_tab_count - 1));
+ browser_proxy->GetTab(tab_count - 1));
+ // Wait for the restored tab to finish loading.
ASSERT_TRUE(restored_tab_proxy->WaitForTabToBeRestored(
action_max_timeout_ms()));
}
@@ -61,16 +59,15 @@ class TabRestoreUITest : public UITest {
TEST_F(TabRestoreUITest, Basic) {
scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
- int initial_tab_count;
- ASSERT_TRUE(browser_proxy->GetTabCount(&initial_tab_count));
+ int tab_count;
+ ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
// Add a tab
browser_proxy->AppendTab(url1_);
- int new_tab_count;
- ASSERT_TRUE(browser_proxy->WaitForTabCountToChange(initial_tab_count,
- &new_tab_count,
+ ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
- scoped_ptr<TabProxy> new_tab(browser_proxy->GetTab(new_tab_count - 1));
+ ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
+ scoped_ptr<TabProxy> new_tab(browser_proxy->GetTab(tab_count - 1));
// Make sure we're at url.
new_tab->NavigateToURL(url1_);
// Close the tab.
@@ -140,16 +137,15 @@ TEST_F(TabRestoreUITest, RestoreWithExistingSiteInstance) {
GURL http_url2(server->TestServerPageW(L"files/title2.html"));
scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
- int initial_tab_count;
- ASSERT_TRUE(browser_proxy->GetTabCount(&initial_tab_count));
+ int tab_count;
+ ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
// Add a tab
browser_proxy->AppendTab(http_url1);
- int new_tab_count;
- ASSERT_TRUE(browser_proxy->WaitForTabCountToChange(initial_tab_count,
- &new_tab_count,
+ ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
- scoped_ptr<TabProxy> tab(browser_proxy->GetTab(new_tab_count - 1));
+ ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
+ scoped_ptr<TabProxy> tab(browser_proxy->GetTab(tab_count - 1));
// Navigate to another same-site URL.
tab->NavigateToURL(http_url2);
@@ -185,16 +181,15 @@ TEST_F(TabRestoreUITest, RestoreCrossSiteWithExistingSiteInstance) {
GURL http_url2(server->TestServerPageW(L"files/title2.html"));
scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
- int initial_tab_count;
- ASSERT_TRUE(browser_proxy->GetTabCount(&initial_tab_count));
+ int tab_count;
+ ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
// Add a tab
browser_proxy->AppendTab(http_url1);
- int new_tab_count;
- ASSERT_TRUE(browser_proxy->WaitForTabCountToChange(initial_tab_count,
- &new_tab_count,
+ ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
- scoped_ptr<TabProxy> tab(browser_proxy->GetTab(new_tab_count - 1));
+ ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
+ scoped_ptr<TabProxy> tab(browser_proxy->GetTab(tab_count - 1));
// Navigate to more URLs, then a cross-site URL.
tab->NavigateToURL(http_url2);
diff --git a/chrome/browser/views/tabs/tab_dragging_test.cc b/chrome/browser/views/tabs/tab_dragging_test.cc
index c0471c8..dba2765 100644
--- a/chrome/browser/views/tabs/tab_dragging_test.cc
+++ b/chrome/browser/views/tabs/tab_dragging_test.cc
@@ -56,12 +56,9 @@ TEST_F(TabDraggingTest, Tab1Tab2) {
scoped_ptr<TabProxy> tab3(browser->GetTab(2));
ASSERT_TRUE(tab3.get());
- // Make sure 3 tabs are open
- int final_tab_count = 0;
- ASSERT_TRUE(browser->WaitForTabCountToChange(initial_tab_count,
- &final_tab_count,
+ // Make sure 3 tabs are open.
+ ASSERT_TRUE(browser->WaitForTabCountToBecome(initial_tab_count + 2,
10000));
- ASSERT_TRUE(final_tab_count == initial_tab_count + 2);
// Get bounds for the tabs.
gfx::Rect bounds1;
@@ -159,12 +156,9 @@ TEST_F(TabDraggingTest, Tab1Tab3) {
scoped_ptr<TabProxy> tab3(browser->GetTab(2));
ASSERT_TRUE(tab3.get());
- // Make sure 3 tabs are open
- int final_tab_count = 0;
- ASSERT_TRUE(browser->WaitForTabCountToChange(initial_tab_count,
- &final_tab_count,
+ // Make sure 3 tabs are open.
+ ASSERT_TRUE(browser->WaitForTabCountToBecome(initial_tab_count + 2,
10000));
- ASSERT_TRUE(final_tab_count == initial_tab_count + 2);
// Get bounds for the tabs.
gfx::Rect bounds1;
@@ -269,12 +263,9 @@ TEST_F(TabDraggingTest, Tab1Tab3Escape) {
scoped_ptr<TabProxy> tab3(browser->GetTab(2));
ASSERT_TRUE(tab3.get());
- // Make sure 3 tabs are open
- int final_tab_count = 0;
- ASSERT_TRUE(browser->WaitForTabCountToChange(initial_tab_count,
- &final_tab_count,
+ // Make sure 3 tabs are open.
+ ASSERT_TRUE(browser->WaitForTabCountToBecome(initial_tab_count + 2,
10000));
- ASSERT_TRUE(final_tab_count == initial_tab_count + 2);
// Get bounds for the tabs.
gfx::Rect bounds1;
@@ -383,11 +374,8 @@ TEST_F(TabDraggingTest, Tab2OutOfTabStrip) {
ASSERT_TRUE(tab3.get());
// Make sure 3 tabs are opened.
- int final_tab_count = 0;
- ASSERT_TRUE(browser->WaitForTabCountToChange(initial_tab_count,
- &final_tab_count,
+ ASSERT_TRUE(browser->WaitForTabCountToBecome(initial_tab_count + 2,
10000));
- ASSERT_TRUE(final_tab_count == initial_tab_count + 2);
// Make sure all the tab URL specs are different.
ASSERT_TRUE(tab1_url != tab2_url);
diff --git a/chrome/test/accessibility/accessibility_tests.cc b/chrome/test/accessibility/accessibility_tests.cc
index 4ff6179..bc42dbc 100644
--- a/chrome/test/accessibility/accessibility_tests.cc
+++ b/chrome/test/accessibility/accessibility_tests.cc
@@ -127,22 +127,15 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) {
// Check button and its Name, Role, State.
EXPECT_EQ(l10n_util::GetString(IDS_ACCNAME_BACK), GetName(acc_obj));
EXPECT_EQ(ROLE_SYSTEM_BUTTONDROPDOWN, GetRole(acc_obj));
- // State "has popup" only supported in XP and higher.
- if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
- EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
- STATE_SYSTEM_FOCUSABLE |
- STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- } else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- }
+ EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
+ STATE_SYSTEM_FOCUSABLE |
+ STATE_SYSTEM_UNAVAILABLE,
+ GetState(acc_obj));
// Now check Back status in different situations.
scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
ASSERT_TRUE(window.get());
- int old_tab_count = -1;
- int new_tab_count = -1;
+ int tab_count = -1;
// Set URL and check button status.
scoped_ptr<TabProxy> tab1(window->GetTab(0));
@@ -151,62 +144,40 @@ TEST_F(AccessibilityTest, DISABLED_TestBackBtnStatusOnNewTab) {
file_util::AppendToPath(&test_file1, L"title1.html");
tab1->NavigateToURL(net::FilePathToFileURL(test_file1));
Sleep(sleep_timeout_ms());
- if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
- EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE,
- GetState(acc_obj));
- } else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
- }
+ EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE,
+ GetState(acc_obj));
// Go Back and check status.
window->ApplyAccelerator(IDC_BACK);
Sleep(sleep_timeout_ms());
- if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
- EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
- STATE_SYSTEM_FOCUSABLE |
- STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- } else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- }
+ EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
+ STATE_SYSTEM_FOCUSABLE |
+ STATE_SYSTEM_UNAVAILABLE,
+ GetState(acc_obj));
// Add empty new tab and check status.
- ASSERT_TRUE(window->GetTabCount(&old_tab_count));
+ ASSERT_TRUE(window->GetTabCount(&tab_count));
ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB));
- ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
+ ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
- // Check tab count. Also, check accessibility object's children.
- ASSERT_GE(new_tab_count, old_tab_count);
- if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
- EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
- STATE_SYSTEM_FOCUSABLE |
- STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- } else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- }
+ // Check accessibility object's children.
+ EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
+ STATE_SYSTEM_FOCUSABLE |
+ STATE_SYSTEM_UNAVAILABLE,
+ GetState(acc_obj));
// Add new tab with URL and check status.
- old_tab_count = new_tab_count;
+ ASSERT_TRUE(window->GetTabCount(&tab_count));
std::wstring test_file2 = test_data_directory_;
file_util::AppendToPath(&test_file2, L"title1.html");
ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2)));
- ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
+ ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
- // Check tab count. Also, check accessibility object's children.
- ASSERT_GE(new_tab_count, old_tab_count);
+ // Check accessibility object's children.
Sleep(sleep_timeout_ms());
- if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
- EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
- STATE_SYSTEM_FOCUSABLE |
- STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- } else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- }
-
+ EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
+ STATE_SYSTEM_FOCUSABLE |
+ STATE_SYSTEM_UNAVAILABLE,
+ GetState(acc_obj));
CHK_RELEASE(acc_obj);
}
@@ -266,8 +237,7 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) {
// Now check Back status in different situations.
scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
ASSERT_TRUE(window.get());
- int old_tab_count = -1;
- int new_tab_count = -1;
+ int tab_count = -1;
// Set URL and check button status.
scoped_ptr<TabProxy> tab1(window->GetTab(0));
@@ -276,74 +246,45 @@ TEST_F(AccessibilityTest, DISABLED_TestForwardBtnStatusOnNewTab) {
file_util::AppendToPath(&test_file1, L"title1.html");
tab1->NavigateToURL(net::FilePathToFileURL(test_file1));
Sleep(sleep_timeout_ms());
- if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
- EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
- STATE_SYSTEM_FOCUSABLE |
- STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- } else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- }
+ EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
+ STATE_SYSTEM_FOCUSABLE |
+ STATE_SYSTEM_UNAVAILABLE,
+ GetState(acc_obj));
// Go Back and check status.
window->ApplyAccelerator(IDC_BACK);
Sleep(sleep_timeout_ms());
- if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
- EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE,
- GetState(acc_obj));
- } else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
- }
+ EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE,
+ GetState(acc_obj));
// Go Forward and check status.
window->ApplyAccelerator(IDC_FORWARD);
Sleep(sleep_timeout_ms());
- if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
- EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
- STATE_SYSTEM_FOCUSABLE |
- STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- } else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- }
+ EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
+ STATE_SYSTEM_FOCUSABLE |
+ STATE_SYSTEM_UNAVAILABLE,
+ GetState(acc_obj));
// Add empty new tab and check status.
- ASSERT_TRUE(window->GetTabCount(&old_tab_count));
+ ASSERT_TRUE(window->GetTabCount(&tab_count));
ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB));
- ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
+ ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
- // Check tab count.
- ASSERT_GE(new_tab_count, old_tab_count);
- if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
- EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
- STATE_SYSTEM_FOCUSABLE |
- STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- } else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- }
+ EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
+ STATE_SYSTEM_FOCUSABLE |
+ STATE_SYSTEM_UNAVAILABLE,
+ GetState(acc_obj));
// Add new tab with URL and check status.
- old_tab_count = new_tab_count;
+ ASSERT_TRUE(window->GetTabCount(&tab_count));
std::wstring test_file2 = test_data_directory_;
file_util::AppendToPath(&test_file2, L"title1.html");
ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2)));
- ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
+ ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
- // Check tab count.
- ASSERT_GE(new_tab_count, old_tab_count);
Sleep(sleep_timeout_ms());
- if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
- EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
- STATE_SYSTEM_FOCUSABLE |
- STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- } else {
- EXPECT_EQ(STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_UNAVAILABLE,
- GetState(acc_obj));
- }
-
+ EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
+ STATE_SYSTEM_FOCUSABLE |
+ STATE_SYSTEM_UNAVAILABLE,
+ GetState(acc_obj));
CHK_RELEASE(acc_obj);
}
@@ -394,26 +335,23 @@ TEST_F(AccessibilityTest, DISABLED_TestStarBtnStatusOnNewTab) {
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
// Add empty new tab and check status.
- int old_tab_count = -1;
- ASSERT_TRUE(window->GetTabCount(&old_tab_count));
+ int tab_count = -1;
+ ASSERT_TRUE(window->GetTabCount(&tab_count));
ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB));
- int new_tab_count;
- ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
+ ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
// Check tab count. Also, check accessibility object's state.
- ASSERT_GE(new_tab_count, old_tab_count);
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
// Add new tab with URL and check status.
- old_tab_count = new_tab_count;
+ ASSERT_TRUE(window->GetTabCount(&tab_count));
std::wstring test_file2 = test_data_directory_;
file_util::AppendToPath(&test_file2, L"title1.html");
ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2)));
- ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
+ ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
action_max_timeout_ms()));
// Check tab count. Also, check accessibility object's state.
- ASSERT_GE(new_tab_count, old_tab_count);
Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc
index 0567d26..287e38e 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.cc
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc
@@ -455,11 +455,9 @@ bool AutomatedUITest::CloseActiveTab() {
automation()->GetBrowserWindowCount(&browser_windows_count);
// Avoid quitting the application by not closing the last window.
if (tab_count > 1) {
- int new_tab_count;
return_value = browser->RunCommand(IDC_CLOSE_TAB);
// Wait for the tab to close before we continue.
- if (!browser->WaitForTabCountToChange(tab_count,
- &new_tab_count,
+ if (!browser->WaitForTabCountToBecome(tab_count - 1,
action_max_timeout_ms())) {
AddWarningAttribute("tab_count_failed_to_change");
return false;
diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc
index 1445061..d2d6ac7 100644
--- a/chrome/test/automation/automation_proxy_uitest.cc
+++ b/chrome/test/automation/automation_proxy_uitest.cc
@@ -487,17 +487,14 @@ TEST_F(AutomationProxyTest, NavigateToURLAsync) {
TEST_F(AutomationProxyTest, AcceleratorNewTab) {
scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
- int old_tab_count = -1;
- ASSERT_TRUE(window->GetTabCount(&old_tab_count));
+ int tab_count = -1;
+ ASSERT_TRUE(window->GetTabCount(&tab_count));
ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB));
- int new_tab_count;
- ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
- 5000));
- if (new_tab_count == -1)
- FAIL();
- ASSERT_EQ(old_tab_count + 1, new_tab_count);
- scoped_ptr<TabProxy> tab(window->GetTab(new_tab_count - 1));
+ ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1,
+ action_timeout_ms()));
+ ASSERT_TRUE(window->GetTabCount(&tab_count));
+ scoped_ptr<TabProxy> tab(window->GetTab(tab_count - 1));
ASSERT_TRUE(tab.get());
std::wstring title;
diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc
index 9340a61..240974e 100644
--- a/chrome/test/automation/browser_proxy.cc
+++ b/chrome/test/automation/browser_proxy.cc
@@ -205,24 +205,6 @@ bool BrowserProxy::SimulateDragWithTimeout(const POINT& start,
}
#endif // defined(OS_WIN)
-bool BrowserProxy::WaitForTabCountToChange(int count, int* new_count,
- int wait_timeout) {
- const TimeTicks start = TimeTicks::Now();
- const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout);
- while (TimeTicks::Now() - start < timeout) {
- PlatformThread::Sleep(automation::kSleepTime);
- bool is_timeout;
- bool succeeded = GetTabCountWithTimeout(new_count, wait_timeout,
- &is_timeout);
- if (!succeeded)
- return false;
- if (count != *new_count)
- return true;
- }
- // If we get here, the tab count hasn't changed.
- return false;
-}
-
bool BrowserProxy::WaitForTabCountToBecome(int count, int wait_timeout) {
const TimeTicks start = TimeTicks::Now();
const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout);
diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h
index dffcae1..0e9107c 100644
--- a/chrome/test/automation/browser_proxy.h
+++ b/chrome/test/automation/browser_proxy.h
@@ -139,14 +139,9 @@ class BrowserProxy : public AutomationResourceProxy {
bool press_escape_en_route);
#endif // defined(OS_WIN)
- // Block the thread until the tab count changes.
- // |count| is the original tab count.
- // |new_count| is updated with the number of new tabs.
- // |wait_timeout| is the timeout, in milliseconds, for waiting.
- // Returns false if the tab count does not change.
- bool WaitForTabCountToChange(int count, int* new_count, int wait_timeout);
-
// Block the thread until the tab count is |count|.
+ // |wait_timeout| is the timeout, in milliseconds, for waiting.
+ // Returns true on success.
bool WaitForTabCountToBecome(int count, int wait_timeout);
// Block the thread until the specified tab is the active tab.
diff --git a/chrome/test/startup/feature_startup_test.cc b/chrome/test/startup/feature_startup_test.cc
index 770ceb4..cca5a0b 100644
--- a/chrome/test/startup/feature_startup_test.cc
+++ b/chrome/test/startup/feature_startup_test.cc
@@ -64,28 +64,21 @@ class NewTabUIStartupTest : public UITest {
// first (the first is about:blank).
BrowserProxy* window = automation()->GetBrowserWindow(0);
ASSERT_TRUE(window);
- int old_tab_count = -1;
- ASSERT_TRUE(window->GetTabCount(&old_tab_count));
- ASSERT_EQ(1, old_tab_count);
+ int tab_count = -1;
+ ASSERT_TRUE(window->GetTabCount(&tab_count));
+ ASSERT_EQ(1, tab_count);
// Hit ctl-t and wait for the tab to load.
window->ApplyAccelerator(IDC_NEW_TAB);
- int new_tab_count = -1;
- ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
- 5000));
- ASSERT_EQ(2, new_tab_count);
+ ASSERT_TRUE(window->WaitForTabCountToBecome(2, 5000));
int load_time;
ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time));
timings[i] = TimeDelta::FromMilliseconds(load_time);
if (want_warm) {
// Bring up a second tab, now that we've already shown one tab.
- old_tab_count = new_tab_count;
- new_tab_count = -1;
window->ApplyAccelerator(IDC_NEW_TAB);
- ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count,
- &new_tab_count, 5000));
- ASSERT_EQ(3, new_tab_count);
+ ASSERT_TRUE(window->WaitForTabCountToBecome(3, 5000));
ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time));
timings[i] = TimeDelta::FromMilliseconds(load_time);
}
diff --git a/chrome/test/tab_switching/tab_switching_test.cc b/chrome/test/tab_switching/tab_switching_test.cc
index 5fbbae5..3cbbfa6 100644
--- a/chrome/test/tab_switching/tab_switching_test.cc
+++ b/chrome/test/tab_switching/tab_switching_test.cc
@@ -45,14 +45,13 @@ class TabSwitchingUITest : public UITest {
int initial_tab_count = 0;
ASSERT_TRUE(browser_proxy_->GetTabCount(&initial_tab_count));
int new_tab_count = OpenTabs();
- int final_tab_count = 0;
- ASSERT_TRUE(browser_proxy_->WaitForTabCountToChange(initial_tab_count,
- &final_tab_count,
- 10000));
- ASSERT_TRUE(final_tab_count == initial_tab_count + new_tab_count);
+ ASSERT_TRUE(browser_proxy_->WaitForTabCountToBecome(
+ initial_tab_count + new_tab_count, 10000));
// Switch linearly between tabs.
browser_proxy_->ActivateTab(0);
+ int final_tab_count = 0;
+ ASSERT_TRUE(browser_proxy_->GetTabCount(&final_tab_count));
for (int i = initial_tab_count; i < final_tab_count; ++i) {
browser_proxy_->ActivateTab(i);
ASSERT_TRUE(browser_proxy_->WaitForTabToBecomeActive(i, 10000));