| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/service_worker/service_worker_registration.h" | 5 #include "content/browser/service_worker/service_worker_registration.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "content/browser/browser_thread_impl.h" | |
| 13 #include "content/browser/service_worker/service_worker_context_core.h" | 12 #include "content/browser/service_worker/service_worker_context_core.h" |
| 14 #include "content/browser/service_worker/service_worker_registration_handle.h" | 13 #include "content/browser/service_worker/service_worker_registration_handle.h" |
| 14 #include "content/public/test/test_browser_thread_bundle.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 class ServiceWorkerRegistrationTest : public testing::Test { | 20 class ServiceWorkerRegistrationTest : public testing::Test { |
| 21 public: | 21 public: |
| 22 ServiceWorkerRegistrationTest() | 22 ServiceWorkerRegistrationTest() |
| 23 : io_thread_(BrowserThread::IO, &message_loop_) {} | 23 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} |
| 24 | 24 |
| 25 void SetUp() override { | 25 void SetUp() override { |
| 26 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( | 26 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( |
| 27 new MockServiceWorkerDatabaseTaskManager( | 27 new MockServiceWorkerDatabaseTaskManager( |
| 28 base::ThreadTaskRunnerHandle::Get())); | 28 base::ThreadTaskRunnerHandle::Get())); |
| 29 context_.reset( | 29 context_.reset( |
| 30 new ServiceWorkerContextCore(base::FilePath(), | 30 new ServiceWorkerContextCore(base::FilePath(), |
| 31 database_task_manager.Pass(), | 31 database_task_manager.Pass(), |
| 32 base::ThreadTaskRunnerHandle::Get(), | 32 base::ThreadTaskRunnerHandle::Get(), |
| 33 NULL, | 33 NULL, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 scoped_refptr<ServiceWorkerRegistration> observed_registration_; | 77 scoped_refptr<ServiceWorkerRegistration> observed_registration_; |
| 78 ChangedVersionAttributesMask observed_changed_mask_; | 78 ChangedVersionAttributesMask observed_changed_mask_; |
| 79 ServiceWorkerRegistrationInfo observed_info_; | 79 ServiceWorkerRegistrationInfo observed_info_; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 protected: | 82 protected: |
| 83 scoped_ptr<ServiceWorkerContextCore> context_; | 83 scoped_ptr<ServiceWorkerContextCore> context_; |
| 84 base::WeakPtr<ServiceWorkerContextCore> context_ptr_; | 84 base::WeakPtr<ServiceWorkerContextCore> context_ptr_; |
| 85 base::MessageLoopForIO message_loop_; | 85 base::MessageLoopForIO message_loop_; |
| 86 BrowserThreadImpl io_thread_; | 86 TestBrowserThreadBundle thread_bundle_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 TEST_F(ServiceWorkerRegistrationTest, SetAndUnsetVersions) { | 89 TEST_F(ServiceWorkerRegistrationTest, SetAndUnsetVersions) { |
| 90 const GURL kScope("http://www.example.not/"); | 90 const GURL kScope("http://www.example.not/"); |
| 91 const GURL kScript("http://www.example.not/service_worker.js"); | 91 const GURL kScript("http://www.example.not/service_worker.js"); |
| 92 int64 kRegistrationId = 1L; | 92 int64 kRegistrationId = 1L; |
| 93 scoped_refptr<ServiceWorkerRegistration> registration = | 93 scoped_refptr<ServiceWorkerRegistration> registration = |
| 94 new ServiceWorkerRegistration( | 94 new ServiceWorkerRegistration( |
| 95 kScope, | 95 kScope, |
| 96 kRegistrationId, | 96 kRegistrationId, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 scoped_ptr<ServiceWorkerRegistrationHandle> handle( | 167 scoped_ptr<ServiceWorkerRegistrationHandle> handle( |
| 168 new ServiceWorkerRegistrationHandle( | 168 new ServiceWorkerRegistrationHandle( |
| 169 context_ptr_, | 169 context_ptr_, |
| 170 base::WeakPtr<ServiceWorkerProviderHost>(), | 170 base::WeakPtr<ServiceWorkerProviderHost>(), |
| 171 registration.get())); | 171 registration.get())); |
| 172 registration->NotifyRegistrationFailed(); | 172 registration->NotifyRegistrationFailed(); |
| 173 // Don't crash when handle gets destructed. | 173 // Don't crash when handle gets destructed. |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace content | 176 } // namespace content |
| OLD | NEW |