diff options
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/testing_profile.cc | 26 | ||||
-rw-r--r-- | chrome/test/testing_profile.h | 11 |
2 files changed, 24 insertions, 13 deletions
diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc index 7cc0455..c91c372 100644 --- a/chrome/test/testing_profile.cc +++ b/chrome/test/testing_profile.cc @@ -4,6 +4,7 @@ #include "chrome/test/testing_profile.h" +#include "chrome/browser/history/history_backend.h" #include "chrome/common/chrome_constants.h" TestingProfile::TestingProfile() @@ -30,9 +31,8 @@ void TestingProfile::CreateHistoryService(bool delete_file) { file_util::AppendToPath(&path, chrome::kHistoryFilename); file_util::Delete(path, false); } - file_util::CreateDirectory(history_dir_); - history_service_ = new HistoryService(); - history_service_->Init(GetPath()); + history_service_ = new HistoryService(this); + history_service_->Init(GetPath(), bookmark_bar_model_.get()); } void TestingProfile::DestroyHistoryService() { @@ -56,11 +56,23 @@ void TestingProfile::DestroyHistoryService() { MessageLoop::current()->Run(); } -void TestingProfile::CreateBookmarkBarModel() { - std::wstring path = GetPath(); - file_util::AppendToPath(&path, chrome::kBookmarksFileName); - file_util::Delete(path, false); +void TestingProfile::CreateBookmarkBarModel(bool delete_file) { + // Nuke the model first, that way we're sure it's done writing to disk. + bookmark_bar_model_.reset(NULL); + + if (delete_file) { + std::wstring path = GetPath(); + file_util::AppendToPath(&path, chrome::kBookmarksFileName); + file_util::Delete(path, false); + } bookmark_bar_model_.reset(new BookmarkBarModel(this)); + if (history_service_.get()) { + history_service_->history_backend_->bookmark_service_ = + bookmark_bar_model_.get(); + history_service_->history_backend_->expirer_.bookmark_service_ = + bookmark_bar_model_.get(); + } + bookmark_bar_model_->Load(); } void TestingProfile::CreateTemplateURLModel() { diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index d56e909..3d8e04c 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -27,8 +27,11 @@ class TestingProfile : public Profile { void CreateHistoryService(bool delete_file); // Creates the BookmkarBarModel. If not invoked the bookmark bar model is - // NULL. - void CreateBookmarkBarModel(); + // NULL. If |delete_file| is true, the bookmarks file is deleted first, then + // the model is created. As TestingProfile deletes the directory containing + // the files used by HistoryService, the boolean only matters if you're + // recreating the BookmarkBarModel. + void CreateBookmarkBarModel(bool delete_file); // Creates a TemplateURLModel. If not invoked the TemplateURLModel is NULL. void CreateTemplateURLModel(); @@ -164,9 +167,6 @@ class TestingProfile : public Profile { // from the destructor. void DestroyHistoryService(); - // Directory for the history service. - std::wstring history_dir_; - // The history service. Only created if CreateHistoryService is invoked. scoped_refptr<HistoryService> history_service_; @@ -182,4 +182,3 @@ class TestingProfile : public Profile { }; #endif // CHROME_TEST_TESTING_PROFILE_H__ - |