| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/test/automation/tab_proxy.h" | 9 #include "chrome/test/automation/tab_proxy.h" |
| 10 #include "chrome/test/ui/ui_test.h" | 10 #include "chrome/test/ui/ui_test.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // Provides a UI Test that lets us take the browser to a url, and | 14 // Provides a UI Test that lets us take the browser to a url, and |
| 15 // wait for a cookie value to be set before closing the page. | 15 // wait for a cookie value to be set before closing the page. |
| 16 class UrlFetchTest : public UITest { | 16 class UrlFetchTest : public UITest { |
| 17 public: | 17 public: |
| 18 UrlFetchTest() { | 18 UrlFetchTest() { |
| 19 show_window_ = true; | 19 show_window_ = true; |
| 20 dom_automation_enabled_ = true; | 20 dom_automation_enabled_ = true; |
| 21 } | 21 } |
| 22 struct UrlFetchTestResult { | 22 struct UrlFetchTestResult { |
| 23 std::string cookie_value; | 23 std::string cookie_value; |
| 24 std::string javascript_variable; | 24 std::string javascript_variable; |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 void RunTest(const GURL& url, const char *waitCookieName, | 27 void RunTest(const GURL& url, const char *waitCookieName, |
| 28 const char *waitCookieValue, const wchar_t *varToFetch, | 28 const char *waitCookieValue, const wchar_t *varToFetch, |
| 29 UrlFetchTestResult *result) { | 29 UrlFetchTestResult *result) { |
| 30 scoped_ptr<TabProxy> tab(GetActiveTab()); | 30 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 31 tab->NavigateToURL(url); | 31 tab->NavigateToURL(url); |
| 32 | 32 |
| 33 if (waitCookieName) { | 33 if (waitCookieName) { |
| 34 if (waitCookieValue) { | 34 if (waitCookieValue) { |
| 35 bool completed = WaitUntilCookieValue(tab.get(), url, waitCookieName, | 35 bool completed = WaitUntilCookieValue(tab.get(), url, waitCookieName, |
| 36 3000, UITest::test_timeout_ms(), | 36 3000, UITest::test_timeout_ms(), |
| 37 waitCookieValue); | 37 waitCookieValue); |
| 38 ASSERT_TRUE(completed); | 38 ASSERT_TRUE(completed); |
| 39 } else { | 39 } else { |
| 40 result->cookie_value = WaitUntilCookieNonEmpty( | 40 result->cookie_value = WaitUntilCookieNonEmpty( |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 if (cookieOutputPath.length() > 0) { | 114 if (cookieOutputPath.length() > 0) { |
| 115 ASSERT_TRUE(writeValueToFile(result.cookie_value, cookieOutputPath)); | 115 ASSERT_TRUE(writeValueToFile(result.cookie_value, cookieOutputPath)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Write out the JS Variable if requested | 118 // Write out the JS Variable if requested |
| 119 std::wstring jsvarOutputPath = cmdLine->GetSwitchValue(L"jsvar_output"); | 119 std::wstring jsvarOutputPath = cmdLine->GetSwitchValue(L"jsvar_output"); |
| 120 if (jsvarOutputPath.length() > 0) { | 120 if (jsvarOutputPath.length() > 0) { |
| 121 ASSERT_TRUE(writeValueToFile(result.javascript_variable, jsvarOutputPath)); | 121 ASSERT_TRUE(writeValueToFile(result.javascript_variable, jsvarOutputPath)); |
| 122 } | 122 } |
| 123 } | 123 } |
| OLD | NEW |