| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <mshtmcid.h> |
| 6 #include <string> |
| 7 |
| 8 #include "chrome/common/url_constants.h" |
| 9 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 10 #include "chrome_frame/test/mock_ie_event_sink_actions.h" |
| 11 #include "chrome_frame/test/mock_ie_event_sink_test.h" |
| 12 |
| 13 using testing::_; |
| 14 using testing::InSequence; |
| 15 using testing::StrCaseEq; |
| 16 using testing::StrEq; |
| 17 |
| 18 namespace chrome_frame_test { |
| 19 |
| 20 // This parameterized test fixture uses the MockIEEventSink and is used by |
| 21 // UI-related tests. |
| 22 class FullTabUITest : public MockIEEventSinkTest, |
| 23 public testing::TestWithParam<CFInvocation> { |
| 24 public: |
| 25 FullTabUITest() {} |
| 26 |
| 27 virtual void SetUp() { |
| 28 // These are UI-related tests, so we do not care about the exact requests |
| 29 // and navigations that occur. |
| 30 server_mock_.ExpectAndServeAnyRequests(GetParam()); |
| 31 ie_mock_.ExpectAnyNavigations(); |
| 32 } |
| 33 }; |
| 34 |
| 35 // Instantiate each test case for the IE case and for CF meta tag case. |
| 36 // It does not seem too useful to also run the CF http header case since these |
| 37 // are UI, not navigation tests. |
| 38 INSTANTIATE_TEST_CASE_P(IE, FullTabUITest, |
| 39 testing::Values(CFInvocation::None())); |
| 40 INSTANTIATE_TEST_CASE_P(CF, FullTabUITest, |
| 41 testing::Values(CFInvocation::MetaTag())); |
| 42 |
| 43 // Tests keyboard input. |
| 44 // Marking this test FLAKY as it fails at times on the buildbot. |
| 45 // http://code.google.com/p/chromium/issues/detail?id=26549 |
| 46 TEST_P(FullTabUITest, FLAKY_KeyboardInput) { |
| 47 if (!GetParam().invokes_cf()) |
| 48 return; // This test does not work for IE yet. |
| 49 std::wstring key_event_url = GetTestUrl(L"keyevent.html"); |
| 50 |
| 51 const wchar_t* input = L"Chrome"; |
| 52 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), StrEq(key_event_url))) |
| 53 .WillOnce(testing::DoAll( |
| 54 SetFocusToRenderer(&ie_mock_), |
| 55 DelaySendString(&loop_, 500, input))); |
| 56 |
| 57 EXPECT_CALL(ie_mock_, OnMessage(StrCaseEq(input), _, _)) |
| 58 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 59 |
| 60 LaunchIEAndNavigate(key_event_url); |
| 61 } |
| 62 |
| 63 // Tests keyboard shortcuts for back and forward. |
| 64 // Marking this test FLAKY as it fails at times on the buildbot. |
| 65 // http://code.google.com/p/chromium/issues/detail?id=26549 |
| 66 TEST_P(FullTabUITest, FLAKY_KeyboardBackForward) { |
| 67 std::wstring page1 = GetSimplePageUrl(); |
| 68 std::wstring page2 = GetLinkPageUrl(); |
| 69 bool in_cf = GetParam().invokes_cf(); |
| 70 InSequence expect_in_sequence_for_scope; |
| 71 |
| 72 // This test performs the following steps. |
| 73 // 1. Launches IE and navigates to page1 |
| 74 // 2. It then navigates to page2 |
| 75 // 3. Sends the VK_BACK keystroke to IE, which should navigate back to |
| 76 // page 1 |
| 77 // 4. Sends the Shift + VK_BACK keystroke to IE which should navigate |
| 78 // forward to page2 |
| 79 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page1))) |
| 80 .WillOnce(Navigate(&ie_mock_, page2)); |
| 81 |
| 82 short bkspace = VkKeyScanA(VK_BACK); // NOLINT |
| 83 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2))) |
| 84 .WillOnce(testing::DoAll( |
| 85 SetFocusToRenderer(&ie_mock_), |
| 86 DelaySendScanCode(&loop_, 500, bkspace, simulate_input::NONE))); |
| 87 |
| 88 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page1))) |
| 89 .WillOnce(testing::DoAll( |
| 90 SetFocusToRenderer(&ie_mock_), |
| 91 DelaySendScanCode(&loop_, 500, bkspace, simulate_input::SHIFT))); |
| 92 |
| 93 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2))) |
| 94 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 95 |
| 96 LaunchIEAndNavigate(page1); |
| 97 } |
| 98 |
| 99 // Tests new window behavior with ctrl+N. |
| 100 TEST_P(FullTabUITest, FLAKY_CtrlN) { |
| 101 bool is_cf = GetParam().invokes_cf(); |
| 102 if (!is_cf) { |
| 103 return; // This test does not work for IE yet. |
| 104 } |
| 105 // Ideally we want to use a ie_mock_ to watch for finer grained |
| 106 // events for New Window, but for Crl+N we don't get any |
| 107 // OnNewWindowX notifications. :( |
| 108 MockWindowObserver win_observer_mock; |
| 109 const wchar_t* kIEFrameClass = L"IEFrame"; |
| 110 EXPECT_CALL(ie_mock_, OnLoad(is_cf, StrEq(GetSimplePageUrl()))) |
| 111 .WillOnce(testing::DoAll( |
| 112 WatchWindow(&win_observer_mock, kIEFrameClass), |
| 113 SetFocusToRenderer(&ie_mock_), |
| 114 DelaySendChar(&loop_, 500, 'n', simulate_input::CONTROL))); |
| 115 |
| 116 // Watch for new window |
| 117 const char* kNewWindowTitle = "Internet Explorer"; |
| 118 EXPECT_CALL(win_observer_mock, |
| 119 OnWindowDetected(_, testing::HasSubstr(kNewWindowTitle))) |
| 120 .WillOnce(testing::DoAll( |
| 121 DoCloseWindow(), |
| 122 CloseBrowserMock(&ie_mock_))); |
| 123 |
| 124 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 125 // TODO(kkania): The new window does not close properly. |
| 126 } |
| 127 |
| 128 // Test that ctrl+r does cause a refresh. |
| 129 TEST_P(FullTabUITest, FLAKY_CtrlR) { |
| 130 InSequence expect_in_sequence_for_scope; |
| 131 bool is_cf = GetParam().invokes_cf(); |
| 132 |
| 133 EXPECT_CALL(ie_mock_, OnLoad(is_cf, StrEq(GetSimplePageUrl()))) |
| 134 .WillOnce(testing::DoAll( |
| 135 SetFocusToRenderer(&ie_mock_), |
| 136 DelaySendChar(&loop_, 500, 'r', simulate_input::CONTROL))); |
| 137 |
| 138 EXPECT_CALL(server_mock_, Get(_, UrlPathEq(GetSimplePageUrl()), _)) |
| 139 .WillOnce(testing::DoAll( |
| 140 SendResponse(&server_mock_, GetParam()), |
| 141 CloseBrowserMock(&ie_mock_))); |
| 142 |
| 143 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 144 } |
| 145 |
| 146 // Test window close with ctrl+w. |
| 147 TEST_P(FullTabUITest, FLAKY_CtrlW) { |
| 148 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), |
| 149 StrEq(GetSimplePageUrl()))) |
| 150 .WillOnce(testing::DoAll( |
| 151 SetFocusToRenderer(&ie_mock_), |
| 152 DelaySendChar(&loop_, 500, 'w', simulate_input::CONTROL))); |
| 153 |
| 154 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 155 } |
| 156 |
| 157 // Test address bar navigation with Alt+d and URL. |
| 158 TEST_P(FullTabUITest, FLAKY_AltD) { |
| 159 if (IsIBrowserServicePatchEnabled()) { |
| 160 LOG(ERROR) << "Not running test. IBrowserServicePatch is in place."; |
| 161 return; |
| 162 } |
| 163 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), |
| 164 StrEq(GetSimplePageUrl()))) |
| 165 .WillOnce(testing::DoAll( |
| 166 SetFocusToRenderer(&ie_mock_), |
| 167 TypeUrlInAddressBar(&loop_, GetLinkPageUrl(), 1500))); |
| 168 |
| 169 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), |
| 170 StrEq(GetLinkPageUrl()))) |
| 171 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 172 |
| 173 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 174 } |
| 175 |
| 176 // Tests that the renderer has focus after navigation. |
| 177 TEST_P(FullTabUITest, RendererHasFocus) { |
| 178 EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), |
| 179 StrEq(GetSimplePageUrl()))) |
| 180 .WillOnce(testing::DoAll( |
| 181 ExpectRendererHasFocus(&ie_mock_), |
| 182 CloseBrowserMock(&ie_mock_))); |
| 183 |
| 184 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 185 } |
| 186 |
| 187 // Tests that view source works. |
| 188 // This test has been marked FLAKY |
| 189 // http://code.google.com/p/chromium/issues/detail?id=35370 |
| 190 TEST_P(FullTabUITest, FLAKY_ViewSource) { |
| 191 bool in_cf = GetParam().invokes_cf(); |
| 192 if (!in_cf) |
| 193 return; // This test does not work for IE yet. |
| 194 MockIEEventSink view_source_mock; |
| 195 InSequence expect_in_sequence_for_scope; |
| 196 |
| 197 // After navigation invoke view soruce action using IWebBrowser2::ExecWB |
| 198 VARIANT empty = ScopedVariant::kEmptyVariant; |
| 199 EXPECT_CALL(ie_mock_, OnLoad(in_cf, |
| 200 StrEq(GetSimplePageUrl()))) |
| 201 .WillOnce(DelayExecCommand(&ie_mock_, &loop_, 0, &CGID_MSHTML, |
| 202 static_cast<OLECMDID>(IDM_VIEWSOURCE), |
| 203 OLECMDEXECOPT_DONTPROMPTUSER, &empty, &empty)); |
| 204 |
| 205 // Expect notification for view-source window, handle new window event |
| 206 // and attach a new ie_mock_ to the received web browser |
| 207 std::wstring view_source_url; |
| 208 view_source_url += UTF8ToWide(chrome::kViewSourceScheme); |
| 209 view_source_url += L":"; |
| 210 view_source_url += GetSimplePageUrl(); |
| 211 std::wstring url_in_new_window = kChromeProtocolPrefix; |
| 212 url_in_new_window += view_source_url; |
| 213 |
| 214 ie_mock_.ExpectNewWindow(&view_source_mock); |
| 215 // For some reason this happens occasionally at least on XP IE7. |
| 216 EXPECT_CALL(view_source_mock, OnLoad(false, StrEq(url_in_new_window))) |
| 217 .Times(testing::AtMost(1)); |
| 218 EXPECT_CALL(view_source_mock, OnLoad(in_cf, StrEq(view_source_url))) |
| 219 .WillOnce(testing::DoAll( |
| 220 VerifyAddressBarUrlWithGcf(&view_source_mock), |
| 221 CloseBrowserMock(&view_source_mock))); |
| 222 |
| 223 EXPECT_CALL(view_source_mock, OnQuit()) |
| 224 .Times(testing::AtMost(1)) |
| 225 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 226 |
| 227 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 228 } |
| 229 |
| 230 // Test fixture for tests related to the context menu UI. Since the context |
| 231 // menus for CF and IE are different, these tests are not parameterized. |
| 232 class ContextMenuTest : public MockIEEventSinkTest, public testing::Test { |
| 233 public: |
| 234 ContextMenuTest() {} |
| 235 |
| 236 virtual void SetUp() { |
| 237 // These are UI-related tests, so we do not care about the exact requests |
| 238 // and navigations that occur. |
| 239 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag()); |
| 240 ie_mock_.ExpectAnyNavigations(); |
| 241 } |
| 242 }; |
| 243 |
| 244 // Test Reload from context menu. |
| 245 // Marking this test FLAKY as it fails at times on the buildbot. |
| 246 // http://code.google.com/p/chromium/issues/detail?id=26549 |
| 247 TEST_F(ContextMenuTest, FLAKY_CFReload) { |
| 248 InSequence expect_in_sequence_for_scope; |
| 249 |
| 250 // Reload using Rt-Click + DOWN + DOWN + DOWN + ENTER |
| 251 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl()))) |
| 252 .WillOnce(testing::DoAll( |
| 253 DelaySendMouseClick(&ie_mock_, &loop_, 0, 10, 10, |
| 254 simulate_input::RIGHT), |
| 255 SendExtendedKeysEnter(&loop_, 500, VK_DOWN, 3, |
| 256 simulate_input::NONE))); |
| 257 |
| 258 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl()))) |
| 259 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 260 |
| 261 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 262 } |
| 263 |
| 264 // Test view source using context menu |
| 265 // Marking this test FLAKY as it fails at times on the buildbot. |
| 266 // http://code.google.com/p/chromium/issues/detail?id=26549 |
| 267 TEST_F(ContextMenuTest, FLAKY_CFViewSource) { |
| 268 MockIEEventSink view_source_mock; |
| 269 InSequence expect_in_sequence_for_scope; |
| 270 |
| 271 // View source using Rt-Click + UP + UP + UP + UP + ENTER |
| 272 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl()))) |
| 273 .WillOnce(testing::DoAll( |
| 274 DelaySendMouseClick(&ie_mock_, &loop_, 0, 10, 10, |
| 275 simulate_input::RIGHT), |
| 276 SendExtendedKeysEnter(&loop_, 500, VK_UP, 4, simulate_input::NONE))); |
| 277 |
| 278 // Expect notification for view-source window, handle new window event |
| 279 // and attach a new ie_mock_ to the received web browser |
| 280 std::wstring view_source_url; |
| 281 view_source_url += UTF8ToWide(chrome::kViewSourceScheme); |
| 282 view_source_url += L":"; |
| 283 view_source_url += GetSimplePageUrl(); |
| 284 std::wstring url_in_new_window = kChromeProtocolPrefix; |
| 285 url_in_new_window += view_source_url; |
| 286 |
| 287 ie_mock_.ExpectNewWindow(&view_source_mock); |
| 288 EXPECT_CALL(view_source_mock, OnLoad(IN_CF, StrEq(view_source_url))) |
| 289 .WillOnce(testing::DoAll( |
| 290 VerifyAddressBarUrlWithGcf(&view_source_mock), |
| 291 CloseBrowserMock(&view_source_mock))); |
| 292 EXPECT_CALL(view_source_mock, OnQuit()) |
| 293 .Times(testing::AtMost(1)) |
| 294 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 295 |
| 296 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 297 } |
| 298 |
| 299 TEST_F(ContextMenuTest, FLAKY_CFPageInfo) { |
| 300 MockWindowObserver win_observer_mock; |
| 301 InSequence expect_in_sequence_for_scope; |
| 302 |
| 303 // View page information using Rt-Click + UP + UP + UP + ENTER |
| 304 const wchar_t* kPageInfoWindowClass = L"Chrome_WidgetWin_0"; |
| 305 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl()))) |
| 306 .WillOnce(testing::DoAll( |
| 307 WatchWindow(&win_observer_mock, kPageInfoWindowClass), |
| 308 DelaySendMouseClick(&ie_mock_, &loop_, 0, 10, 10, |
| 309 simulate_input::RIGHT), |
| 310 SendExtendedKeysEnter(&loop_, 500, VK_UP, 3, simulate_input::NONE))); |
| 311 |
| 312 // Expect page info dialog to pop up. Dismiss the dialog with 'Esc' key |
| 313 const char* kPageInfoCaption = "Security Information"; |
| 314 EXPECT_CALL(win_observer_mock, OnWindowDetected(_, StrEq(kPageInfoCaption))) |
| 315 .WillOnce(testing::DoAll( |
| 316 DelaySendChar(&loop_, 100, VK_ESCAPE, simulate_input::NONE), |
| 317 DelayCloseBrowserMock(&loop_, 2000, &ie_mock_))); |
| 318 |
| 319 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 320 } |
| 321 |
| 322 TEST_F(ContextMenuTest, FLAKY_CFInspector) { |
| 323 MockWindowObserver win_observer_mock; |
| 324 InSequence expect_in_sequence_for_scope; |
| 325 |
| 326 // Open developer tools using Rt-Click + UP + UP + ENTER |
| 327 const wchar_t* kPageInfoWindowClass = L"Chrome_WidgetWin_0"; |
| 328 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl()))) |
| 329 .WillOnce(testing::DoAll( |
| 330 WatchWindow(&win_observer_mock, kPageInfoWindowClass), |
| 331 DelaySendMouseClick(&ie_mock_, &loop_, 0, 10, 10, |
| 332 simulate_input::RIGHT), |
| 333 SendExtendedKeysEnter(&loop_, 500, VK_UP, 2, simulate_input::NONE))); |
| 334 |
| 335 // Devtools begins life with "Untitled" caption and it changes |
| 336 // later to the 'Developer Tools - <url> form. |
| 337 const char* kPageInfoCaption = "Untitled"; |
| 338 EXPECT_CALL(win_observer_mock, |
| 339 OnWindowDetected(_, testing::StartsWith(kPageInfoCaption))) |
| 340 .WillOnce(testing::DoAll( |
| 341 SetFocusToRenderer(&ie_mock_), |
| 342 DelayCloseBrowserMock(&loop_, 2000, &ie_mock_))); |
| 343 |
| 344 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 345 } |
| 346 |
| 347 TEST_F(ContextMenuTest, FLAKY_CFSaveAs) { |
| 348 MockWindowObserver win_observer_mock; |
| 349 InSequence expect_in_sequence_for_scope; |
| 350 |
| 351 // Open'Save As' dialog using Rt-Click + DOWN + DOWN + DOWN + DOWN + ENTER |
| 352 const wchar_t* kSaveDlgClass = L"#32770"; |
| 353 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl()))) |
| 354 .WillOnce(testing::DoAll( |
| 355 WatchWindow(&win_observer_mock, kSaveDlgClass), |
| 356 DelaySendMouseClick(&ie_mock_, &loop_, 0, 10, 10, |
| 357 simulate_input::RIGHT), |
| 358 SendExtendedKeysEnter(&loop_, 500, VK_DOWN, 4, |
| 359 simulate_input::NONE))); |
| 360 |
| 361 FilePath temp_file_path; |
| 362 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); |
| 363 temp_file_path = temp_file_path.ReplaceExtension(L".htm"); |
| 364 |
| 365 const wchar_t* kSaveFileName = temp_file_path.value().c_str(); |
| 366 DeleteFile(kSaveFileName); |
| 367 |
| 368 const char* kSaveDlgCaption = "Save As"; |
| 369 EXPECT_CALL(win_observer_mock, OnWindowDetected(_, StrEq(kSaveDlgCaption))) |
| 370 .WillOnce(testing::DoAll( |
| 371 DelaySendString(&loop_, 100, kSaveFileName), |
| 372 DelaySendChar(&loop_, 200, VK_RETURN, simulate_input::NONE), |
| 373 DelayCloseBrowserMock(&loop_, 4000, &ie_mock_))); |
| 374 |
| 375 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 376 ASSERT_NE(INVALID_FILE_ATTRIBUTES, GetFileAttributes(kSaveFileName)); |
| 377 ASSERT_TRUE(DeleteFile(kSaveFileName)); |
| 378 } |
| 379 |
| 380 // This tests that the about:version page can be opened via the CF context menu. |
| 381 TEST_F(ContextMenuTest, FLAKY_CFAboutVersionLoads) { |
| 382 const wchar_t* kAboutVersionUrl = L"gcf:about:version"; |
| 383 const wchar_t* kAboutVersionWithoutProtoUrl = L"about:version"; |
| 384 MockIEEventSink new_window_mock; |
| 385 |
| 386 ie_mock_.ExpectNavigation(IN_CF, GetSimplePageUrl()); |
| 387 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl()))) |
| 388 .WillOnce(testing::DoAll( |
| 389 DelaySendMouseClick(&ie_mock_, &loop_, 0, 10, 10, |
| 390 simulate_input::RIGHT), |
| 391 SendExtendedKeysEnter(&loop_, 500, VK_UP, 1, simulate_input::NONE))); |
| 392 |
| 393 ie_mock_.ExpectNewWindow(&new_window_mock); |
| 394 EXPECT_CALL(new_window_mock, |
| 395 OnLoad(IN_CF, StrEq(kAboutVersionWithoutProtoUrl))) |
| 396 .WillOnce(testing::DoAll( |
| 397 VerifyAddressBarUrlWithGcf(&new_window_mock), |
| 398 CloseBrowserMock(&new_window_mock))); |
| 399 |
| 400 EXPECT_CALL(new_window_mock, OnQuit()) |
| 401 .Times(testing::AtMost(1)) |
| 402 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 403 |
| 404 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 405 } |
| 406 |
| 407 TEST_F(ContextMenuTest, FLAKY_IEOpen) { |
| 408 server_mock_.ExpectAndServeAnyRequests(CFInvocation::None()); |
| 409 // Focus the renderer window by clicking and then tab once to highlight the |
| 410 // link. |
| 411 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(GetLinkPageUrl()))) |
| 412 .WillOnce(testing::DoAll( |
| 413 DelaySendMouseClick(&ie_mock_, &loop_, 0, 1, 1, simulate_input::LEFT), |
| 414 DelaySendScanCode(&loop_, 1000, VK_TAB, simulate_input::NONE), |
| 415 OpenContextMenu(&loop_, 2000), |
| 416 SelectItem(&loop_, 3000, 0))); |
| 417 |
| 418 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(GetSimplePageUrl()))) |
| 419 .WillOnce(testing::DoAll( |
| 420 VerifyAddressBarUrl(&ie_mock_), |
| 421 CloseBrowserMock(&ie_mock_))); |
| 422 |
| 423 LaunchIEAndNavigate(GetLinkPageUrl()); |
| 424 } |
| 425 |
| 426 TEST_F(ContextMenuTest, FLAKY_IEOpenInNewWindow) { |
| 427 server_mock_.ExpectAndServeAnyRequests(CFInvocation::None()); |
| 428 MockIEEventSink new_window_mock; |
| 429 |
| 430 int open_new_window_index = 2; |
| 431 if (chrome_frame_test::GetInstalledIEVersion() == IE_6) |
| 432 open_new_window_index = 1; |
| 433 |
| 434 // Focus the renderer window by clicking and then tab once to highlight the |
| 435 // link. |
| 436 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(GetLinkPageUrl()))) |
| 437 .WillOnce(testing::DoAll( |
| 438 DelaySendMouseClick(&ie_mock_, &loop_, 0, 1, 1, simulate_input::LEFT), |
| 439 DelaySendScanCode(&loop_, 500, VK_TAB, simulate_input::NONE), |
| 440 OpenContextMenu(&loop_, 1000), |
| 441 SelectItem(&loop_, 1500, open_new_window_index))); |
| 442 |
| 443 ie_mock_.ExpectNewWindow(&new_window_mock); |
| 444 EXPECT_CALL(new_window_mock, OnLoad(IN_IE, StrEq(GetSimplePageUrl()))) |
| 445 // TODO(kkania): Verifying the address bar is flaky with this, at least |
| 446 // on XP ie6. Fix. |
| 447 .WillOnce(CloseBrowserMock(&new_window_mock)); |
| 448 |
| 449 EXPECT_CALL(new_window_mock, OnQuit()) |
| 450 .Times(testing::AtMost(1)) |
| 451 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 452 |
| 453 LaunchIEAndNavigate(GetLinkPageUrl()); |
| 454 } |
| 455 |
| 456 // Test Back/Forward from context menu. |
| 457 // Marking this test FLAKY as it fails at times on the buildbot. |
| 458 // http://code.google.com/p/chromium/issues/detail?id=26549 |
| 459 TEST_F(ContextMenuTest, FLAKY_IEBackForward) { |
| 460 server_mock_.ExpectAndServeAnyRequests(CFInvocation::None()); |
| 461 std::wstring page1 = GetLinkPageUrl(); |
| 462 std::wstring page2 = GetSimplePageUrl(); |
| 463 InSequence expect_in_sequence_for_scope; |
| 464 |
| 465 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page1))) |
| 466 .WillOnce(Navigate(&ie_mock_, page2)); |
| 467 |
| 468 // Go back using Rt-Click + DOWN + ENTER |
| 469 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page2))) |
| 470 .WillOnce(testing::DoAll( |
| 471 DelaySendMouseClick(&ie_mock_, &loop_, 0, 10, 10, |
| 472 simulate_input::RIGHT), |
| 473 SendExtendedKeysEnter(&loop_, 500, VK_DOWN, 1, |
| 474 simulate_input::NONE))); |
| 475 |
| 476 // Go forward using Rt-Click + DOWN + DOWN + ENTER |
| 477 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page1))) |
| 478 .WillOnce(testing::DoAll( |
| 479 DelaySendMouseClick(&ie_mock_, &loop_, 0, 10, 10, |
| 480 simulate_input::RIGHT), |
| 481 SendExtendedKeysEnter(&loop_, 500, VK_DOWN, 2, |
| 482 simulate_input::NONE))); |
| 483 |
| 484 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page2))) |
| 485 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 486 |
| 487 LaunchIEAndNavigate(page1); |
| 488 } |
| 489 |
| 490 // Test Back/Forward from context menu. Loads page 1 in chrome and page 2 |
| 491 // in IE. Then it tests back and forward using context menu |
| 492 // Disabling this test as it won't work as per the current chrome external tab |
| 493 // design. |
| 494 // http://code.google.com/p/chromium/issues/detail?id=46615 |
| 495 TEST_F(ContextMenuTest, DISABLED_BackForwardWithSwitch) { |
| 496 std::wstring page1 = GetLinkPageUrl(); |
| 497 std::wstring page2 = GetSimplePageUrl(); |
| 498 InSequence expect_in_sequence_for_scope; |
| 499 |
| 500 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(page1))) |
| 501 .WillOnce(Navigate(&ie_mock_, page2)); |
| 502 |
| 503 server_mock_.ExpectAndServeRequest(CFInvocation::None(), page2); |
| 504 // Go back using Rt-Click + DOWN + ENTER |
| 505 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page2))) |
| 506 .WillOnce(testing::DoAll( |
| 507 DelaySendMouseClick(&ie_mock_, &loop_, 0, 10, 10, |
| 508 simulate_input::RIGHT), |
| 509 SendExtendedKeysEnter(&loop_, 500, VK_DOWN, 1, |
| 510 simulate_input::NONE))); |
| 511 |
| 512 // Go forward using Rt-Click + DOWN + DOWN + ENTER |
| 513 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(page1))) |
| 514 .WillOnce(testing::DoAll( |
| 515 DelaySendMouseClick(&ie_mock_, &loop_, 0, 10, 10, |
| 516 simulate_input::RIGHT), |
| 517 SendExtendedKeysEnter(&loop_, 500, VK_DOWN, 2, |
| 518 simulate_input::NONE))); |
| 519 |
| 520 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page2))) |
| 521 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 522 |
| 523 LaunchIEAndNavigate(page1); |
| 524 } |
| 525 |
| 526 } // namespace chrome_frame_test |
| OLD | NEW |