Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: content/browser/service_worker/service_worker_version_unittest.cc

Issue 964353002: ServiceWorkerVersion: remove unused SendMessage method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_version.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "content/browser/service_worker/embedded_worker_registry.h" 7 #include "content/browser/service_worker/embedded_worker_registry.h"
8 #include "content/browser/service_worker/embedded_worker_test_helper.h" 8 #include "content/browser/service_worker/embedded_worker_test_helper.h"
9 #include "content/browser/service_worker/service_worker_context_core.h" 9 #include "content/browser/service_worker/service_worker_context_core.h"
10 #include "content/browser/service_worker/service_worker_registration.h" 10 #include "content/browser/service_worker/service_worker_registration.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 EXPECT_EQ(ServiceWorkerVersion::STOPPING, version_->running_status()); 243 EXPECT_EQ(ServiceWorkerVersion::STOPPING, version_->running_status());
244 base::RunLoop().RunUntilIdle(); 244 base::RunLoop().RunUntilIdle();
245 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version_->running_status()); 245 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version_->running_status());
246 246
247 // All should just succeed. 247 // All should just succeed.
248 EXPECT_EQ(SERVICE_WORKER_OK, status1); 248 EXPECT_EQ(SERVICE_WORKER_OK, status1);
249 EXPECT_EQ(SERVICE_WORKER_OK, status2); 249 EXPECT_EQ(SERVICE_WORKER_OK, status2);
250 EXPECT_EQ(SERVICE_WORKER_OK, status3); 250 EXPECT_EQ(SERVICE_WORKER_OK, status3);
251 } 251 }
252 252
253 TEST_F(ServiceWorkerVersionTest, SendMessage) { 253 TEST_F(ServiceWorkerVersionTest, DispatchEventToStoppedWorker) {
254 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 254 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
255 255
256 // Send a message without starting the worker. 256 // Dispatch an event without starting the worker.
257 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 257 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
258 version_->SendMessage(TestMsg_Message(), 258 version_->SetStatus(ServiceWorkerVersion::INSTALLING);
259 CreateReceiverOnCurrentThread(&status)); 259 version_->DispatchInstallEvent(-1, CreateReceiverOnCurrentThread(&status));
260 base::RunLoop().RunUntilIdle(); 260 base::RunLoop().RunUntilIdle();
261 EXPECT_EQ(SERVICE_WORKER_OK, status); 261 EXPECT_EQ(SERVICE_WORKER_OK, status);
262 262
263 // The worker should be now started. 263 // The worker should be now started.
264 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version_->running_status()); 264 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version_->running_status());
265 265
266 // Stop the worker, and then send the message immediately. 266 // Stop the worker, and then dispatch an event immediately after that.
267 ServiceWorkerStatusCode msg_status = SERVICE_WORKER_ERROR_FAILED; 267 status = SERVICE_WORKER_ERROR_FAILED;
268 ServiceWorkerStatusCode stop_status = SERVICE_WORKER_ERROR_FAILED; 268 ServiceWorkerStatusCode stop_status = SERVICE_WORKER_ERROR_FAILED;
269 version_->StopWorker(CreateReceiverOnCurrentThread(&stop_status)); 269 version_->StopWorker(CreateReceiverOnCurrentThread(&stop_status));
270 version_->SendMessage(TestMsg_Message(), 270 version_->DispatchInstallEvent(
271 CreateReceiverOnCurrentThread(&msg_status)); 271 -1, CreateReceiverOnCurrentThread(&status));
272 base::RunLoop().RunUntilIdle(); 272 base::RunLoop().RunUntilIdle();
273 EXPECT_EQ(SERVICE_WORKER_OK, stop_status); 273 EXPECT_EQ(SERVICE_WORKER_OK, stop_status);
274 274
275 // SendMessage should return SERVICE_WORKER_OK since the worker should have 275 // Dispatch an event should return SERVICE_WORKER_OK since the worker
276 // been restarted to deliver the message. 276 // should have been restarted to dispatch the event.
277 EXPECT_EQ(SERVICE_WORKER_OK, msg_status); 277 EXPECT_EQ(SERVICE_WORKER_OK, status);
278 278
279 // The worker should be now started again. 279 // The worker should be now started again.
280 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version_->running_status()); 280 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version_->running_status());
281 } 281 }
282 282
283 TEST_F(ServiceWorkerVersionTest, ReceiveMessageFromWorker) { 283 TEST_F(ServiceWorkerVersionTest, ReceiveMessageFromWorker) {
284 // Start worker. 284 // Start worker.
285 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 285 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
286 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); 286 version_->StartWorker(CreateReceiverOnCurrentThread(&status));
287 EXPECT_EQ(ServiceWorkerVersion::STARTING, version_->running_status()); 287 EXPECT_EQ(ServiceWorkerVersion::STARTING, version_->running_status());
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender( 445 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender(
446 process_id); 446 process_id);
447 base::RunLoop().RunUntilIdle(); 447 base::RunLoop().RunUntilIdle();
448 448
449 // Callback completed. 449 // Callback completed.
450 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); 450 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status);
451 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 451 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
452 } 452 }
453 453
454 } // namespace content 454 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_version.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698