| Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
|
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
|
| index 2ab778ea91d8db3c8a3fc13a5020cfa05dd16265..000689229cfebad2dc4e1311e458a3e9c3f4b331 100644
|
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
|
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
|
| @@ -27,6 +27,7 @@
|
| #include "ui/views/controls/button/label_button.h"
|
| #include "ui/views/controls/button/menu_button.h"
|
|
|
| +using bookmarks::BookmarkModel;
|
| using bookmarks::BookmarkNode;
|
|
|
| class BookmarkBarViewTest : public BrowserWithTestWindowTest {
|
| @@ -78,10 +79,6 @@ class BookmarkBarViewTest : public BrowserWithTestWindowTest {
|
| }
|
| }
|
|
|
| - const BookmarkNode* GetBookmarkBarNode() {
|
| - return BookmarkModelFactory::GetForProfile(profile())->bookmark_bar_node();
|
| - }
|
| -
|
| void WaitForBookmarkModelToLoad() {
|
| bookmarks::test::WaitForBookmarkModelToLoad(
|
| BookmarkModelFactory::GetForProfile(profile()));
|
| @@ -90,10 +87,9 @@ class BookmarkBarViewTest : public BrowserWithTestWindowTest {
|
| // Adds nodes to the bookmark bar node from |string|. See
|
| // bookmarks::test::AddNodesFromModelString() for details on |string|.
|
| void AddNodesToBookmarkBarFromModelString(const std::string& string) {
|
| - bookmarks::test::AddNodesFromModelString(
|
| - BookmarkModelFactory::GetForProfile(profile()),
|
| - GetBookmarkBarNode(),
|
| - string);
|
| + BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
|
| + bookmarks::test::AddNodesFromModelString(model, model->bookmark_bar_node(),
|
| + string);
|
| }
|
| // Creates the BookmarkBarView and BookmarkBarViewTestHelper. Generally you'll
|
| // want to use CreateBookmarkModelAndBookmarkBarView(), but use this if
|
| @@ -238,35 +234,32 @@ TEST_F(BookmarkBarViewTest, AddNodesWhenBarAlreadySized) {
|
| // Various assertions for removing nodes.
|
| TEST_F(BookmarkBarViewTest, RemoveNode) {
|
| CreateBookmarkModelAndBookmarkBarView();
|
| - const BookmarkNode* bookmark_bar_node =
|
| - BookmarkModelFactory::GetForProfile(profile())->bookmark_bar_node();
|
| + BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
|
| + const BookmarkNode* bookmark_bar_node = model->bookmark_bar_node();
|
| AddNodesToBookmarkBarFromModelString("a b c d e f ");
|
| EXPECT_EQ(0, test_helper_->GetBookmarkButtonCount());
|
| SizeUntilButtonsVisible(1);
|
| EXPECT_EQ(2, test_helper_->GetBookmarkButtonCount());
|
|
|
| // Remove the 2nd node, should still only have 1 visible.
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->Remove(bookmark_bar_node->GetChild(1));
|
| + model->Remove(bookmark_bar_node->GetChild(1));
|
| EXPECT_EQ("a", GetStringForVisibleButtons());
|
|
|
| // Remove the first node, should force a new button (for the 'c' node).
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->Remove(bookmark_bar_node->GetChild(0));
|
| + model->Remove(bookmark_bar_node->GetChild(0));
|
| ASSERT_EQ("c", GetStringForVisibleButtons());
|
| }
|
|
|
| // Assertions for moving a node on the bookmark bar.
|
| TEST_F(BookmarkBarViewTest, MoveNode) {
|
| CreateBookmarkModelAndBookmarkBarView();
|
| - const BookmarkNode* bookmark_bar_node =
|
| - BookmarkModelFactory::GetForProfile(profile())->bookmark_bar_node();
|
| + BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
|
| + const BookmarkNode* bookmark_bar_node = model->bookmark_bar_node();
|
| AddNodesToBookmarkBarFromModelString("a b c d e f ");
|
| EXPECT_EQ(0, test_helper_->GetBookmarkButtonCount());
|
|
|
| // Move 'c' first resulting in 'c a b d e f'.
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->Move(bookmark_bar_node->GetChild(2), bookmark_bar_node, 0);
|
| + model->Move(bookmark_bar_node->GetChild(2), bookmark_bar_node, 0);
|
| EXPECT_EQ(0, test_helper_->GetBookmarkButtonCount());
|
|
|
| // Make enough room for 1 node.
|
| @@ -274,20 +267,17 @@ TEST_F(BookmarkBarViewTest, MoveNode) {
|
| EXPECT_EQ("c", GetStringForVisibleButtons());
|
|
|
| // Move 'f' first, resulting in 'f c a b d e'.
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->Move(bookmark_bar_node->GetChild(5), bookmark_bar_node, 0);
|
| + model->Move(bookmark_bar_node->GetChild(5), bookmark_bar_node, 0);
|
| SizeUntilButtonsVisible(2);
|
| EXPECT_EQ("f c", GetStringForVisibleButtons());
|
|
|
| // Move 'f' to the end, resulting in 'c a b d e f'.
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->Move(bookmark_bar_node->GetChild(0), bookmark_bar_node, 6);
|
| + model->Move(bookmark_bar_node->GetChild(0), bookmark_bar_node, 6);
|
| SizeUntilButtonsVisible(2);
|
| EXPECT_EQ("c a", GetStringForVisibleButtons());
|
|
|
| // Move 'c' after 'a', resulting in 'a c b d e f'.
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->Move(bookmark_bar_node->GetChild(0), bookmark_bar_node, 2);
|
| + model->Move(bookmark_bar_node->GetChild(0), bookmark_bar_node, 2);
|
| SizeUntilButtonsVisible(2);
|
| EXPECT_EQ("a c", GetStringForVisibleButtons());
|
| }
|
| @@ -295,43 +285,38 @@ TEST_F(BookmarkBarViewTest, MoveNode) {
|
| // Assertions for changing the title of a node.
|
| TEST_F(BookmarkBarViewTest, ChangeTitle) {
|
| CreateBookmarkModelAndBookmarkBarView();
|
| - const BookmarkNode* bookmark_bar_node = GetBookmarkBarNode();
|
| + BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
|
| + const BookmarkNode* bookmark_bar_node = model->bookmark_bar_node();
|
| AddNodesToBookmarkBarFromModelString("a b c d e f ");
|
| EXPECT_EQ(0, test_helper_->GetBookmarkButtonCount());
|
|
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->SetTitle(bookmark_bar_node->GetChild(0), base::ASCIIToUTF16("a1"));
|
| + model->SetTitle(bookmark_bar_node->GetChild(0), base::ASCIIToUTF16("a1"));
|
| EXPECT_EQ(0, test_helper_->GetBookmarkButtonCount());
|
|
|
| // Make enough room for 1 node.
|
| SizeUntilButtonsVisible(1);
|
| EXPECT_EQ("a1", GetStringForVisibleButtons());
|
|
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->SetTitle(bookmark_bar_node->GetChild(1), base::ASCIIToUTF16("b1"));
|
| + model->SetTitle(bookmark_bar_node->GetChild(1), base::ASCIIToUTF16("b1"));
|
| EXPECT_EQ("a1", GetStringForVisibleButtons());
|
|
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->SetTitle(bookmark_bar_node->GetChild(5), base::ASCIIToUTF16("f1"));
|
| + model->SetTitle(bookmark_bar_node->GetChild(5), base::ASCIIToUTF16("f1"));
|
| EXPECT_EQ("a1", GetStringForVisibleButtons());
|
|
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->SetTitle(bookmark_bar_node->GetChild(3), base::ASCIIToUTF16("d1"));
|
| + model->SetTitle(bookmark_bar_node->GetChild(3), base::ASCIIToUTF16("d1"));
|
|
|
| // Make the second button visible, changes the title of the first to something
|
| // really long and make sure the second button hides.
|
| SizeUntilButtonsVisible(2);
|
| EXPECT_EQ("a1 b1", GetStringForVisibleButtons());
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->SetTitle(bookmark_bar_node->GetChild(0),
|
| - base::ASCIIToUTF16("a_really_long_title"));
|
| + model->SetTitle(bookmark_bar_node->GetChild(0),
|
| + base::ASCIIToUTF16("a_really_long_title"));
|
| EXPECT_LE(1, test_helper_->GetBookmarkButtonCount());
|
|
|
| // Change the title back and make sure the 2nd button is visible again. Don't
|
| // use GetStringForVisibleButtons() here as more buttons may have been
|
| // created.
|
| - BookmarkModelFactory::GetForProfile(profile())
|
| - ->SetTitle(bookmark_bar_node->GetChild(0), base::ASCIIToUTF16("a1"));
|
| + model->SetTitle(bookmark_bar_node->GetChild(0), base::ASCIIToUTF16("a1"));
|
| ASSERT_LE(2, test_helper_->GetBookmarkButtonCount());
|
| EXPECT_TRUE(test_helper_->GetBookmarkButton(0)->visible());
|
| EXPECT_TRUE(test_helper_->GetBookmarkButton(1)->visible());
|
|
|