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_storage.h" | 5 #include "content/browser/service_worker/service_worker_storage.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) { | 286 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) { |
287 } | 287 } |
288 | 288 |
289 void SetUp() override { InitializeTestHelper(); } | 289 void SetUp() override { InitializeTestHelper(); } |
290 | 290 |
291 void TearDown() override { | 291 void TearDown() override { |
292 helper_.reset(); | 292 helper_.reset(); |
293 base::RunLoop().RunUntilIdle(); | 293 base::RunLoop().RunUntilIdle(); |
294 } | 294 } |
295 | 295 |
296 base::FilePath GetUserDataDirectory() { return user_data_directory_.path(); } | 296 base::FilePath GetUserDataDirectory() { return user_data_directory_path_; } |
297 | 297 |
298 bool InitUserDataDirectory() { | 298 bool InitUserDataDirectory() { |
299 return user_data_directory_.CreateUniqueTempDir(); | 299 if (!user_data_directory_.CreateUniqueTempDir()) |
vabr (Chromium)
2016/09/09 15:41:46
Also here the comment from content/browser/cache_s
nhiroki
2016/09/12 01:50:08
Acknowledged.
| |
300 return false; | |
301 user_data_directory_path_ = user_data_directory_.GetPath(); | |
302 return true; | |
300 } | 303 } |
301 | 304 |
302 void InitializeTestHelper() { | 305 void InitializeTestHelper() { |
303 helper_.reset(new EmbeddedWorkerTestHelper(GetUserDataDirectory())); | 306 helper_.reset(new EmbeddedWorkerTestHelper(GetUserDataDirectory())); |
304 base::RunLoop().RunUntilIdle(); | 307 base::RunLoop().RunUntilIdle(); |
305 } | 308 } |
306 | 309 |
307 ServiceWorkerContextCore* context() { return helper_->context(); } | 310 ServiceWorkerContextCore* context() { return helper_->context(); } |
308 ServiceWorkerStorage* storage() { return helper_->context()->storage(); } | 311 ServiceWorkerStorage* storage() { return helper_->context()->storage(); } |
309 | 312 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_MAX_VALUE; | 499 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_MAX_VALUE; |
497 storage()->FindRegistrationForIdOnly( | 500 storage()->FindRegistrationForIdOnly( |
498 registration_id, MakeFindCallback(&was_called, &result, registration)); | 501 registration_id, MakeFindCallback(&was_called, &result, registration)); |
499 base::RunLoop().RunUntilIdle(); | 502 base::RunLoop().RunUntilIdle(); |
500 EXPECT_TRUE(was_called); | 503 EXPECT_TRUE(was_called); |
501 return result; | 504 return result; |
502 } | 505 } |
503 | 506 |
504 // user_data_directory_ must be declared first to preserve destructor order. | 507 // user_data_directory_ must be declared first to preserve destructor order. |
505 base::ScopedTempDir user_data_directory_; | 508 base::ScopedTempDir user_data_directory_; |
509 base::FilePath user_data_directory_path_; | |
506 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; | 510 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; |
507 TestBrowserThreadBundle browser_thread_bundle_; | 511 TestBrowserThreadBundle browser_thread_bundle_; |
508 }; | 512 }; |
509 | 513 |
510 TEST_F(ServiceWorkerStorageTest, DisabledStorage) { | 514 TEST_F(ServiceWorkerStorageTest, DisabledStorage) { |
511 const GURL kScope("http://www.example.com/scope/"); | 515 const GURL kScope("http://www.example.com/scope/"); |
512 const GURL kScript("http://www.example.com/script.js"); | 516 const GURL kScript("http://www.example.com/script.js"); |
513 const GURL kDocumentUrl("http://www.example.com/scope/document.html"); | 517 const GURL kDocumentUrl("http://www.example.com/scope/document.html"); |
514 const int64_t kRegistrationId = 0; | 518 const int64_t kRegistrationId = 0; |
515 const int64_t kVersionId = 0; | 519 const int64_t kVersionId = 0; |
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1755 // Remove other registration at first origin. | 1759 // Remove other registration at first origin. |
1756 EXPECT_EQ(SERVICE_WORKER_OK, | 1760 EXPECT_EQ(SERVICE_WORKER_OK, |
1757 DeleteRegistration(kRegistrationId2, kScope2.GetOrigin())); | 1761 DeleteRegistration(kRegistrationId2, kScope2.GetOrigin())); |
1758 | 1762 |
1759 // No foreign fetch registrations remain. | 1763 // No foreign fetch registrations remain. |
1760 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin1)); | 1764 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin1)); |
1761 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin2)); | 1765 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin2)); |
1762 } | 1766 } |
1763 | 1767 |
1764 } // namespace content | 1768 } // namespace content |
OLD | NEW |