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

Unified Diff: content/browser/service_worker/service_worker_job_unittest.cc

Issue 140743012: Start EmbeddedWorker during registration - take 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_job_unittest.cc
diff --git a/content/browser/service_worker/service_worker_job_unittest.cc b/content/browser/service_worker/service_worker_job_unittest.cc
index 8c5d8cc74697b10d6be6517708bdb2c245d77f80..61fdb62d6005b1c07ca16c77be3b911f0da40e26 100644
--- a/content/browser/service_worker/service_worker_job_unittest.cc
+++ b/content/browser/service_worker/service_worker_job_unittest.cc
@@ -6,10 +6,13 @@
#include "base/logging.h"
#include "base/run_loop.h"
#include "content/browser/browser_thread_impl.h"
+#include "content/browser/service_worker/embedded_worker_registry.h"
#include "content/browser/service_worker/service_worker_job_coordinator.h"
+#include "content/browser/service_worker/service_worker_provider_host.h"
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/browser/service_worker/service_worker_registration_status.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "ipc/ipc_test_sink.h"
#include "testing/gtest/include/gtest/gtest.h"
// Unit tests for testing all job registration tasks.
@@ -92,15 +95,37 @@ class ServiceWorkerJobTest : public testing::Test {
virtual void SetUp() OVERRIDE {
storage_.reset(new ServiceWorkerStorage(base::FilePath(), NULL));
- job_coordinator_.reset(new ServiceWorkerJobCoordinator(storage_.get()));
+ embedded_worker_registry_ =
+ new EmbeddedWorkerRegistry(base::WeakPtr<ServiceWorkerContextCore>());
+ job_coordinator_.reset(new ServiceWorkerJobCoordinator(
+ storage_.get(), embedded_worker_registry_));
+
+ int provider_id = 77;
+ render_process_id_ = 88;
+ embedded_worker_registry_->AddChildProcessSender(render_process_id_,
+ &sink_);
+ scoped_ptr<ServiceWorkerProviderHost> provider_host(
+ new ServiceWorkerProviderHost(render_process_id_, provider_id));
+
+ provider_host_ = provider_host.get();
+ // provider_host_ = context_->GetProviderHost(render_process_id_,
+ // provider_id);
+ // context_->AddProviderHost(provider_host.Pass());
}
- virtual void TearDown() OVERRIDE { storage_.reset(); }
+ virtual void TearDown() OVERRIDE {
+ storage_.reset();
+ delete provider_host_;
+ }
protected:
TestBrowserThreadBundle browser_thread_bundle_;
+ IPC::TestSink sink_;
scoped_ptr<ServiceWorkerStorage> storage_;
scoped_ptr<ServiceWorkerJobCoordinator> job_coordinator_;
+ scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_;
+ ServiceWorkerProviderHost* provider_host_;
+ int render_process_id_;
};
TEST_F(ServiceWorkerJobTest, SameDocumentSameRegistration) {
@@ -109,6 +134,7 @@ TEST_F(ServiceWorkerJobTest, SameDocumentSameRegistration) {
job_coordinator_->Register(
GURL("http://www.example.com/*"),
GURL("http://www.example.com/service_worker.js"),
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &called, &original_registration));
EXPECT_FALSE(called);
base::RunLoop().RunUntilIdle();
@@ -141,6 +167,7 @@ TEST_F(ServiceWorkerJobTest, SameMatchSameRegistration) {
job_coordinator_->Register(
GURL("http://www.example.com/*"),
GURL("http://www.example.com/service_worker.js"),
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &called, &original_registration));
EXPECT_FALSE(called);
base::RunLoop().RunUntilIdle();
@@ -174,6 +201,7 @@ TEST_F(ServiceWorkerJobTest, DifferentMatchDifferentRegistration) {
job_coordinator_->Register(
GURL("http://www.example.com/one/*"),
GURL("http://www.example.com/service_worker.js"),
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &called1, &original_registration1));
bool called2;
@@ -181,6 +209,7 @@ TEST_F(ServiceWorkerJobTest, DifferentMatchDifferentRegistration) {
job_coordinator_->Register(
GURL("http://www.example.com/two/*"),
GURL("http://www.example.com/service_worker.js"),
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &called2, &original_registration2));
EXPECT_FALSE(called1);
@@ -214,6 +243,7 @@ TEST_F(ServiceWorkerJobTest, Register) {
job_coordinator_->Register(
GURL("http://www.example.com/*"),
GURL("http://www.example.com/service_worker.js"),
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &called, &registration));
ASSERT_FALSE(called);
@@ -232,14 +262,15 @@ TEST_F(ServiceWorkerJobTest, Unregister) {
job_coordinator_->Register(
pattern,
GURL("http://www.example.com/service_worker.js"),
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &called, &registration));
ASSERT_FALSE(called);
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(called);
- job_coordinator_->Unregister(pattern,
- SaveUnregistration(REGISTRATION_OK, &called));
+ job_coordinator_->Unregister(
+ pattern, provider_host_, SaveUnregistration(REGISTRATION_OK, &called));
ASSERT_FALSE(called);
base::RunLoop().RunUntilIdle();
@@ -268,6 +299,7 @@ TEST_F(ServiceWorkerJobTest, RegisterNewScript) {
job_coordinator_->Register(
pattern,
GURL("http://www.example.com/service_worker.js"),
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &called, &old_registration));
ASSERT_FALSE(called);
@@ -291,6 +323,7 @@ TEST_F(ServiceWorkerJobTest, RegisterNewScript) {
job_coordinator_->Register(
pattern,
GURL("http://www.example.com/service_worker_new.js"),
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &called, &new_registration));
ASSERT_FALSE(called);
@@ -324,6 +357,7 @@ TEST_F(ServiceWorkerJobTest, RegisterDuplicateScript) {
job_coordinator_->Register(
pattern,
script_url,
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &called, &old_registration));
ASSERT_FALSE(called);
@@ -345,6 +379,7 @@ TEST_F(ServiceWorkerJobTest, RegisterDuplicateScript) {
job_coordinator_->Register(
pattern,
script_url,
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &called, &new_registration));
ASSERT_FALSE(called);
@@ -379,11 +414,14 @@ TEST_F(ServiceWorkerJobTest, ParallelRegUnreg) {
job_coordinator_->Register(
pattern,
script_url,
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &registration_called, &registration));
bool unregistration_called = false;
job_coordinator_->Unregister(
- pattern, SaveUnregistration(REGISTRATION_OK, &unregistration_called));
+ pattern,
+ provider_host_,
+ SaveUnregistration(REGISTRATION_OK, &unregistration_called));
ASSERT_FALSE(registration_called);
ASSERT_FALSE(unregistration_called);
@@ -416,6 +454,7 @@ TEST_F(ServiceWorkerJobTest, ParallelRegNewScript) {
job_coordinator_->Register(
pattern,
script_url1,
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &registration1_called, &registration1));
GURL script_url2("http://www.example.com/service_worker2.js");
@@ -424,6 +463,7 @@ TEST_F(ServiceWorkerJobTest, ParallelRegNewScript) {
job_coordinator_->Register(
pattern,
script_url2,
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &registration2_called, &registration2));
ASSERT_FALSE(registration1_called);
@@ -458,6 +498,7 @@ TEST_F(ServiceWorkerJobTest, ParallelRegSameScript) {
job_coordinator_->Register(
pattern,
script_url,
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &registration1_called, &registration1));
bool registration2_called = false;
@@ -465,6 +506,7 @@ TEST_F(ServiceWorkerJobTest, ParallelRegSameScript) {
job_coordinator_->Register(
pattern,
script_url,
+ provider_host_,
SaveRegistration(REGISTRATION_OK, &registration2_called, &registration2));
ASSERT_FALSE(registration1_called);
@@ -493,11 +535,15 @@ TEST_F(ServiceWorkerJobTest, ParallelUnreg) {
GURL script_url("http://www.example.com/service_worker.js");
bool unregistration1_called = false;
job_coordinator_->Unregister(
- pattern, SaveUnregistration(REGISTRATION_OK, &unregistration1_called));
+ pattern,
+ provider_host_,
+ SaveUnregistration(REGISTRATION_OK, &unregistration1_called));
bool unregistration2_called = false;
job_coordinator_->Unregister(
- pattern, SaveUnregistration(REGISTRATION_OK, &unregistration2_called));
+ pattern,
+ provider_host_,
+ SaveUnregistration(REGISTRATION_OK, &unregistration2_called));
ASSERT_FALSE(unregistration1_called);
ASSERT_FALSE(unregistration2_called);

Powered by Google App Engine
This is Rietveld 408576698