OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/browser/service_worker/embedded_worker_instance.h" | 5 #include "content/browser/service_worker/embedded_worker_instance.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "content/browser/service_worker/embedded_worker_registry.h" | 15 #include "content/browser/service_worker/embedded_worker_registry.h" |
16 #include "content/browser/service_worker/embedded_worker_status.h" | 16 #include "content/browser/service_worker/embedded_worker_status.h" |
17 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 17 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
18 #include "content/browser/service_worker/service_worker_context_core.h" | 18 #include "content/browser/service_worker/service_worker_context_core.h" |
19 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 19 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 20 #include "content/browser/service_worker/service_worker_test_utils.h" |
20 #include "content/common/service_worker/embedded_worker.mojom.h" | 21 #include "content/common/service_worker/embedded_worker.mojom.h" |
21 #include "content/common/service_worker/embedded_worker_messages.h" | 22 #include "content/common/service_worker/embedded_worker_messages.h" |
22 #include "content/common/service_worker/embedded_worker_start_params.h" | 23 #include "content/common/service_worker/embedded_worker_start_params.h" |
23 #include "content/common/service_worker/service_worker_utils.h" | 24 #include "content/common/service_worker/service_worker_utils.h" |
24 #include "content/public/common/child_process_host.h" | 25 #include "content/public/common/child_process_host.h" |
25 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
26 #include "content/public/test/test_browser_thread_bundle.h" | 27 #include "content/public/test/test_browser_thread_bundle.h" |
27 #include "mojo/public/cpp/bindings/strong_binding.h" | 28 #include "mojo/public/cpp/bindings/strong_binding.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 129 } |
129 | 130 |
130 TestBrowserThreadBundle thread_bundle_; | 131 TestBrowserThreadBundle thread_bundle_; |
131 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; | 132 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; |
132 std::vector<EventLog> events_; | 133 std::vector<EventLog> events_; |
133 | 134 |
134 private: | 135 private: |
135 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceTest); | 136 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceTest); |
136 }; | 137 }; |
137 | 138 |
138 class EmbeddedWorkerInstanceTestP : public EmbeddedWorkerInstanceTest, | 139 class EmbeddedWorkerInstanceTestP |
139 public testing::WithParamInterface<bool> { | 140 : public MojoServiceWorkerTestP<EmbeddedWorkerInstanceTest> {}; |
140 protected: | |
141 void SetUp() override { | |
142 is_mojo_enabled_ = GetParam(); | |
143 if (is_mojo_enabled()) { | |
144 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
145 switches::kMojoServiceWorker); | |
146 } | |
147 EmbeddedWorkerInstanceTest::SetUp(); | |
148 } | |
149 | |
150 bool is_mojo_enabled() { return is_mojo_enabled_; } | |
151 | |
152 private: | |
153 bool is_mojo_enabled_ = false; | |
154 }; | |
155 | 141 |
156 // A helper to simulate the start worker sequence is stalled in a worker | 142 // A helper to simulate the start worker sequence is stalled in a worker |
157 // process. | 143 // process. |
158 class StalledInStartWorkerHelper : public EmbeddedWorkerTestHelper { | 144 class StalledInStartWorkerHelper : public EmbeddedWorkerTestHelper { |
159 public: | 145 public: |
160 StalledInStartWorkerHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {} | 146 StalledInStartWorkerHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {} |
161 ~StalledInStartWorkerHelper() override{}; | 147 ~StalledInStartWorkerHelper() override{}; |
162 | 148 |
163 void OnStartWorker(int embedded_worker_id, | 149 void OnStartWorker(int embedded_worker_id, |
164 int64_t service_worker_version_id, | 150 int64_t service_worker_version_id, |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type); | 753 EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type); |
768 EXPECT_EQ(DETACHED, events_[2].type); | 754 EXPECT_EQ(DETACHED, events_[2].type); |
769 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status); | 755 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status); |
770 } | 756 } |
771 | 757 |
772 INSTANTIATE_TEST_CASE_P(EmbeddedWorkerInstanceTest, | 758 INSTANTIATE_TEST_CASE_P(EmbeddedWorkerInstanceTest, |
773 EmbeddedWorkerInstanceTestP, | 759 EmbeddedWorkerInstanceTestP, |
774 ::testing::Values(false, true)); | 760 ::testing::Values(false, true)); |
775 | 761 |
776 } // namespace content | 762 } // namespace content |
OLD | NEW |