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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 // IPC sink for EmbeddedWorker messages. | 69 // IPC sink for EmbeddedWorker messages. |
70 IPC::TestSink* ipc_sink() { return &sink_; } | 70 IPC::TestSink* ipc_sink() { return &sink_; } |
71 // Inner IPC sink for script context messages sent via EmbeddedWorker. | 71 // Inner IPC sink for script context messages sent via EmbeddedWorker. |
72 IPC::TestSink* inner_ipc_sink() { return &inner_sink_; } | 72 IPC::TestSink* inner_ipc_sink() { return &inner_sink_; } |
73 | 73 |
74 ServiceWorkerContextCore* context(); | 74 ServiceWorkerContextCore* context(); |
75 ServiceWorkerContextWrapper* context_wrapper() { return wrapper_.get(); } | 75 ServiceWorkerContextWrapper* context_wrapper() { return wrapper_.get(); } |
76 void ShutdownContext(); | 76 void ShutdownContext(); |
77 | 77 |
| 78 int GetNextThreadId() { return next_thread_id_++; } |
| 79 |
78 int mock_render_process_id() const { return mock_render_process_id_;} | 80 int mock_render_process_id() const { return mock_render_process_id_;} |
| 81 |
| 82 std::map<int, int64_t> embedded_worker_id_service_worker_version_id_map() { |
| 83 return embedded_worker_id_service_worker_version_id_map_; |
| 84 } |
| 85 |
79 // Mock render process. Only set if the one-parameter constructor was used. | 86 // Mock render process. Only set if the one-parameter constructor was used. |
80 MockRenderProcessHost* mock_render_process_host() { | 87 MockRenderProcessHost* mock_render_process_host() { |
81 return render_process_host_.get(); | 88 return render_process_host_.get(); |
82 } | 89 } |
83 | 90 |
84 TestBrowserContext* browser_context() { return browser_context_.get(); } | 91 TestBrowserContext* browser_context() { return browser_context_.get(); } |
85 | 92 |
86 protected: | 93 protected: |
87 // Called when StartWorker, StopWorker and SendMessageToWorker message | 94 // Called when StartWorker, StopWorker and SendMessageToWorker message |
88 // is sent to the embedded worker. Override if necessary. By default | 95 // is sent to the embedded worker. Override if necessary. By default |
(...skipping 22 matching lines...) Expand all Loading... |
111 virtual void OnPushEvent(int embedded_worker_id, | 118 virtual void OnPushEvent(int embedded_worker_id, |
112 int request_id, | 119 int request_id, |
113 const std::string& data); | 120 const std::string& data); |
114 | 121 |
115 // These functions simulate sending an EmbeddedHostMsg message to the | 122 // These functions simulate sending an EmbeddedHostMsg message to the |
116 // browser. | 123 // browser. |
117 void SimulateWorkerReadyForInspection(int embedded_worker_id); | 124 void SimulateWorkerReadyForInspection(int embedded_worker_id); |
118 void SimulateWorkerScriptCached(int embedded_worker_id); | 125 void SimulateWorkerScriptCached(int embedded_worker_id); |
119 void SimulateWorkerScriptLoaded(int embedded_worker_id); | 126 void SimulateWorkerScriptLoaded(int embedded_worker_id); |
120 void SimulateWorkerThreadStarted(int thread_id, int embedded_worker_id); | 127 void SimulateWorkerThreadStarted(int thread_id, int embedded_worker_id); |
121 void SimulateWorkerScriptEvaluated(int embedded_worker_id); | 128 void SimulateWorkerScriptEvaluated(int embedded_worker_id, bool success); |
122 void SimulateWorkerStarted(int embedded_worker_id); | 129 void SimulateWorkerStarted(int embedded_worker_id); |
123 void SimulateWorkerStopped(int embedded_worker_id); | 130 void SimulateWorkerStopped(int embedded_worker_id); |
124 void SimulateSend(IPC::Message* message); | 131 void SimulateSend(IPC::Message* message); |
125 | 132 |
126 EmbeddedWorkerRegistry* registry(); | 133 EmbeddedWorkerRegistry* registry(); |
127 | 134 |
128 private: | 135 private: |
129 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); | 136 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); |
130 void OnStopWorkerStub(int embedded_worker_id); | 137 void OnStopWorkerStub(int embedded_worker_id); |
131 void OnMessageToWorkerStub(int thread_id, | 138 void OnMessageToWorkerStub(int thread_id, |
(...skipping 27 matching lines...) Expand all Loading... |
159 message_port_message_filters_; | 166 message_port_message_filters_; |
160 | 167 |
161 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 168 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
162 | 169 |
163 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 170 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
164 }; | 171 }; |
165 | 172 |
166 } // namespace content | 173 } // namespace content |
167 | 174 |
168 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 175 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
OLD | NEW |