summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/bookmark_button_cell_unittest.mm
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-07 00:55:49 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-07 00:55:49 +0000
commit73448fc4d5e742a7e2afe4325abbb3f4a44b0aef (patch)
treef7e0828bd05feca241ba05f2423444c3f4d81d6d /chrome/browser/cocoa/bookmark_button_cell_unittest.mm
parent6c2e45b826315fb4a3d452d589e245cdf2297991 (diff)
downloadchromium_src-73448fc4d5e742a7e2afe4325abbb3f4a44b0aef.zip
chromium_src-73448fc4d5e742a7e2afe4325abbb3f4a44b0aef.tar.gz
chromium_src-73448fc4d5e742a7e2afe4325abbb3f4a44b0aef.tar.bz2
Icon-only (titleless) bookmarks are squeezed closer.
BUG=42516 TEST=change some bookmark titles to "" and watch them get Kate Mossified. Review URL: http://codereview.chromium.org/2045002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_button_cell_unittest.mm')
-rw-r--r--chrome/browser/cocoa/bookmark_button_cell_unittest.mm32
1 files changed, 32 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/bookmark_button_cell_unittest.mm b/chrome/browser/cocoa/bookmark_button_cell_unittest.mm
index 0762863..a665a48 100644
--- a/chrome/browser/cocoa/bookmark_button_cell_unittest.mm
+++ b/chrome/browser/cocoa/bookmark_button_cell_unittest.mm
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "app/resource_bundle.h"
#include "base/scoped_nsobject.h"
#import "chrome/browser/cocoa/bookmark_button_cell.h"
#import "chrome/browser/cocoa/bookmark_menu.h"
#include "chrome/browser/cocoa/browser_test_helper.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
+#include "grit/app_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -52,6 +54,36 @@ TEST_F(BookmarkButtonCellTest, SizeForBounds) {
EXPECT_TRUE(size.width < 200 && size.height < 200);
}
+// Make sure icon-only buttons are squeezed tightly.
+TEST_F(BookmarkButtonCellTest, IconOnlySqueeze) {
+ NSRect frame = NSMakeRect(0, 0, 50, 30);
+ scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]);
+ scoped_nsobject<BookmarkButtonCell> cell(
+ [[BookmarkButtonCell alloc] initTextCell:@"Testing"]);
+ [view setCell:cell.get()];
+ [[test_window() contentView] addSubview:view];
+
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ scoped_nsobject<NSImage> image([rb.GetNSImageNamed(IDR_DEFAULT_FAVICON)
+ retain]);
+ EXPECT_TRUE(image.get());
+
+ NSRect r = NSMakeRect(0, 0, 100, 100);
+ [cell setBookmarkCellText:@" " image:image];
+ CGFloat two_space_width = [cell.get() cellSizeForBounds:r].width;
+ [cell setBookmarkCellText:@" " image:image];
+ CGFloat one_space_width = [cell.get() cellSizeForBounds:r].width;
+ [cell setBookmarkCellText:@"" image:image];
+ CGFloat zero_space_width = [cell.get() cellSizeForBounds:r].width;
+
+ // Make sure the switch to "no title" is more significant than we
+ // would otherwise see by decreasing the length of the title.
+ CGFloat delta1 = two_space_width - one_space_width;
+ CGFloat delta2 = one_space_width - zero_space_width;
+ EXPECT_GT(delta2, delta1);
+
+}
+
// Make sure the default from the base class is overridden.
TEST_F(BookmarkButtonCellTest, MouseEnterStuff) {
scoped_nsobject<BookmarkButtonCell> cell(