| 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/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
| 7 #include "content/browser/service_worker/service_worker_context_core.h" | 7 #include "content/browser/service_worker/service_worker_context_core.h" |
| 8 #include "content/browser/service_worker/service_worker_provider_host.h" | 8 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 9 #include "content/browser/service_worker/service_worker_register_job.h" | 9 #include "content/browser/service_worker/service_worker_register_job.h" |
| 10 #include "content/browser/service_worker/service_worker_registration.h" | 10 #include "content/browser/service_worker/service_worker_registration.h" |
| 11 #include "content/browser/service_worker/service_worker_version.h" | 11 #include "content/browser/service_worker/service_worker_version.h" |
| 12 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 static const int kRenderProcessId = 33; // Dummy process ID for testing. | 17 static const int kRenderProcessId = 33; // Dummy process ID for testing. |
| 18 | 18 |
| 19 class ServiceWorkerProviderHostTest : public testing::Test { | 19 class ServiceWorkerProviderHostTest : public testing::Test { |
| 20 protected: | 20 protected: |
| 21 ServiceWorkerProviderHostTest() | 21 ServiceWorkerProviderHostTest() |
| 22 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} | 22 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} |
| 23 virtual ~ServiceWorkerProviderHostTest() {} | 23 virtual ~ServiceWorkerProviderHostTest() {} |
| 24 | 24 |
| 25 virtual void SetUp() OVERRIDE { | 25 virtual void SetUp() OVERRIDE { |
| 26 context_.reset( | 26 context_.reset(new ServiceWorkerContextCore( |
| 27 new ServiceWorkerContextCore(base::FilePath(), | 27 base::FilePath(), |
| 28 base::MessageLoopProxy::current(), | 28 base::MessageLoopProxy::current(), |
| 29 base::MessageLoopProxy::current(), | 29 base::MessageLoopProxy::current(), |
| 30 NULL, | 30 NULL, |
| 31 NULL, | 31 NULL, |
| 32 NULL)); | 32 scoped_ptr<ServiceWorkerProcessManager>())); |
| 33 | 33 |
| 34 scope_ = GURL("http://www.example.com/*"); | 34 scope_ = GURL("http://www.example.com/*"); |
| 35 script_url_ = GURL("http://www.example.com/service_worker.js"); | 35 script_url_ = GURL("http://www.example.com/service_worker.js"); |
| 36 registration_ = new ServiceWorkerRegistration( | 36 registration_ = new ServiceWorkerRegistration( |
| 37 scope_, script_url_, 1L, context_->AsWeakPtr()); | 37 scope_, script_url_, 1L, context_->AsWeakPtr()); |
| 38 version_ = new ServiceWorkerVersion( | 38 version_ = new ServiceWorkerVersion( |
| 39 registration_, | 39 registration_, |
| 40 1L, context_->AsWeakPtr()); | 40 1L, context_->AsWeakPtr()); |
| 41 | 41 |
| 42 // Prepare provider hosts (for the same process). | 42 // Prepare provider hosts (for the same process). |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 EXPECT_EQ(version_.get(), provider_host2_->pending_version()); | 185 EXPECT_EQ(version_.get(), provider_host2_->pending_version()); |
| 186 EXPECT_EQ(NULL, provider_host3_->pending_version()); | 186 EXPECT_EQ(NULL, provider_host3_->pending_version()); |
| 187 | 187 |
| 188 register_job_->AssociatePendingVersionToDocuments(NULL); | 188 register_job_->AssociatePendingVersionToDocuments(NULL); |
| 189 EXPECT_EQ(NULL, provider_host1_->pending_version()); | 189 EXPECT_EQ(NULL, provider_host1_->pending_version()); |
| 190 EXPECT_EQ(NULL, provider_host2_->pending_version()); | 190 EXPECT_EQ(NULL, provider_host2_->pending_version()); |
| 191 EXPECT_EQ(NULL, provider_host3_->pending_version()); | 191 EXPECT_EQ(NULL, provider_host3_->pending_version()); |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace content | 194 } // namespace content |
| OLD | NEW |