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/service_worker_dispatcher_host.h" | 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 switches::kEnableServiceWorker)); | 124 switches::kEnableServiceWorker)); |
125 CommandLine::ForCurrentProcess()->AppendSwitch( | 125 CommandLine::ForCurrentProcess()->AppendSwitch( |
126 switches::kEnableServiceWorker); | 126 switches::kEnableServiceWorker); |
127 | 127 |
128 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host = | 128 scoped_refptr<TestingServiceWorkerDispatcherHost> dispatcher_host = |
129 new TestingServiceWorkerDispatcherHost( | 129 new TestingServiceWorkerDispatcherHost( |
130 kRenderProcessId, context_wrapper(), helper_.get()); | 130 kRenderProcessId, context_wrapper(), helper_.get()); |
131 | 131 |
132 helper_->ShutdownContext(); | 132 helper_->ShutdownContext(); |
133 | 133 |
| 134 // Let the shutdown reach the simulated IO thread. |
| 135 base::RunLoop().RunUntilIdle(); |
| 136 |
134 dispatcher_host->OnMessageReceived( | 137 dispatcher_host->OnMessageReceived( |
135 ServiceWorkerHostMsg_RegisterServiceWorker(-1, -1, -1, GURL(), GURL())); | 138 ServiceWorkerHostMsg_RegisterServiceWorker(-1, -1, -1, GURL(), GURL())); |
136 | 139 |
137 // TODO(alecflett): Pump the message loop when this becomes async. | 140 // TODO(alecflett): Pump the message loop when this becomes async. |
138 ASSERT_EQ(1UL, dispatcher_host->ipc_sink()->message_count()); | 141 ASSERT_EQ(1UL, dispatcher_host->ipc_sink()->message_count()); |
139 EXPECT_TRUE(dispatcher_host->ipc_sink()->GetUniqueMessageMatching( | 142 EXPECT_TRUE(dispatcher_host->ipc_sink()->GetUniqueMessageMatching( |
140 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID)); | 143 ServiceWorkerMsg_ServiceWorkerRegistrationError::ID)); |
141 } | 144 } |
142 | 145 |
143 TEST_F(ServiceWorkerDispatcherHostTest, ProviderCreatedAndDestroyed) { | 146 TEST_F(ServiceWorkerDispatcherHostTest, ProviderCreatedAndDestroyed) { |
(...skipping 25 matching lines...) Expand all Loading... |
169 // process to get deleted as well. | 172 // process to get deleted as well. |
170 dispatcher_host->OnMessageReceived( | 173 dispatcher_host->OnMessageReceived( |
171 ServiceWorkerHostMsg_ProviderCreated(kProviderId)); | 174 ServiceWorkerHostMsg_ProviderCreated(kProviderId)); |
172 EXPECT_TRUE(context()->GetProviderHost(kRenderProcessId, kProviderId)); | 175 EXPECT_TRUE(context()->GetProviderHost(kRenderProcessId, kProviderId)); |
173 EXPECT_TRUE(dispatcher_host->HasOneRef()); | 176 EXPECT_TRUE(dispatcher_host->HasOneRef()); |
174 dispatcher_host = NULL; | 177 dispatcher_host = NULL; |
175 EXPECT_FALSE(context()->GetProviderHost(kRenderProcessId, kProviderId)); | 178 EXPECT_FALSE(context()->GetProviderHost(kRenderProcessId, kProviderId)); |
176 } | 179 } |
177 | 180 |
178 } // namespace content | 181 } // namespace content |
OLD | NEW |