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