summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-12 21:23:17 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-12 21:23:17 +0000
commitb7a4f36aa4ac90259978a7bdf83288e6889fbc83 (patch)
tree64cad15c393d984da88807aedf14b23faa58e22b
parent22b6c2fa87b4eb076ada08b949c30ebb3b0b727a (diff)
downloadchromium_src-b7a4f36aa4ac90259978a7bdf83288e6889fbc83.zip
chromium_src-b7a4f36aa4ac90259978a7bdf83288e6889fbc83.tar.gz
chromium_src-b7a4f36aa4ac90259978a7bdf83288e6889fbc83.tar.bz2
Fix flakiness
Fix expectations and check for locked workstation to make tests depending on user input non-flaky. BUG=47596,26549 TEST=FullTabUITest.CtrlN,FullTabUITest.KeyboardBackForward Review URL: http://codereview.chromium.org/4866002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65994 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome_frame/test/navigation_test.cc62
-rw-r--r--chrome_frame/test/ui_test.cc15
2 files changed, 40 insertions, 37 deletions
diff --git a/chrome_frame/test/navigation_test.cc b/chrome_frame/test/navigation_test.cc
index c8861d9..2a76d91 100644
--- a/chrome_frame/test/navigation_test.cc
+++ b/chrome_frame/test/navigation_test.cc
@@ -76,6 +76,7 @@ TEST_P(FullTabNavigationTest, TypeAnchorUrl) {
ie_mock_.ExpectNavigation(IN_IE, GetSimplePageUrl());
server_mock_.ExpectAndServeRequest(CFInvocation::None(), GetSimplePageUrl());
+
// Enter the new url into the address bar.
EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(GetSimplePageUrl())))
.WillOnce(testing::DoAll(
@@ -83,7 +84,7 @@ TEST_P(FullTabNavigationTest, TypeAnchorUrl) {
AccWatchForOneValueChange(&acc_observer, address_matcher)));
// Click the go button once the address has changed.
EXPECT_CALL(acc_observer, OnAccValueChange(_, _, GetAnchorPageUrl(1)))
- .WillOnce(AccLeftClickInBrowser(&ie_mock_, go_matcher));
+ .WillOnce(AccDoDefaultActionInBrowser(&ie_mock_, go_matcher));
bool in_cf = GetParam().invokes_cf();
ie_mock_.ExpectNavigation(in_cf, GetAnchorPageUrl(1));
@@ -273,50 +274,47 @@ TEST_P(FullTabNavigationTest, BackForwardAnchor) {
// Test that a user cannot navigate to a restricted site and that the security
// dialog appears.
-TEST_P(FullTabNavigationTest, FLAKY_RestrictedSite) {
- if (!GetParam().invokes_cf() || GetInstalledIEVersion() == IE_8) {
- // Test has been disabled on IE8 bot because it hangs at times.
- // http://crbug.com/47596
- LOG(ERROR) << "Test disabled for this configuration.";
- return;
- }
- MockWindowObserver win_observer_mock;
-
+TEST_P(FullTabNavigationTest, RestrictedSite) {
+ // Add the server to restricted sites zone.
ScopedComPtr<IInternetSecurityManager> security_manager;
HRESULT hr = security_manager.CreateInstance(CLSID_InternetSecurityManager);
ASSERT_HRESULT_SUCCEEDED(hr);
- // Add the server to restricted sites zone.
hr = security_manager->SetZoneMapping(URLZONE_UNTRUSTED,
GetTestUrl(L"").c_str(), SZM_CREATE);
EXPECT_CALL(ie_mock_, OnFileDownload(_, _)).Times(testing::AnyNumber());
server_mock_.ExpectAndServeAnyRequests(GetParam());
- const char* kAlertDlgCaption = "Security Alert";
+ MockWindowObserver win_observer_mock;
- EXPECT_CALL(ie_mock_, OnBeforeNavigate2(
- _,
- testing::Field(&VARIANT::bstrVal, testing::StrCaseEq(GetSimplePageUrl())),
- _, _, _, _, _))
- .Times(1)
- .WillOnce(WatchWindow(&win_observer_mock, kAlertDlgCaption, ""));
+ // If the page is loaded in mshtml, then IE allows the page to be loaded
+ // and just shows 'Restricted sites' in the status bar.
+ if (!GetParam().invokes_cf()) {
+ ie_mock_.ExpectNavigation(IN_IE, GetSimplePageUrl());
+ EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(GetSimplePageUrl())))
+ .Times(1)
+ .WillOnce(CloseBrowserMock(&ie_mock_));
+ } else {
+ // If the page is being loaded in chrome frame then we will see
+ // a security dialog.
+ const char* kAlertDlgCaption = "Security Alert";
+ win_observer_mock.WatchWindow(kAlertDlgCaption, "");
- EXPECT_CALL(ie_mock_, OnBeforeNavigate2(
- _,
- testing::Field(&VARIANT::bstrVal, testing::HasSubstr(L"res://")),
- _, _, _, _, _))
- .Times(testing::AtMost(1));
+ EXPECT_CALL(ie_mock_, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal,
+ testing::StrCaseEq(GetSimplePageUrl())), _, _, _, _, _))
+ .Times(1);
- EXPECT_CALL(ie_mock_, OnNavigateComplete2(_,
- testing::Field(&VARIANT::bstrVal, StrEq(GetSimplePageUrl()))))
- .Times(testing::AtMost(1));
+ EXPECT_CALL(ie_mock_, OnNavigateComplete2(_,
+ testing::Field(&VARIANT::bstrVal, StrEq(GetSimplePageUrl()))))
+ .Times(testing::AtMost(1));
- EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
- .Times(1)
- .WillOnce(DoCloseWindow());
- EXPECT_CALL(win_observer_mock, OnWindowClose(_))
- .Times(1)
- .WillOnce(CloseBrowserMock(&ie_mock_));
+ EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
+ .Times(1)
+ .WillOnce(DoCloseWindow());
+ EXPECT_CALL(win_observer_mock, OnWindowClose(_))
+ .Times(1)
+ .WillOnce(CloseBrowserMock(&ie_mock_));
+ }
LaunchIEAndNavigate(GetSimplePageUrl());
diff --git a/chrome_frame/test/ui_test.cc b/chrome_frame/test/ui_test.cc
index eaa6af0..aa2e809 100644
--- a/chrome_frame/test/ui_test.cc
+++ b/chrome_frame/test/ui_test.cc
@@ -67,9 +67,12 @@ TEST_P(FullTabUITest, KeyboardInput) {
}
// Tests keyboard shortcuts for back and forward.
-// Marking this test FLAKY as it fails at times on the buildbot.
-// http://code.google.com/p/chromium/issues/detail?id=26549
-TEST_P(FullTabUITest, FLAKY_KeyboardBackForward) {
+TEST_P(FullTabUITest, KeyboardBackForward) {
+ if (IsWorkstationLocked()) {
+ LOG(ERROR) << "This test cannot be run in a locked workstation.";
+ return;
+ }
+
std::wstring page1 = GetSimplePageUrl();
std::wstring page2 = GetLinkPageUrl();
bool in_cf = GetParam().invokes_cf();
@@ -89,7 +92,7 @@ TEST_P(FullTabUITest, FLAKY_KeyboardBackForward) {
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2)))
.WillOnce(testing::DoAll(
SetFocusToRenderer(&ie_mock_),
- DelaySendScanCode(&loop_, 500, bkspace, simulate_input::NONE)));
+ DelaySendScanCode(&loop_, 1000, bkspace, simulate_input::NONE)));
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page1)))
.WillOnce(testing::DoAll(
@@ -135,7 +138,9 @@ TEST_P(FullTabUITest, CtrlN) {
.WillOnce(testing::Return());
EXPECT_CALL(win_observer_mock, OnWindowClose(_))
- .WillOnce(CloseBrowserMock(&ie_mock_));
+ .Times(testing::AtMost(2))
+ .WillOnce(CloseBrowserMock(&ie_mock_))
+ .WillOnce(testing::Return());
LaunchIEAndNavigate(GetSimplePageUrl());
}