| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
| 6 #include "base/string_number_conversions.h" | 6 #include "base/string_number_conversions.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/test/automation/extension_proxy.h" | 9 #include "chrome/test/automation/extension_proxy.h" |
| 10 #include "chrome/test/automation/tab_proxy.h" | 10 #include "chrome/test/automation/tab_proxy.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 MessageLoop::Type msg_loop_type) { | 58 MessageLoop::Type msg_loop_type) { |
| 59 if (!message_loop_) // Create a shared instance of MessageLoop | 59 if (!message_loop_) // Create a shared instance of MessageLoop |
| 60 message_loop_ = new MessageLoop(msg_loop_type); | 60 message_loop_ = new MessageLoop(msg_loop_type); |
| 61 return message_loop_; | 61 return message_loop_; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void PyUITestBase::Initialize(const FilePath& browser_dir) { | 64 void PyUITestBase::Initialize(const FilePath& browser_dir) { |
| 65 UITestBase::SetBrowserDirectory(browser_dir); | 65 UITestBase::SetBrowserDirectory(browser_dir); |
| 66 } | 66 } |
| 67 | 67 |
| 68 ProxyLauncher* PyUITestBase::CreateProxyLauncher() { |
| 69 if (named_channel_id_.empty()) |
| 70 return new AnonymousProxyLauncher(false); |
| 71 return new NamedProxyLauncher(named_channel_id_, false, false); |
| 72 } |
| 73 |
| 68 void PyUITestBase::SetUp() { | 74 void PyUITestBase::SetUp() { |
| 69 UITestBase::SetUp(); | 75 UITestBase::SetUp(); |
| 70 } | 76 } |
| 71 | 77 |
| 72 void PyUITestBase::TearDown() { | 78 void PyUITestBase::TearDown() { |
| 73 UITestBase::TearDown(); | 79 UITestBase::TearDown(); |
| 74 } | 80 } |
| 75 | 81 |
| 76 void PyUITestBase::NavigateToURL(const char* url_string) { | 82 void PyUITestBase::NavigateToURL(const char* url_string) { |
| 77 GURL url(url_string); | 83 GURL url(url_string); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 return false; | 312 return false; |
| 307 | 313 |
| 308 return browser_proxy->RemoveBookmark(StringToId(id)); | 314 return browser_proxy->RemoveBookmark(StringToId(id)); |
| 309 } | 315 } |
| 310 | 316 |
| 311 scoped_refptr<BrowserProxy> PyUITestBase::GetBrowserWindow(int window_index) { | 317 scoped_refptr<BrowserProxy> PyUITestBase::GetBrowserWindow(int window_index) { |
| 312 return automation()->GetBrowserWindow(window_index); | 318 return automation()->GetBrowserWindow(window_index); |
| 313 } | 319 } |
| 314 | 320 |
| 315 std::string PyUITestBase::_SendJSONRequest(int window_index, | 321 std::string PyUITestBase::_SendJSONRequest(int window_index, |
| 316 std::string& request) { | 322 const std::string& request) { |
| 317 scoped_refptr<BrowserProxy> browser_proxy = | |
| 318 automation()->GetBrowserWindow(window_index); | |
| 319 EXPECT_TRUE(browser_proxy.get()); | |
| 320 std::string response; | 323 std::string response; |
| 321 if (browser_proxy.get()) { | 324 if (window_index < 0) { // Do not need to target a browser window. |
| 322 EXPECT_TRUE(browser_proxy->SendJSONRequest(request, &response)); | 325 EXPECT_TRUE(automation()->SendJSONRequest(request, &response)); |
| 326 } else { |
| 327 scoped_refptr<BrowserProxy> browser_proxy = |
| 328 automation()->GetBrowserWindow(window_index); |
| 329 EXPECT_TRUE(browser_proxy.get()); |
| 330 if (browser_proxy.get()) { |
| 331 EXPECT_TRUE(browser_proxy->SendJSONRequest(request, &response)); |
| 332 } |
| 323 } | 333 } |
| 324 return response; | 334 return response; |
| 325 } | 335 } |
| 326 | 336 |
| 327 std::wstring PyUITestBase::ExecuteJavascript(const std::wstring& script, | 337 std::wstring PyUITestBase::ExecuteJavascript(const std::wstring& script, |
| 328 int window_index, | 338 int window_index, |
| 329 int tab_index, | 339 int tab_index, |
| 330 const std::wstring& frame_xpath) { | 340 const std::wstring& frame_xpath) { |
| 331 scoped_refptr<BrowserProxy> browser_proxy = | 341 scoped_refptr<BrowserProxy> browser_proxy = |
| 332 automation()->GetBrowserWindow(window_index); | 342 automation()->GetBrowserWindow(window_index); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 // TODO(phadjan.jr): figure out a way to unambiguously report error. | 392 // TODO(phadjan.jr): figure out a way to unambiguously report error. |
| 383 if (!browser_proxy.get()) | 393 if (!browser_proxy.get()) |
| 384 return cookie_val; | 394 return cookie_val; |
| 385 scoped_refptr<TabProxy> tab_proxy = browser_proxy->GetTab(tab_index); | 395 scoped_refptr<TabProxy> tab_proxy = browser_proxy->GetTab(tab_index); |
| 386 EXPECT_TRUE(tab_proxy.get()); | 396 EXPECT_TRUE(tab_proxy.get()); |
| 387 if (!tab_proxy.get()) | 397 if (!tab_proxy.get()) |
| 388 return cookie_val; | 398 return cookie_val; |
| 389 EXPECT_TRUE(tab_proxy->GetCookies(cookie_url, &cookie_val)); | 399 EXPECT_TRUE(tab_proxy->GetCookies(cookie_url, &cookie_val)); |
| 390 return cookie_val; | 400 return cookie_val; |
| 391 } | 401 } |
| OLD | NEW |