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(new ServiceWorkerContextCore( | 26 context_.reset(new ServiceWorkerContextCore( |
27 base::FilePath(), | 27 base::FilePath(), |
28 base::MessageLoopProxy::current(), | 28 base::MessageLoopProxy::current(), |
| 29 base::MessageLoopProxy::current(), |
29 NULL, | 30 NULL, |
30 NULL, | 31 NULL, |
31 scoped_ptr<ServiceWorkerProcessManager>())); | 32 scoped_ptr<ServiceWorkerProcessManager>())); |
32 | 33 |
33 scope_ = GURL("http://www.example.com/*"); | 34 scope_ = GURL("http://www.example.com/*"); |
34 script_url_ = GURL("http://www.example.com/service_worker.js"); | 35 script_url_ = GURL("http://www.example.com/service_worker.js"); |
35 registration_ = new ServiceWorkerRegistration( | 36 registration_ = new ServiceWorkerRegistration( |
36 scope_, script_url_, 1L, context_->AsWeakPtr()); | 37 scope_, script_url_, 1L, context_->AsWeakPtr()); |
37 version_ = new ServiceWorkerVersion( | 38 version_ = new ServiceWorkerVersion( |
38 registration_, | 39 registration_, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 EXPECT_EQ(version_.get(), provider_host2_->pending_version()); | 185 EXPECT_EQ(version_.get(), provider_host2_->pending_version()); |
185 EXPECT_EQ(NULL, provider_host3_->pending_version()); | 186 EXPECT_EQ(NULL, provider_host3_->pending_version()); |
186 | 187 |
187 register_job_->AssociatePendingVersionToDocuments(NULL); | 188 register_job_->AssociatePendingVersionToDocuments(NULL); |
188 EXPECT_EQ(NULL, provider_host1_->pending_version()); | 189 EXPECT_EQ(NULL, provider_host1_->pending_version()); |
189 EXPECT_EQ(NULL, provider_host2_->pending_version()); | 190 EXPECT_EQ(NULL, provider_host2_->pending_version()); |
190 EXPECT_EQ(NULL, provider_host3_->pending_version()); | 191 EXPECT_EQ(NULL, provider_host3_->pending_version()); |
191 } | 192 } |
192 | 193 |
193 } // namespace content | 194 } // namespace content |
OLD | NEW |