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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "content/browser/service_worker/embedded_worker_instance.h" | 8 #include "content/browser/service_worker/embedded_worker_instance.h" |
9 #include "content/browser/service_worker/embedded_worker_registry.h" | 9 #include "content/browser/service_worker/embedded_worker_registry.h" |
10 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 10 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
11 #include "content/browser/service_worker/service_worker_context_core.h" | 11 #include "content/browser/service_worker/service_worker_context_core.h" |
12 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 12 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
13 #include "content/common/service_worker/embedded_worker_messages.h" | 13 #include "content/common/service_worker/embedded_worker_messages.h" |
14 #include "content/public/test/test_browser_thread_bundle.h" | 14 #include "content/public/test/test_browser_thread_bundle.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 static const int kRenderProcessId = 11; | 20 static const int kRenderProcessId = 11; |
21 | 21 |
22 class EmbeddedWorkerInstanceTest : public testing::Test { | 22 class EmbeddedWorkerInstanceTest : public testing::Test { |
23 protected: | 23 protected: |
24 EmbeddedWorkerInstanceTest() | 24 EmbeddedWorkerInstanceTest() |
25 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} | 25 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} |
26 | 26 |
27 virtual void SetUp() override { | 27 void SetUp() override { |
28 helper_.reset(new EmbeddedWorkerTestHelper(kRenderProcessId)); | 28 helper_.reset(new EmbeddedWorkerTestHelper(kRenderProcessId)); |
29 } | 29 } |
30 | 30 |
31 virtual void TearDown() override { | 31 void TearDown() override { helper_.reset(); } |
32 helper_.reset(); | |
33 } | |
34 | 32 |
35 ServiceWorkerContextCore* context() { return helper_->context(); } | 33 ServiceWorkerContextCore* context() { return helper_->context(); } |
36 | 34 |
37 EmbeddedWorkerRegistry* embedded_worker_registry() { | 35 EmbeddedWorkerRegistry* embedded_worker_registry() { |
38 DCHECK(context()); | 36 DCHECK(context()); |
39 return context()->embedded_worker_registry(); | 37 return context()->embedded_worker_registry(); |
40 } | 38 } |
41 | 39 |
42 IPC::TestSink* ipc_sink() { return helper_->ipc_sink(); } | 40 IPC::TestSink* ipc_sink() { return helper_->ipc_sink(); } |
43 | 41 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 worker.reset(); | 122 worker.reset(); |
125 run_loop.Run(); | 123 run_loop.Run(); |
126 EXPECT_EQ(SERVICE_WORKER_ERROR_ABORT, status); | 124 EXPECT_EQ(SERVICE_WORKER_ERROR_ABORT, status); |
127 | 125 |
128 // Verify that we didn't send the message to start the worker. | 126 // Verify that we didn't send the message to start the worker. |
129 ASSERT_FALSE( | 127 ASSERT_FALSE( |
130 ipc_sink()->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID)); | 128 ipc_sink()->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID)); |
131 } | 129 } |
132 | 130 |
133 } // namespace content | 131 } // namespace content |
OLD | NEW |