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

Side by Side Diff: chrome_frame/test/navigation_test.cc

Issue 10053004: Use TimeDelta for Chrome Frame test's TimedMsgLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome_frame/test/mock_ie_event_sink_test.cc ('k') | chrome_frame/test/ready_mode_unittest.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/test/test_file_util.h" 7 #include "base/test/test_file_util.h"
8 #include "base/win/scoped_comptr.h" 8 #include "base/win/scoped_comptr.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "chrome_frame/test/chrome_frame_test_utils.h" 10 #include "chrome_frame/test/chrome_frame_test_utils.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 VerifyAddressBarUrl(&ie_mock_), 179 VerifyAddressBarUrl(&ie_mock_),
180 DelayGoForward(&ie_mock_, &loop_, 0))); 180 DelayGoForward(&ie_mock_, &loop_, 0)));
181 181
182 // We have reached url 2 and have 1 back & 1 forward entries for url 1 & 3. 182 // We have reached url 2 and have 1 back & 1 forward entries for url 1 & 3.
183 ie_mock_.ExpectNavigation(in_cf, page3); 183 ie_mock_.ExpectNavigation(in_cf, page3);
184 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page3))) 184 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page3)))
185 .WillOnce(testing::DoAll( 185 .WillOnce(testing::DoAll(
186 VerifyAddressBarUrl(&ie_mock_), 186 VerifyAddressBarUrl(&ie_mock_),
187 CloseBrowserMock(&ie_mock_))); 187 CloseBrowserMock(&ie_mock_)));
188 188
189 LaunchIENavigateAndLoop(page1, 189 LaunchIENavigateAndLoop(page1, kChromeFrameLongNavigationTimeout * 2);
190 kChromeFrameLongNavigationTimeoutInSeconds * 2);
191 } 190 }
192 191
193 // Test multiple back and forward operations among urls with anchors. 192 // Test multiple back and forward operations among urls with anchors.
194 TEST_P(FullTabNavigationTest, BackForwardAnchor) { 193 TEST_P(FullTabNavigationTest, BackForwardAnchor) {
195 std::wstring title(GetAnchorPageTitle()); 194 std::wstring title(GetAnchorPageTitle());
196 bool in_cf = GetParam().invokes_cf(); 195 bool in_cf = GetParam().invokes_cf();
197 ie_mock_.ExpectAnyNavigations(); 196 ie_mock_.ExpectAnyNavigations();
198 server_mock_.ExpectAndServeAnyRequests(GetParam()); 197 server_mock_.ExpectAndServeAnyRequests(GetParam());
199 MockAccEventObserver acc_observer; 198 MockAccEventObserver acc_observer;
200 EXPECT_CALL(acc_observer, OnAccDocLoad(_)).Times(testing::AnyNumber()); 199 EXPECT_CALL(acc_observer, OnAccDocLoad(_)).Times(testing::AnyNumber());
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 .WillOnce(CloseBrowserMock(&new_window_mock)); 355 .WillOnce(CloseBrowserMock(&new_window_mock));
357 356
358 EXPECT_CALL(new_window_mock, OnLoad(_, _)) 357 EXPECT_CALL(new_window_mock, OnLoad(_, _))
359 .Times(testing::AtMost(1)); 358 .Times(testing::AtMost(1));
360 359
361 EXPECT_CALL(new_window_mock, OnQuit()) 360 EXPECT_CALL(new_window_mock, OnQuit())
362 .Times(1) 361 .Times(1)
363 .WillOnce(CloseBrowserMock(&ie_mock_)); 362 .WillOnce(CloseBrowserMock(&ie_mock_));
364 363
365 // OnNavigateError can take a long time to fire. 364 // OnNavigateError can take a long time to fire.
366 LaunchIENavigateAndLoop(parent_url, 365 LaunchIENavigateAndLoop(parent_url, kChromeFrameLongNavigationTimeout * 4);
367 kChromeFrameLongNavigationTimeoutInSeconds * 4);
368 ASSERT_TRUE(new_window_mock.event_sink()->web_browser2() != NULL); 366 ASSERT_TRUE(new_window_mock.event_sink()->web_browser2() != NULL);
369 } 367 }
370 368
371 // Tests that the parent window can successfully close its popup through 369 // Tests that the parent window can successfully close its popup through
372 // the javascript close method. 370 // the javascript close method.
373 TEST_P(FullTabNavigationTest, JavascriptWindowOpenCanClose) { 371 TEST_P(FullTabNavigationTest, JavascriptWindowOpenCanClose) {
374 // Please see http://code.google.com/p/chromium/issues/detail?id=60987 372 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
375 // for more information on why this test is disabled for Vista with IE7. 373 // for more information on why this test is disabled for Vista with IE7.
376 if (base::win::GetVersion() == base::win::VERSION_VISTA && 374 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
377 GetInstalledIEVersion() == IE_7) { 375 GetInstalledIEVersion() == IE_7) {
(...skipping 18 matching lines...) Expand all
396 394
397 ie_mock_.ExpectNewWindow(&new_window_mock); 395 ie_mock_.ExpectNewWindow(&new_window_mock);
398 EXPECT_CALL(new_window_mock, OnLoad(_, StrEq(GetSimplePageUrl()))) 396 EXPECT_CALL(new_window_mock, OnLoad(_, StrEq(GetSimplePageUrl())))
399 .Times(testing::AtMost(2)) 397 .Times(testing::AtMost(2))
400 .WillOnce(PostCharMessageToRenderer(&ie_mock_, 'C')) // close the popup 398 .WillOnce(PostCharMessageToRenderer(&ie_mock_, 'C')) // close the popup
401 .WillOnce(testing::Return()); 399 .WillOnce(testing::Return());
402 400
403 EXPECT_CALL(new_window_mock, OnQuit()) 401 EXPECT_CALL(new_window_mock, OnQuit())
404 .WillOnce(CloseBrowserMock(&ie_mock_)); 402 .WillOnce(CloseBrowserMock(&ie_mock_));
405 403
406 LaunchIENavigateAndLoop(parent_url, 404 LaunchIENavigateAndLoop(parent_url, kChromeFrameLongNavigationTimeout * 2);
407 kChromeFrameLongNavigationTimeoutInSeconds * 2);
408 } 405 }
409 406
410 // Parameter for tests using the NavigationTransitionTest fixture. Includes two 407 // Parameter for tests using the NavigationTransitionTest fixture. Includes two
411 // pages, each with their own possible CF invocation. 408 // pages, each with their own possible CF invocation.
412 struct NavigationTransitionTestParameter { 409 struct NavigationTransitionTestParameter {
413 NavigationTransitionTestParameter(CFInvocation::Type type1, 410 NavigationTransitionTestParameter(CFInvocation::Type type1,
414 CFInvocation::Type type2) { 411 CFInvocation::Type type2) {
415 page1_ = CFInvocation(type1); 412 page1_ = CFInvocation(type1);
416 page2_ = CFInvocation(type2); 413 page2_ = CFInvocation(type2);
417 } 414 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 new_window_url); 496 new_window_url);
500 server_mock_.ExpectAndServeRequest(page2_, new_window_url); 497 server_mock_.ExpectAndServeRequest(page2_, new_window_url);
501 EXPECT_CALL(new_window_mock, OnLoad(expect_cf, StrEq(new_window_url))) 498 EXPECT_CALL(new_window_mock, OnLoad(expect_cf, StrEq(new_window_url)))
502 .WillOnce(testing::DoAll( 499 .WillOnce(testing::DoAll(
503 ValidateWindowSize(&new_window_mock, 10, 10, 250, 250), 500 ValidateWindowSize(&new_window_mock, 10, 10, 250, 250),
504 CloseBrowserMock(&new_window_mock))); 501 CloseBrowserMock(&new_window_mock)));
505 502
506 EXPECT_CALL(new_window_mock, OnQuit()) 503 EXPECT_CALL(new_window_mock, OnQuit())
507 .WillOnce(CloseBrowserMock(&ie_mock_)); 504 .WillOnce(CloseBrowserMock(&ie_mock_));
508 505
509 LaunchIENavigateAndLoop(parent_url, 506 LaunchIENavigateAndLoop(parent_url, kChromeFrameLongNavigationTimeout * 2);
510 kChromeFrameLongNavigationTimeoutInSeconds * 2);
511 } 507 }
512 508
513 // Test redirection with window.location in Javascript. 509 // Test redirection with window.location in Javascript.
514 // Disabled because crashes IE occasionally: http://crbug.com/48849. 510 // Disabled because crashes IE occasionally: http://crbug.com/48849.
515 TEST_P(NavigationTransitionTest, DISABLED_JavascriptRedirection) { 511 TEST_P(NavigationTransitionTest, DISABLED_JavascriptRedirection) {
516 std::wstring redirect_url = GetTestUrl(L"javascript_redirect.html"); 512 std::wstring redirect_url = GetTestUrl(L"javascript_redirect.html");
517 513
518 ie_mock_.ExpectNavigation(page1_.invokes_cf(), redirect_url); 514 ie_mock_.ExpectNavigation(page1_.invokes_cf(), redirect_url);
519 server_mock_.ExpectAndServeRequest(page1_, redirect_url); 515 server_mock_.ExpectAndServeRequest(page1_, redirect_url);
520 EXPECT_CALL(ie_mock_, OnLoad(page1_.invokes_cf(), StrEq(redirect_url))) 516 EXPECT_CALL(ie_mock_, OnLoad(page1_.invokes_cf(), StrEq(redirect_url)))
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 AccSendCharMessage(file_name_box, L'a'), 852 AccSendCharMessage(file_name_box, L'a'),
857 AccSetValue(file_name_box, temp_file_path.value()), 853 AccSetValue(file_name_box, temp_file_path.value()),
858 AccDoDefaultAction(AccObjectMatcher(L"Save", L"push button")))); 854 AccDoDefaultAction(AccObjectMatcher(L"Save", L"push button"))));
859 855
860 EXPECT_CALL(save_dialog_watcher, OnWindowClose(_)) 856 EXPECT_CALL(save_dialog_watcher, OnWindowClose(_))
861 .WillOnce(testing::DoAll( 857 .WillOnce(testing::DoAll(
862 WaitForFileSave(temp_file_path, 2000), 858 WaitForFileSave(temp_file_path, 2000),
863 testing::InvokeWithoutArgs( 859 testing::InvokeWithoutArgs(
864 testing::CreateFunctor(CloseWindow, &owner_window)), 860 testing::CreateFunctor(CloseWindow, &owner_window)),
865 CloseBrowserMock(&ie_mock_))); 861 CloseBrowserMock(&ie_mock_)));
866 LaunchIENavigateAndLoop(src_url, 862 LaunchIENavigateAndLoop(src_url, kChromeFrameVeryLongNavigationTimeout);
867 kChromeFrameVeryLongNavigationTimeoutInSeconds);
868 863
869 std::string data; 864 std::string data;
870 EXPECT_TRUE(file_util::ReadFileToString(temp_file_path, &data)); 865 EXPECT_TRUE(file_util::ReadFileToString(temp_file_path, &data));
871 EXPECT_EQ("hello", data); 866 EXPECT_EQ("hello", data);
872 file_util::DieFileDie(temp_file_path, false); 867 file_util::DieFileDie(temp_file_path, false);
873 } 868 }
874 869
875 // Test fixture for testing if http header works for supported content types 870 // Test fixture for testing if http header works for supported content types
876 class HttpHeaderTest : public MockIEEventSinkTest, public testing::Test { 871 class HttpHeaderTest : public MockIEEventSinkTest, public testing::Test {
877 public: 872 public:
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 StrEq(src_url)), 958 StrEq(src_url)),
964 _, _, _, _, _)); 959 _, _, _, _, _));
965 EXPECT_CALL(ie_mock_, 960 EXPECT_CALL(ie_mock_,
966 OnNavigateComplete2(_, testing::Field(&VARIANT::bstrVal, 961 OnNavigateComplete2(_, testing::Field(&VARIANT::bstrVal,
967 StrEq(src_url)))); 962 StrEq(src_url))));
968 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(src_url))) 963 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(src_url)))
969 .Times(2) 964 .Times(2)
970 .WillOnce(DelayRefresh(&ie_mock_, &loop_, 50)) 965 .WillOnce(DelayRefresh(&ie_mock_, &loop_, 50))
971 .WillOnce(CloseBrowserMock(&ie_mock_)); 966 .WillOnce(CloseBrowserMock(&ie_mock_));
972 967
973 LaunchIENavigateAndLoop(src_url, 968 LaunchIENavigateAndLoop(src_url, kChromeFrameVeryLongNavigationTimeout);
974 kChromeFrameVeryLongNavigationTimeoutInSeconds);
975 } 969 }
976 970
977 class FullTabSeleniumTest 971 class FullTabSeleniumTest
978 : public MockIEEventSinkTest, public testing::TestWithParam<CFInvocation> { 972 : public MockIEEventSinkTest, public testing::TestWithParam<CFInvocation> {
979 public: 973 public:
980 FullTabSeleniumTest() 974 FullTabSeleniumTest()
981 : MockIEEventSinkTest(1337, L"127.0.0.1", GetSeleniumTestFolder()) {} 975 : MockIEEventSinkTest(1337, L"127.0.0.1", GetSeleniumTestFolder()) {}
982 }; 976 };
983 977
984 ACTION(VerifySeleniumCoreTestResults) { 978 ACTION(VerifySeleniumCoreTestResults) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 testing::StartsWith(attach_url_prefix))) 1029 testing::StartsWith(attach_url_prefix)))
1036 .Times(testing::AnyNumber()); 1030 .Times(testing::AnyNumber());
1037 1031
1038 // At the end the tests will post us a message. See _onTestSuiteComplete in 1032 // At the end the tests will post us a message. See _onTestSuiteComplete in
1039 // ...\src\data\selenium_core\core\scripts\selenium-testrunner.js 1033 // ...\src\data\selenium_core\core\scripts\selenium-testrunner.js
1040 EXPECT_CALL(ie_mock_, OnMessage(_, _, _)) 1034 EXPECT_CALL(ie_mock_, OnMessage(_, _, _))
1041 .WillOnce(testing::DoAll(VerifySeleniumCoreTestResults(), 1035 .WillOnce(testing::DoAll(VerifySeleniumCoreTestResults(),
1042 CloseBrowserMock(&ie_mock_))); 1036 CloseBrowserMock(&ie_mock_)));
1043 1037
1044 // Selenium tests take longer to finish, lets give it 2 mins. 1038 // Selenium tests take longer to finish, lets give it 2 mins.
1045 const int kSeleniumTestTimeout = 120; 1039 const base::TimeDelta kSeleniumTestTimeout = base::TimeDelta::FromMinutes(2);
1046 LaunchIENavigateAndLoop(url, kSeleniumTestTimeout); 1040 LaunchIENavigateAndLoop(url, kSeleniumTestTimeout);
1047 } 1041 }
1048 1042
1049 // See bug http://code.google.com/p/chromium/issues/detail?id=64901 1043 // See bug http://code.google.com/p/chromium/issues/detail?id=64901
1050 // This test does the following:- 1044 // This test does the following:-
1051 // Navigates IE to a non ChromeFrame URL. 1045 // Navigates IE to a non ChromeFrame URL.
1052 // Performs a top level form post in the document 1046 // Performs a top level form post in the document
1053 // In response to the POST send over a html document containing a meta tag 1047 // In response to the POST send over a html document containing a meta tag
1054 // This would cause IE to switch to ChromeFrame. 1048 // This would cause IE to switch to ChromeFrame.
1055 // Refresh the page in ChromeFrame. 1049 // Refresh the page in ChromeFrame.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 EXPECT_CALL(ie_mock_, OnBeforeNavigate2(_, 1107 EXPECT_CALL(ie_mock_, OnBeforeNavigate2(_,
1114 testing::Field(&VARIANT::bstrVal, 1108 testing::Field(&VARIANT::bstrVal,
1115 StrEq(tgt_url)), _, _, _, _, _)) 1109 StrEq(tgt_url)), _, _, _, _, _))
1116 .Times(2); 1110 .Times(2);
1117 1111
1118 EXPECT_CALL(ie_mock_, OnNavigateComplete2(_, 1112 EXPECT_CALL(ie_mock_, OnNavigateComplete2(_,
1119 testing::Field(&VARIANT::bstrVal, 1113 testing::Field(&VARIANT::bstrVal,
1120 StrEq(tgt_url)))) 1114 StrEq(tgt_url))))
1121 .Times(2); 1115 .Times(2);
1122 1116
1123 LaunchIENavigateAndLoop(src_url, 1117 LaunchIENavigateAndLoop(src_url, kChromeFrameVeryLongNavigationTimeout);
1124 kChromeFrameVeryLongNavigationTimeoutInSeconds);
1125 } 1118 }
1126 1119
1127 MATCHER_P(UserAgentHeaderMatcher, ua_string, "") { 1120 MATCHER_P(UserAgentHeaderMatcher, ua_string, "") {
1128 std::string headers = arg.headers(); 1121 std::string headers = arg.headers();
1129 StringToUpperASCII(&headers); 1122 StringToUpperASCII(&headers);
1130 1123
1131 std::string ua_string_to_search = ua_string; 1124 std::string ua_string_to_search = ua_string;
1132 StringToUpperASCII(&ua_string_to_search); 1125 StringToUpperASCII(&ua_string_to_search);
1133 1126
1134 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), 1127 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 .Times(2) 1190 .Times(2)
1198 .WillOnce(DelayRefresh(&ie_mock_, &loop_, 50)) 1191 .WillOnce(DelayRefresh(&ie_mock_, &loop_, 50))
1199 .WillOnce(CloseBrowserMock(&ie_mock_)); 1192 .WillOnce(CloseBrowserMock(&ie_mock_));
1200 } else { 1193 } else {
1201 // As mentioned above, we only receive an OnLoad for the intial load, not 1194 // As mentioned above, we only receive an OnLoad for the intial load, not
1202 // for the refresh. 1195 // for the refresh.
1203 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(src_url))) 1196 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(src_url)))
1204 .WillOnce(DelayRefresh(&ie_mock_, &loop_, 50)); 1197 .WillOnce(DelayRefresh(&ie_mock_, &loop_, 50));
1205 } 1198 }
1206 1199
1207 LaunchIENavigateAndLoop(src_url, 1200 LaunchIENavigateAndLoop(src_url, kChromeFrameVeryLongNavigationTimeout);
1208 kChromeFrameVeryLongNavigationTimeoutInSeconds);
1209 } 1201 }
1210 1202
1211 // Link navigations in the same domain specified with the noreferrer flag 1203 // Link navigations in the same domain specified with the noreferrer flag
1212 // should be opened in the host browser. 1204 // should be opened in the host browser.
1213 TEST_F(FullTabNavigationTest, JavascriptWindowOpenNoReferrerOpensInHost) { 1205 TEST_F(FullTabNavigationTest, JavascriptWindowOpenNoReferrerOpensInHost) {
1214 // Please see http://code.google.com/p/chromium/issues/detail?id=60987 1206 // Please see http://code.google.com/p/chromium/issues/detail?id=60987
1215 // for more information on why this test is disabled for Vista with IE7. 1207 // for more information on why this test is disabled for Vista with IE7.
1216 if (base::win::GetVersion() == base::win::VERSION_VISTA && 1208 if (base::win::GetVersion() == base::win::VERSION_VISTA &&
1217 GetInstalledIEVersion() == IE_7) { 1209 GetInstalledIEVersion() == IE_7) {
1218 LOG(INFO) << "Not running test on Vista with IE7"; 1210 LOG(INFO) << "Not running test on Vista with IE7";
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 EXPECT_CALL(new_window_mock, OnLoad(false, StrEq(new_window_url))) 1272 EXPECT_CALL(new_window_mock, OnLoad(false, StrEq(new_window_url)))
1281 .WillOnce(CloseBrowserMock(&new_window_mock)); 1273 .WillOnce(CloseBrowserMock(&new_window_mock));
1282 1274
1283 EXPECT_CALL(new_window_mock, OnQuit()) 1275 EXPECT_CALL(new_window_mock, OnQuit())
1284 .WillOnce(CloseBrowserMock( 1276 .WillOnce(CloseBrowserMock(
1285 &no_referrer_target_opener_window_mock)); 1277 &no_referrer_target_opener_window_mock));
1286 1278
1287 EXPECT_CALL(no_referrer_target_opener_window_mock, OnQuit()) 1279 EXPECT_CALL(no_referrer_target_opener_window_mock, OnQuit())
1288 .WillOnce(CloseBrowserMock(&ie_mock_)); 1280 .WillOnce(CloseBrowserMock(&ie_mock_));
1289 1281
1290 LaunchIENavigateAndLoop(initial_url, 1282 LaunchIENavigateAndLoop(initial_url, kChromeFrameVeryLongNavigationTimeout);
1291 kChromeFrameVeryLongNavigationTimeoutInSeconds);
1292 } 1283 }
1293 1284
1294 } // namespace chrome_frame_test 1285 } // namespace chrome_frame_test
OLDNEW
« no previous file with comments | « chrome_frame/test/mock_ie_event_sink_test.cc ('k') | chrome_frame/test/ready_mode_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698