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

Unified Diff: content/test/mock_render_thread.h

Issue 8230034: Split most of RenderViewTest and associated classes into content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review! Created 9 years, 2 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
Index: content/test/mock_render_thread.h
diff --git a/content/test/mock_render_thread.h b/content/test/mock_render_thread.h
new file mode 100644
index 0000000000000000000000000000000000000000..ba560f5b61e124986b167cff7af28a4b7d8459c8
--- /dev/null
+++ b/content/test/mock_render_thread.h
@@ -0,0 +1,116 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
jam 2011/10/13 17:35:32 nit: it would be better if this file was svn moved
Jói 2011/10/13 18:47:27 Yeah, sorry about that, it's hard to fix now but I
jam 2011/10/13 19:03:44 this won't get automatically fixed on commit, but
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_TEST_MOCK_RENDER_THREAD_H_
+#define CONTENT_TEST_MOCK_RENDER_THREAD_H_
+#pragma once
+
+#include "base/shared_memory.h"
+#include "content/public/renderer/render_thread.h"
+#include "ipc/ipc_test_sink.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h"
+
+namespace IPC {
+class MessageReplyDeserializer;
+}
+
+namespace content {
+
+class MockRenderThread : public content::RenderThread {
jam 2011/10/13 17:35:32 nit: add small comment?
Jói 2011/10/13 18:47:27 Done.
+ public:
+ MockRenderThread();
+ ~MockRenderThread();
+
+ // Provides access to the messages that have been received by this thread.
+ IPC::TestSink& sink() { return sink_; }
+
+ // content::RenderThread implementation:
+ virtual bool Send(IPC::Message* msg) OVERRIDE;
+ virtual MessageLoop* GetMessageLoop() OVERRIDE;
+ virtual IPC::SyncChannel* GetChannel() OVERRIDE;
+ virtual ResourceDispatcher* GetResourceDispatcher() OVERRIDE;
+ virtual std::string GetLocale() OVERRIDE;
+ virtual void AddRoute(int32 routing_id,
+ IPC::Channel::Listener* listener) OVERRIDE;
+ virtual void RemoveRoute(int32 routing_id) OVERRIDE;
+ virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE;
+ virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE;
+ virtual void SetOutgoingMessageFilter(
+ IPC::ChannelProxy::OutgoingMessageFilter* filter) OVERRIDE;
+ virtual void AddObserver(content::RenderProcessObserver* observer) OVERRIDE;
+ virtual void RemoveObserver(
+ content::RenderProcessObserver* observer) OVERRIDE;
+ virtual void WidgetHidden() OVERRIDE;
+ virtual void WidgetRestored() OVERRIDE;
+ virtual void EnsureWebKitInitialized() OVERRIDE;
+ virtual void RecordUserMetrics(const std::string& action) OVERRIDE;
+ virtual base::SharedMemoryHandle HostAllocateSharedMemoryBuffer(
+ uint32 buffer_size) OVERRIDE;
+ virtual void RegisterExtension(v8::Extension* extension) OVERRIDE;
+ virtual bool IsRegisteredExtension(
+ const std::string& v8_extension_name) const OVERRIDE;
+ virtual void ScheduleIdleHandler(double initial_delay_s) OVERRIDE;
+ virtual void IdleHandler() OVERRIDE;
+ virtual double GetIdleNotificationDelayInS() const OVERRIDE;
+ virtual void SetIdleNotificationDelayInS(
+ double idle_notification_delay_in_s) OVERRIDE;
+#if defined(OS_WIN)
+ virtual void PreCacheFont(const LOGFONT& log_font) OVERRIDE;
+ virtual void ReleaseCachedFonts() OVERRIDE;
+#endif
+
+ //////////////////////////////////////////////////////////////////////////
+ // The following functions are called by the test itself.
+
+ void set_routing_id(int32 id) {
+ routing_id_ = id;
+ }
+
+ int32 opener_id() const {
+ return opener_id_;
+ }
+
+ bool has_widget() const {
+ return widget_ ? true : false;
+ }
+
+ // Simulates the Widget receiving a close message. This should result
+ // on releasing the internal reference counts and destroying the internal
+ // state.
+ void SendCloseMessage();
+
+ protected:
+ // This function operates as a regular IPC listener. Subclasses
+ // overriding this should first delegate to this implementation.
+ virtual bool OnMessageReceived(const IPC::Message& msg);
+
+ // The Widget expects to be returned valid route_id.
+ void OnMsgCreateWidget(int opener_id,
+ WebKit::WebPopupType popup_type,
+ int* route_id);
+
+#if defined(OS_WIN)
+ void OnDuplicateSection(base::SharedMemoryHandle renderer_handle,
+ base::SharedMemoryHandle* browser_handle);
+#endif
+
+ IPC::TestSink sink_;
+
+ // Routing id what will be assigned to the Widget.
+ int32 routing_id_;
+
+ // Opener id reported by the Widget.
+ int32 opener_id_;
+
+ // We only keep track of one Widget, we learn its pointer when it
+ // adds a new route.
+ IPC::Channel::Listener* widget_;
+
+ // The last known good deserializer for sync messages.
+ scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_;
+};
+
+} // namespace content
+
+#endif // CONTENT_TEST_MOCK_RENDER_THREAD_H_

Powered by Google App Engine
This is Rietveld 408576698