| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 <mshtmcid.h> | 5 #include <mshtmcid.h> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/scoped_variant_win.h" | 8 #include "base/scoped_variant_win.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "chrome_frame/test/chrome_frame_test_utils.h" | 10 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 11 #include "chrome_frame/test/mock_ie_event_sink_actions.h" | 11 #include "chrome_frame/test/mock_ie_event_sink_actions.h" |
| 12 #include "chrome_frame/test/mock_ie_event_sink_test.h" | 12 #include "chrome_frame/test/mock_ie_event_sink_test.h" |
| 13 | 13 |
| 14 #include "testing/gmock_mutant.h" |
| 15 |
| 14 using testing::_; | 16 using testing::_; |
| 15 using testing::InSequence; | 17 using testing::InSequence; |
| 16 using testing::StrCaseEq; | 18 using testing::StrCaseEq; |
| 17 using testing::StrEq; | 19 using testing::StrEq; |
| 18 | 20 |
| 19 namespace chrome_frame_test { | 21 namespace chrome_frame_test { |
| 20 | 22 |
| 21 // This parameterized test fixture uses the MockIEEventSink and is used by | 23 // This parameterized test fixture uses the MockIEEventSink and is used by |
| 22 // UI-related tests. | 24 // UI-related tests. |
| 23 class FullTabUITest : public MockIEEventSinkTest, | 25 class FullTabUITest : public MockIEEventSinkTest, |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 VerifyAddressBarUrlWithGcf(&view_source_mock), | 230 VerifyAddressBarUrlWithGcf(&view_source_mock), |
| 229 CloseBrowserMock(&view_source_mock))); | 231 CloseBrowserMock(&view_source_mock))); |
| 230 | 232 |
| 231 EXPECT_CALL(view_source_mock, OnQuit()) | 233 EXPECT_CALL(view_source_mock, OnQuit()) |
| 232 .Times(testing::AtMost(1)) | 234 .Times(testing::AtMost(1)) |
| 233 .WillOnce(CloseBrowserMock(&ie_mock_)); | 235 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 234 | 236 |
| 235 LaunchIEAndNavigate(GetSimplePageUrl()); | 237 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 236 } | 238 } |
| 237 | 239 |
| 240 void NavigateToCurrentUrl(MockIEEventSink* mock) { |
| 241 IWebBrowser2* browser = mock->event_sink()->web_browser2(); |
| 242 DCHECK(browser); |
| 243 ScopedBstr bstr; |
| 244 HRESULT hr = browser->get_LocationURL(bstr.Receive()); |
| 245 EXPECT_HRESULT_SUCCEEDED(hr); |
| 246 if (SUCCEEDED(hr)) { |
| 247 DCHECK(bstr.Length()); |
| 248 VARIANT empty = ScopedVariant::kEmptyVariant; |
| 249 hr = browser->Navigate(bstr, &empty, &empty, &empty, &empty); |
| 250 EXPECT_HRESULT_SUCCEEDED(hr); |
| 251 } |
| 252 } |
| 253 |
| 254 // Tests that Chrome gets re-instantiated after crash if we reload via |
| 255 // the address bar or via a new navigation. |
| 256 TEST_P(FullTabUITest, TabCrashReload) { |
| 257 using testing::DoAll; |
| 258 |
| 259 if (!GetParam().invokes_cf()) { |
| 260 LOG(ERROR) << "Test needs CF."; |
| 261 return; |
| 262 } |
| 263 |
| 264 MockPropertyNotifySinkListener prop_listener; |
| 265 InSequence expect_in_sequence_for_scope; |
| 266 |
| 267 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl()))) |
| 268 .WillOnce(DoAll( |
| 269 ExpectRendererHasFocus(&ie_mock_), |
| 270 ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE), |
| 271 ConnectDocPropNotifySink(&ie_mock_, &prop_listener), |
| 272 KillChromeFrameProcesses())); |
| 273 |
| 274 EXPECT_CALL(prop_listener, OnChanged(DISPID_READYSTATE)) |
| 275 .WillOnce(DoAll( |
| 276 ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED), |
| 277 DelayNavigateToCurrentUrl(&ie_mock_, &loop_, 10))); |
| 278 |
| 279 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl()))) |
| 280 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 281 |
| 282 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 283 } |
| 284 |
| 285 // Tests if Chrome gets restarted after a crash by just refreshing the document. |
| 286 TEST_P(FullTabUITest, TabCrashRefresh) { |
| 287 using testing::DoAll; |
| 288 |
| 289 if (!GetParam().invokes_cf()) { |
| 290 LOG(ERROR) << "Test needs CF."; |
| 291 return; |
| 292 } |
| 293 |
| 294 MockPropertyNotifySinkListener prop_listener; |
| 295 InSequence expect_in_sequence_for_scope; |
| 296 |
| 297 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl()))) |
| 298 .WillOnce(DoAll( |
| 299 ExpectRendererHasFocus(&ie_mock_), |
| 300 ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE), |
| 301 ConnectDocPropNotifySink(&ie_mock_, &prop_listener), |
| 302 KillChromeFrameProcesses())); |
| 303 |
| 304 VARIANT empty = ScopedVariant::kEmptyVariant; |
| 305 EXPECT_CALL(prop_listener, OnChanged(/*DISPID_READYSTATE*/_)) |
| 306 .WillOnce(DoAll( |
| 307 DisconnectDocPropNotifySink(&prop_listener), |
| 308 ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED), |
| 309 DelayExecCommand(&ie_mock_, &loop_, 10, static_cast<GUID*>(NULL), |
| 310 OLECMDID_REFRESH, 0, &empty, &empty))); |
| 311 |
| 312 EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl()))) |
| 313 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 314 |
| 315 LaunchIEAndNavigate(GetSimplePageUrl()); |
| 316 } |
| 317 |
| 238 // Test fixture for tests related to the context menu UI. Since the context | 318 // Test fixture for tests related to the context menu UI. Since the context |
| 239 // menus for CF and IE are different, these tests are not parameterized. | 319 // menus for CF and IE are different, these tests are not parameterized. |
| 240 class ContextMenuTest : public MockIEEventSinkTest, public testing::Test { | 320 class ContextMenuTest : public MockIEEventSinkTest, public testing::Test { |
| 241 public: | 321 public: |
| 242 ContextMenuTest() {} | 322 ContextMenuTest() {} |
| 243 | 323 |
| 244 virtual void SetUp() { | 324 virtual void SetUp() { |
| 245 // These are UI-related tests, so we do not care about the exact | 325 // These are UI-related tests, so we do not care about the exact |
| 246 // navigations that occur. | 326 // navigations that occur. |
| 247 ie_mock_.ExpectAnyNavigations(); | 327 ie_mock_.ExpectAnyNavigations(); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 SendExtendedKeysEnter(&loop_, 500, VK_DOWN, 2, | 613 SendExtendedKeysEnter(&loop_, 500, VK_DOWN, 2, |
| 534 simulate_input::NONE))); | 614 simulate_input::NONE))); |
| 535 | 615 |
| 536 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page2))) | 616 EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page2))) |
| 537 .WillOnce(CloseBrowserMock(&ie_mock_)); | 617 .WillOnce(CloseBrowserMock(&ie_mock_)); |
| 538 | 618 |
| 539 LaunchIEAndNavigate(page1); | 619 LaunchIEAndNavigate(page1); |
| 540 } | 620 } |
| 541 | 621 |
| 542 } // namespace chrome_frame_test | 622 } // namespace chrome_frame_test |
| OLD | NEW |