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

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

Issue 1912: Renames BoomarkBarModel to BookmarkModel. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/testing_profile.h" 5 #include "chrome/test/testing_profile.h"
6 6
7 #include "chrome/browser/history/history_backend.h" 7 #include "chrome/browser/history/history_backend.h"
8 #include "chrome/common/chrome_constants.h" 8 #include "chrome/common/chrome_constants.h"
9 9
10 namespace { 10 namespace {
11 11
12 // BookmarkLoadObserver is used when blocking until the BookmarkBarModel 12 // BookmarkLoadObserver is used when blocking until the BookmarkModel
13 // finishes loading. As soon as the BookmarkBarModel finishes loading the 13 // finishes loading. As soon as the BookmarkModel finishes loading the message
14 // message loop is quit. 14 // loop is quit.
15 class BookmarkLoadObserver : public BookmarkBarModelObserver { 15 class BookmarkLoadObserver : public BookmarkModelObserver {
16 public: 16 public:
17 BookmarkLoadObserver() {} 17 BookmarkLoadObserver() {}
18 virtual void Loaded(BookmarkBarModel* model) { 18 virtual void Loaded(BookmarkModel* model) {
19 MessageLoop::current()->Quit(); 19 MessageLoop::current()->Quit();
20 } 20 }
21 21
22 virtual void BookmarkNodeMoved(BookmarkBarModel* model, 22 virtual void BookmarkNodeMoved(BookmarkModel* model,
23 BookmarkBarNode* old_parent, 23 BookmarkNode* old_parent,
24 int old_index, 24 int old_index,
25 BookmarkBarNode* new_parent, 25 BookmarkNode* new_parent,
26 int new_index) {} 26 int new_index) {}
27 virtual void BookmarkNodeAdded(BookmarkBarModel* model, 27 virtual void BookmarkNodeAdded(BookmarkModel* model,
28 BookmarkBarNode* parent, 28 BookmarkNode* parent,
29 int index) {} 29 int index) {}
30 virtual void BookmarkNodeRemoved(BookmarkBarModel* model, 30 virtual void BookmarkNodeRemoved(BookmarkModel* model,
31 BookmarkBarNode* parent, 31 BookmarkNode* parent,
32 int index) {} 32 int index) {}
33 virtual void BookmarkNodeChanged(BookmarkBarModel* model, 33 virtual void BookmarkNodeChanged(BookmarkModel* model,
34 BookmarkBarNode* node) {} 34 BookmarkNode* node) {}
35 virtual void BookmarkNodeFavIconLoaded(BookmarkBarModel* model, 35 virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
36 BookmarkBarNode* node) {} 36 BookmarkNode* node) {}
37 37
38 private: 38 private:
39 DISALLOW_COPY_AND_ASSIGN(BookmarkLoadObserver); 39 DISALLOW_COPY_AND_ASSIGN(BookmarkLoadObserver);
40 }; 40 };
41 41
42 } // namespace 42 } // namespace
43 43
44 TestingProfile::TestingProfile() 44 TestingProfile::TestingProfile()
45 : start_time_(Time::Now()), has_history_service_(false) { 45 : start_time_(Time::Now()), has_history_service_(false) {
46 PathService::Get(base::DIR_TEMP, &path_); 46 PathService::Get(base::DIR_TEMP, &path_);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // probably leaking a reference to the history backend, so it never calls 83 // probably leaking a reference to the history backend, so it never calls
84 // our destroy task. 84 // our destroy task.
85 MessageLoop::current()->Run(); 85 MessageLoop::current()->Run();
86 86
87 // Make sure we don't have any event pending that could disrupt the next 87 // Make sure we don't have any event pending that could disrupt the next
88 // test. 88 // test.
89 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); 89 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask);
90 MessageLoop::current()->Run(); 90 MessageLoop::current()->Run();
91 } 91 }
92 92
93 void TestingProfile::CreateBookmarkBarModel(bool delete_file) { 93 void TestingProfile::CreateBookmarkModel(bool delete_file) {
94 // Nuke the model first, that way we're sure it's done writing to disk. 94 // Nuke the model first, that way we're sure it's done writing to disk.
95 bookmark_bar_model_.reset(NULL); 95 bookmark_bar_model_.reset(NULL);
96 96
97 if (delete_file) { 97 if (delete_file) {
98 std::wstring path = GetPath(); 98 std::wstring path = GetPath();
99 file_util::AppendToPath(&path, chrome::kBookmarksFileName); 99 file_util::AppendToPath(&path, chrome::kBookmarksFileName);
100 file_util::Delete(path, false); 100 file_util::Delete(path, false);
101 } 101 }
102 bookmark_bar_model_.reset(new BookmarkBarModel(this)); 102 bookmark_bar_model_.reset(new BookmarkModel(this));
103 if (history_service_.get()) { 103 if (history_service_.get()) {
104 history_service_->history_backend_->bookmark_service_ = 104 history_service_->history_backend_->bookmark_service_ =
105 bookmark_bar_model_.get(); 105 bookmark_bar_model_.get();
106 history_service_->history_backend_->expirer_.bookmark_service_ = 106 history_service_->history_backend_->expirer_.bookmark_service_ =
107 bookmark_bar_model_.get(); 107 bookmark_bar_model_.get();
108 } 108 }
109 bookmark_bar_model_->Load(); 109 bookmark_bar_model_->Load();
110 } 110 }
111 111
112 void TestingProfile::BlockUntilBookmarkModelLoaded() { 112 void TestingProfile::BlockUntilBookmarkModelLoaded() {
113 DCHECK(bookmark_bar_model_.get()); 113 DCHECK(bookmark_bar_model_.get());
114 if (bookmark_bar_model_->IsLoaded()) 114 if (bookmark_bar_model_->IsLoaded())
115 return; 115 return;
116 BookmarkLoadObserver observer; 116 BookmarkLoadObserver observer;
117 bookmark_bar_model_->AddObserver(&observer); 117 bookmark_bar_model_->AddObserver(&observer);
118 MessageLoop::current()->Run(); 118 MessageLoop::current()->Run();
119 bookmark_bar_model_->RemoveObserver(&observer); 119 bookmark_bar_model_->RemoveObserver(&observer);
120 DCHECK(bookmark_bar_model_->IsLoaded()); 120 DCHECK(bookmark_bar_model_->IsLoaded());
121 } 121 }
122 122
123 void TestingProfile::CreateTemplateURLModel() { 123 void TestingProfile::CreateTemplateURLModel() {
124 template_url_model_.reset(new TemplateURLModel(this)); 124 template_url_model_.reset(new TemplateURLModel(this));
125 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698