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

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

Issue 962543005: Service Worker: Add metrics and timeout for starting a Service Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review 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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 helper_->context()->RemoveAllProviderHostsForProcess(process_id); 444 helper_->context()->RemoveAllProviderHostsForProcess(process_id);
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 TEST_F(ServiceWorkerFailToStartTest, Timeout) {
455 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_NETWORK; // dummy value
456
457 // We could just call StartWorker but make it interesting and test
458 // starting the worker as part of dispatching an event.
459 version_->SetStatus(ServiceWorkerVersion::ACTIVATING);
460 version_->DispatchActivateEvent(CreateReceiverOnCurrentThread(&status));
461 base::RunLoop().RunUntilIdle();
462
463 // Callback has not completed yet.
464 EXPECT_EQ(SERVICE_WORKER_ERROR_NETWORK, status);
465 EXPECT_EQ(ServiceWorkerVersion::STARTING, version_->running_status());
466
467 // Simulate timeout.
468 EXPECT_TRUE(version_->start_worker_timeout_timer_.IsRunning());
469 version_->start_worker_timeout_timer_.user_task().Run();
470 base::RunLoop().RunUntilIdle();
471 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status);
472 EXPECT_EQ(ServiceWorkerVersion::STOPPED, version_->running_status());
473 }
474
454 } // namespace content 475 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698