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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 184 } |
185 | 185 |
186 } // namespace | 186 } // namespace |
187 | 187 |
188 class ServiceWorkerStorageTest : public testing::Test { | 188 class ServiceWorkerStorageTest : public testing::Test { |
189 public: | 189 public: |
190 ServiceWorkerStorageTest() | 190 ServiceWorkerStorageTest() |
191 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) { | 191 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) { |
192 } | 192 } |
193 | 193 |
194 virtual void SetUp() OVERRIDE { | 194 virtual void SetUp() override { |
195 context_.reset( | 195 context_.reset( |
196 new ServiceWorkerContextCore(GetUserDataDirectory(), | 196 new ServiceWorkerContextCore(GetUserDataDirectory(), |
197 base::ThreadTaskRunnerHandle::Get(), | 197 base::ThreadTaskRunnerHandle::Get(), |
198 base::ThreadTaskRunnerHandle::Get(), | 198 base::ThreadTaskRunnerHandle::Get(), |
199 base::ThreadTaskRunnerHandle::Get(), | 199 base::ThreadTaskRunnerHandle::Get(), |
200 NULL, | 200 NULL, |
201 NULL, | 201 NULL, |
202 NULL)); | 202 NULL)); |
203 context_ptr_ = context_->AsWeakPtr(); | 203 context_ptr_ = context_->AsWeakPtr(); |
204 } | 204 } |
205 | 205 |
206 virtual void TearDown() OVERRIDE { | 206 virtual void TearDown() override { |
207 context_.reset(); | 207 context_.reset(); |
208 } | 208 } |
209 | 209 |
210 virtual base::FilePath GetUserDataDirectory() { return base::FilePath(); } | 210 virtual base::FilePath GetUserDataDirectory() { return base::FilePath(); } |
211 | 211 |
212 ServiceWorkerStorage* storage() { return context_->storage(); } | 212 ServiceWorkerStorage* storage() { return context_->storage(); } |
213 | 213 |
214 // A static class method for friendliness. | 214 // A static class method for friendliness. |
215 static void VerifyPurgeableListStatusCallback( | 215 static void VerifyPurgeableListStatusCallback( |
216 ServiceWorkerDatabase* database, | 216 ServiceWorkerDatabase* database, |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, | 537 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, |
538 FindRegistrationForPattern(kScope, &found_registration)); | 538 FindRegistrationForPattern(kScope, &found_registration)); |
539 EXPECT_FALSE(found_registration.get()); | 539 EXPECT_FALSE(found_registration.get()); |
540 | 540 |
541 GetAllRegistrations(&all_registrations); | 541 GetAllRegistrations(&all_registrations); |
542 EXPECT_TRUE(all_registrations.empty()); | 542 EXPECT_TRUE(all_registrations.empty()); |
543 } | 543 } |
544 | 544 |
545 class ServiceWorkerResourceStorageTest : public ServiceWorkerStorageTest { | 545 class ServiceWorkerResourceStorageTest : public ServiceWorkerStorageTest { |
546 public: | 546 public: |
547 virtual void SetUp() OVERRIDE { | 547 virtual void SetUp() override { |
548 ServiceWorkerStorageTest::SetUp(); | 548 ServiceWorkerStorageTest::SetUp(); |
549 | 549 |
550 storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 550 storage()->LazyInitialize(base::Bind(&base::DoNothing)); |
551 base::RunLoop().RunUntilIdle(); | 551 base::RunLoop().RunUntilIdle(); |
552 scope_ = GURL("http://www.test.not/scope/"); | 552 scope_ = GURL("http://www.test.not/scope/"); |
553 script_ = GURL("http://www.test.not/script.js"); | 553 script_ = GURL("http://www.test.not/script.js"); |
554 import_ = GURL("http://www.test.not/import.js"); | 554 import_ = GURL("http://www.test.not/import.js"); |
555 document_url_ = GURL("http://www.test.not/scope/document.html"); | 555 document_url_ = GURL("http://www.test.not/scope/document.html"); |
556 registration_id_ = storage()->NewRegistrationId(); | 556 registration_id_ = storage()->NewRegistrationId(); |
557 version_id_ = storage()->NewVersionId(); | 557 version_id_ = storage()->NewVersionId(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 int64 registration_id_; | 605 int64 registration_id_; |
606 int64 version_id_; | 606 int64 version_id_; |
607 int64 resource_id1_; | 607 int64 resource_id1_; |
608 int64 resource_id2_; | 608 int64 resource_id2_; |
609 scoped_refptr<ServiceWorkerRegistration> registration_; | 609 scoped_refptr<ServiceWorkerRegistration> registration_; |
610 }; | 610 }; |
611 | 611 |
612 class ServiceWorkerResourceStorageDiskTest | 612 class ServiceWorkerResourceStorageDiskTest |
613 : public ServiceWorkerResourceStorageTest { | 613 : public ServiceWorkerResourceStorageTest { |
614 public: | 614 public: |
615 virtual void SetUp() OVERRIDE { | 615 virtual void SetUp() override { |
616 ASSERT_TRUE(user_data_directory_.CreateUniqueTempDir()); | 616 ASSERT_TRUE(user_data_directory_.CreateUniqueTempDir()); |
617 ServiceWorkerResourceStorageTest::SetUp(); | 617 ServiceWorkerResourceStorageTest::SetUp(); |
618 } | 618 } |
619 | 619 |
620 virtual base::FilePath GetUserDataDirectory() OVERRIDE { | 620 virtual base::FilePath GetUserDataDirectory() override { |
621 return user_data_directory_.path(); | 621 return user_data_directory_.path(); |
622 } | 622 } |
623 | 623 |
624 protected: | 624 protected: |
625 base::ScopedTempDir user_data_directory_; | 625 base::ScopedTempDir user_data_directory_; |
626 }; | 626 }; |
627 | 627 |
628 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_NoLiveVersion) { | 628 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_NoLiveVersion) { |
629 bool was_called = false; | 629 bool was_called = false; |
630 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 630 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 are_equal = true; | 1038 are_equal = true; |
1039 storage()->CompareScriptResources( | 1039 storage()->CompareScriptResources( |
1040 5, 6, | 1040 5, 6, |
1041 base::Bind(&OnCompareComplete, &status, &are_equal)); | 1041 base::Bind(&OnCompareComplete, &status, &are_equal)); |
1042 base::RunLoop().RunUntilIdle(); | 1042 base::RunLoop().RunUntilIdle(); |
1043 EXPECT_EQ(SERVICE_WORKER_OK, status); | 1043 EXPECT_EQ(SERVICE_WORKER_OK, status); |
1044 EXPECT_FALSE(are_equal); | 1044 EXPECT_FALSE(are_equal); |
1045 } | 1045 } |
1046 | 1046 |
1047 } // namespace content | 1047 } // namespace content |
OLD | NEW |