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

Side by Side 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: Fix Mac build breaks. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/test/mock_keyboard_driver_win.cc ('k') | content/test/mock_render_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_TEST_MOCK_RENDER_THREAD_H_
6 #define CONTENT_TEST_MOCK_RENDER_THREAD_H_
7 #pragma once
8
9 #include "base/shared_memory.h"
10 #include "content/public/renderer/render_thread.h"
11 #include "ipc/ipc_test_sink.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h"
13
14 namespace IPC {
15 class MessageReplyDeserializer;
16 }
17
18 namespace content {
19
20 // This class is a very simple mock of RenderThread. It simulates an IPC channel
21 // which supports only two messages:
22 // ViewHostMsg_CreateWidget : sync message sent by the Widget.
23 // ViewMsg_Close : async, send to the Widget.
24 class MockRenderThread : public content::RenderThread {
25 public:
26 MockRenderThread();
27 virtual ~MockRenderThread();
28
29 // Provides access to the messages that have been received by this thread.
30 IPC::TestSink& sink() { return sink_; }
31
32 // content::RenderThread implementation:
33 virtual bool Send(IPC::Message* msg) OVERRIDE;
34 virtual MessageLoop* GetMessageLoop() OVERRIDE;
35 virtual IPC::SyncChannel* GetChannel() OVERRIDE;
36 virtual std::string GetLocale() OVERRIDE;
37 virtual void AddRoute(int32 routing_id,
38 IPC::Channel::Listener* listener) OVERRIDE;
39 virtual void RemoveRoute(int32 routing_id) OVERRIDE;
40 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE;
41 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE;
42 virtual void SetOutgoingMessageFilter(
43 IPC::ChannelProxy::OutgoingMessageFilter* filter) OVERRIDE;
44 virtual void AddObserver(content::RenderProcessObserver* observer) OVERRIDE;
45 virtual void RemoveObserver(
46 content::RenderProcessObserver* observer) OVERRIDE;
47 virtual void SetResourceDispatcherDelegate(
48 content::ResourceDispatcherDelegate* delegate) OVERRIDE;
49 virtual void WidgetHidden() OVERRIDE;
50 virtual void WidgetRestored() OVERRIDE;
51 virtual void EnsureWebKitInitialized() OVERRIDE;
52 virtual void RecordUserMetrics(const std::string& action) OVERRIDE;
53 virtual base::SharedMemoryHandle HostAllocateSharedMemoryBuffer(
54 uint32 buffer_size) OVERRIDE;
55 virtual void RegisterExtension(v8::Extension* extension) OVERRIDE;
56 virtual bool IsRegisteredExtension(
57 const std::string& v8_extension_name) const OVERRIDE;
58 virtual void ScheduleIdleHandler(double initial_delay_s) OVERRIDE;
59 virtual void IdleHandler() OVERRIDE;
60 virtual double GetIdleNotificationDelayInS() const OVERRIDE;
61 virtual void SetIdleNotificationDelayInS(
62 double idle_notification_delay_in_s) OVERRIDE;
63 #if defined(OS_WIN)
64 virtual void PreCacheFont(const LOGFONT& log_font) OVERRIDE;
65 virtual void ReleaseCachedFonts() OVERRIDE;
66 #endif
67
68 //////////////////////////////////////////////////////////////////////////
69 // The following functions are called by the test itself.
70
71 void set_routing_id(int32 id) {
72 routing_id_ = id;
73 }
74
75 int32 opener_id() const {
76 return opener_id_;
77 }
78
79 bool has_widget() const {
80 return widget_ ? true : false;
81 }
82
83 // Simulates the Widget receiving a close message. This should result
84 // on releasing the internal reference counts and destroying the internal
85 // state.
86 void SendCloseMessage();
87
88 protected:
89 // This function operates as a regular IPC listener. Subclasses
90 // overriding this should first delegate to this implementation.
91 virtual bool OnMessageReceived(const IPC::Message& msg);
92
93 // The Widget expects to be returned valid route_id.
94 void OnMsgCreateWidget(int opener_id,
95 WebKit::WebPopupType popup_type,
96 int* route_id);
97
98 #if defined(OS_WIN)
99 void OnDuplicateSection(base::SharedMemoryHandle renderer_handle,
100 base::SharedMemoryHandle* browser_handle);
101 #endif
102
103 IPC::TestSink sink_;
104
105 // Routing id what will be assigned to the Widget.
106 int32 routing_id_;
107
108 // Opener id reported by the Widget.
109 int32 opener_id_;
110
111 // We only keep track of one Widget, we learn its pointer when it
112 // adds a new route.
113 IPC::Channel::Listener* widget_;
114
115 // The last known good deserializer for sync messages.
116 scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_;
117 };
118
119 } // namespace content
120
121 #endif // CONTENT_TEST_MOCK_RENDER_THREAD_H_
OLDNEW
« no previous file with comments | « content/test/mock_keyboard_driver_win.cc ('k') | content/test/mock_render_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698