| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 base::WeakPtr<EmbeddedWorkerTestHelper> helper); | 71 base::WeakPtr<EmbeddedWorkerTestHelper> helper); |
| 72 ~MockEmbeddedWorkerInstanceClient() override; | 72 ~MockEmbeddedWorkerInstanceClient() override; |
| 73 | 73 |
| 74 static void Bind(const base::WeakPtr<EmbeddedWorkerTestHelper>& helper, | 74 static void Bind(const base::WeakPtr<EmbeddedWorkerTestHelper>& helper, |
| 75 mojom::EmbeddedWorkerInstanceClientRequest request); | 75 mojom::EmbeddedWorkerInstanceClientRequest request); |
| 76 | 76 |
| 77 // MOCK_METHOD cannot be used for StartWorker because the mock method cannot | 77 // MOCK_METHOD cannot be used for StartWorker because the mock method cannot |
| 78 // take move-only objects directly. | 78 // take move-only objects directly. |
| 79 MOCK_METHOD1(MockStartWorker, | 79 MOCK_METHOD1(MockStartWorker, |
| 80 void(mojom::EmbeddedWorkerStartWorkerParams* params)); | 80 void(mojom::EmbeddedWorkerStartWorkerParams* params)); |
| 81 MOCK_METHOD1(MockStopWorker, void(const StopWorkerCallback& callback)); |
| 81 | 82 |
| 82 private: | 83 private: |
| 83 // Implementation of mojo interface; they just calls a mock function. | 84 // Implementation of mojo interface; they just calls a mock function. |
| 84 void StartWorker( | 85 void StartWorker( |
| 85 mojom::EmbeddedWorkerStartWorkerParamsPtr params) override { | 86 mojom::EmbeddedWorkerStartWorkerParamsPtr params) override { |
| 86 MockStartWorker(params.get()); | 87 MockStartWorker(params.get()); |
| 87 } | 88 } |
| 88 | 89 |
| 90 void StopWorker(const StopWorkerCallback& callback) override { |
| 91 MockStopWorker(callback); |
| 92 } |
| 93 |
| 89 // Default behavior which can be overridden by using mock interfaces. | 94 // Default behavior which can be overridden by using mock interfaces. |
| 90 void DefaultStartWorker(mojom::EmbeddedWorkerStartWorkerParams* params); | 95 void DefaultStartWorker(mojom::EmbeddedWorkerStartWorkerParams* params); |
| 96 void DefaultStopWorker(const StopWorkerCallback& callback); |
| 91 | 97 |
| 92 base::WeakPtr<EmbeddedWorkerTestHelper> helper_; | 98 base::WeakPtr<EmbeddedWorkerTestHelper> helper_; |
| 93 mojo::Binding<mojom::EmbeddedWorkerInstanceClient> binding_; | 99 mojo::Binding<mojom::EmbeddedWorkerInstanceClient> binding_; |
| 94 | 100 |
| 95 base::Optional<int> embedded_worker_id_; | 101 base::Optional<int> embedded_worker_id_; |
| 96 | 102 |
| 97 DISALLOW_COPY_AND_ASSIGN(MockEmbeddedWorkerInstanceClient); | 103 DISALLOW_COPY_AND_ASSIGN(MockEmbeddedWorkerInstanceClient); |
| 98 }; | 104 }; |
| 99 | 105 |
| 100 // If |user_data_directory| is empty, the context makes storage stuff in | 106 // If |user_data_directory| is empty, the context makes storage stuff in |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 message_port_message_filters_; | 265 message_port_message_filters_; |
| 260 | 266 |
| 261 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 267 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
| 262 | 268 |
| 263 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 269 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
| 264 }; | 270 }; |
| 265 | 271 |
| 266 } // namespace content | 272 } // namespace content |
| 267 | 273 |
| 268 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 274 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
| OLD | NEW |