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

Unified Diff: chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc

Issue 8568011: gtk/bookmarks: Reuse |model_| in BookmarkBarGtkUnittest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: erg review Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc
diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc
index a48f5878125ff56d69bc0d4e7633611864373dda..94a5a32ca90639d1f7b071e0535812fc9293077e 100644
--- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc
+++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc
@@ -4,7 +4,8 @@
#include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h"
-#include "base/task.h"
+#include "base/compiler_specific.h"
+#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/ui/browser.h"
@@ -31,18 +32,19 @@ class BookmarkBarGtkUnittest : public testing::Test {
file_thread_(BrowserThread::FILE, &message_loop_) {
}
- virtual void SetUp() {
+ virtual void SetUp() OVERRIDE {
profile_.reset(new TestingProfile());
profile_->CreateBookmarkModel(true);
profile_->BlockUntilBookmarkModelLoaded();
- browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get()));
+ model_ = profile_->GetBookmarkModel();
+ browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get()));
origin_provider_.reset(new EmptyTabstripOriginProvider);
bookmark_bar_.reset(new BookmarkBarGtk(NULL, browser_.get(),
origin_provider_.get()));
}
- virtual void TearDown() {
+ virtual void TearDown() OVERRIDE {
message_loop_.RunAllPending();
bookmark_bar_.reset();
@@ -51,6 +53,8 @@ class BookmarkBarGtkUnittest : public testing::Test {
profile_.reset();
}
+ BookmarkModel* model_;
+
MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
@@ -62,8 +66,7 @@ class BookmarkBarGtkUnittest : public testing::Test {
};
TEST_F(BookmarkBarGtkUnittest, DisplaysHelpMessageOnEmpty) {
- BookmarkModel* model = profile_->GetBookmarkModel();
- bookmark_bar_->Loaded(model, false);
+ bookmark_bar_->Loaded(model_, false);
// There are no bookmarks in the model by default. Expect that the
// |instructions_label| is shown.
@@ -71,26 +74,22 @@ TEST_F(BookmarkBarGtkUnittest, DisplaysHelpMessageOnEmpty) {
}
TEST_F(BookmarkBarGtkUnittest, HidesHelpMessageWithBookmark) {
- BookmarkModel* model = profile_->GetBookmarkModel();
+ const BookmarkNode* parent = model_->bookmark_bar_node();
+ model_->AddURL(parent, parent->child_count(),
+ ASCIIToUTF16("title"), GURL("http://one.com"));
- const BookmarkNode* parent = model->bookmark_bar_node();
- model->AddURL(parent, parent->child_count(),
- ASCIIToUTF16("title"), GURL("http://one.com"));
-
- bookmark_bar_->Loaded(model, false);
+ bookmark_bar_->Loaded(model_, false);
EXPECT_FALSE(bookmark_bar_->show_instructions_);
}
TEST_F(BookmarkBarGtkUnittest, BuildsButtons) {
- BookmarkModel* model = profile_->GetBookmarkModel();
-
- const BookmarkNode* parent = model->bookmark_bar_node();
- model->AddURL(parent, parent->child_count(),
- ASCIIToUTF16("title"), GURL("http://one.com"));
- model->AddURL(parent, parent->child_count(),
- ASCIIToUTF16("other"), GURL("http://two.com"));
+ const BookmarkNode* parent = model_->bookmark_bar_node();
+ model_->AddURL(parent, parent->child_count(),
+ ASCIIToUTF16("title"), GURL("http://one.com"));
+ model_->AddURL(parent, parent->child_count(),
+ ASCIIToUTF16("other"), GURL("http://two.com"));
- bookmark_bar_->Loaded(model, false);
+ bookmark_bar_->Loaded(model_, false);
// We should expect two children to the bookmark bar's toolbar.
GList* children = gtk_container_get_children(
« 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