summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test/mock_ie_event_sink_test.h
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/mock_ie_event_sink_test.h
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/mock_ie_event_sink_test.h')
-rw-r--r--chrome_frame/test/mock_ie_event_sink_test.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/chrome_frame/test/mock_ie_event_sink_test.h b/chrome_frame/test/mock_ie_event_sink_test.h
index 73e8778..b6e772a 100644
--- a/chrome_frame/test/mock_ie_event_sink_test.h
+++ b/chrome_frame/test/mock_ie_event_sink_test.h
@@ -114,6 +114,8 @@ class MockIEEventSink : public IEEventListener {
// Expects any and all navigations.
void ExpectAnyNavigations();
+ void ExpectDocumentReadystate(int ready_state);
+
IEEventSink* event_sink() { return event_sink_; }
private:
@@ -147,6 +149,59 @@ class MockIEEventSink : public IEEventListener {
CComObject<IEEventSink>* event_sink_;
};
+// This mocks a PropertyNotifySinkListener, providing methods for
+// expecting certain sequences of events.
+class MockPropertyNotifySinkListener : public PropertyNotifySinkListener {
+ public:
+ MockPropertyNotifySinkListener() : cookie_(0), sink_(NULL) {
+ CComObject<PropertyNotifySinkImpl>::CreateInstance(&sink_);
+ sink_->AddRef();
+ sink_->set_listener(this);
+ }
+
+ ~MockPropertyNotifySinkListener() {
+ Detach();
+ sink_->set_listener(NULL);
+ DLOG_IF(ERROR, sink_->m_dwRef != 1)
+ << "Event sink is still referenced externally: ref count = "
+ << sink_->m_dwRef;
+ sink_->Release();
+ }
+
+ // Override PropertyNotifySinkListener methods.
+ MOCK_METHOD1(OnChanged, void (DISPID dispid)); // NOLINT
+
+ bool Attach(IUnknown* obj) {
+ DCHECK_EQ(cookie_, 0UL);
+ DCHECK(obj);
+ HRESULT hr = AtlAdvise(obj, sink_->GetUnknown(), IID_IPropertyNotifySink,
+ &cookie_);
+ if (SUCCEEDED(hr)) {
+ event_source_ = obj;
+ } else {
+ LOG(ERROR) << StringPrintf("AtlAdvise: 0x%08X", hr);
+ cookie_ = 0;
+ }
+
+ return SUCCEEDED(hr);
+ }
+
+ void Detach() {
+ if (event_source_) {
+ DCHECK_NE(cookie_, 0UL);
+ AtlUnadvise(event_source_, IID_IPropertyNotifySink, cookie_);
+ event_source_.Release();
+ cookie_ = 0;
+ }
+ }
+
+ private:
+ CComObject<PropertyNotifySinkImpl>* sink_;
+ DWORD cookie_;
+ ScopedComPtr<IUnknown> event_source_;
+};
+
+
// Mocks a window observer so that tests can detect new windows.
class MockWindowObserver : public WindowObserver {
public: