OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
6 #define CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 6 #define CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // renderer via this RenderProcessHost. | 29 // renderer via this RenderProcessHost. |
30 IPC::TestSink& sink() { return sink_; } | 30 IPC::TestSink& sink() { return sink_; } |
31 | 31 |
32 // Provides test access to how many times a bad message has been received. | 32 // Provides test access to how many times a bad message has been received. |
33 int bad_msg_count() const { return bad_msg_count_; } | 33 int bad_msg_count() const { return bad_msg_count_; } |
34 | 34 |
35 // RenderProcessHost implementation (public portion). | 35 // RenderProcessHost implementation (public portion). |
36 virtual void EnableSendQueue() OVERRIDE; | 36 virtual void EnableSendQueue() OVERRIDE; |
37 virtual bool Init() OVERRIDE; | 37 virtual bool Init() OVERRIDE; |
38 virtual int GetNextRoutingID() OVERRIDE; | 38 virtual int GetNextRoutingID() OVERRIDE; |
| 39 virtual void AddRoute(int32 routing_id, IPC::Listener* listener) OVERRIDE; |
| 40 virtual void RemoveRoute(int32 routing_id) OVERRIDE; |
39 virtual bool WaitForBackingStoreMsg(int render_widget_id, | 41 virtual bool WaitForBackingStoreMsg(int render_widget_id, |
40 const base::TimeDelta& max_delay, | 42 const base::TimeDelta& max_delay, |
41 IPC::Message* msg) OVERRIDE; | 43 IPC::Message* msg) OVERRIDE; |
42 virtual void ReceivedBadMessage() OVERRIDE; | 44 virtual void ReceivedBadMessage() OVERRIDE; |
43 virtual void WidgetRestored() OVERRIDE; | 45 virtual void WidgetRestored() OVERRIDE; |
44 virtual void WidgetHidden() OVERRIDE; | 46 virtual void WidgetHidden() OVERRIDE; |
45 virtual int VisibleWidgetCount() const OVERRIDE; | 47 virtual int VisibleWidgetCount() const OVERRIDE; |
46 virtual bool IsGuest() const OVERRIDE; | 48 virtual bool IsGuest() const OVERRIDE; |
47 virtual StoragePartition* GetStoragePartition() const OVERRIDE; | 49 virtual StoragePartition* GetStoragePartition() const OVERRIDE; |
48 virtual void AddWord(const string16& word); | 50 virtual void AddWord(const string16& word); |
49 virtual bool FastShutdownIfPossible() OVERRIDE; | 51 virtual bool FastShutdownIfPossible() OVERRIDE; |
50 virtual bool FastShutdownStarted() const OVERRIDE; | 52 virtual bool FastShutdownStarted() const OVERRIDE; |
51 virtual void DumpHandles() OVERRIDE; | 53 virtual void DumpHandles() OVERRIDE; |
52 virtual base::ProcessHandle GetHandle() const OVERRIDE; | 54 virtual base::ProcessHandle GetHandle() const OVERRIDE; |
53 virtual TransportDIB* MapTransportDIB(TransportDIB::Id dib_id) OVERRIDE; | 55 virtual TransportDIB* MapTransportDIB(TransportDIB::Id dib_id) OVERRIDE; |
54 virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) OVERRIDE; | 56 virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) OVERRIDE; |
55 virtual int GetID() const OVERRIDE; | 57 virtual int GetID() const OVERRIDE; |
56 virtual bool HasConnection() const OVERRIDE; | 58 virtual bool HasConnection() const OVERRIDE; |
57 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; | 59 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; |
58 virtual bool IgnoreInputEvents() const OVERRIDE; | 60 virtual bool IgnoreInputEvents() const OVERRIDE; |
59 virtual void Attach(RenderWidgetHost* host, int routing_id) OVERRIDE; | |
60 virtual void Release(int routing_id) OVERRIDE; | |
61 virtual void Cleanup() OVERRIDE; | 61 virtual void Cleanup() OVERRIDE; |
62 virtual void AddPendingView() OVERRIDE; | 62 virtual void AddPendingView() OVERRIDE; |
63 virtual void RemovePendingView() OVERRIDE; | 63 virtual void RemovePendingView() OVERRIDE; |
64 virtual void SetSuddenTerminationAllowed(bool allowed) OVERRIDE; | 64 virtual void SetSuddenTerminationAllowed(bool allowed) OVERRIDE; |
65 virtual bool SuddenTerminationAllowed() const OVERRIDE; | 65 virtual bool SuddenTerminationAllowed() const OVERRIDE; |
66 virtual RenderWidgetHost* GetRenderWidgetHostByID(int routing_id) | |
67 OVERRIDE; | |
68 virtual BrowserContext* GetBrowserContext() const OVERRIDE; | 66 virtual BrowserContext* GetBrowserContext() const OVERRIDE; |
69 virtual bool InSameStoragePartition( | 67 virtual bool InSameStoragePartition( |
70 StoragePartition* partition) const OVERRIDE; | 68 StoragePartition* partition) const OVERRIDE; |
71 virtual IPC::ChannelProxy* GetChannel() OVERRIDE; | 69 virtual IPC::ChannelProxy* GetChannel() OVERRIDE; |
72 virtual RenderWidgetHostsIterator GetRenderWidgetHostsIterator() OVERRIDE; | |
73 virtual bool FastShutdownForPageCount(size_t count) OVERRIDE; | 70 virtual bool FastShutdownForPageCount(size_t count) OVERRIDE; |
74 virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE; | 71 virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE; |
75 virtual void SurfaceUpdated(int32 surface_id) OVERRIDE; | 72 virtual void SurfaceUpdated(int32 surface_id) OVERRIDE; |
76 virtual void ResumeRequestsForView(int route_id) OVERRIDE; | 73 virtual void ResumeRequestsForView(int route_id) OVERRIDE; |
77 | 74 |
78 // IPC::Sender via RenderProcessHost. | 75 // IPC::Sender via RenderProcessHost. |
79 virtual bool Send(IPC::Message* msg) OVERRIDE; | 76 virtual bool Send(IPC::Message* msg) OVERRIDE; |
80 | 77 |
81 // IPC::Listener via RenderProcessHost. | 78 // IPC::Listener via RenderProcessHost. |
82 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 79 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
83 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 80 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
84 | 81 |
85 // Attaches the factory object so we can remove this object in its destructor | 82 // Attaches the factory object so we can remove this object in its destructor |
86 // and prevent MockRenderProcessHostFacotry from deleting it. | 83 // and prevent MockRenderProcessHostFacotry from deleting it. |
87 void SetFactory(const MockRenderProcessHostFactory* factory) { | 84 void SetFactory(const MockRenderProcessHostFactory* factory) { |
88 factory_ = factory; | 85 factory_ = factory; |
89 } | 86 } |
90 | 87 |
| 88 int GetActiveViewCount(); |
| 89 |
91 private: | 90 private: |
92 // Stores IPC messages that would have been sent to the renderer. | 91 // Stores IPC messages that would have been sent to the renderer. |
93 IPC::TestSink sink_; | 92 IPC::TestSink sink_; |
94 TransportDIB* transport_dib_; | 93 TransportDIB* transport_dib_; |
95 int bad_msg_count_; | 94 int bad_msg_count_; |
96 const MockRenderProcessHostFactory* factory_; | 95 const MockRenderProcessHostFactory* factory_; |
97 int id_; | 96 int id_; |
98 BrowserContext* browser_context_; | 97 BrowserContext* browser_context_; |
99 | 98 |
100 IDMap<RenderWidgetHost> render_widget_hosts_; | 99 IDMap<RenderWidgetHost> render_widget_hosts_; |
| 100 IDMap<IPC::Listener> listeners_; |
101 bool fast_shutdown_started_; | 101 bool fast_shutdown_started_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); | 103 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); |
104 }; | 104 }; |
105 | 105 |
106 class MockRenderProcessHostFactory : public RenderProcessHostFactory { | 106 class MockRenderProcessHostFactory : public RenderProcessHostFactory { |
107 public: | 107 public: |
108 MockRenderProcessHostFactory(); | 108 MockRenderProcessHostFactory(); |
109 virtual ~MockRenderProcessHostFactory(); | 109 virtual ~MockRenderProcessHostFactory(); |
110 | 110 |
(...skipping 11 matching lines...) Expand all Loading... |
122 // for deleting all MockRenderProcessHosts that have not deleted by a test in | 122 // for deleting all MockRenderProcessHosts that have not deleted by a test in |
123 // the destructor and prevent them from being leaked. | 123 // the destructor and prevent them from being leaked. |
124 mutable ScopedVector<MockRenderProcessHost> processes_; | 124 mutable ScopedVector<MockRenderProcessHost> processes_; |
125 | 125 |
126 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); | 126 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); |
127 }; | 127 }; |
128 | 128 |
129 } // namespace content | 129 } // namespace content |
130 | 130 |
131 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 131 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
OLD | NEW |