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

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

Issue 19616004: Add asserts to TestingProfile::CreateHistoryService to ensure files are deleted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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 | « no previous file | 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 "build/build_config.h" 7 #include "build/build_config.h"
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 static BrowserContextKeyedService* BuildHistoryService( 352 static BrowserContextKeyedService* BuildHistoryService(
353 content::BrowserContext* profile) { 353 content::BrowserContext* profile) {
354 return new HistoryService(static_cast<Profile*>(profile)); 354 return new HistoryService(static_cast<Profile*>(profile));
355 } 355 }
356 356
357 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { 357 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
358 DestroyHistoryService(); 358 DestroyHistoryService();
359 if (delete_file) { 359 if (delete_file) {
360 base::FilePath path = GetPath(); 360 base::FilePath path = GetPath();
361 path = path.Append(chrome::kHistoryFilename); 361 path = path.Append(chrome::kHistoryFilename);
362 base::DeleteFile(path, false); 362 ASSERT_TRUE(base::DeleteFile(path, false));
sky 2013/07/19 20:04:57 In general you shouldn't use ASSERTS in tests. It
rmcilroy 2013/07/22 11:18:07 Changed these to EXPECTS (I thought ASSERTS were a
363 ASSERT_FALSE(base::PathExists(path));
363 } 364 }
364 // This will create and init the history service. 365 // This will create and init the history service.
365 HistoryService* history_service = static_cast<HistoryService*>( 366 HistoryService* history_service = static_cast<HistoryService*>(
366 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( 367 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(
367 this, BuildHistoryService)); 368 this, BuildHistoryService));
368 if (!history_service->Init(this->GetPath(), 369 if (!history_service->Init(this->GetPath(),
369 BookmarkModelFactory::GetForProfile(this), 370 BookmarkModelFactory::GetForProfile(this),
370 no_db)) { 371 no_db)) {
371 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL); 372 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL);
372 } 373 }
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 812
812 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { 813 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
813 DCHECK(!build_called_); 814 DCHECK(!build_called_);
814 build_called_ = true; 815 build_called_ = true;
815 return scoped_ptr<TestingProfile>(new TestingProfile( 816 return scoped_ptr<TestingProfile>(new TestingProfile(
816 path_, 817 path_,
817 delegate_, 818 delegate_,
818 extension_policy_, 819 extension_policy_,
819 pref_service_.Pass())); 820 pref_service_.Pass()));
820 } 821 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698