summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test/ui_test.cc
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-10 14:09:37 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-10 14:09:37 +0000
commitbbfa9a15797ba107dcae0f7fff85a7f12ffd26b9 (patch)
treeee15898939e4989b96c6419217696f63d7a5585b /chrome_frame/test/ui_test.cc
parente721ebe885b159f9b18047392be9a0f5834998fb (diff)
downloadchromium_src-bbfa9a15797ba107dcae0f7fff85a7f12ffd26b9.zip
chromium_src-bbfa9a15797ba107dcae0f7fff85a7f12ffd26b9.tar.gz
chromium_src-bbfa9a15797ba107dcae0f7fff85a7f12ffd26b9.tar.bz2
Handle automation server crashes. When Chrome crashes, we now handle the case and support document refresh or reload.
When chrome crashes, we draw a poor man's sad tab (":-("), so that can clearly be improved. Another thing is that if the chrome instance that crashed held several navigational entries, then that history is lost. TEST=There are a couple of tests included, so run those (*TabCrash*) and also verify that when the chrome automation server is killed that we do the right thing. Also check info in bug report. BUG=25839 Review URL: http://codereview.chromium.org/3061036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55565 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test/ui_test.cc')
-rw-r--r--chrome_frame/test/ui_test.cc80
1 files changed, 80 insertions, 0 deletions
diff --git a/chrome_frame/test/ui_test.cc b/chrome_frame/test/ui_test.cc
index 143df63..8eb4475 100644
--- a/chrome_frame/test/ui_test.cc
+++ b/chrome_frame/test/ui_test.cc
@@ -11,6 +11,8 @@
#include "chrome_frame/test/mock_ie_event_sink_actions.h"
#include "chrome_frame/test/mock_ie_event_sink_test.h"
+#include "testing/gmock_mutant.h"
+
using testing::_;
using testing::InSequence;
using testing::StrCaseEq;
@@ -235,6 +237,84 @@ TEST_P(FullTabUITest, FLAKY_ViewSource) {
LaunchIEAndNavigate(GetSimplePageUrl());
}
+void NavigateToCurrentUrl(MockIEEventSink* mock) {
+ IWebBrowser2* browser = mock->event_sink()->web_browser2();
+ DCHECK(browser);
+ ScopedBstr bstr;
+ HRESULT hr = browser->get_LocationURL(bstr.Receive());
+ EXPECT_HRESULT_SUCCEEDED(hr);
+ if (SUCCEEDED(hr)) {
+ DCHECK(bstr.Length());
+ VARIANT empty = ScopedVariant::kEmptyVariant;
+ hr = browser->Navigate(bstr, &empty, &empty, &empty, &empty);
+ EXPECT_HRESULT_SUCCEEDED(hr);
+ }
+}
+
+// Tests that Chrome gets re-instantiated after crash if we reload via
+// the address bar or via a new navigation.
+TEST_P(FullTabUITest, TabCrashReload) {
+ using testing::DoAll;
+
+ if (!GetParam().invokes_cf()) {
+ LOG(ERROR) << "Test needs CF.";
+ return;
+ }
+
+ MockPropertyNotifySinkListener prop_listener;
+ InSequence expect_in_sequence_for_scope;
+
+ EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
+ .WillOnce(DoAll(
+ ExpectRendererHasFocus(&ie_mock_),
+ ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE),
+ ConnectDocPropNotifySink(&ie_mock_, &prop_listener),
+ KillChromeFrameProcesses()));
+
+ EXPECT_CALL(prop_listener, OnChanged(DISPID_READYSTATE))
+ .WillOnce(DoAll(
+ ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED),
+ DelayNavigateToCurrentUrl(&ie_mock_, &loop_, 10)));
+
+ EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
+ .WillOnce(CloseBrowserMock(&ie_mock_));
+
+ LaunchIEAndNavigate(GetSimplePageUrl());
+}
+
+// Tests if Chrome gets restarted after a crash by just refreshing the document.
+TEST_P(FullTabUITest, TabCrashRefresh) {
+ using testing::DoAll;
+
+ if (!GetParam().invokes_cf()) {
+ LOG(ERROR) << "Test needs CF.";
+ return;
+ }
+
+ MockPropertyNotifySinkListener prop_listener;
+ InSequence expect_in_sequence_for_scope;
+
+ EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
+ .WillOnce(DoAll(
+ ExpectRendererHasFocus(&ie_mock_),
+ ExpectDocumentReadystate(&ie_mock_, READYSTATE_COMPLETE),
+ ConnectDocPropNotifySink(&ie_mock_, &prop_listener),
+ KillChromeFrameProcesses()));
+
+ VARIANT empty = ScopedVariant::kEmptyVariant;
+ EXPECT_CALL(prop_listener, OnChanged(/*DISPID_READYSTATE*/_))
+ .WillOnce(DoAll(
+ DisconnectDocPropNotifySink(&prop_listener),
+ ExpectDocumentReadystate(&ie_mock_, READYSTATE_UNINITIALIZED),
+ DelayExecCommand(&ie_mock_, &loop_, 10, static_cast<GUID*>(NULL),
+ OLECMDID_REFRESH, 0, &empty, &empty)));
+
+ EXPECT_CALL(ie_mock_, OnLoad(_, StrEq(GetSimplePageUrl())))
+ .WillOnce(CloseBrowserMock(&ie_mock_));
+
+ LaunchIEAndNavigate(GetSimplePageUrl());
+}
+
// Test fixture for tests related to the context menu UI. Since the context
// menus for CF and IE are different, these tests are not parameterized.
class ContextMenuTest : public MockIEEventSinkTest, public testing::Test {