Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: content/browser/service_worker/service_worker_storage_unittest.cc

Issue 2316043002: //content: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(); }
297
298 bool InitUserDataDirectory() { 296 bool InitUserDataDirectory() {
299 return user_data_directory_.CreateUniqueTempDir(); 297 if (!user_data_directory_.CreateUniqueTempDir())
298 return false;
299 user_data_directory_path_ = user_data_directory_.GetPath();
300 return true;
300 } 301 }
301 302
302 void InitializeTestHelper() { 303 void InitializeTestHelper() {
303 helper_.reset(new EmbeddedWorkerTestHelper(GetUserDataDirectory())); 304 helper_.reset(new EmbeddedWorkerTestHelper(user_data_directory_path_));
304 base::RunLoop().RunUntilIdle(); 305 base::RunLoop().RunUntilIdle();
305 } 306 }
306 307
307 ServiceWorkerContextCore* context() { return helper_->context(); } 308 ServiceWorkerContextCore* context() { return helper_->context(); }
308 ServiceWorkerStorage* storage() { return helper_->context()->storage(); } 309 ServiceWorkerStorage* storage() { return helper_->context()->storage(); }
309 310
310 // A static class method for friendliness. 311 // A static class method for friendliness.
311 static void VerifyPurgeableListStatusCallback( 312 static void VerifyPurgeableListStatusCallback(
312 ServiceWorkerDatabase* database, 313 ServiceWorkerDatabase* database,
313 std::set<int64_t>* purgeable_ids, 314 std::set<int64_t>* purgeable_ids,
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_MAX_VALUE; 497 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_MAX_VALUE;
497 storage()->FindRegistrationForIdOnly( 498 storage()->FindRegistrationForIdOnly(
498 registration_id, MakeFindCallback(&was_called, &result, registration)); 499 registration_id, MakeFindCallback(&was_called, &result, registration));
499 base::RunLoop().RunUntilIdle(); 500 base::RunLoop().RunUntilIdle();
500 EXPECT_TRUE(was_called); 501 EXPECT_TRUE(was_called);
501 return result; 502 return result;
502 } 503 }
503 504
504 // user_data_directory_ must be declared first to preserve destructor order. 505 // user_data_directory_ must be declared first to preserve destructor order.
505 base::ScopedTempDir user_data_directory_; 506 base::ScopedTempDir user_data_directory_;
507 base::FilePath user_data_directory_path_;
506 std::unique_ptr<EmbeddedWorkerTestHelper> helper_; 508 std::unique_ptr<EmbeddedWorkerTestHelper> helper_;
507 TestBrowserThreadBundle browser_thread_bundle_; 509 TestBrowserThreadBundle browser_thread_bundle_;
508 }; 510 };
509 511
510 TEST_F(ServiceWorkerStorageTest, DisabledStorage) { 512 TEST_F(ServiceWorkerStorageTest, DisabledStorage) {
511 const GURL kScope("http://www.example.com/scope/"); 513 const GURL kScope("http://www.example.com/scope/");
512 const GURL kScript("http://www.example.com/script.js"); 514 const GURL kScript("http://www.example.com/script.js");
513 const GURL kDocumentUrl("http://www.example.com/scope/document.html"); 515 const GURL kDocumentUrl("http://www.example.com/scope/document.html");
514 const int64_t kRegistrationId = 0; 516 const int64_t kRegistrationId = 0;
515 const int64_t kVersionId = 0; 517 const int64_t kVersionId = 0;
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 // Remove other registration at first origin. 1757 // Remove other registration at first origin.
1756 EXPECT_EQ(SERVICE_WORKER_OK, 1758 EXPECT_EQ(SERVICE_WORKER_OK,
1757 DeleteRegistration(kRegistrationId2, kScope2.GetOrigin())); 1759 DeleteRegistration(kRegistrationId2, kScope2.GetOrigin()));
1758 1760
1759 // No foreign fetch registrations remain. 1761 // No foreign fetch registrations remain.
1760 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin1)); 1762 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin1));
1761 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin2)); 1763 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin2));
1762 } 1764 }
1763 1765
1764 } // namespace content 1766 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698