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" | |
21 #include "content/common/service_worker/embedded_worker.mojom.h" | 20 #include "content/common/service_worker/embedded_worker.mojom.h" |
22 #include "content/common/service_worker/embedded_worker_messages.h" | 21 #include "content/common/service_worker/embedded_worker_messages.h" |
23 #include "content/common/service_worker/embedded_worker_start_params.h" | 22 #include "content/common/service_worker/embedded_worker_start_params.h" |
24 #include "content/common/service_worker/service_worker_utils.h" | 23 #include "content/common/service_worker/service_worker_utils.h" |
25 #include "content/public/common/child_process_host.h" | 24 #include "content/public/common/child_process_host.h" |
26 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
27 #include "content/public/test/test_browser_thread_bundle.h" | 26 #include "content/public/test/test_browser_thread_bundle.h" |
28 #include "mojo/public/cpp/bindings/strong_binding.h" | 27 #include "mojo/public/cpp/bindings/strong_binding.h" |
29 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 128 } |
130 | 129 |
131 TestBrowserThreadBundle thread_bundle_; | 130 TestBrowserThreadBundle thread_bundle_; |
132 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; | 131 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; |
133 std::vector<EventLog> events_; | 132 std::vector<EventLog> events_; |
134 | 133 |
135 private: | 134 private: |
136 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceTest); | 135 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstanceTest); |
137 }; | 136 }; |
138 | 137 |
139 class EmbeddedWorkerInstanceTestP | 138 class EmbeddedWorkerInstanceTestP : public EmbeddedWorkerInstanceTest, |
140 : public MojoServiceWorkerTestP<EmbeddedWorkerInstanceTest> {}; | 139 public testing::WithParamInterface<bool> { |
| 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 }; |
141 | 155 |
142 // A helper to simulate the start worker sequence is stalled in a worker | 156 // A helper to simulate the start worker sequence is stalled in a worker |
143 // process. | 157 // process. |
144 class StalledInStartWorkerHelper : public EmbeddedWorkerTestHelper { | 158 class StalledInStartWorkerHelper : public EmbeddedWorkerTestHelper { |
145 public: | 159 public: |
146 StalledInStartWorkerHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {} | 160 StalledInStartWorkerHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {} |
147 ~StalledInStartWorkerHelper() override{}; | 161 ~StalledInStartWorkerHelper() override{}; |
148 | 162 |
149 void OnStartWorker(int embedded_worker_id, | 163 void OnStartWorker(int embedded_worker_id, |
150 int64_t service_worker_version_id, | 164 int64_t service_worker_version_id, |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type); | 767 EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type); |
754 EXPECT_EQ(DETACHED, events_[2].type); | 768 EXPECT_EQ(DETACHED, events_[2].type); |
755 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status); | 769 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status); |
756 } | 770 } |
757 | 771 |
758 INSTANTIATE_TEST_CASE_P(EmbeddedWorkerInstanceTest, | 772 INSTANTIATE_TEST_CASE_P(EmbeddedWorkerInstanceTest, |
759 EmbeddedWorkerInstanceTestP, | 773 EmbeddedWorkerInstanceTestP, |
760 ::testing::Values(false, true)); | 774 ::testing::Values(false, true)); |
761 | 775 |
762 } // namespace content | 776 } // namespace content |
OLD | NEW |