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

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

Issue 8792001: A BookmarkBarFolderButtonCell should have the favicon aligned left when no title is provided (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: handle nits; add unit test Created 9 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
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell_unittest.mm
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell_unittest.mm
index dff15be173ce60828d156f29294734e2d42f26ab..bc8394c145a8c4277c2e6254b0be672ec27a874a 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell_unittest.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell_unittest.mm
@@ -5,6 +5,7 @@
#include "base/memory/scoped_nsobject.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h"
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
+#include "ui/gfx/mac/nsimage_cache.h"
namespace {
@@ -21,4 +22,47 @@ TEST_F(BookmarkBarFolderButtonCellTest, Create) {
EXPECT_TRUE(cell);
}
+TEST_F(BookmarkBarFolderButtonCellTest, FaviconPositioning) {
+ NSRect frame = NSMakeRect(0, 0, 50, 30);
+ scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]);
+ scoped_nsobject<NSButton> folder_view(
+ [[NSButton alloc] initWithFrame:frame]);
+
+ EXPECT_TRUE(view.get());
+ EXPECT_TRUE(folder_view.get());
+
+ scoped_nsobject<NSImage> image(
+ [gfx::GetCachedImageWithName(@"nav.pdf") retain]);
+ EXPECT_TRUE(image.get());
+
+ scoped_nsobject<BookmarkButtonCell> cell(
+ [[BookmarkButtonCell alloc] initTextCell:@"Testing"]);
+ scoped_nsobject<BookmarkBarFolderButtonCell> folder_cell(
+ [[BookmarkBarFolderButtonCell buttonCellForNode:nil
+ contextMenu:nil
+ cellText:@"Testing"
+ cellImage:image] retain]);
+
+ EXPECT_TRUE(cell.get());
+ EXPECT_TRUE(folder_cell.get());
+
+ [view setCell:cell.get()];
+ [folder_view setCell:folder_cell.get()];
+
+ [[test_window() contentView] addSubview:view];
+ [[test_window() contentView] addSubview:folder_view];
+
+ [cell setBookmarkCellText:@"" image:image];
+ EXPECT_EQ(NSImageOnly, [cell imagePosition]);
+
+ [cell setBookmarkCellText:@"test" image:image];
+ EXPECT_EQ(NSImageLeft, [cell imagePosition]);
+
+ [folder_cell setBookmarkCellText:@"" image:image];
+ EXPECT_EQ(NSImageLeft, [cell imagePosition]);
+
+ [folder_cell setBookmarkCellText:@"test" image:image];
+ EXPECT_EQ(NSImageLeft, [cell imagePosition]);
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698