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

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

Issue 966393002: ServiceWorkerVersion: remove unused parameter in DispatchInstallEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix 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
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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, DispatchEventToStoppedWorker) { 253 TEST_F(ServiceWorkerVersionTest, DispatchEventToStoppedWorker) {
254 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 254 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
255 255
256 // Dispatch an event 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_->SetStatus(ServiceWorkerVersion::INSTALLING); 258 version_->SetStatus(ServiceWorkerVersion::INSTALLING);
259 version_->DispatchInstallEvent(-1, CreateReceiverOnCurrentThread(&status)); 259 version_->DispatchInstallEvent(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 dispatch an event immediately after that. 266 // Stop the worker, and then dispatch an event immediately after that.
267 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_->DispatchInstallEvent( 270 version_->DispatchInstallEvent(CreateReceiverOnCurrentThread(&status));
271 -1, CreateReceiverOnCurrentThread(&status));
272 base::RunLoop().RunUntilIdle(); 271 base::RunLoop().RunUntilIdle();
273 EXPECT_EQ(SERVICE_WORKER_OK, stop_status); 272 EXPECT_EQ(SERVICE_WORKER_OK, stop_status);
274 273
275 // Dispatch an event should return SERVICE_WORKER_OK since the worker 274 // Dispatch an event should return SERVICE_WORKER_OK since the worker
276 // should have been restarted to dispatch the event. 275 // should have been restarted to dispatch the event.
277 EXPECT_EQ(SERVICE_WORKER_OK, status); 276 EXPECT_EQ(SERVICE_WORKER_OK, status);
278 277
279 // The worker should be now started again. 278 // The worker should be now started again.
280 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version_->running_status()); 279 EXPECT_EQ(ServiceWorkerVersion::RUNNING, version_->running_status());
281 } 280 }
(...skipping 19 matching lines...) Expand all
301 ASSERT_EQ(2U, receiver.received_values().size()); 300 ASSERT_EQ(2U, receiver.received_values().size());
302 EXPECT_EQ(555, receiver.received_values()[0]); 301 EXPECT_EQ(555, receiver.received_values()[0]);
303 EXPECT_EQ(777, receiver.received_values()[1]); 302 EXPECT_EQ(777, receiver.received_values()[1]);
304 } 303 }
305 304
306 TEST_F(ServiceWorkerVersionTest, InstallAndWaitCompletion) { 305 TEST_F(ServiceWorkerVersionTest, InstallAndWaitCompletion) {
307 version_->SetStatus(ServiceWorkerVersion::INSTALLING); 306 version_->SetStatus(ServiceWorkerVersion::INSTALLING);
308 307
309 // Dispatch an install event. 308 // Dispatch an install event.
310 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 309 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
311 version_->DispatchInstallEvent(-1, CreateReceiverOnCurrentThread(&status)); 310 version_->DispatchInstallEvent(CreateReceiverOnCurrentThread(&status));
312 311
313 // Wait for the completion. 312 // Wait for the completion.
314 bool status_change_called = false; 313 bool status_change_called = false;
315 version_->RegisterStatusChangeCallback( 314 version_->RegisterStatusChangeCallback(
316 base::Bind(&VerifyCalled, &status_change_called)); 315 base::Bind(&VerifyCalled, &status_change_called));
317 316
318 base::RunLoop().RunUntilIdle(); 317 base::RunLoop().RunUntilIdle();
319 318
320 // Version's status must not have changed during installation. 319 // Version's status must not have changed during installation.
321 EXPECT_EQ(SERVICE_WORKER_OK, status); 320 EXPECT_EQ(SERVICE_WORKER_OK, status);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender( 444 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender(
446 process_id); 445 process_id);
447 base::RunLoop().RunUntilIdle(); 446 base::RunLoop().RunUntilIdle();
448 447
449 // Callback completed. 448 // Callback completed.
450 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); 449 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status);
451 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 450 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
452 } 451 }
453 452
454 } // namespace content 453 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_version.cc ('k') | content/common/service_worker/service_worker_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698