| OLD | NEW |
| 1 // Copyright (c) 2011 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_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/test/automation/tab_proxy.h" | 14 #include "chrome/test/automation/tab_proxy.h" |
| 15 #include "chrome/test/ui/ui_test.h" | 15 #include "chrome/test/ui/ui_perf_test.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // Provides a UI Test that lets us take the browser to a url, and | 19 // Provides a UI Test that lets us take the browser to a url, and |
| 20 // wait for a cookie value to be set or a JavaScript expression to evaluate | 20 // wait for a cookie value to be set or a JavaScript expression to evaluate |
| 21 // true before closing the page. It is undefined what happens if you specify | 21 // true before closing the page. It is undefined what happens if you specify |
| 22 // both a cookie and a JS expression. | 22 // both a cookie and a JS expression. |
| 23 class UrlFetchTest : public UITest { | 23 class UrlFetchTest : public UIPerfTest { |
| 24 public: | 24 public: |
| 25 UrlFetchTest() { | 25 UrlFetchTest() { |
| 26 show_window_ = true; | 26 show_window_ = true; |
| 27 dom_automation_enabled_ = true; | 27 dom_automation_enabled_ = true; |
| 28 } | 28 } |
| 29 struct UrlFetchTestResult { | 29 struct UrlFetchTestResult { |
| 30 std::string cookie_value; | 30 std::string cookie_value; |
| 31 std::string javascript_variable; | 31 std::string javascript_variable; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 void SetUp() { | 34 void SetUp() { |
| 35 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 35 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 36 if (cmd_line->HasSwitch("reference_build")) { | 36 if (cmd_line->HasSwitch("reference_build")) { |
| 37 FilePath dir; | 37 UseReferenceBuild(); |
| 38 PathService::Get(chrome::DIR_TEST_TOOLS, &dir); | |
| 39 dir = dir.AppendASCII("reference_build"); | |
| 40 #if defined(OS_WIN) | |
| 41 dir = dir.AppendASCII("chrome"); | |
| 42 #elif defined(OS_LINUX) | |
| 43 dir = dir.AppendASCII("chrome_linux"); | |
| 44 #elif defined(OS_MACOSX) | |
| 45 dir = dir.AppendASCII("chrome_mac"); | |
| 46 #endif | |
| 47 browser_directory_ = dir; | |
| 48 } | 38 } |
| 49 UITest::SetUp(); | 39 UITest::SetUp(); |
| 50 } | 40 } |
| 51 | 41 |
| 52 void RunTest(const GURL& url, | 42 void RunTest(const GURL& url, |
| 53 const char* wait_cookie_name, | 43 const char* wait_cookie_name, |
| 54 const char* wait_cookie_value, | 44 const char* wait_cookie_value, |
| 55 const char* var_to_fetch, | 45 const char* var_to_fetch, |
| 56 const std::string& wait_js_expr, | 46 const std::string& wait_js_expr, |
| 57 const std::string& wait_js_frame_xpath, | 47 const std::string& wait_js_frame_xpath, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 173 |
| 184 // Write out the JS Variable if requested | 174 // Write out the JS Variable if requested |
| 185 FilePath jsvar_output_path = cmd_line->GetSwitchValuePath("jsvar_output"); | 175 FilePath jsvar_output_path = cmd_line->GetSwitchValuePath("jsvar_output"); |
| 186 if (!jsvar_output_path.value().empty()) { | 176 if (!jsvar_output_path.value().empty()) { |
| 187 ASSERT_TRUE(WriteValueToFile(result.javascript_variable, | 177 ASSERT_TRUE(WriteValueToFile(result.javascript_variable, |
| 188 jsvar_output_path)); | 178 jsvar_output_path)); |
| 189 } | 179 } |
| 190 } | 180 } |
| 191 | 181 |
| 192 } // namespace | 182 } // namespace |
| OLD | NEW |