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

Side by Side 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: add imageRectForBounds tests 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "base/memory/scoped_nsobject.h" 5 #include "base/memory/scoped_nsobject.h"
6 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h" 6 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h"
7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
8 #include "ui/gfx/mac/nsimage_cache.h"
8 9
9 namespace { 10 namespace {
10 11
11 class BookmarkBarFolderButtonCellTest : public CocoaTest { 12 class BookmarkBarFolderButtonCellTest : public CocoaTest {
12 }; 13 };
13 14
14 // Basic creation. 15 // Basic creation.
15 TEST_F(BookmarkBarFolderButtonCellTest, Create) { 16 TEST_F(BookmarkBarFolderButtonCellTest, Create) {
16 scoped_nsobject<BookmarkBarFolderButtonCell> cell; 17 scoped_nsobject<BookmarkBarFolderButtonCell> cell;
17 cell.reset([[BookmarkBarFolderButtonCell buttonCellForNode:nil 18 cell.reset([[BookmarkBarFolderButtonCell buttonCellForNode:nil
18 contextMenu:nil 19 contextMenu:nil
19 cellText:nil 20 cellText:nil
20 cellImage:nil] retain]); 21 cellImage:nil] retain]);
21 EXPECT_TRUE(cell); 22 EXPECT_TRUE(cell);
22 } 23 }
23 24
25 TEST_F(BookmarkBarFolderButtonCellTest, FaviconPositioning) {
26 NSRect frame = NSMakeRect(0, 0, 50, 30);
27 scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]);
28 scoped_nsobject<NSButton> folder_view(
29 [[NSButton alloc] initWithFrame:frame]);
30
31 EXPECT_TRUE(view.get());
32 EXPECT_TRUE(folder_view.get());
33
34 scoped_nsobject<NSImage> image(
35 [gfx::GetCachedImageWithName(@"nav.pdf") retain]);
36 EXPECT_TRUE(image.get());
37
38 scoped_nsobject<BookmarkButtonCell> cell(
39 [[BookmarkButtonCell alloc] initTextCell:@"Testing"]);
40 scoped_nsobject<BookmarkBarFolderButtonCell> folder_cell(
41 [[BookmarkBarFolderButtonCell buttonCellForNode:nil
42 contextMenu:nil
43 cellText:@"Testing"
44 cellImage:image] retain]);
45
46 EXPECT_TRUE(cell.get());
47 EXPECT_TRUE(folder_cell.get());
48
49 [view setCell:cell.get()];
50 [folder_view setCell:folder_cell.get()];
51
52 [[test_window() contentView] addSubview:view];
53 [[test_window() contentView] addSubview:folder_view];
54
55 NSRect rect = NSMakeRect(50, 50, 50, 50);
56
57 [cell setBookmarkCellText:@"" image:image];
58 EXPECT_EQ(NSImageOnly, [cell imagePosition]);
59 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.
60 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
61
62 [cell setBookmarkCellText:@"test" image:image];
63 EXPECT_EQ(NSImageLeft, [cell imagePosition]);
64 EXPECT_EQ(67, ([cell imageRectForBounds:rect]).origin.y);
65 EXPECT_EQ(55, ([cell imageRectForBounds:rect]).origin.x);
66
67 [folder_cell setBookmarkCellText:@"" image:image];
68 EXPECT_EQ(NSImageLeft, [cell imagePosition]);
69 EXPECT_EQ(67, ([cell imageRectForBounds:rect]).origin.y);
70 EXPECT_EQ(55, ([cell imageRectForBounds:rect]).origin.x);
71
72 [folder_cell setBookmarkCellText:@"test" image:image];
73 EXPECT_EQ(NSImageLeft, [cell imagePosition]);
74 EXPECT_EQ(67, ([cell imageRectForBounds:rect]).origin.y);
75 EXPECT_EQ(55, ([cell imageRectForBounds:rect]).origin.x);
76 }
77
24 } // namespace 78 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698