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 "chrome/test/webdriver/automation.h" | 5 #include "chrome/test/webdriver/automation.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 } | 43 } |
44 | 44 |
45 void Automation::Terminate() { | 45 void Automation::Terminate() { |
46 QuitBrowser(); | 46 QuitBrowser(); |
47 } | 47 } |
48 | 48 |
49 void Automation::ExecuteScript(const std::string& frame_xpath, | 49 void Automation::ExecuteScript(const std::string& frame_xpath, |
50 const std::string& script, | 50 const std::string& script, |
51 std::string* result, | 51 std::string* result, |
52 bool* success) { | 52 bool* success) { |
53 std::wstring wide_xpath = UTF8ToWide(frame_xpath); | 53 string16 xpath16 = UTF8ToUTF16(frame_xpath); |
54 std::wstring wide_script = UTF8ToWide(script); | 54 string16 script16 = UTF8ToUTF16(script); |
55 std::wstring wide_result; | 55 string16 result16; |
56 *success = tab_->ExecuteAndExtractString( | 56 *success = tab_->ExecuteAndExtractString( |
57 wide_xpath, wide_script, &wide_result); | 57 xpath16, script16, &result16); |
Evan Martin
2011/02/07 22:52:29
Maybe fits on one line?
Avi (use Gerrit)
2011/02/07 22:55:25
Done.
| |
58 if (*success) | 58 if (*success) |
59 *result = WideToUTF8(wide_result); | 59 *result = UTF16ToUTF8(result16); |
60 } | 60 } |
61 | 61 |
62 void Automation::NavigateToURL(const std::string& url, | 62 void Automation::NavigateToURL(const std::string& url, |
63 bool* success) { | 63 bool* success) { |
64 *success = tab_->NavigateToURL(GURL(url)); | 64 *success = tab_->NavigateToURL(GURL(url)); |
65 } | 65 } |
66 | 66 |
67 void Automation::GoForward(bool* success) { | 67 void Automation::GoForward(bool* success) { |
68 *success = tab_->GoForward(); | 68 *success = tab_->GoForward(); |
69 } | 69 } |
70 | 70 |
71 void Automation::GoBack(bool* success) { | 71 void Automation::GoBack(bool* success) { |
72 *success = tab_->GoBack(); | 72 *success = tab_->GoBack(); |
73 } | 73 } |
74 | 74 |
75 void Automation::Reload(bool* success) { | 75 void Automation::Reload(bool* success) { |
76 *success = tab_->Reload(); | 76 *success = tab_->Reload(); |
77 } | 77 } |
78 | 78 |
79 void Automation::GetURL(std::string* url, | 79 void Automation::GetURL(std::string* url, |
80 bool* success) { | 80 bool* success) { |
81 GURL gurl; | 81 GURL gurl; |
82 *success = tab_->GetCurrentURL(&gurl); | 82 *success = tab_->GetCurrentURL(&gurl); |
83 if (*success) | 83 if (*success) |
84 *url = gurl.possibly_invalid_spec(); | 84 *url = gurl.possibly_invalid_spec(); |
85 } | 85 } |
86 | 86 |
87 void Automation::GetTabTitle(std::string* tab_title, | 87 void Automation::GetTabTitle(std::string* tab_title, |
88 bool* success) { | 88 bool* success) { |
89 std::wstring wide_title; | 89 string16 title16; |
90 *success = tab_->GetTabTitle(&wide_title); | 90 *success = tab_->GetTabTitle(&title16); |
91 if (*success) | 91 if (*success) |
92 *tab_title = WideToUTF8(wide_title); | 92 *tab_title = UTF16ToUTF8(title16); |
93 } | 93 } |
94 | 94 |
95 } // namespace webdriver | 95 } // namespace webdriver |
OLD | NEW |