OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/test/test_timeouts.h" |
10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
11 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
12 #include "chrome/test/automation/tab_proxy.h" | 13 #include "chrome/test/automation/tab_proxy.h" |
13 #include "chrome/test/ui/ui_test.h" | 14 #include "chrome/test/ui/ui_test.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 // Provides a UI Test that lets us take the browser to a url, and | 18 // Provides a UI Test that lets us take the browser to a url, and |
18 // wait for a cookie value to be set before closing the page. | 19 // wait for a cookie value to be set before closing the page. |
19 class UrlFetchTest : public UITest { | 20 class UrlFetchTest : public UITest { |
(...skipping 26 matching lines...) Expand all Loading... |
46 } | 47 } |
47 | 48 |
48 void RunTest(const GURL& url, const char* wait_cookie_name, | 49 void RunTest(const GURL& url, const char* wait_cookie_name, |
49 const char* wait_cookie_value, const char* var_to_fetch, | 50 const char* wait_cookie_value, const char* var_to_fetch, |
50 UrlFetchTestResult* result) { | 51 UrlFetchTestResult* result) { |
51 scoped_refptr<TabProxy> tab(GetActiveTab()); | 52 scoped_refptr<TabProxy> tab(GetActiveTab()); |
52 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); | 53 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); |
53 | 54 |
54 if (wait_cookie_name) { | 55 if (wait_cookie_name) { |
55 if (wait_cookie_value) { | 56 if (wait_cookie_value) { |
56 bool completed = WaitUntilCookieValue(tab.get(), url, wait_cookie_name, | 57 bool completed = WaitUntilCookieValue( |
57 UITest::test_timeout_ms(), | 58 tab.get(), url, wait_cookie_name, |
58 wait_cookie_value); | 59 TestTimeouts::huge_test_timeout_ms(), |
| 60 wait_cookie_value); |
59 ASSERT_TRUE(completed); | 61 ASSERT_TRUE(completed); |
60 } else { | 62 } else { |
61 result->cookie_value = WaitUntilCookieNonEmpty( | 63 result->cookie_value = WaitUntilCookieNonEmpty( |
62 tab.get(), url, wait_cookie_name, UITest::test_timeout_ms()); | 64 tab.get(), url, wait_cookie_name, |
| 65 TestTimeouts::huge_test_timeout_ms()); |
63 ASSERT_TRUE(result->cookie_value.length()); | 66 ASSERT_TRUE(result->cookie_value.length()); |
64 } | 67 } |
65 } | 68 } |
66 if (var_to_fetch) { | 69 if (var_to_fetch) { |
67 std::string script = StringPrintf( | 70 std::string script = StringPrintf( |
68 "window.domAutomationController.send(%s);", var_to_fetch); | 71 "window.domAutomationController.send(%s);", var_to_fetch); |
69 | 72 |
70 std::wstring value; | 73 std::wstring value; |
71 bool success = tab->ExecuteAndExtractString(L"", ASCIIToWide(script), | 74 bool success = tab->ExecuteAndExtractString(L"", ASCIIToWide(script), |
72 &value); | 75 &value); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 140 |
138 // Write out the JS Variable if requested | 141 // Write out the JS Variable if requested |
139 FilePath jsvar_output_path = cmd_line->GetSwitchValuePath("jsvar_output"); | 142 FilePath jsvar_output_path = cmd_line->GetSwitchValuePath("jsvar_output"); |
140 if (jsvar_output_path.value().size() > 0) { | 143 if (jsvar_output_path.value().size() > 0) { |
141 ASSERT_TRUE(WriteValueToFile(result.javascript_variable, | 144 ASSERT_TRUE(WriteValueToFile(result.javascript_variable, |
142 jsvar_output_path)); | 145 jsvar_output_path)); |
143 } | 146 } |
144 } | 147 } |
145 | 148 |
146 } // namespace | 149 } // namespace |
OLD | NEW |