| OLD | NEW |
| 1 // Copyright (c) 2010 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/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" |
| 11 #include "chrome/test/pyautolib/pyautolib.h" | 11 #include "chrome/test/pyautolib/pyautolib.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 313 |
| 314 return browser_proxy->RemoveBookmark(StringToId(id)); | 314 return browser_proxy->RemoveBookmark(StringToId(id)); |
| 315 } | 315 } |
| 316 | 316 |
| 317 scoped_refptr<BrowserProxy> PyUITestBase::GetBrowserWindow(int window_index) { | 317 scoped_refptr<BrowserProxy> PyUITestBase::GetBrowserWindow(int window_index) { |
| 318 return automation()->GetBrowserWindow(window_index); | 318 return automation()->GetBrowserWindow(window_index); |
| 319 } | 319 } |
| 320 | 320 |
| 321 std::string PyUITestBase::_SendJSONRequest(int window_index, | 321 std::string PyUITestBase::_SendJSONRequest(int window_index, |
| 322 const std::string& request) { | 322 const std::string& request) { |
| 323 return _SendJSONRequest(window_index, request, |
| 324 TestTimeouts::action_max_timeout_ms()); |
| 325 } |
| 326 |
| 327 std::string PyUITestBase::_SendJSONRequest(int window_index, |
| 328 const std::string& request, |
| 329 int timeout) { |
| 323 std::string response; | 330 std::string response; |
| 324 if (window_index < 0) { // Do not need to target a browser window. | 331 if (window_index < 0) { // Do not need to target a browser window. |
| 325 EXPECT_TRUE(automation()->SendJSONRequest(request, &response)); | 332 EXPECT_TRUE(automation()->SendJSONRequest(request, &response, timeout)); |
| 326 } else { | 333 } else { |
| 327 scoped_refptr<BrowserProxy> browser_proxy = | 334 scoped_refptr<BrowserProxy> browser_proxy = |
| 328 automation()->GetBrowserWindow(window_index); | 335 automation()->GetBrowserWindow(window_index); |
| 329 EXPECT_TRUE(browser_proxy.get()); | 336 EXPECT_TRUE(browser_proxy.get()); |
| 330 if (browser_proxy.get()) { | 337 if (browser_proxy.get()) { |
| 331 EXPECT_TRUE(browser_proxy->SendJSONRequest(request, &response)); | 338 EXPECT_TRUE(browser_proxy->SendJSONRequest(request, &response, timeout)); |
| 332 } | 339 } |
| 333 } | 340 } |
| 334 return response; | 341 return response; |
| 335 } | 342 } |
| 336 | 343 |
| 337 std::wstring PyUITestBase::ExecuteJavascript(const std::wstring& script, | 344 std::wstring PyUITestBase::ExecuteJavascript(const std::wstring& script, |
| 338 int window_index, | 345 int window_index, |
| 339 int tab_index, | 346 int tab_index, |
| 340 const std::wstring& frame_xpath) { | 347 const std::wstring& frame_xpath) { |
| 341 scoped_refptr<BrowserProxy> browser_proxy = | 348 scoped_refptr<BrowserProxy> browser_proxy = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 // TODO(phadjan.jr): figure out a way to unambiguously report error. | 399 // TODO(phadjan.jr): figure out a way to unambiguously report error. |
| 393 if (!browser_proxy.get()) | 400 if (!browser_proxy.get()) |
| 394 return cookie_val; | 401 return cookie_val; |
| 395 scoped_refptr<TabProxy> tab_proxy = browser_proxy->GetTab(tab_index); | 402 scoped_refptr<TabProxy> tab_proxy = browser_proxy->GetTab(tab_index); |
| 396 EXPECT_TRUE(tab_proxy.get()); | 403 EXPECT_TRUE(tab_proxy.get()); |
| 397 if (!tab_proxy.get()) | 404 if (!tab_proxy.get()) |
| 398 return cookie_val; | 405 return cookie_val; |
| 399 EXPECT_TRUE(tab_proxy->GetCookies(cookie_url, &cookie_val)); | 406 EXPECT_TRUE(tab_proxy->GetCookies(cookie_url, &cookie_val)); |
| 400 return cookie_val; | 407 return cookie_val; |
| 401 } | 408 } |
| OLD | NEW |