OLD | NEW |
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 "grit/ui_resources_standard.h" |
| 9 #include "ui/base/resource/resource_bundle.h" |
8 #include "ui/gfx/mac/nsimage_cache.h" | 10 #include "ui/gfx/mac/nsimage_cache.h" |
9 | 11 |
10 namespace { | 12 namespace { |
11 | 13 |
12 class BookmarkBarFolderButtonCellTest : public CocoaTest { | 14 class BookmarkBarFolderButtonCellTest : public CocoaTest { |
13 }; | 15 }; |
14 | 16 |
15 // Basic creation. | 17 // Basic creation. |
16 TEST_F(BookmarkBarFolderButtonCellTest, Create) { | 18 TEST_F(BookmarkBarFolderButtonCellTest, Create) { |
17 scoped_nsobject<BookmarkBarFolderButtonCell> cell; | 19 scoped_nsobject<BookmarkBarFolderButtonCell> cell; |
18 cell.reset([[BookmarkBarFolderButtonCell buttonCellForNode:nil | 20 cell.reset([[BookmarkBarFolderButtonCell buttonCellForNode:nil |
19 contextMenu:nil | 21 contextMenu:nil |
20 cellText:nil | 22 cellText:nil |
21 cellImage:nil] retain]); | 23 cellImage:nil] retain]); |
22 EXPECT_TRUE(cell); | 24 EXPECT_TRUE(cell); |
23 } | 25 } |
24 | 26 |
25 TEST_F(BookmarkBarFolderButtonCellTest, FaviconPositioning) { | 27 TEST_F(BookmarkBarFolderButtonCellTest, FaviconPositioning) { |
26 NSRect frame = NSMakeRect(0, 0, 50, 30); | 28 NSRect frame = NSMakeRect(0, 0, 50, 30); |
27 scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]); | 29 scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]); |
28 scoped_nsobject<NSButton> folder_view( | 30 scoped_nsobject<NSButton> folder_view( |
29 [[NSButton alloc] initWithFrame:frame]); | 31 [[NSButton alloc] initWithFrame:frame]); |
30 | 32 |
31 ASSERT_TRUE(view.get()); | 33 ASSERT_TRUE(view.get()); |
32 ASSERT_TRUE(folder_view.get()); | 34 ASSERT_TRUE(folder_view.get()); |
33 | 35 |
| 36 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
34 scoped_nsobject<NSImage> image( | 37 scoped_nsobject<NSImage> image( |
35 [gfx::GetCachedImageWithName(@"nav.pdf") retain]); | 38 [rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON) retain]); |
36 ASSERT_TRUE(image.get()); | 39 ASSERT_TRUE(image.get()); |
37 | 40 |
38 scoped_nsobject<BookmarkButtonCell> cell( | 41 scoped_nsobject<BookmarkButtonCell> cell( |
39 [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); | 42 [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); |
40 scoped_nsobject<BookmarkBarFolderButtonCell> folder_cell( | 43 scoped_nsobject<BookmarkBarFolderButtonCell> folder_cell( |
41 [[BookmarkBarFolderButtonCell buttonCellForNode:nil | 44 [[BookmarkBarFolderButtonCell buttonCellForNode:nil |
42 contextMenu:nil | 45 contextMenu:nil |
43 cellText:@"Testing" | 46 cellText:@"Testing" |
44 cellImage:image] retain]); | 47 cellImage:image] retain]); |
45 | 48 |
(...skipping 25 matching lines...) Expand all Loading... |
71 | 74 |
72 [folder_cell setBookmarkCellText:@"test" image:image]; | 75 [folder_cell setBookmarkCellText:@"test" image:image]; |
73 float folder_cell_x_with_title = ([cell imageRectForBounds:rect]).origin.x; | 76 float folder_cell_x_with_title = ([cell imageRectForBounds:rect]).origin.x; |
74 float folder_cell_width_with_title = ([cell cellSize]).width; | 77 float folder_cell_width_with_title = ([cell cellSize]).width; |
75 | 78 |
76 EXPECT_EQ(folder_cell_x_without_title, folder_cell_x_with_title); | 79 EXPECT_EQ(folder_cell_x_without_title, folder_cell_x_with_title); |
77 EXPECT_EQ(folder_cell_width_without_title, folder_cell_width_with_title); | 80 EXPECT_EQ(folder_cell_width_without_title, folder_cell_width_with_title); |
78 } | 81 } |
79 | 82 |
80 } // namespace | 83 } // namespace |
OLD | NEW |