OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 } |
OLD | NEW |