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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 [bar_ shrinkOrHideView:view forMaxX:40.0]; 1561 [bar_ shrinkOrHideView:view forMaxX:40.0];
1562 EXPECT_EQ(40.0, NSWidth([view frame])); 1562 EXPECT_EQ(40.0, NSWidth([view frame]));
1563 EXPECT_FALSE([view isHidden]); 1563 EXPECT_FALSE([view isHidden]);
1564 [bar_ shrinkOrHideView:view forMaxX:31.0]; 1564 [bar_ shrinkOrHideView:view forMaxX:31.0];
1565 EXPECT_EQ(31.0, NSWidth([view frame])); 1565 EXPECT_EQ(31.0, NSWidth([view frame]));
1566 EXPECT_FALSE([view isHidden]); 1566 EXPECT_FALSE([view isHidden]);
1567 [bar_ shrinkOrHideView:view forMaxX:29.0]; 1567 [bar_ shrinkOrHideView:view forMaxX:29.0];
1568 EXPECT_TRUE([view isHidden]); 1568 EXPECT_TRUE([view isHidden]);
1569 } 1569 }
1570 1570
1571 // Simulate coarse browser window width change and ensure that the bookmark
1572 // buttons that should be visible are visible.
1573 TEST_F(BookmarkBarControllerTest, RedistributeButtonsOnBarAsNeeded) {
1574 // Hide the apps shortcut.
1575 profile()->GetPrefs()->SetBoolean(
1576 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, false);
1577 ASSERT_TRUE([bar_ appsPageShortcutButtonIsHidden]);
1578
1579 // Add three buttons to the bookmark bar.
1580 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile());
1581 const BookmarkNode* root = model->bookmark_bar_node();
1582 // Make long labels to test coarse resizes. After 16 digits, text eliding
1583 // starts.
1584 const std::string model_string(
1585 "0000000000000000 1111111111111111 2222222222222222 ");
1586 bookmarks::test::AddNodesFromModelString(model, root, model_string);
1587 NSRect frame = [[bar_ view] frame];
1588 frame.size.width = 400; // Typical minimum browser size.
1589 [[bar_ view] setFrame:frame];
1590 EXPECT_EQ(2, [bar_ displayedButtonCount]);
1591
1592 {
1593 base::mac::ScopedNSAutoreleasePool pool;
1594 frame.size.width = 800;
1595 [[bar_ view] setFrame:frame];
1596 EXPECT_EQ(3, [bar_ displayedButtonCount]);
1597
1598 const BookmarkNode* last = model->bookmark_bar_node()->GetChild(2);
1599 EXPECT_TRUE(last);
1600 [bar_ startPulsingBookmarkNode:last];
1601
1602 frame.size.width = 400;
1603 [[bar_ view] setFrame:frame];
1604 EXPECT_EQ(2, [bar_ displayedButtonCount]);
1605 }
1606
1607 // Regression test for http://crbug.com/616051.
1608 [bar_ stopPulsingBookmarkNode];
1609 }
1610
1571 // Simiulate browser window width change and ensure that the bookmark buttons 1611 // Simiulate browser window width change and ensure that the bookmark buttons
1572 // that should be visible are visible. 1612 // that should be visible are visible.
1573 // Appears to fail on Mac 10.11 bot on the waterfall; http://crbug.com/612640. 1613 // Appears to fail on Mac 10.11 bot on the waterfall; http://crbug.com/612640.
1574 TEST_F(BookmarkBarControllerTest, DISABLED_LastBookmarkResizeBehavior) { 1614 TEST_F(BookmarkBarControllerTest, DISABLED_LastBookmarkResizeBehavior) {
1575 // Hide the apps shortcut. 1615 // Hide the apps shortcut.
1576 profile()->GetPrefs()->SetBoolean( 1616 profile()->GetPrefs()->SetBoolean(
1577 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, false); 1617 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, false);
1578 ASSERT_TRUE([bar_ appsPageShortcutButtonIsHidden]); 1618 ASSERT_TRUE([bar_ appsPageShortcutButtonIsHidden]);
1579 1619
1580 // Add three buttons to the bookmark bar. 1620 // Add three buttons to the bookmark bar.
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 "2f3b ] 4b "); 2220 "2f3b ] 4b ");
2181 actual = bookmarks::test::ModelStringFromNode(root); 2221 actual = bookmarks::test::ModelStringFromNode(root);
2182 EXPECT_EQ(expected, actual); 2222 EXPECT_EQ(expected, actual);
2183 2223
2184 // Verify that the other bookmark folder can't be deleted. 2224 // Verify that the other bookmark folder can't be deleted.
2185 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; 2225 BookmarkButton *otherButton = [bar_ otherBookmarksButton];
2186 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); 2226 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]);
2187 } 2227 }
2188 2228
2189 } // namespace 2229 } // namespace
OLDNEW
« 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