| OLD | NEW |
| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 ASSERT_EQ(ServiceWorkerVersion::ACTIVATING, statuses[2]); | 356 ASSERT_EQ(ServiceWorkerVersion::ACTIVATING, statuses[2]); |
| 357 ASSERT_EQ(ServiceWorkerVersion::ACTIVATED, statuses[3]); | 357 ASSERT_EQ(ServiceWorkerVersion::ACTIVATED, statuses[3]); |
| 358 ASSERT_EQ(ServiceWorkerVersion::REDUNDANT, statuses[4]); | 358 ASSERT_EQ(ServiceWorkerVersion::REDUNDANT, statuses[4]); |
| 359 } | 359 } |
| 360 | 360 |
| 361 TEST_F(ServiceWorkerVersionTest, ScheduleStopWorker) { | 361 TEST_F(ServiceWorkerVersionTest, ScheduleStopWorker) { |
| 362 // Verify the timer is not running when version initializes its status. | 362 // Verify the timer is not running when version initializes its status. |
| 363 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); | 363 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); |
| 364 EXPECT_FALSE(version_->stop_worker_timer_.IsRunning()); | 364 EXPECT_FALSE(version_->stop_worker_timer_.IsRunning()); |
| 365 | 365 |
| 366 // Verify the timer is running when version status changes frome ACTIVATING | 366 // Verify the timer is running after the worker is started. |
| 367 // to ACTIVATED. | |
| 368 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 367 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
| 369 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); | 368 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); |
| 370 base::RunLoop().RunUntilIdle(); | 369 base::RunLoop().RunUntilIdle(); |
| 371 EXPECT_EQ(SERVICE_WORKER_OK, status); | 370 EXPECT_EQ(SERVICE_WORKER_OK, status); |
| 372 version_->SetStatus(ServiceWorkerVersion::ACTIVATING); | |
| 373 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); | |
| 374 EXPECT_TRUE(version_->stop_worker_timer_.IsRunning()); | 371 EXPECT_TRUE(version_->stop_worker_timer_.IsRunning()); |
| 375 | 372 |
| 376 // The timer should be running if the worker is restarted without controllee. | 373 // The timer should be running if the worker is restarted without controllee. |
| 377 status = SERVICE_WORKER_ERROR_FAILED; | 374 status = SERVICE_WORKER_ERROR_FAILED; |
| 378 version_->StopWorker(CreateReceiverOnCurrentThread(&status)); | 375 version_->StopWorker(CreateReceiverOnCurrentThread(&status)); |
| 379 base::RunLoop().RunUntilIdle(); | 376 base::RunLoop().RunUntilIdle(); |
| 380 EXPECT_EQ(SERVICE_WORKER_OK, status); | 377 EXPECT_EQ(SERVICE_WORKER_OK, status); |
| 381 status = SERVICE_WORKER_ERROR_FAILED; | 378 status = SERVICE_WORKER_ERROR_FAILED; |
| 382 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); | 379 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); |
| 383 base::RunLoop().RunUntilIdle(); | 380 base::RunLoop().RunUntilIdle(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender( | 440 helper_->context()->embedded_worker_registry()->RemoveChildProcessSender( |
| 444 process_id); | 441 process_id); |
| 445 base::RunLoop().RunUntilIdle(); | 442 base::RunLoop().RunUntilIdle(); |
| 446 | 443 |
| 447 // Callback completed. | 444 // Callback completed. |
| 448 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); | 445 EXPECT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); |
| 449 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); | 446 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); |
| 450 } | 447 } |
| 451 | 448 |
| 452 } // namespace content | 449 } // namespace content |
| OLD | NEW |