Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Side by Side Diff: chrome/test/automation/automation_proxy_uitest.cc

Issue 155941: Make AutomationProxyTest.NavigateToURLWithTimeout* tests not-flaky. (Closed)
Patch Set: maintainability fixes Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/chrome.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/app/chrome_dll_resource.h" 14 #include "chrome/app/chrome_dll_resource.h"
15 #include "chrome/browser/automation/url_request_slow_http_job.h"
15 #include "chrome/browser/view_ids.h" 16 #include "chrome/browser/view_ids.h"
16 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
17 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/json_value_serializer.h" 19 #include "chrome/common/json_value_serializer.h"
19 #include "chrome/test/automation/automation_proxy_uitest.h" 20 #include "chrome/test/automation/automation_proxy_uitest.h"
20 #include "chrome/test/automation/browser_proxy.h" 21 #include "chrome/test/automation/browser_proxy.h"
21 #include "chrome/test/automation/tab_proxy.h" 22 #include "chrome/test/automation/tab_proxy.h"
22 #include "chrome/test/automation/window_proxy.h" 23 #include "chrome/test/automation/window_proxy.h"
23 #include "chrome/test/ui/ui_test.h" 24 #include "chrome/test/ui/ui_test.h"
24 #include "net/base/net_util.h" 25 #include "net/base/net_util.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 filename = filename.AppendASCII("title2.html"); 281 filename = filename.AppendASCII("title2.html");
281 282
282 bool is_timeout; 283 bool is_timeout;
283 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), 284 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename),
284 5000, &is_timeout); 285 5000, &is_timeout);
285 ASSERT_FALSE(is_timeout); 286 ASSERT_FALSE(is_timeout);
286 287
287 std::wstring title; 288 std::wstring title;
288 ASSERT_TRUE(tab->GetTabTitle(&title)); 289 ASSERT_TRUE(tab->GetTabTitle(&title));
289 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); 290 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str());
291
292 // Use timeout high enough to allow the browser to create a url request job.
293 const int kLowTimeoutMs = 250;
294 ASSERT_GE(URLRequestSlowHTTPJob::kDelayMs, kLowTimeoutMs);
295 tab->NavigateToURLWithTimeout(
296 URLRequestSlowHTTPJob::GetMockUrl(filename.ToWStringHack()),
297 kLowTimeoutMs, &is_timeout);
298 ASSERT_TRUE(is_timeout);
290 } 299 }
291 300
292 TEST_F(AutomationProxyTest, NavigateToURLWithTimeout2) { 301 TEST_F(AutomationProxyTest, NavigateToURLWithTimeout2) {
293 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 302 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
294 ASSERT_TRUE(window.get()); 303 ASSERT_TRUE(window.get());
295 scoped_refptr<TabProxy> tab(window->GetTab(0)); 304 scoped_refptr<TabProxy> tab(window->GetTab(0));
296 ASSERT_TRUE(tab.get()); 305 ASSERT_TRUE(tab.get());
297 306
298 FilePath filename1(test_data_directory_); 307 FilePath filename1(test_data_directory_);
299 filename1 = filename1.AppendASCII("title1.html"); 308 filename1 = filename1.AppendASCII("title1.html");
300 309
301 bool is_timeout; 310 bool is_timeout;
302 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename1), 311
303 1, &is_timeout); 312 // Use timeout high enough to allow the browser to create a url request job.
313 const int kLowTimeoutMs = 250;
314 ASSERT_GE(URLRequestSlowHTTPJob::kDelayMs, kLowTimeoutMs);
315 tab->NavigateToURLWithTimeout(
316 URLRequestSlowHTTPJob::GetMockUrl(filename1.ToWStringHack()),
317 kLowTimeoutMs, &is_timeout);
304 ASSERT_TRUE(is_timeout); 318 ASSERT_TRUE(is_timeout);
305 319
306 FilePath filename2(test_data_directory_); 320 FilePath filename2(test_data_directory_);
307 filename2 = filename2.AppendASCII("title1.html"); 321 filename2 = filename2.AppendASCII("title1.html");
308 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename2), 322 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename2),
309 5000, &is_timeout); 323 5000, &is_timeout);
310 ASSERT_FALSE(is_timeout); 324 ASSERT_FALSE(is_timeout);
311 } 325 }
312 326
313 TEST_F(AutomationProxyTest, GoBackForward) { 327 TEST_F(AutomationProxyTest, GoBackForward) {
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 1102
1089 // Allow some time for the popup to show up and close. 1103 // Allow some time for the popup to show up and close.
1090 PlatformThread::Sleep(2000); 1104 PlatformThread::Sleep(2000);
1091 1105
1092 std::wstring expected(L"string"); 1106 std::wstring expected(L"string");
1093 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); 1107 std::wstring jscript = CreateJSString(L"\"" + expected + L"\"");
1094 std::wstring actual; 1108 std::wstring actual;
1095 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); 1109 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual));
1096 ASSERT_EQ(expected, actual); 1110 ASSERT_EQ(expected, actual);
1097 } 1111 }
OLDNEW
« no previous file with comments | « chrome/chrome.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698