summaryrefslogtreecommitdiffstats
path: root/chrome/test/ui/ui_test.cc
diff options
context:
space:
mode:
authorpatrick@chromium.org <patrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-18 03:39:26 +0000
committerpatrick@chromium.org <patrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-18 03:39:26 +0000
commitde307f3413a7acb430281e67f814ffd0c030a11c (patch)
treec178d9667c717faa276fc019be3ea7d0a6ef7c64 /chrome/test/ui/ui_test.cc
parenta1b155ed4f131575ebf73b115c6f6295858bb330 (diff)
downloadchromium_src-de307f3413a7acb430281e67f814ffd0c030a11c.zip
chromium_src-de307f3413a7acb430281e67f814ffd0c030a11c.tar.gz
chromium_src-de307f3413a7acb430281e67f814ffd0c030a11c.tar.bz2
- Modify DOM checker automation to use DOM Automation Controller instead of
cookie values to get results back to the test executable. This fixes an issue where the test could not be automated to run from local disk - that required file cookies, which causes the DOM checker test to fail. This is also a cleaner approach. - Add test to run DOM checker automation from local disk. - Add code to optionally disable file cookies in UI tests. Disable them in the DOM checker tests. - Add a function to the UITest class that allows a test to wait for a JavaScript condition in the test page. BUG=6274 Review URL: http://codereview.chromium.org/48055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11945 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui/ui_test.cc')
-rw-r--r--chrome/test/ui/ui_test.cc34
1 files changed, 33 insertions, 1 deletions
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 800f593..66d7e75 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -108,6 +108,7 @@ UITest::UITest()
clear_profile_(true),
include_testing_id_(true),
use_existing_browser_(default_use_existing_browser_),
+ enable_file_cookies_(true),
command_execution_timeout_ms_(kMaxTestExecutionTime),
action_timeout_ms_(kWaitForActionMsec),
action_max_timeout_ms_(kWaitForActionMaxMsec),
@@ -256,7 +257,8 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
}
// We need cookies on file:// for things like the page cycler.
- command_line.AppendSwitch(switches::kEnableFileCookies);
+ if (enable_file_cookies_)
+ command_line.AppendSwitch(switches::kEnableFileCookies);
if (dom_automation_enabled_)
command_line.AppendSwitch(switches::kDomAutomationController);
@@ -675,6 +677,36 @@ std::string UITest::WaitUntilCookieNonEmpty(TabProxy* tab,
return cookie_value;
}
+bool UITest::WaitUntilJavaScriptCondition(TabProxy* tab,
+ const std::wstring& frame_xpath,
+ const std::wstring& jscript,
+ int interval_ms,
+ int time_out_ms) {
+ DCHECK_GE(time_out_ms, interval_ms);
+ DCHECK_GT(interval_ms, 0);
+ const int kMaxIntervals = time_out_ms / interval_ms;
+
+ // Wait until the test signals it has completed.
+ bool completed = false;
+ for (int i = 0; i < kMaxIntervals; ++i) {
+ bool browser_survived = CrashAwareSleep(interval_ms);
+
+ EXPECT_TRUE(browser_survived);
+ if (!browser_survived)
+ break;
+
+ bool done_value = false;
+ EXPECT_TRUE(tab->ExecuteAndExtractBool(frame_xpath, jscript, &done_value));
+
+ if (done_value) {
+ completed = true;
+ break;
+ }
+ }
+
+ return completed;
+}
+
void UITest::WaitUntilTabCount(int tab_count) {
for (int i = 0; i < 10; ++i) {
PlatformThread::Sleep(sleep_timeout_ms() / 10);