summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/accessibility/accessibility_tests.cc32
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.cc42
-rw-r--r--chrome/test/automation/automation_proxy_uitest.cc4
-rw-r--r--chrome/test/reliability/page_load_test.cc8
-rw-r--r--chrome/test/ui/ui_test.cc14
-rw-r--r--chrome/test/ui/ui_test.h16
6 files changed, 58 insertions, 58 deletions
diff --git a/chrome/test/accessibility/accessibility_tests.cc b/chrome/test/accessibility/accessibility_tests.cc
index bff3296..6b83812 100644
--- a/chrome/test/accessibility/accessibility_tests.cc
+++ b/chrome/test/accessibility/accessibility_tests.cc
@@ -151,7 +151,7 @@ TEST_F(AccessibilityTest, TestBackBtnStatusOnNewTab) {
std::wstring test_file1 = test_data_directory_;
file_util::AppendToPath(&test_file1, L"title1.html");
tab1->NavigateToURL(net::FilePathToFileURL(test_file1));
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE,
GetState(acc_obj));
@@ -160,7 +160,7 @@ TEST_F(AccessibilityTest, TestBackBtnStatusOnNewTab) {
}
// Go Back and check status.
window->ApplyAccelerator(IDC_BACK);
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
@@ -175,7 +175,7 @@ TEST_F(AccessibilityTest, TestBackBtnStatusOnNewTab) {
ASSERT_TRUE(window->GetTabCount(&old_tab_count));
ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB));
ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
- kWaitForActionMsec * 5));
+ 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) {
@@ -194,10 +194,10 @@ TEST_F(AccessibilityTest, TestBackBtnStatusOnNewTab) {
file_util::AppendToPath(&test_file2, L"title1.html");
ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2)));
ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
- kWaitForActionMsec * 5));
+ action_max_timeout_ms()));
// Check tab count. Also, check accessibility object's children.
ASSERT_GE(new_tab_count, old_tab_count);
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
@@ -276,7 +276,7 @@ TEST_F(AccessibilityTest, TestForwardBtnStatusOnNewTab) {
std::wstring test_file1 = test_data_directory_;
file_util::AppendToPath(&test_file1, L"title1.html");
tab1->NavigateToURL(net::FilePathToFileURL(test_file1));
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
@@ -288,7 +288,7 @@ TEST_F(AccessibilityTest, TestForwardBtnStatusOnNewTab) {
}
// Go Back and check status.
window->ApplyAccelerator(IDC_BACK);
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP | STATE_SYSTEM_FOCUSABLE,
GetState(acc_obj));
@@ -297,7 +297,7 @@ TEST_F(AccessibilityTest, TestForwardBtnStatusOnNewTab) {
}
// Go Forward and check status.
window->ApplyAccelerator(IDC_FORWARD);
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
@@ -312,7 +312,7 @@ TEST_F(AccessibilityTest, TestForwardBtnStatusOnNewTab) {
ASSERT_TRUE(window->GetTabCount(&old_tab_count));
ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB));
ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
- kWaitForActionMsec * 5));
+ action_max_timeout_ms()));
// Check tab count.
ASSERT_GE(new_tab_count, old_tab_count);
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
@@ -331,10 +331,10 @@ TEST_F(AccessibilityTest, TestForwardBtnStatusOnNewTab) {
file_util::AppendToPath(&test_file2, L"title1.html");
ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2)));
ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
- kWaitForActionMsec * 5));
+ action_max_timeout_ms()));
// Check tab count.
ASSERT_GE(new_tab_count, old_tab_count);
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
if (win_util::GetWinVersion() > win_util::WINVERSION_2000) {
EXPECT_EQ(STATE_SYSTEM_HASPOPUP |
STATE_SYSTEM_FOCUSABLE |
@@ -391,7 +391,7 @@ TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) {
std::wstring test_file1 = test_data_directory_;
file_util::AppendToPath(&test_file1, L"title1.html");
tab1->NavigateToURL(net::FilePathToFileURL(test_file1));
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
// Add empty new tab and check status.
@@ -400,10 +400,10 @@ TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) {
ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB));
int new_tab_count;
ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
- kWaitForActionMsec * 5));
+ action_max_timeout_ms()));
// Check tab count. Also, check accessibility object's state.
ASSERT_GE(new_tab_count, old_tab_count);
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
// Add new tab with URL and check status.
@@ -412,10 +412,10 @@ TEST_F(AccessibilityTest, TestStarBtnStatusOnNewTab) {
file_util::AppendToPath(&test_file2, L"title1.html");
ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(test_file2)));
ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count,
- kWaitForActionMsec * 5));
+ action_max_timeout_ms()));
// Check tab count. Also, check accessibility object's state.
ASSERT_GE(new_tab_count, old_tab_count);
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
EXPECT_EQ(STATE_SYSTEM_FOCUSABLE, GetState(acc_obj));
CHK_RELEASE(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 3f1f317..dcbac5b 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.cc
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc
@@ -398,7 +398,7 @@ bool AutomatedUITest::OpenAndActivateNewBrowserWindow() {
return false;
}
bool is_timeout;
- if (!browser->ActivateTabWithTimeout(0, kWaitForActionMaxMsec,
+ if (!browser->ActivateTabWithTimeout(0, action_max_timeout_ms(),
&is_timeout)) {
AddWarningAttribute("failed_to_activate_tab");
return false;
@@ -439,7 +439,8 @@ bool AutomatedUITest::CloseActiveTab() {
int browser_windows_count;
int tab_count;
bool is_timeout;
- browser->GetTabCountWithTimeout(&tab_count, kWaitForActionMaxMsec,
+ browser->GetTabCountWithTimeout(&tab_count,
+ action_max_timeout_ms(),
&is_timeout);
automation()->GetBrowserWindowCount(&browser_windows_count);
// Avoid quitting the application by not closing the last window.
@@ -447,8 +448,9 @@ bool AutomatedUITest::CloseActiveTab() {
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, kWaitForActionMaxMsec)) {
+ if (!browser->WaitForTabCountToChange(tab_count,
+ &new_tab_count,
+ action_max_timeout_ms())) {
AddWarningAttribute("tab_count_failed_to_change");
return false;
}
@@ -456,8 +458,9 @@ bool AutomatedUITest::CloseActiveTab() {
int new_window_count;
return_value = browser->RunCommand(IDC_CLOSE_TAB);
// Wait for the window to close before we continue.
- if (!automation()->WaitForWindowCountToChange(
- browser_windows_count, &new_window_count, kWaitForActionMaxMsec)) {
+ if (!automation()->WaitForWindowCountToChange(browser_windows_count,
+ &new_window_count,
+ action_max_timeout_ms())) {
AddWarningAttribute("window_count_failed_to_change");
return false;
}
@@ -504,7 +507,7 @@ bool AutomatedUITest::Navigate() {
}
bool did_timeout;
scoped_ptr<TabProxy> tab(
- browser->GetActiveTabWithTimeout(kWaitForActionMaxMsec, &did_timeout));
+ browser->GetActiveTabWithTimeout(action_max_timeout_ms(), &did_timeout));
// TODO(devint): This might be masking a bug. I can't think of many
// valid cases where we would get a browser window, but not be able
// to return an active tab. Yet this has happened and has triggered crashes.
@@ -519,7 +522,9 @@ bool AutomatedUITest::Navigate() {
}
GURL test_url(url);
did_timeout = false;
- tab->NavigateToURLWithTimeout(test_url, kMaxTestExecutionTime, &did_timeout);
+ tab->NavigateToURLWithTimeout(test_url,
+ command_execution_timeout_ms(),
+ &did_timeout);
if (did_timeout) {
AddWarningAttribute("timeout");
@@ -537,13 +542,15 @@ bool AutomatedUITest::NewTab() {
int old_tab_count;
int new_tab_count;
bool is_timeout;
- browser->GetTabCountWithTimeout(&old_tab_count, kWaitForActionMaxMsec,
- &is_timeout);
+ browser->GetTabCountWithTimeout(&old_tab_count,
+ action_max_timeout_ms(),
+ &is_timeout);
// Apply accelerator and wait for a new tab to open, if either
// fails, return false. Apply Accelerator takes care of logging its failure.
bool return_value = RunCommand(IDC_NEW_TAB);
- if (!browser->WaitForTabCountToChange(
- old_tab_count, &new_tab_count, kWaitForActionMaxMsec)) {
+ if (!browser->WaitForTabCountToChange(old_tab_count,
+ &new_tab_count,
+ action_max_timeout_ms())) {
AddWarningAttribute("tab_count_failed_to_change");
return false;
}
@@ -746,7 +753,8 @@ bool AutomatedUITest::DragActiveTab(bool drag_right, bool drag_out) {
return false;
}
int tab_count;
- browser->GetTabCountWithTimeout(&tab_count, kWaitForActionMaxMsec,
+ browser->GetTabCountWithTimeout(&tab_count,
+ action_max_timeout_ms(),
&is_timeout);
// As far as we're concerned, if we can't get a view for a tab, it doesn't
// exist, so cap tab_count at the number of tab view ids there are.
@@ -754,7 +762,7 @@ bool AutomatedUITest::DragActiveTab(bool drag_right, bool drag_out) {
int tab_index;
if (!browser->GetActiveTabIndexWithTimeout(&tab_index,
- kWaitForActionMaxMsec,
+ action_max_timeout_ms(),
&is_timeout)) {
AddWarningAttribute("no_active_tab");
return false;
@@ -763,7 +771,7 @@ bool AutomatedUITest::DragActiveTab(bool drag_right, bool drag_out) {
gfx::Rect dragged_tab_bounds;
if (!window->GetViewBoundsWithTimeout(VIEW_ID_TAB_0 + tab_index,
&dragged_tab_bounds, false,
- kWaitForActionMaxMsec,
+ action_max_timeout_ms(),
&is_timeout)) {
AddWarningAttribute("no_tab_view_found");
return false;
@@ -794,7 +802,7 @@ bool AutomatedUITest::DragActiveTab(bool drag_right, bool drag_out) {
if (!browser->SimulateDragWithTimeout(dragged_tab_point,
destination_point,
views::Event::EF_LEFT_BUTTON_DOWN,
- kWaitForActionMaxMsec,
+ action_max_timeout_ms(),
&is_timeout, false)) {
AddWarningAttribute("failed_to_simulate_drag");
return false;
@@ -820,7 +828,7 @@ WindowProxy* AutomatedUITest::GetAndActivateWindowForBrowser(
WindowProxy* window = automation()->GetWindowForBrowser(browser);
bool did_timeout;
- if (!browser->BringToFrontWithTimeout(kWaitForActionMaxMsec, &did_timeout)) {
+ if (!browser->BringToFrontWithTimeout(action_max_timeout_ms(), &did_timeout)) {
AddWarningAttribute("failed_to_bring_window_to_front");
return NULL;
}
diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc
index 053e69c..33c6a30 100644
--- a/chrome/test/automation/automation_proxy_uitest.cc
+++ b/chrome/test/automation/automation_proxy_uitest.cc
@@ -489,7 +489,7 @@ TEST_F(AutomationProxyTest, AcceleratorNewTab) {
std::wstring title;
int i;
for (i = 0; i < 10; ++i) {
- Sleep(kWaitForActionMaxMsec / 10);
+ Sleep(sleep_timeout_ms());
ASSERT_TRUE(tab->GetTabTitle(&title));
if (title == L"Destinations" || title == L"New Tab")
break;
@@ -626,7 +626,7 @@ TEST_F(AutomationProxyTest3, FrameDocumentCanBeAccessed) {
std::wstring title;
int i;
for (i = 0; i < 10; ++i) {
- Sleep(kWaitForActionMaxMsec / 10);
+ Sleep(sleep_timeout_ms());
ASSERT_TRUE(tab->GetTabTitle(&title));
if (title == L"Destinations")
break;
diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc
index 16b32b5..353c599 100644
--- a/chrome/test/reliability/page_load_test.cc
+++ b/chrome/test/reliability/page_load_test.cc
@@ -102,8 +102,6 @@ bool save_debug_log = false;
std::wstring chrome_log_path;
std::wstring v8_log_path;
-int kWaitForActionMsec = 4000;
-
class PageLoadTest : public UITest {
public:
enum NavigationResult {
@@ -160,13 +158,13 @@ class PageLoadTest : public UITest {
automation()->GetWindowForBrowser(browser.get()));
if (window.get()) {
bool activation_timeout;
- browser->BringToFrontWithTimeout(kWaitForActionMsec,
+ browser->BringToFrontWithTimeout(action_max_timeout_ms(),
&activation_timeout);
if (!activation_timeout) {
window->SimulateOSKeyPress(VK_NEXT, 0);
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
window->SimulateOSKeyPress(VK_NEXT, 0);
- Sleep(kWaitForActionMsec);
+ Sleep(sleep_timeout_ms());
}
}
}
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index b35305d..3393d69 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -38,10 +38,10 @@
using base::TimeTicks;
// Delay to let browser complete a requested action.
-const int UITest::kWaitForActionMsec = 2000;
-const int UITest::kWaitForActionMaxMsec = 10000;
+static const int kWaitForActionMsec = 2000;
+static const int kWaitForActionMaxMsec = 10000;
// Delay to let the browser complete the test.
-const int UITest::kMaxTestExecutionTime = 30000;
+static const int kMaxTestExecutionTime = 30000;
const wchar_t UITest::kFailedNoCrashService[] =
L"NOTE: This test is expected to fail if crash_service.exe is not "
@@ -85,7 +85,7 @@ bool UITest::DieFileDie(const std::wstring& file, bool recurse) {
for (int i = 0; i < 10; ++i) {
if (file_util::Delete(file, recurse))
return true;
- PlatformThread::Sleep(kWaitForActionMaxMsec / 10);
+ PlatformThread::Sleep(action_max_timeout_ms() / 10);
}
return false;
}
@@ -520,7 +520,7 @@ bool UITest::WaitForFindWindowVisibilityChange(TabProxy* tab,
return true; // Find window visibility change complete.
// Give it a chance to catch up.
- Sleep(kWaitForActionMaxMsec / kCycles);
+ Sleep(sleep_timeout_ms() / kCycles);
}
return false;
}
@@ -537,7 +537,7 @@ bool UITest::WaitForBookmarkBarVisibilityChange(BrowserProxy* browser,
return true; // Bookmark bar visibility change complete.
// Give it a chance to catch up.
- Sleep(kWaitForActionMaxMsec / kCycles);
+ Sleep(sleep_timeout_ms() / kCycles);
}
return false;
}
@@ -671,7 +671,7 @@ std::string UITest::WaitUntilCookieNonEmpty(TabProxy* tab,
void UITest::WaitUntilTabCount(int tab_count) {
for (int i = 0; i < 10; ++i) {
- Sleep(kWaitForActionMaxMsec / 10);
+ Sleep(sleep_timeout_ms() / 10);
if (GetTabCount() == tab_count)
break;
}
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 7baeb60..7f6c906 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -45,21 +45,10 @@ class TabProxy;
class UITest : public testing::Test {
protected:
- // Delay to let browser complete a requested action.
- static const int kWaitForActionMsec;
- static const int kWaitForActionMaxMsec;
- // Delay to let the browser complete the test.
- static const int kMaxTestExecutionTime;
-
// String to display when a test fails because the crash service isn't
// running.
static const wchar_t kFailedNoCrashService[];
- // Tries to delete the specified file/directory returning true on success.
- // This differs from file_util::Delete in that it repeatedly invokes Delete
- // until successful, or a timeout is reached. Returns true on success.
- static bool DieFileDie(const std::wstring& file, bool recurse);
-
// Constructor
UITest();
@@ -75,6 +64,11 @@ class UITest : public testing::Test {
// ********* Utility functions *********
+ // Tries to delete the specified file/directory returning true on success.
+ // This differs from file_util::Delete in that it repeatedly invokes Delete
+ // until successful, or a timeout is reached. Returns true on success.
+ bool DieFileDie(const std::wstring& file, bool recurse);
+
// Launches the browser and IPC testing server.
void LaunchBrowserAndServer();