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 "base/observer_list.h" | 10 #include "base/observer_list.h" |
11 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
12 #include "content/public/browser/render_process_host_factory.h" | 12 #include "content/public/browser/render_process_host_factory.h" |
13 #include "ipc/ipc_test_sink.h" | 13 #include "ipc/ipc_test_sink.h" |
14 | 14 |
15 class StoragePartition; | 15 class StoragePartition; |
16 class TransportDIB; | |
17 | 16 |
18 namespace content { | 17 namespace content { |
19 | 18 |
20 class MockRenderProcessHostFactory; | 19 class MockRenderProcessHostFactory; |
21 | 20 |
22 // A mock render process host that has no corresponding renderer process. All | 21 // A mock render process host that has no corresponding renderer process. All |
23 // IPC messages are sent into the message sink for inspection by tests. | 22 // IPC messages are sent into the message sink for inspection by tests. |
24 class MockRenderProcessHost : public RenderProcessHost { | 23 class MockRenderProcessHost : public RenderProcessHost { |
25 public: | 24 public: |
26 explicit MockRenderProcessHost(BrowserContext* browser_context); | 25 explicit MockRenderProcessHost(BrowserContext* browser_context); |
(...skipping 21 matching lines...) Expand all Loading... |
48 virtual void WidgetRestored() OVERRIDE; | 47 virtual void WidgetRestored() OVERRIDE; |
49 virtual void WidgetHidden() OVERRIDE; | 48 virtual void WidgetHidden() OVERRIDE; |
50 virtual int VisibleWidgetCount() const OVERRIDE; | 49 virtual int VisibleWidgetCount() const OVERRIDE; |
51 virtual bool IsGuest() const OVERRIDE; | 50 virtual bool IsGuest() const OVERRIDE; |
52 virtual StoragePartition* GetStoragePartition() const OVERRIDE; | 51 virtual StoragePartition* GetStoragePartition() const OVERRIDE; |
53 virtual void AddWord(const base::string16& word); | 52 virtual void AddWord(const base::string16& word); |
54 virtual bool FastShutdownIfPossible() OVERRIDE; | 53 virtual bool FastShutdownIfPossible() OVERRIDE; |
55 virtual bool FastShutdownStarted() const OVERRIDE; | 54 virtual bool FastShutdownStarted() const OVERRIDE; |
56 virtual void DumpHandles() OVERRIDE; | 55 virtual void DumpHandles() OVERRIDE; |
57 virtual base::ProcessHandle GetHandle() const OVERRIDE; | 56 virtual base::ProcessHandle GetHandle() const OVERRIDE; |
58 virtual TransportDIB* MapTransportDIB(TransportDIB::Id dib_id) OVERRIDE; | |
59 virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) OVERRIDE; | |
60 virtual int GetID() const OVERRIDE; | 57 virtual int GetID() const OVERRIDE; |
61 virtual bool HasConnection() const OVERRIDE; | 58 virtual bool HasConnection() const OVERRIDE; |
62 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; | 59 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; |
63 virtual bool IgnoreInputEvents() const OVERRIDE; | 60 virtual bool IgnoreInputEvents() const OVERRIDE; |
64 virtual void Cleanup() OVERRIDE; | 61 virtual void Cleanup() OVERRIDE; |
65 virtual void AddPendingView() OVERRIDE; | 62 virtual void AddPendingView() OVERRIDE; |
66 virtual void RemovePendingView() OVERRIDE; | 63 virtual void RemovePendingView() OVERRIDE; |
67 virtual void SetSuddenTerminationAllowed(bool allowed) OVERRIDE; | 64 virtual void SetSuddenTerminationAllowed(bool allowed) OVERRIDE; |
68 virtual bool SuddenTerminationAllowed() const OVERRIDE; | 65 virtual bool SuddenTerminationAllowed() const OVERRIDE; |
69 virtual BrowserContext* GetBrowserContext() const OVERRIDE; | 66 virtual BrowserContext* GetBrowserContext() const OVERRIDE; |
(...skipping 30 matching lines...) Expand all Loading... |
100 | 97 |
101 int GetActiveViewCount(); | 98 int GetActiveViewCount(); |
102 | 99 |
103 void SetIsGuest(bool is_guest) { | 100 void SetIsGuest(bool is_guest) { |
104 is_guest_ = is_guest; | 101 is_guest_ = is_guest; |
105 } | 102 } |
106 | 103 |
107 private: | 104 private: |
108 // Stores IPC messages that would have been sent to the renderer. | 105 // Stores IPC messages that would have been sent to the renderer. |
109 IPC::TestSink sink_; | 106 IPC::TestSink sink_; |
110 TransportDIB* transport_dib_; | |
111 int bad_msg_count_; | 107 int bad_msg_count_; |
112 const MockRenderProcessHostFactory* factory_; | 108 const MockRenderProcessHostFactory* factory_; |
113 int id_; | 109 int id_; |
114 BrowserContext* browser_context_; | 110 BrowserContext* browser_context_; |
115 ObserverList<RenderProcessHostObserver> observers_; | 111 ObserverList<RenderProcessHostObserver> observers_; |
116 | 112 |
117 IDMap<RenderWidgetHost> render_widget_hosts_; | 113 IDMap<RenderWidgetHost> render_widget_hosts_; |
118 int prev_routing_id_; | 114 int prev_routing_id_; |
119 IDMap<IPC::Listener> listeners_; | 115 IDMap<IPC::Listener> listeners_; |
120 bool fast_shutdown_started_; | 116 bool fast_shutdown_started_; |
(...skipping 22 matching lines...) Expand all Loading... |
143 // for deleting all MockRenderProcessHosts that have not deleted by a test in | 139 // for deleting all MockRenderProcessHosts that have not deleted by a test in |
144 // the destructor and prevent them from being leaked. | 140 // the destructor and prevent them from being leaked. |
145 mutable ScopedVector<MockRenderProcessHost> processes_; | 141 mutable ScopedVector<MockRenderProcessHost> processes_; |
146 | 142 |
147 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); | 143 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); |
148 }; | 144 }; |
149 | 145 |
150 } // namespace content | 146 } // namespace content |
151 | 147 |
152 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 148 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
OLD | NEW |