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

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: Add missing forward declaration 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
441 TEST_F(ServiceWorkerFailToStartTest, RendererCrash) { 414 TEST_F(ServiceWorkerFailToStartTest, RendererCrash) {
442 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_NETWORK; // dummy value 415 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_NETWORK; // dummy value
443 version_->StartWorker( 416 version_->StartWorker(
444 CreateReceiverOnCurrentThread(&status)); 417 CreateReceiverOnCurrentThread(&status));
445 base::RunLoop().RunUntilIdle(); 418 base::RunLoop().RunUntilIdle();
446 419
447 // Callback has not completed yet. 420 // Callback has not completed yet.
448 EXPECT_EQ(SERVICE_WORKER_ERROR_NETWORK, status); 421 EXPECT_EQ(SERVICE_WORKER_ERROR_NETWORK, status);
449 EXPECT_EQ(ServiceWorkerVersion::STARTING, version_->running_status()); 422 EXPECT_EQ(ServiceWorkerVersion::STARTING, version_->running_status());
450 423
(...skipping 29 matching lines...) Expand all
480 base::TimeTicks::Now() - 453 base::TimeTicks::Now() -
481 base::TimeDelta::FromMinutes( 454 base::TimeDelta::FromMinutes(
482 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1); 455 ServiceWorkerVersion::kStartWorkerTimeoutMinutes + 1);
483 version_->timeout_timer_.user_task().Run(); 456 version_->timeout_timer_.user_task().Run();
484 base::RunLoop().RunUntilIdle(); 457 base::RunLoop().RunUntilIdle();
485 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status); 458 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status);
486 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status()); 459 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
487 } 460 }
488 461
489 } // namespace content 462 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698