OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/ui/views/bookmarks/bookmark_bar_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 TEST_F(BookmarkBarViewTest, RemoveNode) { | 238 TEST_F(BookmarkBarViewTest, RemoveNode) { |
239 CreateBookmarkModelAndBookmarkBarView(); | 239 CreateBookmarkModelAndBookmarkBarView(); |
240 const BookmarkNode* bookmark_bar_node = | 240 const BookmarkNode* bookmark_bar_node = |
241 BookmarkModelFactory::GetForProfile(profile())->bookmark_bar_node(); | 241 BookmarkModelFactory::GetForProfile(profile())->bookmark_bar_node(); |
242 AddNodesToBookmarkBarFromModelString("a b c d e f "); | 242 AddNodesToBookmarkBarFromModelString("a b c d e f "); |
243 EXPECT_EQ(0, test_helper_->GetBookmarkButtonCount()); | 243 EXPECT_EQ(0, test_helper_->GetBookmarkButtonCount()); |
244 SizeUntilButtonsVisible(1); | 244 SizeUntilButtonsVisible(1); |
245 EXPECT_EQ(2, test_helper_->GetBookmarkButtonCount()); | 245 EXPECT_EQ(2, test_helper_->GetBookmarkButtonCount()); |
246 | 246 |
247 // Remove the 2nd node, should still only have 1 visible. | 247 // Remove the 2nd node, should still only have 1 visible. |
248 BookmarkModelFactory::GetForProfile(profile())->Remove(bookmark_bar_node, 1); | 248 BookmarkModelFactory::GetForProfile(profile()) |
| 249 ->Remove(bookmark_bar_node->GetChild(1)); |
249 EXPECT_EQ("a", GetStringForVisibleButtons()); | 250 EXPECT_EQ("a", GetStringForVisibleButtons()); |
250 | 251 |
251 // Remove the first node, should force a new button (for the 'c' node). | 252 // Remove the first node, should force a new button (for the 'c' node). |
252 BookmarkModelFactory::GetForProfile(profile())->Remove(bookmark_bar_node, 0); | 253 BookmarkModelFactory::GetForProfile(profile()) |
| 254 ->Remove(bookmark_bar_node->GetChild(0)); |
253 ASSERT_EQ("c", GetStringForVisibleButtons()); | 255 ASSERT_EQ("c", GetStringForVisibleButtons()); |
254 } | 256 } |
255 | 257 |
256 // Assertions for moving a node on the bookmark bar. | 258 // Assertions for moving a node on the bookmark bar. |
257 TEST_F(BookmarkBarViewTest, MoveNode) { | 259 TEST_F(BookmarkBarViewTest, MoveNode) { |
258 CreateBookmarkModelAndBookmarkBarView(); | 260 CreateBookmarkModelAndBookmarkBarView(); |
259 const BookmarkNode* bookmark_bar_node = | 261 const BookmarkNode* bookmark_bar_node = |
260 BookmarkModelFactory::GetForProfile(profile())->bookmark_bar_node(); | 262 BookmarkModelFactory::GetForProfile(profile())->bookmark_bar_node(); |
261 AddNodesToBookmarkBarFromModelString("a b c d e f "); | 263 AddNodesToBookmarkBarFromModelString("a b c d e f "); |
262 EXPECT_EQ(0, test_helper_->GetBookmarkButtonCount()); | 264 EXPECT_EQ(0, test_helper_->GetBookmarkButtonCount()); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, | 356 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
355 new base::FundamentalValue(false)); | 357 new base::FundamentalValue(false)); |
356 EXPECT_FALSE(test_helper_->apps_page_shortcut()->visible()); | 358 EXPECT_FALSE(test_helper_->apps_page_shortcut()->visible()); |
357 | 359 |
358 // And try showing it via policy too. | 360 // And try showing it via policy too. |
359 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, | 361 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
360 new base::FundamentalValue(true)); | 362 new base::FundamentalValue(true)); |
361 EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible()); | 363 EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible()); |
362 } | 364 } |
363 #endif | 365 #endif |
OLD | NEW |