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..fedcf3dadcc99f0ab57235510c7f73cc33ac004c 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,57 @@ 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]; |
| + |
| + NSRect rect = NSMakeRect(50, 50, 50, 50); |
| + |
| + [cell setBookmarkCellText:@"" image:image]; |
| + EXPECT_EQ(NSImageOnly, [cell imagePosition]); |
| + EXPECT_EQ(67, ([cell imageRectForBounds:rect]).origin.y); |
|
Ilya Sherman
2011/12/14 00:27:39
nit: No need to test the y co-ordinate.
|
| + EXPECT_EQ(67, ([cell imageRectForBounds:rect]).origin.x); |
|
Ilya Sherman
2011/12/14 00:27:39
Rather than testing that the x-coordinate is 55 or
KushalP
2011/12/14 00:31:04
So something like:
EXPECT_NE(67, ([cell imageRect
Ilya Sherman
2011/12/14 00:33:06
Something like:
[cell setBookmarkCellText:@"" ima
|
| + |
| + [cell setBookmarkCellText:@"test" image:image]; |
| + EXPECT_EQ(NSImageLeft, [cell imagePosition]); |
| + EXPECT_EQ(67, ([cell imageRectForBounds:rect]).origin.y); |
| + EXPECT_EQ(55, ([cell imageRectForBounds:rect]).origin.x); |
| + |
| + [folder_cell setBookmarkCellText:@"" image:image]; |
| + EXPECT_EQ(NSImageLeft, [cell imagePosition]); |
| + EXPECT_EQ(67, ([cell imageRectForBounds:rect]).origin.y); |
| + EXPECT_EQ(55, ([cell imageRectForBounds:rect]).origin.x); |
| + |
| + [folder_cell setBookmarkCellText:@"test" image:image]; |
| + EXPECT_EQ(NSImageLeft, [cell imagePosition]); |
| + EXPECT_EQ(67, ([cell imageRectForBounds:rect]).origin.y); |
| + EXPECT_EQ(55, ([cell imageRectForBounds:rect]).origin.x); |
| +} |
| + |
| } // namespace |