| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "app/message_box_flags.h" | 9 #include "app/message_box_flags.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 275 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 276 ASSERT_TRUE(window.get()); | 276 ASSERT_TRUE(window.get()); |
| 277 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 277 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 278 ASSERT_TRUE(tab.get()); | 278 ASSERT_TRUE(tab.get()); |
| 279 | 279 |
| 280 FilePath filename(test_data_directory_); | 280 FilePath filename(test_data_directory_); |
| 281 filename = filename.AppendASCII("title2.html"); | 281 filename = filename.AppendASCII("title2.html"); |
| 282 | 282 |
| 283 bool is_timeout; | 283 bool is_timeout; |
| 284 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), | 284 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), |
| 285 5000, &is_timeout); | 285 1, 5000, &is_timeout); |
| 286 ASSERT_FALSE(is_timeout); | 286 ASSERT_FALSE(is_timeout); |
| 287 | 287 |
| 288 std::wstring title; | 288 std::wstring title; |
| 289 ASSERT_TRUE(tab->GetTabTitle(&title)); | 289 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 290 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 290 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); |
| 291 | 291 |
| 292 // Use timeout high enough to allow the browser to create a url request job. | 292 // Use timeout high enough to allow the browser to create a url request job. |
| 293 const int kLowTimeoutMs = 250; | 293 const int kLowTimeoutMs = 250; |
| 294 ASSERT_GE(URLRequestSlowHTTPJob::kDelayMs, kLowTimeoutMs); | 294 ASSERT_GE(URLRequestSlowHTTPJob::kDelayMs, kLowTimeoutMs); |
| 295 tab->NavigateToURLWithTimeout( | 295 tab->NavigateToURLWithTimeout( |
| 296 URLRequestSlowHTTPJob::GetMockUrl(filename.ToWStringHack()), | 296 URLRequestSlowHTTPJob::GetMockUrl(filename.ToWStringHack()), |
| 297 kLowTimeoutMs, &is_timeout); | 297 1, kLowTimeoutMs, &is_timeout); |
| 298 ASSERT_TRUE(is_timeout); | 298 ASSERT_TRUE(is_timeout); |
| 299 } | 299 } |
| 300 | 300 |
| 301 TEST_F(AutomationProxyTest, NavigateToURLWithTimeout2) { | 301 TEST_F(AutomationProxyTest, NavigateToURLWithTimeout2) { |
| 302 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 302 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 303 ASSERT_TRUE(window.get()); | 303 ASSERT_TRUE(window.get()); |
| 304 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 304 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 305 ASSERT_TRUE(tab.get()); | 305 ASSERT_TRUE(tab.get()); |
| 306 | 306 |
| 307 FilePath filename1(test_data_directory_); | 307 FilePath filename1(test_data_directory_); |
| 308 filename1 = filename1.AppendASCII("title1.html"); | 308 filename1 = filename1.AppendASCII("title1.html"); |
| 309 | 309 |
| 310 bool is_timeout; | 310 bool is_timeout; |
| 311 | 311 |
| 312 // Use timeout high enough to allow the browser to create a url request job. | 312 // Use timeout high enough to allow the browser to create a url request job. |
| 313 const int kLowTimeoutMs = 250; | 313 const int kLowTimeoutMs = 250; |
| 314 ASSERT_GE(URLRequestSlowHTTPJob::kDelayMs, kLowTimeoutMs); | 314 ASSERT_GE(URLRequestSlowHTTPJob::kDelayMs, kLowTimeoutMs); |
| 315 tab->NavigateToURLWithTimeout( | 315 tab->NavigateToURLWithTimeout( |
| 316 URLRequestSlowHTTPJob::GetMockUrl(filename1.ToWStringHack()), | 316 URLRequestSlowHTTPJob::GetMockUrl(filename1.ToWStringHack()), |
| 317 kLowTimeoutMs, &is_timeout); | 317 1, kLowTimeoutMs, &is_timeout); |
| 318 ASSERT_TRUE(is_timeout); | 318 ASSERT_TRUE(is_timeout); |
| 319 | 319 |
| 320 FilePath filename2(test_data_directory_); | 320 FilePath filename2(test_data_directory_); |
| 321 filename2 = filename2.AppendASCII("title1.html"); | 321 filename2 = filename2.AppendASCII("title1.html"); |
| 322 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename2), | 322 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename2), |
| 323 5000, &is_timeout); | 323 1, 5000, &is_timeout); |
| 324 ASSERT_FALSE(is_timeout); | 324 ASSERT_FALSE(is_timeout); |
| 325 } | 325 } |
| 326 | 326 |
| 327 TEST_F(AutomationProxyTest, GoBackForward) { | 327 TEST_F(AutomationProxyTest, GoBackForward) { |
| 328 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 328 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 329 ASSERT_TRUE(window.get()); | 329 ASSERT_TRUE(window.get()); |
| 330 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 330 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 331 ASSERT_TRUE(tab.get()); | 331 ASSERT_TRUE(tab.get()); |
| 332 | 332 |
| 333 std::wstring title; | 333 std::wstring title; |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 | 1105 |
| 1106 // Allow some time for the popup to show up and close. | 1106 // Allow some time for the popup to show up and close. |
| 1107 PlatformThread::Sleep(2000); | 1107 PlatformThread::Sleep(2000); |
| 1108 | 1108 |
| 1109 std::wstring expected(L"string"); | 1109 std::wstring expected(L"string"); |
| 1110 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); | 1110 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); |
| 1111 std::wstring actual; | 1111 std::wstring actual; |
| 1112 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); | 1112 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); |
| 1113 ASSERT_EQ(expected, actual); | 1113 ASSERT_EQ(expected, actual); |
| 1114 } | 1114 } |
| OLD | NEW |