Chromium Code Reviews| 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..7f136777414aa5412f47f123b376dfe30c31c942 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,59 @@ 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()); |
|
Ryan Sleevi
2011/12/15 00:45:54
Drive by: Should these be ASSERT_TRUEs instead?
KushalP
2011/12/15 01:29:26
Yes they should. Updating now.
|
| + 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]; |
| + |
| + NSRect rect = NSMakeRect(20, 20, 20, 20); |
| + |
| + [cell setBookmarkCellText:@"" image:image]; |
| + float cell_x_without_title = ([cell imageRectForBounds:rect]).origin.x; |
| + float cell_width_without_title = ([cell cellSize]).width; |
| + |
| + [cell setBookmarkCellText:@"test" image:image]; |
| + float cell_x_with_title = ([cell imageRectForBounds:rect]).origin.x; |
| + float cell_width_with_title = ([cell cellSize]).width; |
| + |
| + EXPECT_LT(cell_x_without_title, cell_x_with_title); |
| + EXPECT_LT(cell_width_without_title, cell_width_with_title); |
| + |
| + [folder_cell setBookmarkCellText:@"" image:image]; |
| + float folder_cell_x_without_title = ([cell imageRectForBounds:rect]).origin.x; |
| + float folder_cell_width_without_title = ([cell cellSize]).width; |
| + |
| + [folder_cell setBookmarkCellText:@"test" image:image]; |
| + float folder_cell_x_with_title = ([cell imageRectForBounds:rect]).origin.x; |
| + float folder_cell_width_with_title = ([cell cellSize]).width; |
| + |
| + EXPECT_EQ(folder_cell_x_without_title, folder_cell_x_with_title); |
| + EXPECT_EQ(folder_cell_width_without_title, folder_cell_width_with_title); |
| +} |
| + |
| } // namespace |