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> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/optional.h" | 18 #include "base/optional.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "content/common/service_worker/embedded_worker.mojom.h" | 20 #include "content/common/service_worker/embedded_worker.mojom.h" |
21 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" | 21 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" |
22 #include "content/common/service_worker/service_worker_status_code.h" | 22 #include "content/common/service_worker/service_worker_status_code.h" |
23 #include "ipc/ipc_listener.h" | 23 #include "ipc/ipc_listener.h" |
24 #include "ipc/ipc_test_sink.h" | 24 #include "ipc/ipc_test_sink.h" |
25 #include "mojo/public/cpp/bindings/binding.h" | 25 #include "mojo/public/cpp/bindings/binding.h" |
| 26 #include "net/http/http_response_info.h" |
26 #include "services/service_manager/public/cpp/interface_provider.h" | 27 #include "services/service_manager/public/cpp/interface_provider.h" |
27 #include "services/service_manager/public/cpp/interface_registry.h" | 28 #include "services/service_manager/public/cpp/interface_registry.h" |
28 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" | 29 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
31 | 32 |
32 class GURL; | 33 class GURL; |
33 | 34 |
34 namespace service_manager { | 35 namespace service_manager { |
35 class InterfaceProvider; | 36 class InterfaceProvider; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 148 |
148 // Only used for tests that force creating a new render process. | 149 // Only used for tests that force creating a new render process. |
149 int new_render_process_id() const { return new_mock_render_process_id_; } | 150 int new_render_process_id() const { return new_mock_render_process_id_; } |
150 | 151 |
151 TestBrowserContext* browser_context() { return browser_context_.get(); } | 152 TestBrowserContext* browser_context() { return browser_context_.get(); } |
152 | 153 |
153 base::WeakPtr<EmbeddedWorkerTestHelper> AsWeakPtr() { | 154 base::WeakPtr<EmbeddedWorkerTestHelper> AsWeakPtr() { |
154 return weak_factory_.GetWeakPtr(); | 155 return weak_factory_.GetWeakPtr(); |
155 } | 156 } |
156 | 157 |
| 158 static net::HttpResponseInfo CreateHttpResponseInfo(); |
| 159 |
157 protected: | 160 protected: |
158 // Called when StartWorker, StopWorker and SendMessageToWorker message | 161 // Called when StartWorker, StopWorker and SendMessageToWorker message |
159 // is sent to the embedded worker. Override if necessary. By default | 162 // is sent to the embedded worker. Override if necessary. By default |
160 // they verify given parameters and: | 163 // they verify given parameters and: |
161 // - OnStartWorker calls SimulateWorkerStarted | 164 // - OnStartWorker calls SimulateWorkerStarted |
162 // - OnStopWorker calls SimulateWorkerStoped | 165 // - OnStopWorker calls SimulateWorkerStoped |
163 // - OnSendMessageToWorker calls the message's respective On*Event handler | 166 // - OnSendMessageToWorker calls the message's respective On*Event handler |
164 virtual void OnStartWorker(int embedded_worker_id, | 167 virtual void OnStartWorker(int embedded_worker_id, |
165 int64_t service_worker_version_id, | 168 int64_t service_worker_version_id, |
166 const GURL& scope, | 169 const GURL& scope, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 std::unique_ptr<MockType> mock = | 293 std::unique_ptr<MockType> mock = |
291 base::MakeUnique<MockType>(std::forward<Args>(args)...); | 294 base::MakeUnique<MockType>(std::forward<Args>(args)...); |
292 MockType* mock_rawptr = mock.get(); | 295 MockType* mock_rawptr = mock.get(); |
293 RegisterMockInstanceClient(std::move(mock)); | 296 RegisterMockInstanceClient(std::move(mock)); |
294 return mock_rawptr; | 297 return mock_rawptr; |
295 } | 298 } |
296 | 299 |
297 } // namespace content | 300 } // namespace content |
298 | 301 |
299 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 302 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
OLD | NEW |