OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 // IPC sink for EmbeddedWorker messages. | 71 // IPC sink for EmbeddedWorker messages. |
72 IPC::TestSink* ipc_sink() { return &sink_; } | 72 IPC::TestSink* ipc_sink() { return &sink_; } |
73 // Inner IPC sink for script context messages sent via EmbeddedWorker. | 73 // Inner IPC sink for script context messages sent via EmbeddedWorker. |
74 IPC::TestSink* inner_ipc_sink() { return &inner_sink_; } | 74 IPC::TestSink* inner_ipc_sink() { return &inner_sink_; } |
75 | 75 |
76 ServiceWorkerContextCore* context(); | 76 ServiceWorkerContextCore* context(); |
77 ServiceWorkerContextWrapper* context_wrapper() { return wrapper_.get(); } | 77 ServiceWorkerContextWrapper* context_wrapper() { return wrapper_.get(); } |
78 void ShutdownContext(); | 78 void ShutdownContext(); |
79 | 79 |
| 80 int GetNextThreadId() { return next_thread_id_++; } |
| 81 |
80 int mock_render_process_id() const { return mock_render_process_id_;} | 82 int mock_render_process_id() const { return mock_render_process_id_;} |
| 83 |
| 84 std::map<int, int64_t> embedded_worker_id_service_worker_version_id_map() { |
| 85 return embedded_worker_id_service_worker_version_id_map_; |
| 86 } |
| 87 |
81 // Mock render process. Only set if the one-parameter constructor was used. | 88 // Mock render process. Only set if the one-parameter constructor was used. |
82 MockRenderProcessHost* mock_render_process_host() { | 89 MockRenderProcessHost* mock_render_process_host() { |
83 return render_process_host_.get(); | 90 return render_process_host_.get(); |
84 } | 91 } |
85 | 92 |
86 TestBrowserContext* browser_context() { return browser_context_.get(); } | 93 TestBrowserContext* browser_context() { return browser_context_.get(); } |
87 | 94 |
88 protected: | 95 protected: |
89 // Called when StartWorker, StopWorker and SendMessageToWorker message | 96 // Called when StartWorker, StopWorker and SendMessageToWorker message |
90 // is sent to the embedded worker. Override if necessary. By default | 97 // is sent to the embedded worker. Override if necessary. By default |
(...skipping 26 matching lines...) Expand all Loading... |
117 virtual void OnPushEvent(int embedded_worker_id, | 124 virtual void OnPushEvent(int embedded_worker_id, |
118 int request_id, | 125 int request_id, |
119 const std::string& data); | 126 const std::string& data); |
120 | 127 |
121 // These functions simulate sending an EmbeddedHostMsg message to the | 128 // These functions simulate sending an EmbeddedHostMsg message to the |
122 // browser. | 129 // browser. |
123 void SimulateWorkerReadyForInspection(int embedded_worker_id); | 130 void SimulateWorkerReadyForInspection(int embedded_worker_id); |
124 void SimulateWorkerScriptCached(int embedded_worker_id); | 131 void SimulateWorkerScriptCached(int embedded_worker_id); |
125 void SimulateWorkerScriptLoaded(int embedded_worker_id); | 132 void SimulateWorkerScriptLoaded(int embedded_worker_id); |
126 void SimulateWorkerThreadStarted(int thread_id, int embedded_worker_id); | 133 void SimulateWorkerThreadStarted(int thread_id, int embedded_worker_id); |
127 void SimulateWorkerScriptEvaluated(int embedded_worker_id); | 134 void SimulateWorkerScriptEvaluated(int embedded_worker_id, bool success); |
128 void SimulateWorkerStarted(int embedded_worker_id); | 135 void SimulateWorkerStarted(int embedded_worker_id); |
129 void SimulateWorkerStopped(int embedded_worker_id); | 136 void SimulateWorkerStopped(int embedded_worker_id); |
130 void SimulateSend(IPC::Message* message); | 137 void SimulateSend(IPC::Message* message); |
131 | 138 |
132 EmbeddedWorkerRegistry* registry(); | 139 EmbeddedWorkerRegistry* registry(); |
133 | 140 |
134 private: | 141 private: |
135 class MockEmbeddedWorkerSetup; | 142 class MockEmbeddedWorkerSetup; |
136 | 143 |
137 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); | 144 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 message_port_message_filters_; | 184 message_port_message_filters_; |
178 | 185 |
179 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 186 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
180 | 187 |
181 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 188 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
182 }; | 189 }; |
183 | 190 |
184 } // namespace content | 191 } // namespace content |
185 | 192 |
186 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 193 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
OLD | NEW |