Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: chrome_frame/test/mock_ie_event_sink_test.h

Issue 3061036: Handle automation server crashes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_frame/test/mock_ie_event_sink_actions.h ('k') | chrome_frame/test/mock_ie_event_sink_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/test/mock_ie_event_sink_test.h
===================================================================
--- chrome_frame/test/mock_ie_event_sink_test.h (revision 55540)
+++ chrome_frame/test/mock_ie_event_sink_test.h (working copy)
@@ -114,6 +114,8 @@
// Expects any and all navigations.
void ExpectAnyNavigations();
+ void ExpectDocumentReadystate(int ready_state);
+
IEEventSink* event_sink() { return event_sink_; }
private:
@@ -147,6 +149,59 @@
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:
« no previous file with comments | « chrome_frame/test/mock_ie_event_sink_actions.h ('k') | chrome_frame/test/mock_ie_event_sink_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698