| 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" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 tab.get(), | 78 tab.get(), |
| 79 UTF8ToWide(wait_js_frame_xpath), | 79 UTF8ToWide(wait_js_frame_xpath), |
| 80 UTF8ToWide(wait_js_expr), | 80 UTF8ToWide(wait_js_expr), |
| 81 wait_js_timeout_ms); | 81 wait_js_timeout_ms); |
| 82 ASSERT_TRUE(completed); | 82 ASSERT_TRUE(completed); |
| 83 } | 83 } |
| 84 if (var_to_fetch) { | 84 if (var_to_fetch) { |
| 85 std::string script = StringPrintf( | 85 std::string script = StringPrintf( |
| 86 "window.domAutomationController.send(%s);", var_to_fetch); | 86 "window.domAutomationController.send(%s);", var_to_fetch); |
| 87 | 87 |
| 88 std::wstring value; | 88 string16 value; |
| 89 bool success = tab->ExecuteAndExtractString(L"", ASCIIToWide(script), | 89 bool success = tab->ExecuteAndExtractString(string16(), |
| 90 ASCIIToUTF16(script), |
| 90 &value); | 91 &value); |
| 91 ASSERT_TRUE(success); | 92 ASSERT_TRUE(success); |
| 92 result->javascript_variable = WideToUTF8(value); | 93 result->javascript_variable = UTF16ToUTF8(value); |
| 93 } | 94 } |
| 94 } | 95 } |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 bool WriteValueToFile(std::string value, const FilePath& path) { | 98 bool WriteValueToFile(std::string value, const FilePath& path) { |
| 98 int retval = file_util::WriteFile(path, value.c_str(), value.length()); | 99 int retval = file_util::WriteFile(path, value.c_str(), value.length()); |
| 99 return retval == static_cast<int>(value.length()); | 100 return retval == static_cast<int>(value.length()); |
| 100 } | 101 } |
| 101 | 102 |
| 102 // To actually do anything useful, this test should have a url | 103 // To actually do anything useful, this test should have a url |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 184 |
| 184 // Write out the JS Variable if requested | 185 // Write out the JS Variable if requested |
| 185 FilePath jsvar_output_path = cmd_line->GetSwitchValuePath("jsvar_output"); | 186 FilePath jsvar_output_path = cmd_line->GetSwitchValuePath("jsvar_output"); |
| 186 if (jsvar_output_path.value().size() > 0) { | 187 if (jsvar_output_path.value().size() > 0) { |
| 187 ASSERT_TRUE(WriteValueToFile(result.javascript_variable, | 188 ASSERT_TRUE(WriteValueToFile(result.javascript_variable, |
| 188 jsvar_output_path)); | 189 jsvar_output_path)); |
| 189 } | 190 } |
| 190 } | 191 } |
| 191 | 192 |
| 192 } // namespace | 193 } // namespace |
| OLD | NEW |