summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/chrome_main_uitest.cc2
-rw-r--r--chrome/browser/browser_uitest.cc6
-rw-r--r--chrome/browser/interstitial_page_uitest.cc10
-rw-r--r--chrome/test/automation/automation_proxy.cc24
-rw-r--r--chrome/test/automation/automation_proxy.h10
-rw-r--r--chrome/test/automation/automation_proxy_uitest.cc2
-rw-r--r--chrome/test/automation/tab_proxy.cc6
-rw-r--r--chrome/test/automation/tab_proxy.h2
-rw-r--r--chrome/test/ui/history_uitest.cc3
-rw-r--r--chrome/test/ui/npapi_uitest.cpp2
-rw-r--r--chrome/test/ui/ui_test.cc42
-rw-r--r--chrome/test/ui/ui_test.h17
-rw-r--r--tools/purify/chrome_tests.py7
13 files changed, 96 insertions, 37 deletions
diff --git a/chrome/app/chrome_main_uitest.cc b/chrome/app/chrome_main_uitest.cc
index 4bde9ea..4217c3b 100644
--- a/chrome/app/chrome_main_uitest.cc
+++ b/chrome/app/chrome_main_uitest.cc
@@ -39,7 +39,7 @@ TEST_F(ChromeMainTest, SecondLaunch) {
int window_count;
ASSERT_TRUE(automation()->WaitForWindowCountToChange(1, &window_count,
- kWaitForActionMsec));
+ action_timeout_ms()));
ASSERT_EQ(2, window_count);
}
diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc
index e6a5033e..f4ca495 100644
--- a/chrome/browser/browser_uitest.cc
+++ b/chrome/browser/browser_uitest.cc
@@ -91,14 +91,14 @@ TEST_F(BrowserTest, WindowsSessionEnd) {
file_util::AppendToPath(&test_file, L"title1.html");
NavigateToURL(net::FilePathToFileURL(test_file));
- Sleep(kWaitForActionMsec);
+ Sleep(action_timeout_ms());
// Simulate an end of session. Normally this happens when the user
// shuts down the pc or logs off.
HWND window_handle = GetMainWindow();
ASSERT_TRUE(::PostMessageW(window_handle, WM_ENDSESSION, 0, 0));
- Sleep(kWaitForActionMsec);
+ Sleep(action_timeout_ms());
ASSERT_FALSE(IsBrowserRunning());
// Make sure the UMA metrics say we didn't crash.
@@ -210,7 +210,7 @@ TEST_F(BrowserTest, DuplicateTab) {
tab_proxy.reset(browser_proxy->GetTab(1));
ASSERT_TRUE(tab_proxy != NULL);
- ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(kWaitForActionMsec));
+ ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms()));
// Verify the stack of urls.
GURL url;
diff --git a/chrome/browser/interstitial_page_uitest.cc b/chrome/browser/interstitial_page_uitest.cc
index c5a9abb..a50908c9 100644
--- a/chrome/browser/interstitial_page_uitest.cc
+++ b/chrome/browser/interstitial_page_uitest.cc
@@ -60,7 +60,7 @@ TEST_F(InterstitialPageTest, TestShowHideInterstitial) {
EXPECT_TRUE(tab->GetPageType(&page_type));
EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type);
- tab->ShowInterstitialPage(kInterstitialPageHTMLText);
+ tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms());
EXPECT_TRUE(tab->GetPageType(&page_type));
EXPECT_EQ(NavigationEntry::INTERSTITIAL_PAGE, page_type);
@@ -84,7 +84,7 @@ TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenBack) {
server.TestServerPageW(L"files/interstitial_page/google.html"));
EXPECT_EQ(L"Google", GetActiveTabTitle());
- tab->ShowInterstitialPage(kInterstitialPageHTMLText);
+ tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms());
EXPECT_EQ(L"Interstitial page", GetActiveTabTitle());
tab->GoBack();
@@ -100,7 +100,7 @@ TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenNavigate) {
server.TestServerPageW(L"files/interstitial_page/google.html"));
EXPECT_EQ(L"Google", GetActiveTabTitle());
- tab->ShowInterstitialPage(kInterstitialPageHTMLText);
+ tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms());
EXPECT_EQ(L"Interstitial page", GetActiveTabTitle());
tab->NavigateToURL(
@@ -117,7 +117,7 @@ TEST_F(InterstitialPageTest, TestShowInterstitialThenCloseTab) {
::scoped_ptr<TabProxy> tab(GetActiveTabProxy());
EXPECT_EQ(L"Google", GetActiveTabTitle());
- tab->ShowInterstitialPage(kInterstitialPageHTMLText);
+ tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms());
EXPECT_EQ(L"Interstitial page", GetActiveTabTitle());
tab->Close();
}
@@ -133,7 +133,7 @@ TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenCloseBrowser) {
server.TestServerPageW(L"files/interstitial_page/google.html"));
EXPECT_EQ(L"Google", GetActiveTabTitle());
- tab->ShowInterstitialPage(kInterstitialPageHTMLText);
+ tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms());
EXPECT_EQ(L"Interstitial page", GetActiveTabTitle());
scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc
index 60806b5..87ed3680 100644
--- a/chrome/test/automation/automation_proxy.cc
+++ b/chrome/test/automation/automation_proxy.cc
@@ -141,9 +141,9 @@ class AutomationMessageFilter : public IPC::ChannelProxy::MessageFilter {
} // anonymous namespace
-const int AutomationProxy::kMaxCommandExecutionTime = 30000;
-
-AutomationProxy::AutomationProxy() : current_request_(NULL) {
+AutomationProxy::AutomationProxy(int command_execution_timeout_ms)
+ : current_request_(NULL),
+ command_execution_timeout_ms_(command_execution_timeout_ms) {
InitializeEvents();
InitializeChannelID();
InitializeThread();
@@ -210,7 +210,7 @@ void AutomationProxy::InitializeHandleTracker() {
bool AutomationProxy::WaitForAppLaunch() {
return ::WaitForSingleObject(app_launched_,
- kMaxCommandExecutionTime) == WAIT_OBJECT_0;
+ command_execution_timeout_ms_) == WAIT_OBJECT_0;
}
void AutomationProxy::SignalAppLaunch() {
@@ -219,12 +219,12 @@ void AutomationProxy::SignalAppLaunch() {
bool AutomationProxy::WaitForInitialLoads() {
return ::WaitForSingleObject(initial_loads_complete_,
- kMaxCommandExecutionTime) == WAIT_OBJECT_0;
+ command_execution_timeout_ms_) == WAIT_OBJECT_0;
}
bool AutomationProxy::WaitForInitialNewTabUILoad(int* load_time) {
if (::WaitForSingleObject(new_tab_ui_load_complete_,
- kMaxCommandExecutionTime) == WAIT_OBJECT_0) {
+ command_execution_timeout_ms_) == WAIT_OBJECT_0) {
*load_time = new_tab_ui_load_time_;
::ResetEvent(new_tab_ui_load_complete_);
return true;
@@ -252,7 +252,7 @@ bool AutomationProxy::GetBrowserWindowCount(int* num_windows) {
bool succeeded = SendAndWaitForResponseWithTimeout(
new AutomationMsg_BrowserWindowCountRequest(0), &response,
AutomationMsg_BrowserWindowCountResponse::ID,
- kMaxCommandExecutionTime, &is_timeout);
+ command_execution_timeout_ms_, &is_timeout);
if (!succeeded)
return false;
@@ -316,7 +316,7 @@ bool AutomationProxy::GetShowingAppModalDialog(
if (!SendAndWaitForResponseWithTimeout(
new AutomationMsg_ShowingAppModalDialogRequest(0), &response,
AutomationMsg_ShowingAppModalDialogResponse::ID,
- kMaxCommandExecutionTime, &is_timeout)) {
+ command_execution_timeout_ms_, &is_timeout)) {
return false;
}
@@ -344,7 +344,7 @@ bool AutomationProxy::ClickAppModalDialogButton(
new AutomationMsg_ClickAppModalDialogButtonRequest(0, button),
&response,
AutomationMsg_ClickAppModalDialogButtonResponse::ID,
- kMaxCommandExecutionTime, &is_timeout)) {
+ command_execution_timeout_ms_, &is_timeout)) {
return false;
}
@@ -400,7 +400,7 @@ WindowProxy* AutomationProxy::GetActiveWindow() {
bool succeeded = SendAndWaitForResponseWithTimeout(
new AutomationMsg_ActiveWindowRequest(0), &response,
AutomationMsg_ActiveWindowResponse::ID,
- kMaxCommandExecutionTime, &is_timeout);
+ command_execution_timeout_ms_, &is_timeout);
if (!succeeded)
return NULL;
@@ -425,7 +425,7 @@ BrowserProxy* AutomationProxy::GetBrowserWindow(int window_index) {
bool succeeded = SendAndWaitForResponseWithTimeout(
new AutomationMsg_BrowserWindowRequest(0, window_index), &response,
AutomationMsg_BrowserWindowResponse::ID,
- kMaxCommandExecutionTime, &is_timeout);
+ command_execution_timeout_ms_, &is_timeout);
if (!succeeded)
return NULL;
@@ -450,7 +450,7 @@ BrowserProxy* AutomationProxy::GetLastActiveBrowserWindow() {
bool succeeded = SendAndWaitForResponseWithTimeout(
new AutomationMsg_LastActiveBrowserWindowRequest(0),
&response, AutomationMsg_LastActiveBrowserWindowResponse::ID,
- kMaxCommandExecutionTime, &is_timeout);
+ command_execution_timeout_ms_, &is_timeout);
if (!succeeded)
return NULL;
diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h
index 0c147fa..f068a0d 100644
--- a/chrome/test/automation/automation_proxy.h
+++ b/chrome/test/automation/automation_proxy.h
@@ -60,7 +60,7 @@ class AutomationMessageSender : public IPC::Message::Sender {
class AutomationProxy : public IPC::Channel::Listener,
public AutomationMessageSender {
public:
- AutomationProxy();
+ explicit AutomationProxy(int command_execution_timeout_ms);
virtual ~AutomationProxy();
// IPC callback
@@ -204,6 +204,10 @@ class AutomationProxy : public IPC::Channel::Listener,
// that can be reparented in another process.
TabProxy* CreateExternalTab(HWND* external_tab_container);
+ int command_execution_timeout_ms() const {
+ return command_execution_timeout_ms_;
+ }
+
private:
DISALLOW_EVIL_CONSTRUCTORS(AutomationProxy);
@@ -225,8 +229,8 @@ class AutomationProxy : public IPC::Channel::Listener,
AutomationRequest* current_request_;
- static const int kMaxCommandExecutionTime; // Delay to let the browser
- // execute the command.;
+ // Delay to let the browser execute the command.
+ int command_execution_timeout_ms_;
};
#endif // CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H__
diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc
index e145675..77721ce 100644
--- a/chrome/test/automation/automation_proxy_uitest.cc
+++ b/chrome/test/automation/automation_proxy_uitest.cc
@@ -791,7 +791,7 @@ TEST_F(AutomationProxyTest, AutocompleteParallelProxy) {
scoped_ptr<AutocompleteEditProxy> edit2(
automation()->GetAutocompleteEditForBrowser(browser2.get()));
ASSERT_TRUE(edit2.get());
- EXPECT_TRUE(browser2->GetTab(0)->WaitForTabToBeRestored(kWaitForActionMsec));
+ EXPECT_TRUE(browser2->GetTab(0)->WaitForTabToBeRestored(action_timeout_ms()));
const std::wstring text_to_set1 = L"Lollerskates";
const std::wstring text_to_set2 = L"Roflcopter";
std::wstring actual_text1, actual_text2;
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index 91cdd1b..a63e08a 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -723,17 +723,17 @@ bool TabProxy::GetDownloadDirectory(std::wstring* download_directory) {
return true;
}
-bool TabProxy::ShowInterstitialPage(const std::string& html_text) {
+bool TabProxy::ShowInterstitialPage(const std::string& html_text,
+ int timeout_ms) {
if (!is_valid())
return false;
- const int kTimeout = 2000;
bool is_timeout = false;
IPC::Message* response = NULL;
bool succeeded = sender_->SendAndWaitForResponseWithTimeout(
new AutomationMsg_ShowInterstitialPageRequest(0, handle_, html_text),
&response,
- AutomationMsg_ShowInterstitialPageResponse::ID, kTimeout, &is_timeout);
+ AutomationMsg_ShowInterstitialPageResponse::ID, timeout_ms, &is_timeout);
if (!succeeded || !is_timeout)
return false;
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h
index 07e3617..15d72c2 100644
--- a/chrome/test/automation/tab_proxy.h
+++ b/chrome/test/automation/tab_proxy.h
@@ -206,7 +206,7 @@ class TabProxy : public AutomationResourceProxy {
// Shows an interstitial page. Blocks until the interstitial page
// has been loaded. Return false if a failure happens.3
- bool ShowInterstitialPage(const std::string& html_text);
+ bool ShowInterstitialPage(const std::string& html_text, int timeout_ms);
// Hides the currently shown interstitial page. Blocks until the interstitial
// page has been hidden. Return false if a failure happens.
diff --git a/chrome/test/ui/history_uitest.cc b/chrome/test/ui/history_uitest.cc
index 931024f..25ee75e 100644
--- a/chrome/test/ui/history_uitest.cc
+++ b/chrome/test/ui/history_uitest.cc
@@ -37,7 +37,6 @@
const char kTestCompleteCookie[] = "status";
const char kTestCompleteSuccess[] = "OK";
-const int kShortWaitTimeout = 5 * 1000;
class HistoryTester : public UITest {
protected:
@@ -54,5 +53,5 @@ TEST_F(HistoryTester, VerifyHistoryLength) {
GURL url = GetTestUrl(L"History", test_case);
NavigateToURL(url);
WaitForFinish("History_Length_Test", "1", url, kTestCompleteCookie,
- kTestCompleteSuccess, kShortWaitTimeout);
+ kTestCompleteSuccess, action_max_timeout_ms());
}
diff --git a/chrome/test/ui/npapi_uitest.cpp b/chrome/test/ui/npapi_uitest.cpp
index b2d48a3..b1e053e 100644
--- a/chrome/test/ui/npapi_uitest.cpp
+++ b/chrome/test/ui/npapi_uitest.cpp
@@ -259,5 +259,5 @@ TEST_F(NPAPIVisiblePluginTester, OpenPopupWindowWithPlugin) {
NavigateToURL(url);
WaitForFinish("plugin_popup_with_plugin_target", "1", url,
kTestCompleteCookie, kTestCompleteSuccess,
- kShortWaitTimeout);
+ action_timeout_ms());
}
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index fbf03f9..4d58e6a 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -50,6 +50,14 @@ bool UITest::disable_breakpad_ = false;
int UITest::timeout_ms_ = 20 * 60 * 1000;
std::wstring UITest::js_flags_ = L"";
+
+// Specify the time (in milliseconds) that the ui_tests should wait before
+// timing out. This is used to specify longer timeouts when running under Purify
+// which requires much more time.
+const wchar_t kUiTestTimeout[] = L"ui-test-timeout";
+const wchar_t kUiTestActionTimeout[] = L"ui-test-action-timeout";
+const wchar_t kUiTestActionMaxTimeout[] = L"ui-test-action-max-timeout";
+
const wchar_t kExtraChromeFlagsSwitch[] = L"extra-chrome-flags";
// Uncomment this line to have the spawned process wait for the debugger to
@@ -81,7 +89,10 @@ UITest::UITest()
show_window_(false),
clear_profile_(true),
include_testing_id_(true),
- use_existing_browser_(default_use_existing_browser_) {
+ use_existing_browser_(default_use_existing_browser_),
+ command_execution_timeout_ms_(kMaxTestExecutionTime),
+ action_timeout_ms_(kWaitForActionMsec),
+ action_max_timeout_ms_(kWaitForActionMaxMsec) {
PathService::Get(chrome::DIR_APP, &browser_directory_);
PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_);
GetSystemTimeAsFileTime(&test_start_time_);
@@ -93,6 +104,7 @@ void UITest::SetUp() {
L"of the app before testing.");
}
+ InitializeTimeouts();
LaunchBrowserAndServer();
}
@@ -130,9 +142,31 @@ void UITest::TearDown() {
EXPECT_EQ(expected_crashes_, actual_crashes) << error_msg;
}
+// Pick up the various test time out values from the command line.
+void UITest::InitializeTimeouts() {
+ if (CommandLine().HasSwitch(kUiTestTimeout)) {
+ std::wstring timeout_str = CommandLine().GetSwitchValue(kUiTestTimeout);
+ int timeout = StringToInt(timeout_str);
+ command_execution_timeout_ms_ = std::max(kMaxTestExecutionTime, timeout);
+ }
+
+ if (CommandLine().HasSwitch(kUiTestActionTimeout)) {
+ std::wstring act_str = CommandLine().GetSwitchValue(kUiTestActionTimeout);
+ int act_timeout = StringToInt(act_str);
+ action_timeout_ms_ = std::max(kWaitForActionMsec, act_timeout);
+ }
+
+ if (CommandLine().HasSwitch(kUiTestActionMaxTimeout)) {
+ std::wstring action_max_str =
+ CommandLine().GetSwitchValue(kUiTestActionMaxTimeout);
+ int max_timeout = StringToInt(action_max_str);
+ action_max_timeout_ms_ = std::max(kWaitForActionMaxMsec, max_timeout);
+ }
+}
+
void UITest::LaunchBrowserAndServer() {
// Set up IPC testing interface server.
- server_.reset(new AutomationProxy);
+ server_.reset(new AutomationProxy(command_execution_timeout_ms_));
LaunchBrowser(launch_arguments_, clear_profile_);
if (wait_for_initial_loads_)
@@ -369,8 +403,8 @@ void UITest::NavigateToURL(const GURL& url) {
return;
bool is_timeout = true;
- ASSERT_TRUE(tab_proxy->NavigateToURLWithTimeout(url, kMaxTestExecutionTime,
- &is_timeout)) << url.spec();
+ ASSERT_TRUE(tab_proxy->NavigateToURLWithTimeout(
+ url, command_execution_timeout_ms(), &is_timeout)) << url.spec();
ASSERT_FALSE(is_timeout) << url.spec();
}
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 8a6aa0a..8601bb8 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -37,6 +37,7 @@ class UITest : public testing::Test {
static const int kWaitForActionMaxMsec = 10000;
// Delay to let the browser complete the test.
static const int kMaxTestExecutionTime = 30000;
+
// String to display when a test fails because the crash service isn't
// running.
static const wchar_t kFailedNoCrashService[];
@@ -56,6 +57,9 @@ class UITest : public testing::Test {
// Closes the browser window.
virtual void TearDown();
+ // Set up the test time out values.
+ virtual void InitializeTimeouts();
+
// ********* Utility functions *********
// Launches the browser and IPC testing server.
@@ -294,6 +298,15 @@ class UITest : public testing::Test {
// UITest::SetUp().
std::wstring user_data_dir() const { return user_data_dir_; }
+ // Timeout accessors.
+ int command_execution_timeout_ms() const {
+ return command_execution_timeout_ms_;
+ }
+
+ int action_timeout_ms() const { return action_timeout_ms_; }
+
+ int action_max_timeout_ms() const { return action_max_timeout_ms_; }
+
// Count the number of active browser processes. This function only counts
// browser processes that share the same profile directory as the current
// process. The count includes browser sub-processes.
@@ -407,6 +420,10 @@ class UITest : public testing::Test {
::scoped_ptr<AutomationProxy> server_;
MessageLoop message_loop_; // Enables PostTask to main thread.
+
+ int command_execution_timeout_ms_;
+ int action_timeout_ms_;
+ int action_max_timeout_ms_;
};
// These exist only to support the gTest assertion macros, and
diff --git a/tools/purify/chrome_tests.py b/tools/purify/chrome_tests.py
index 5b2c535..63f92ce 100644
--- a/tools/purify/chrome_tests.py
+++ b/tools/purify/chrome_tests.py
@@ -285,7 +285,12 @@ class ChromeTests:
if instrumentation_error:
return instrumentation_error
return self.ScriptedTest("chrome", "chrome.exe", "ui_tests",
- ["ui_tests.exe", "--single-process", "--test-timeout=100000000"], multi=True)
+ ["ui_tests.exe",
+ "--single-process",
+ "--ui-test-timeout=120000",
+ "--ui-test-action-timeout=80000",
+ "--ui-test-action-max-timeout=180000"],
+ multi=True)
def _main(argv):