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 <string> | 5 #include <string> |
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/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 } | 182 } |
183 | 183 |
184 } // namespace | 184 } // namespace |
185 | 185 |
186 class ServiceWorkerStorageTest : public testing::Test { | 186 class ServiceWorkerStorageTest : public testing::Test { |
187 public: | 187 public: |
188 ServiceWorkerStorageTest() | 188 ServiceWorkerStorageTest() |
189 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) { | 189 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) { |
190 } | 190 } |
191 | 191 |
192 virtual void SetUp() override { | 192 void SetUp() override { |
193 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( | 193 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( |
194 new MockServiceWorkerDatabaseTaskManager( | 194 new MockServiceWorkerDatabaseTaskManager( |
195 base::ThreadTaskRunnerHandle::Get())); | 195 base::ThreadTaskRunnerHandle::Get())); |
196 context_.reset( | 196 context_.reset( |
197 new ServiceWorkerContextCore(GetUserDataDirectory(), | 197 new ServiceWorkerContextCore(GetUserDataDirectory(), |
198 base::ThreadTaskRunnerHandle::Get(), | 198 base::ThreadTaskRunnerHandle::Get(), |
199 database_task_manager.Pass(), | 199 database_task_manager.Pass(), |
200 base::ThreadTaskRunnerHandle::Get(), | 200 base::ThreadTaskRunnerHandle::Get(), |
201 NULL, | 201 NULL, |
202 NULL, | 202 NULL, |
203 NULL, | 203 NULL, |
204 NULL)); | 204 NULL)); |
205 context_ptr_ = context_->AsWeakPtr(); | 205 context_ptr_ = context_->AsWeakPtr(); |
206 } | 206 } |
207 | 207 |
208 virtual void TearDown() override { | 208 void TearDown() override { context_.reset(); } |
209 context_.reset(); | |
210 } | |
211 | 209 |
212 virtual base::FilePath GetUserDataDirectory() { return base::FilePath(); } | 210 virtual base::FilePath GetUserDataDirectory() { return base::FilePath(); } |
213 | 211 |
214 ServiceWorkerStorage* storage() { return context_->storage(); } | 212 ServiceWorkerStorage* storage() { return context_->storage(); } |
215 | 213 |
216 // A static class method for friendliness. | 214 // A static class method for friendliness. |
217 static void VerifyPurgeableListStatusCallback( | 215 static void VerifyPurgeableListStatusCallback( |
218 ServiceWorkerDatabase* database, | 216 ServiceWorkerDatabase* database, |
219 std::set<int64> *purgeable_ids, | 217 std::set<int64> *purgeable_ids, |
220 bool* was_called, | 218 bool* was_called, |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, | 537 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, |
540 FindRegistrationForPattern(kScope, &found_registration)); | 538 FindRegistrationForPattern(kScope, &found_registration)); |
541 EXPECT_FALSE(found_registration.get()); | 539 EXPECT_FALSE(found_registration.get()); |
542 | 540 |
543 GetAllRegistrations(&all_registrations); | 541 GetAllRegistrations(&all_registrations); |
544 EXPECT_TRUE(all_registrations.empty()); | 542 EXPECT_TRUE(all_registrations.empty()); |
545 } | 543 } |
546 | 544 |
547 class ServiceWorkerResourceStorageTest : public ServiceWorkerStorageTest { | 545 class ServiceWorkerResourceStorageTest : public ServiceWorkerStorageTest { |
548 public: | 546 public: |
549 virtual void SetUp() override { | 547 void SetUp() override { |
550 ServiceWorkerStorageTest::SetUp(); | 548 ServiceWorkerStorageTest::SetUp(); |
551 | 549 |
552 storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 550 storage()->LazyInitialize(base::Bind(&base::DoNothing)); |
553 base::RunLoop().RunUntilIdle(); | 551 base::RunLoop().RunUntilIdle(); |
554 scope_ = GURL("http://www.test.not/scope/"); | 552 scope_ = GURL("http://www.test.not/scope/"); |
555 script_ = GURL("http://www.test.not/script.js"); | 553 script_ = GURL("http://www.test.not/script.js"); |
556 import_ = GURL("http://www.test.not/import.js"); | 554 import_ = GURL("http://www.test.not/import.js"); |
557 document_url_ = GURL("http://www.test.not/scope/document.html"); | 555 document_url_ = GURL("http://www.test.not/scope/document.html"); |
558 registration_id_ = storage()->NewRegistrationId(); | 556 registration_id_ = storage()->NewRegistrationId(); |
559 version_id_ = storage()->NewVersionId(); | 557 version_id_ = storage()->NewVersionId(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 int64 resource_id1_; | 611 int64 resource_id1_; |
614 uint64 resource_id1_size_; | 612 uint64 resource_id1_size_; |
615 int64 resource_id2_; | 613 int64 resource_id2_; |
616 uint64 resource_id2_size_; | 614 uint64 resource_id2_size_; |
617 scoped_refptr<ServiceWorkerRegistration> registration_; | 615 scoped_refptr<ServiceWorkerRegistration> registration_; |
618 }; | 616 }; |
619 | 617 |
620 class ServiceWorkerResourceStorageDiskTest | 618 class ServiceWorkerResourceStorageDiskTest |
621 : public ServiceWorkerResourceStorageTest { | 619 : public ServiceWorkerResourceStorageTest { |
622 public: | 620 public: |
623 virtual void SetUp() override { | 621 void SetUp() override { |
624 ASSERT_TRUE(user_data_directory_.CreateUniqueTempDir()); | 622 ASSERT_TRUE(user_data_directory_.CreateUniqueTempDir()); |
625 ServiceWorkerResourceStorageTest::SetUp(); | 623 ServiceWorkerResourceStorageTest::SetUp(); |
626 } | 624 } |
627 | 625 |
628 base::FilePath GetUserDataDirectory() override { | 626 base::FilePath GetUserDataDirectory() override { |
629 return user_data_directory_.path(); | 627 return user_data_directory_.path(); |
630 } | 628 } |
631 | 629 |
632 protected: | 630 protected: |
633 base::ScopedTempDir user_data_directory_; | 631 base::ScopedTempDir user_data_directory_; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 are_equal = true; | 1047 are_equal = true; |
1050 storage()->CompareScriptResources( | 1048 storage()->CompareScriptResources( |
1051 5, 6, | 1049 5, 6, |
1052 base::Bind(&OnCompareComplete, &status, &are_equal)); | 1050 base::Bind(&OnCompareComplete, &status, &are_equal)); |
1053 base::RunLoop().RunUntilIdle(); | 1051 base::RunLoop().RunUntilIdle(); |
1054 EXPECT_EQ(SERVICE_WORKER_OK, status); | 1052 EXPECT_EQ(SERVICE_WORKER_OK, status); |
1055 EXPECT_FALSE(are_equal); | 1053 EXPECT_FALSE(are_equal); |
1056 } | 1054 } |
1057 | 1055 |
1058 } // namespace content | 1056 } // namespace content |
OLD | NEW |