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

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm

Issue 2567973002: Mac: Fix lifetime problem under BookmarkBarController stopPulsingBookmarkNode. (Closed)
Patch Set: Guarantee a crash Created 4 years 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 | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
index c0056eb82a47219c790f769192bad8b08ef8ddfd..a182b0f1c4c5d169d6345c46f3705f22a4a7845a 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
@@ -1568,6 +1568,46 @@ TEST_F(BookmarkBarControllerTest, ShrinkOrHideView) {
EXPECT_TRUE([view isHidden]);
}
+// Simulate coarse browser window width change and ensure that the bookmark
+// buttons that should be visible are visible.
+TEST_F(BookmarkBarControllerTest, RedistributeButtonsOnBarAsNeeded) {
+ // Hide the apps shortcut.
+ profile()->GetPrefs()->SetBoolean(
+ bookmarks::prefs::kShowAppsShortcutInBookmarkBar, false);
+ ASSERT_TRUE([bar_ appsPageShortcutButtonIsHidden]);
+
+ // Add three buttons to the bookmark bar.
+ BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile());
+ const BookmarkNode* root = model->bookmark_bar_node();
+ // Make long labels to test coarse resizes. After 16 digits, text eliding
+ // starts.
+ const std::string model_string(
+ "0000000000000000 1111111111111111 2222222222222222 ");
+ bookmarks::test::AddNodesFromModelString(model, root, model_string);
+ NSRect frame = [[bar_ view] frame];
+ frame.size.width = 400; // Typical minimum browser size.
+ [[bar_ view] setFrame:frame];
+ EXPECT_EQ(2, [bar_ displayedButtonCount]);
+
+ {
+ base::mac::ScopedNSAutoreleasePool pool;
+ frame.size.width = 800;
+ [[bar_ view] setFrame:frame];
+ EXPECT_EQ(3, [bar_ displayedButtonCount]);
+
+ const BookmarkNode* last = model->bookmark_bar_node()->GetChild(2);
+ EXPECT_TRUE(last);
+ [bar_ startPulsingBookmarkNode:last];
+
+ frame.size.width = 400;
+ [[bar_ view] setFrame:frame];
+ EXPECT_EQ(2, [bar_ displayedButtonCount]);
+ }
+
+ // Regression test for http://crbug.com/616051.
+ [bar_ stopPulsingBookmarkNode];
+}
+
// Simiulate browser window width change and ensure that the bookmark buttons
// that should be visible are visible.
// Appears to fail on Mac 10.11 bot on the waterfall; http://crbug.com/612640.
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698