summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrmcilroy@chromium.org <rmcilroy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-23 17:19:49 +0000
committerrmcilroy@chromium.org <rmcilroy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-23 17:19:49 +0000
commit9d21ec6f72db7c8c866ac36798df22cf690c20b0 (patch)
tree86fa2d9f13c08d1d96d2a848573115a38b619fbf /chrome
parentaba8c0f49ce5ca7a2e7305d1ff1a8c7dd4404db4 (diff)
downloadchromium_src-9d21ec6f72db7c8c866ac36798df22cf690c20b0.zip
chromium_src-9d21ec6f72db7c8c866ac36798df22cf690c20b0.tar.gz
chromium_src-9d21ec6f72db7c8c866ac36798df22cf690c20b0.tar.bz2
Add asserts to TestingProfile::CreateHistoryService to ensure files are deleted
BUG= Review URL: https://chromiumcodereview.appspot.com/19616004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/extension_app_provider_unittest.cc2
-rw-r--r--chrome/browser/autocomplete/history_quick_provider_unittest.cc2
-rw-r--r--chrome/browser/autocomplete/history_url_provider_unittest.cc12
-rw-r--r--chrome/browser/autocomplete/search_provider_unittest.cc2
-rw-r--r--chrome/browser/autocomplete/shortcuts_provider_unittest.cc2
-rw-r--r--chrome/browser/bookmarks/bookmark_html_writer_unittest.cc2
-rw-r--r--chrome/browser/bookmarks/bookmark_index_unittest.cc2
-rw-r--r--chrome/browser/bookmarks/bookmark_model_unittest.cc11
-rw-r--r--chrome/browser/browsing_data/browsing_data_remover_unittest.cc24
-rw-r--r--chrome/browser/download/download_target_determiner_unittest.cc2
-rw-r--r--chrome/browser/history/android/android_history_provider_service_unittest.cc2
-rw-r--r--chrome/browser/history/android/sqlite_cursor_unittest.cc2
-rw-r--r--chrome/browser/history/history_backend_unittest.cc2
-rw-r--r--chrome/browser/history/in_memory_url_index_unittest.cc2
-rw-r--r--chrome/browser/history/top_sites_impl_unittest.cc12
-rw-r--r--chrome/browser/history/top_sites_likely_impl_unittest.cc12
-rw-r--r--chrome/browser/importer/profile_writer_unittest.cc2
-rw-r--r--chrome/browser/predictors/autocomplete_action_predictor_unittest.cc2
-rw-r--r--chrome/browser/predictors/resource_prefetch_predictor_unittest.cc2
-rw-r--r--chrome/browser/profiles/profile_manager_unittest.cc4
-rw-r--r--chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc3
-rw-r--r--chrome/browser/safe_browsing/malware_details_unittest.cc3
-rw-r--r--chrome/browser/search_engines/template_url_service_unittest.cc2
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_prompt_controller_unittest.cc4
-rw-r--r--chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc2
-rw-r--r--chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc2
-rw-r--r--chrome/test/base/testing_profile.cc6
-rw-r--r--chrome/test/base/testing_profile.h4
-rw-r--r--chrome/test/perf/generate_profile.cc5
29 files changed, 71 insertions, 63 deletions
diff --git a/chrome/browser/autocomplete/extension_app_provider_unittest.cc b/chrome/browser/autocomplete/extension_app_provider_unittest.cc
index f9eec44..7ccafc2b 100644
--- a/chrome/browser/autocomplete/extension_app_provider_unittest.cc
+++ b/chrome/browser/autocomplete/extension_app_provider_unittest.cc
@@ -42,7 +42,7 @@ class ExtensionAppProviderTest : public testing::Test {
void ExtensionAppProviderTest::SetUp() {
profile_.reset(new TestingProfile());
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
profile_->BlockUntilHistoryProcessesPendingRequests();
history_service_ =
HistoryServiceFactory::GetForProfile(profile_.get(),
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
index fe50366..29a2a58 100644
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
@@ -151,7 +151,7 @@ class HistoryQuickProviderTest : public testing::Test,
void HistoryQuickProviderTest::SetUp() {
profile_.reset(new TestingProfile());
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
profile_->CreateBookmarkModel(true);
ui_test_utils::WaitForBookmarkModelToLoad(profile_.get());
profile_->BlockUntilHistoryIndexIsRefreshed();
diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc
index b26c9a0..0138751 100644
--- a/chrome/browser/autocomplete/history_url_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc
@@ -152,12 +152,12 @@ class HistoryURLProviderTest : public testing::Test,
// testing::Test
virtual void SetUp() {
- SetUpImpl(false);
+ ASSERT_TRUE(SetUpImpl(false));
}
virtual void TearDown();
// Does the real setup.
- void SetUpImpl(bool no_db);
+ bool SetUpImpl(bool no_db) WARN_UNUSED_RESULT;
// Fills test data into the history system.
void FillData();
@@ -195,7 +195,7 @@ class HistoryURLProviderTest : public testing::Test,
class HistoryURLProviderTestNoDB : public HistoryURLProviderTest {
protected:
virtual void SetUp() {
- SetUpImpl(true);
+ ASSERT_TRUE(SetUpImpl(true));
}
};
@@ -204,9 +204,10 @@ void HistoryURLProviderTest::OnProviderUpdate(bool updated_matches) {
base::MessageLoop::current()->Quit();
}
-void HistoryURLProviderTest::SetUpImpl(bool no_db) {
+bool HistoryURLProviderTest::SetUpImpl(bool no_db) {
profile_.reset(new TestingProfile());
- profile_->CreateHistoryService(true, no_db);
+ if (!(profile_->CreateHistoryService(true, no_db)))
+ return false;
if (!no_db) {
profile_->BlockUntilHistoryProcessesPendingRequests();
profile_->BlockUntilHistoryIndexIsRefreshed();
@@ -219,6 +220,7 @@ void HistoryURLProviderTest::SetUpImpl(bool no_db) {
TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(), &HistoryURLProviderTest::CreateTemplateURLService);
FillData();
+ return true;
}
void HistoryURLProviderTest::TearDown() {
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc
index b32cadc..fba4633 100644
--- a/chrome/browser/autocomplete/search_provider_unittest.cc
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -191,7 +191,7 @@ void SearchProviderTest::SetUp() {
test_factory_.set_remove_fetcher_on_delete(true);
// We need both the history service and template url model loaded.
- profile_.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_.CreateHistoryService(true, false));
TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
&profile_, &TemplateURLServiceFactory::BuildInstanceFor);
diff --git a/chrome/browser/autocomplete/shortcuts_provider_unittest.cc b/chrome/browser/autocomplete/shortcuts_provider_unittest.cc
index 735313b..bd700aa 100644
--- a/chrome/browser/autocomplete/shortcuts_provider_unittest.cc
+++ b/chrome/browser/autocomplete/shortcuts_provider_unittest.cc
@@ -179,7 +179,7 @@ void ShortcutsProviderTest::SetUp() {
&profile_, &ShortcutsBackendFactory::BuildProfileNoDatabaseForTesting);
backend_ = ShortcutsBackendFactory::GetForProfile(&profile_);
ASSERT_TRUE(backend_.get());
- profile_.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_.CreateHistoryService(true, false));
provider_ = new ShortcutsProvider(this, &profile_);
FillData(shortcut_test_db, arraysize(shortcut_test_db));
}
diff --git a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc
index b9c7bed..8f532bc 100644
--- a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc
@@ -148,7 +148,7 @@ TEST_F(BookmarkHTMLWriterTest, Test) {
content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
- profile.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile.CreateHistoryService(true, false));
profile.BlockUntilHistoryProcessesPendingRequests();
profile.CreateFaviconService();
profile.CreateBookmarkModel(true);
diff --git a/chrome/browser/bookmarks/bookmark_index_unittest.cc b/chrome/browser/bookmarks/bookmark_index_unittest.cc
index 724b6c8..caef831 100644
--- a/chrome/browser/bookmarks/bookmark_index_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_index_unittest.cc
@@ -236,7 +236,7 @@ TEST_F(BookmarkIndexTest, GetResultsSortedByTypedCount) {
content::TestBrowserThreadBundle thread_bundle;
TestingProfile profile;
- profile.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile.CreateHistoryService(true, false));
profile.BlockUntilHistoryProcessesPendingRequests();
profile.CreateBookmarkModel(true);
diff --git a/chrome/browser/bookmarks/bookmark_model_unittest.cc b/chrome/browser/bookmarks/bookmark_model_unittest.cc
index 06610d7..65f5c65 100644
--- a/chrome/browser/bookmarks/bookmark_model_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_model_unittest.cc
@@ -910,15 +910,6 @@ class BookmarkModelTestWithProfile : public testing::Test {
ui_test_utils::WaitForBookmarkModelToLoad(bb_model_);
}
- // Destroys the current profile, creates a new one and creates the history
- // service.
- void RecreateProfile() {
- // Need to shutdown the old one before creating a new one.
- profile_.reset(NULL);
- profile_.reset(new TestingProfile());
- profile_->CreateHistoryService(true, false);
- }
-
// The profile.
scoped_ptr<TestingProfile> profile_;
BookmarkModel* bb_model_;
@@ -954,7 +945,7 @@ TEST_F(BookmarkModelTestWithProfile, CreateAndRestore) {
profile_.reset(NULL);
profile_.reset(new TestingProfile());
profile_->CreateBookmarkModel(true);
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
BlockTillBookmarkModelLoaded();
TestNode bbn;
diff --git a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
index 3d659ce..cfb313b 100644
--- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
@@ -333,11 +333,14 @@ class RemoveServerBoundCertTester : public net::SSLConfigService::Observer {
class RemoveHistoryTester {
public:
- explicit RemoveHistoryTester(TestingProfile* profile)
- : query_url_success_(false) {
- profile->CreateHistoryService(true, false);
+ RemoveHistoryTester() : query_url_success_(false), history_service_(NULL) {}
+
+ bool Init(TestingProfile* profile) WARN_UNUSED_RESULT {
+ if (!profile->CreateHistoryService(true, false))
+ return false;
history_service_ = HistoryServiceFactory::GetForProfile(
profile, Profile::EXPLICIT_ACCESS);
+ return true;
}
// Returns true, if the given URL exists in the history service.
@@ -826,7 +829,8 @@ TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) {
}
TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) {
- RemoveHistoryTester tester(GetProfile());
+ RemoveHistoryTester tester;
+ ASSERT_TRUE(tester.Init(GetProfile()));
tester.AddHistory(kOrigin1, base::Time::Now());
ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1));
@@ -840,7 +844,8 @@ TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) {
}
TEST_F(BrowsingDataRemoverTest, RemoveHistoryForLastHour) {
- RemoveHistoryTester tester(GetProfile());
+ RemoveHistoryTester tester;
+ ASSERT_TRUE(tester.Init(GetProfile()));
base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2);
@@ -886,7 +891,8 @@ TEST_F(BrowsingDataRemoverTest, RemoveHistoryProhibited) {
TEST_F(BrowsingDataRemoverTest, RemoveMultipleTypes) {
// Add some history.
- RemoveHistoryTester history_tester(GetProfile());
+ RemoveHistoryTester history_tester;
+ ASSERT_TRUE(history_tester.Init(GetProfile()));
history_tester.AddHistory(kOrigin1, base::Time::Now());
ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1));
@@ -1288,7 +1294,8 @@ TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) {
}
TEST_F(BrowsingDataRemoverTest, OriginBasedHistoryRemoval) {
- RemoveHistoryTester tester(GetProfile());
+ RemoveHistoryTester tester;
+ ASSERT_TRUE(tester.Init(GetProfile()));
base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2);
@@ -1309,7 +1316,8 @@ TEST_F(BrowsingDataRemoverTest, OriginBasedHistoryRemoval) {
}
TEST_F(BrowsingDataRemoverTest, OriginAndTimeBasedHistoryRemoval) {
- RemoveHistoryTester tester(GetProfile());
+ RemoveHistoryTester tester;
+ ASSERT_TRUE(tester.Init(GetProfile()));
base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2);
diff --git a/chrome/browser/download/download_target_determiner_unittest.cc b/chrome/browser/download/download_target_determiner_unittest.cc
index ed943f7..46a1803 100644
--- a/chrome/browser/download/download_target_determiner_unittest.cc
+++ b/chrome/browser/download/download_target_determiner_unittest.cc
@@ -1087,7 +1087,7 @@ TEST_F(DownloadTargetDeterminerTest, TargetDeterminer_VisitedReferrer) {
base::FilePath(FILE_PATH_LITERAL("foo.html"))));
// First the history service must exist.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
GURL url("http://visited.example.com/visited-link.html");
// The time of visit is picked to be several seconds prior to the most recent
diff --git a/chrome/browser/history/android/android_history_provider_service_unittest.cc b/chrome/browser/history/android/android_history_provider_service_unittest.cc
index 7919849..6b882f5 100644
--- a/chrome/browser/history/android/android_history_provider_service_unittest.cc
+++ b/chrome/browser/history/android/android_history_provider_service_unittest.cc
@@ -53,7 +53,7 @@ class AndroidHistoryProviderServiceTest : public testing::Test {
testing_profile_->CreateBookmarkModel(true);
ui_test_utils::WaitForBookmarkModelToLoad(testing_profile_);
- testing_profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false));
service_.reset(new AndroidHistoryProviderService(testing_profile_));
}
diff --git a/chrome/browser/history/android/sqlite_cursor_unittest.cc b/chrome/browser/history/android/sqlite_cursor_unittest.cc
index 7491cd1..fc98bcb 100644
--- a/chrome/browser/history/android/sqlite_cursor_unittest.cc
+++ b/chrome/browser/history/android/sqlite_cursor_unittest.cc
@@ -63,7 +63,7 @@ class SQLiteCursorTest : public testing::Test,
ui_test_utils::WaitForBookmarkModelToLoad(testing_profile_);
testing_profile_->CreateFaviconService();
- testing_profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(testing_profile_->CreateHistoryService(true, false));
service_.reset(new AndroidHistoryProviderService(testing_profile_));
hs_ = HistoryServiceFactory::GetForProfile(testing_profile_,
Profile::EXPLICIT_ACCESS);
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc
index 7bd2328..8e608a7 100644
--- a/chrome/browser/history/history_backend_unittest.cc
+++ b/chrome/browser/history/history_backend_unittest.cc
@@ -2791,7 +2791,7 @@ TEST_F(HistoryBackendSegmentDurationTest, SegmentDuration) {
TEST_F(HistoryBackendTest, RemoveNotification) {
scoped_ptr<TestingProfile> profile(new TestingProfile());
- profile->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile->CreateHistoryService(false, false));
profile->CreateBookmarkModel(true);
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile.get());
ui_test_utils::WaitForBookmarkModelToLoad(model);
diff --git a/chrome/browser/history/in_memory_url_index_unittest.cc b/chrome/browser/history/in_memory_url_index_unittest.cc
index 1e0f72e..4556665 100644
--- a/chrome/browser/history/in_memory_url_index_unittest.cc
+++ b/chrome/browser/history/in_memory_url_index_unittest.cc
@@ -186,7 +186,7 @@ bool InMemoryURLIndexTest::DeleteURL(const GURL& url) {
void InMemoryURLIndexTest::SetUp() {
// We cannot access the database until the backend has been loaded.
- profile_.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_.CreateHistoryService(true, false));
profile_.CreateBookmarkModel(true);
ui_test_utils::WaitForBookmarkModelToLoad(&profile_);
profile_.BlockUntilHistoryProcessesPendingRequests();
diff --git a/chrome/browser/history/top_sites_impl_unittest.cc b/chrome/browser/history/top_sites_impl_unittest.cc
index 251accb..a0b9f22 100644
--- a/chrome/browser/history/top_sites_impl_unittest.cc
+++ b/chrome/browser/history/top_sites_impl_unittest.cc
@@ -149,7 +149,7 @@ class TopSitesImplTest : public HistoryUnitTestBase {
virtual void SetUp() {
profile_.reset(new TestingProfile);
if (CreateHistoryAndTopSites()) {
- profile_->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(false, false));
profile_->CreateTopSites();
profile_->BlockUntilTopSitesLoaded();
}
@@ -360,7 +360,7 @@ class TopSitesMigrationTest : public TopSitesImplTest {
data_path.AppendASCII("thumbnails.3.sql"),
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->CreateTopSites();
profile()->BlockUntilTopSitesLoaded();
}
@@ -914,7 +914,7 @@ TEST_F(TopSitesMigrationTest, Migrate) {
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
// Recreate top sites and make sure everything is still there.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
RecreateTopSitesAndBlock();
ASSERT_NO_FATAL_FAILURE(MigrationAssertions());
@@ -1207,7 +1207,7 @@ TEST_F(TopSitesImplTest, CreateTopSitesThenHistory) {
EXPECT_FALSE(IsTopSitesLoaded());
// Load history, which should make TopSites finish loading too.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->BlockUntilTopSitesLoaded();
EXPECT_TRUE(IsTopSitesLoaded());
}
@@ -1227,7 +1227,7 @@ class TopSitesUnloadTest : public TopSitesImplTest {
// Makes sure if history is unloaded after topsites is loaded we don't hit any
// assertions.
TEST_F(TopSitesUnloadTest, UnloadHistoryTest) {
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->CreateTopSites();
profile()->BlockUntilTopSitesLoaded();
HistoryServiceFactory::GetForProfile(
@@ -1250,7 +1250,7 @@ TEST_F(TopSitesUnloadTest, UnloadWithMigration) {
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
// Create history and block until it's loaded.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->BlockUntilHistoryProcessesPendingRequests();
// Create top sites and unload history.
diff --git a/chrome/browser/history/top_sites_likely_impl_unittest.cc b/chrome/browser/history/top_sites_likely_impl_unittest.cc
index 8ef73a2..01a9504 100644
--- a/chrome/browser/history/top_sites_likely_impl_unittest.cc
+++ b/chrome/browser/history/top_sites_likely_impl_unittest.cc
@@ -149,7 +149,7 @@ class TopSitesLikelyImplTest : public HistoryUnitTestBase {
virtual void SetUp() {
profile_.reset(new TestingProfile);
if (CreateHistoryAndTopSites()) {
- profile_->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(false, false));
profile_->CreateTopSites();
profile_->BlockUntilTopSitesLoaded();
}
@@ -361,7 +361,7 @@ class TopSitesLikelyMigrationTest : public TopSitesLikelyImplTest {
data_path.AppendASCII("thumbnails.3.sql"),
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->CreateTopSites();
profile()->BlockUntilTopSitesLoaded();
}
@@ -915,7 +915,7 @@ TEST_F(TopSitesLikelyMigrationTest, Migrate) {
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
// Recreate top sites and make sure everything is still there.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
RecreateTopSitesAndBlock();
ASSERT_NO_FATAL_FAILURE(MigrationAssertions());
@@ -1208,7 +1208,7 @@ TEST_F(TopSitesLikelyImplTest, CreateTopSitesThenHistory) {
EXPECT_FALSE(IsTopSitesLoaded());
// Load history, which should make TopSites finish loading too.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->BlockUntilTopSitesLoaded();
EXPECT_TRUE(IsTopSitesLoaded());
}
@@ -1228,7 +1228,7 @@ class TopSitesLikelyUnloadTest : public TopSitesLikelyImplTest {
// Makes sure if history is unloaded after topsites is loaded we don't hit any
// assertions.
TEST_F(TopSitesLikelyUnloadTest, UnloadHistoryTest) {
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->CreateTopSites();
profile()->BlockUntilTopSitesLoaded();
HistoryServiceFactory::GetForProfile(
@@ -1251,7 +1251,7 @@ TEST_F(TopSitesLikelyUnloadTest, UnloadWithMigration) {
profile()->GetPath().Append(chrome::kThumbnailsFilename)));
// Create history and block until it's loaded.
- profile()->CreateHistoryService(false, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(false, false));
profile()->BlockUntilHistoryProcessesPendingRequests();
// Create top sites and unload history.
diff --git a/chrome/browser/importer/profile_writer_unittest.cc b/chrome/browser/importer/profile_writer_unittest.cc
index 2f6334b..4641e83 100644
--- a/chrome/browser/importer/profile_writer_unittest.cc
+++ b/chrome/browser/importer/profile_writer_unittest.cc
@@ -194,7 +194,7 @@ TEST_F(ProfileWriterTest, CheckBookmarksAfterWritingDataTwice) {
// Verify that history entires are not duplicated when added twice.
TEST_F(ProfileWriterTest, CheckHistoryAfterWritingDataTwice) {
TestingProfile profile;
- profile.CreateHistoryService(true, false);
+ ASSERT_TRUE(profile.CreateHistoryService(true, false));
profile.BlockUntilHistoryProcessesPendingRequests();
CreateHistoryPageEntries();
diff --git a/chrome/browser/predictors/autocomplete_action_predictor_unittest.cc b/chrome/browser/predictors/autocomplete_action_predictor_unittest.cc
index 921ba20..c13641b 100644
--- a/chrome/browser/predictors/autocomplete_action_predictor_unittest.cc
+++ b/chrome/browser/predictors/autocomplete_action_predictor_unittest.cc
@@ -102,7 +102,7 @@ class AutocompleteActionPredictorTest : public testing::Test {
switches::kPrerenderFromOmniboxSwitchValueEnabled);
predictor_->CreateLocalCachesFromDatabase();
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
profile_->BlockUntilHistoryProcessesPendingRequests();
ASSERT_TRUE(predictor_->initialized_);
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc b/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
index 56d90c6..b0d7fe3 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
@@ -186,7 +186,7 @@ ResourcePrefetchPredictorTest::~ResourcePrefetchPredictorTest() {
void ResourcePrefetchPredictorTest::SetUp() {
InitializeSampleData();
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
profile_->BlockUntilHistoryProcessesPendingRequests();
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile_.get(),
Profile::EXPLICIT_ACCESS));
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc
index 57ad936..0241d0d 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -220,14 +220,14 @@ TEST_F(ProfileManagerTest, CreateAndUseTwoProfiles) {
ASSERT_TRUE(profile2);
// Force lazy-init of some profile services to simulate use.
- profile1->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile1->CreateHistoryService(true, false));
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile1,
Profile::EXPLICIT_ACCESS));
profile1->CreateBookmarkModel(true);
EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile1));
profile2->CreateBookmarkModel(true);
EXPECT_TRUE(BookmarkModelFactory::GetForProfile(profile2));
- profile2->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile2->CreateHistoryService(true, false));
EXPECT_TRUE(HistoryServiceFactory::GetForProfile(profile2,
Profile::EXPLICIT_ACCESS));
diff --git a/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc b/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc
index dce0cf5..c54c71c 100644
--- a/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc
+++ b/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc
@@ -51,7 +51,8 @@ class BrowserFeatureExtractorTest : public ChromeRenderViewHostTestHarness {
protected:
virtual void SetUp() {
ChromeRenderViewHostTestHarness::SetUp();
- profile()->CreateHistoryService(true /* delete_file */, false /* no_db */);
+ ASSERT_TRUE(profile()->CreateHistoryService(
+ true /* delete_file */, false /* no_db */));
service_.reset(new StrictMock<MockClientSideDetectionService>());
extractor_.reset(
new BrowserFeatureExtractor(web_contents(), service_.get()));
diff --git a/chrome/browser/safe_browsing/malware_details_unittest.cc b/chrome/browser/safe_browsing/malware_details_unittest.cc
index 37ada0c..f35884d 100644
--- a/chrome/browser/safe_browsing/malware_details_unittest.cc
+++ b/chrome/browser/safe_browsing/malware_details_unittest.cc
@@ -188,7 +188,8 @@ class MalwareDetailsTest : public ChromeRenderViewHostTestHarness {
virtual void SetUp() OVERRIDE {
ChromeRenderViewHostTestHarness::SetUp();
- profile()->CreateHistoryService(true /* delete_file */, false /* no_db */);
+ ASSERT_TRUE(profile()->CreateHistoryService(
+ true /* delete_file */, false /* no_db */));
}
virtual void TearDown() OVERRIDE {
diff --git a/chrome/browser/search_engines/template_url_service_unittest.cc b/chrome/browser/search_engines/template_url_service_unittest.cc
index b1e95de..4e36bfc 100644
--- a/chrome/browser/search_engines/template_url_service_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_unittest.cc
@@ -1194,7 +1194,7 @@ TEST_F(TemplateURLServiceTest, ChangeGoogleBaseValue) {
// KEYWORD visits.
TEST_F(TemplateURLServiceTest, GenerateVisitOnKeyword) {
test_util_.VerifyLoad();
- test_util_.profile()->CreateHistoryService(true, false);
+ ASSERT_TRUE(test_util_.profile()->CreateHistoryService(true, false));
// Create a keyword.
TemplateURL* t_url = AddKeywordWithDate(
diff --git a/chrome/browser/ui/bookmarks/bookmark_prompt_controller_unittest.cc b/chrome/browser/ui/bookmarks/bookmark_prompt_controller_unittest.cc
index fa79f1b..169f451 100644
--- a/chrome/browser/ui/bookmarks/bookmark_prompt_controller_unittest.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_prompt_controller_unittest.cc
@@ -65,8 +65,8 @@ class BookmarkPromptControllerTest : public BrowserWithTestWindowTest {
TestingBrowserProcess::GetGlobal()->
SetBookmarkPromptController(new BookmarkPromptController);
BrowserWithTestWindowTest::SetUp();
- static_cast<TestingProfile*>(browser()->profile())->
- CreateHistoryService(true, false);
+ ASSERT_TRUE(static_cast<TestingProfile*>(browser()->profile())->
+ CreateHistoryService(true, false));
static_cast<TestingProfile*>(browser()->profile())->
BlockUntilHistoryIndexIsRefreshed();
// Simulate browser activation.
diff --git a/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc b/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc
index e815d38..0fc79ad 100644
--- a/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc
+++ b/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc
@@ -138,7 +138,7 @@ class ProfileSigninConfirmationHelperTest : public testing::Test {
profile_->CreateBookmarkModel(true);
model_ = BookmarkModelFactory::GetForProfile(profile_.get());
ui_test_utils::WaitForBookmarkModelToLoad(model_);
- profile_->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile_->CreateHistoryService(true, false));
extensions::TestExtensionSystem* system =
static_cast<extensions::TestExtensionSystem*>(
extensions::ExtensionSystem::Get(profile_.get()));
diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
index 4f2af32..9339fbe 100644
--- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc
@@ -497,7 +497,7 @@ TEST_F(BackFwdMenuModelTest, EscapeLabel) {
// Test asynchronous loading of favicon from history service.
TEST_F(BackFwdMenuModelTest, FaviconLoadTest) {
- profile()->CreateHistoryService(true, false);
+ ASSERT_TRUE(profile()->CreateHistoryService(true, false));
profile()->CreateFaviconService();
Browser::CreateParams native_params(profile(), chrome::GetActiveDesktop());
scoped_ptr<Browser> browser(
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 2704bc7..11502e4 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -351,12 +351,13 @@ static BrowserContextKeyedService* BuildHistoryService(
return new HistoryService(static_cast<Profile*>(profile));
}
-void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
+bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
DestroyHistoryService();
if (delete_file) {
base::FilePath path = GetPath();
path = path.Append(chrome::kHistoryFilename);
- base::DeleteFile(path, false);
+ if (!base::DeleteFile(path, false) || base::PathExists(path))
+ return false;
}
// This will create and init the history service.
HistoryService* history_service = static_cast<HistoryService*>(
@@ -369,6 +370,7 @@ void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
}
// Disable WebHistoryService by default, since it makes network requests.
WebHistoryServiceFactory::GetInstance()->SetTestingFactory(this, NULL);
+ return true;
}
void TestingProfile::DestroyHistoryService() {
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index 916bc33..dd8d68e 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -132,8 +132,8 @@ class TestingProfile : public Profile {
// deletes the directory containing the files used by HistoryService, this
// only matters if you're recreating the HistoryService. If |no_db| is true,
// the history backend will fail to initialize its database; this is useful
- // for testing error conditions.
- void CreateHistoryService(bool delete_file, bool no_db);
+ // for testing error conditions. Returns true on success.
+ bool CreateHistoryService(bool delete_file, bool no_db) WARN_UNUSED_RESULT;
// Shuts down and nulls out the reference to HistoryService.
void DestroyHistoryService();
diff --git a/chrome/test/perf/generate_profile.cc b/chrome/test/perf/generate_profile.cc
index d37060a..fe46c3d 100644
--- a/chrome/test/perf/generate_profile.cc
+++ b/chrome/test/perf/generate_profile.cc
@@ -229,7 +229,10 @@ bool GenerateProfile(GenerateProfileTypes types,
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
content::TestBrowserThread db_thread(BrowserThread::DB, &message_loop);
TestingProfile profile;
- profile.CreateHistoryService(false, false);
+ if (!profile.CreateHistoryService(false, false)) {
+ PLOG(ERROR) << "Creating history service failed";
+ return false;
+ }
if (types & TOP_SITES) {
profile.CreateTopSites();
profile.BlockUntilTopSitesLoaded();