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

Side by Side Diff: chrome/test/base/testing_profile.cc

Issue 2854323002: Make TestingProfile delete failures explicitly CHECK-fail.
Patch Set: TEMP: Deliberately crash tests on ~ScopedTempDir, to see logs. Created 3 years, 7 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
« no previous file with comments | « base/files/scoped_temp_dir.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/test/base/testing_profile.h" 5 #include "chrome/test/base/testing_profile.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 // Failing a post == leaks == heapcheck failure. Make that an immediate test 559 // Failing a post == leaks == heapcheck failure. Make that an immediate test
560 // failure. 560 // failure.
561 if (resource_context_) { 561 if (resource_context_) {
562 CHECK(BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, 562 CHECK(BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE,
563 resource_context_)); 563 resource_context_));
564 resource_context_ = NULL; 564 resource_context_ = NULL;
565 content::RunAllPendingInMessageLoop(BrowserThread::IO); 565 content::RunAllPendingInMessageLoop(BrowserThread::IO);
566 } 566 }
567 567
568 base::ThreadRestrictions::ScopedAllowIO allow_io; 568 base::ThreadRestrictions::ScopedAllowIO allow_io;
569 ignore_result(temp_dir_.Delete()); 569 // Release the temp dir during the |allow_io| scope (otherwise the
570 // ScopedTempDir destructor will do it in a context where IO is not allowed).
571 // If Delete fails (other than in the valid case where the path is empty), the
572 // test will leave detritus, so fail the test.
573 if (!temp_dir_.IsEmpty()) {
574 if (!temp_dir_.Delete()) {
575 LOG(ERROR) << "CHECK(temp_dir_.Delete()) would fail!!!";
576 } else {
577 LOG(WARNING) << "Delete in ScopedAllowIO succeeded";
578 }
579 } else {
580 LOG(WARNING) << "Not calling Delete in ScopedAllowIO (path is empty)";
581 }
570 } 582 }
571 583
572 void TestingProfile::CreateFaviconService() { 584 void TestingProfile::CreateFaviconService() {
573 // It is up to the caller to create the history service if one is needed. 585 // It is up to the caller to create the history service if one is needed.
574 FaviconServiceFactory::GetInstance()->SetTestingFactory( 586 FaviconServiceFactory::GetInstance()->SetTestingFactory(
575 this, FaviconServiceFactory::GetDefaultFactory()); 587 this, FaviconServiceFactory::GetDefaultFactory());
576 } 588 }
577 589
578 bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { 590 bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
579 DestroyHistoryService(); 591 DestroyHistoryService();
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 // Note: Owned by |original_profile|. 1111 // Note: Owned by |original_profile|.
1100 return new TestingProfile(path_, delegate_, 1112 return new TestingProfile(path_, delegate_,
1101 #if BUILDFLAG(ENABLE_EXTENSIONS) 1113 #if BUILDFLAG(ENABLE_EXTENSIONS)
1102 extension_policy_, 1114 extension_policy_,
1103 #endif 1115 #endif
1104 std::move(pref_service_), original_profile, 1116 std::move(pref_service_), original_profile,
1105 guest_session_, supervised_user_id_, 1117 guest_session_, supervised_user_id_,
1106 std::move(policy_service_), testing_factories_, 1118 std::move(policy_service_), testing_factories_,
1107 profile_name_); 1119 profile_name_);
1108 } 1120 }
OLDNEW
« no previous file with comments | « base/files/scoped_temp_dir.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698