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

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

Issue 992353003: Decouple Cache Storage messaging from Service Worker/Embedded Worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 new ServiceWorkerProviderHost(33 /* dummy render process id */, 404 new ServiceWorkerProviderHost(33 /* dummy render process id */,
405 MSG_ROUTING_NONE /* render_frame_id */, 405 MSG_ROUTING_NONE /* render_frame_id */,
406 1 /* dummy provider_id */, 406 1 /* dummy provider_id */,
407 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE, 407 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE,
408 helper_->context()->AsWeakPtr(), 408 helper_->context()->AsWeakPtr(),
409 NULL)); 409 NULL));
410 version_->AddControllee(host.get()); 410 version_->AddControllee(host.get());
411 EXPECT_TRUE(version_->timeout_timer_.IsRunning()); 411 EXPECT_TRUE(version_->timeout_timer_.IsRunning());
412 } 412 }
413 413
414 TEST_F(ServiceWorkerVersionTest, ListenerAvailability) {
415 // Initially the worker is not running. There should be no cache_listener_.
416 EXPECT_FALSE(version_->cache_listener_.get());
417
418 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
419 version_->StartWorker(
420 CreateReceiverOnCurrentThread(&status));
421 base::RunLoop().RunUntilIdle();
422
423 // A new cache listener should be available once the worker starts.
424 EXPECT_TRUE(version_->cache_listener_.get());
425
426 version_->StopWorker(
427 CreateReceiverOnCurrentThread(&status));
428 base::RunLoop().RunUntilIdle();
429
430 // Should be destroyed when the worker stops.
431 EXPECT_FALSE(version_->cache_listener_.get());
432
433 version_->StartWorker(
434 CreateReceiverOnCurrentThread(&status));
435 base::RunLoop().RunUntilIdle();
436
437 // Recreated when the worker starts again.
438 EXPECT_TRUE(version_->cache_listener_.get());
439 }
440 414
441 TEST_F(ServiceWorkerVersionTest, SetDevToolsAttached) { 415 TEST_F(ServiceWorkerVersionTest, SetDevToolsAttached) {
442 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 416 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
443 version_->StartWorker(CreateReceiverOnCurrentThread(&status)); 417 version_->StartWorker(CreateReceiverOnCurrentThread(&status));
444 418
445 ASSERT_EQ(ServiceWorkerVersion::STARTING, version_->running_status()); 419 ASSERT_EQ(ServiceWorkerVersion::STARTING, version_->running_status());
446 420
447 ASSERT_TRUE(version_->timeout_timer_.IsRunning()); 421 ASSERT_TRUE(version_->timeout_timer_.IsRunning());
448 ASSERT_FALSE(version_->start_time_.is_null()); 422 ASSERT_FALSE(version_->start_time_.is_null());
449 ASSERT_FALSE(version_->skip_recording_startup_time_); 423 ASSERT_FALSE(version_->skip_recording_startup_time_);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 base::TimeTicks::Now() - 483 base::TimeTicks::Now() -
510 base::TimeDelta::FromMinutes( 484 base::TimeDelta::FromMinutes(
511 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1); 485 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1);
512 version_->timeout_timer_.user_task().Run(); 486 version_->timeout_timer_.user_task().Run();
513 base::RunLoop().RunUntilIdle(); 487 base::RunLoop().RunUntilIdle();
514 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status); 488 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status);
515 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 489 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
516 } 490 }
517 491
518 } // namespace content 492 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_version.cc ('k') | content/browser/storage_partition_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698