Chromium Code Reviews| 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/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.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 scoped_nsobject<BookmarkBarFolderButtonCell> cell; |
| 19 cell.reset([[BookmarkBarFolderButtonCell buttonCellForNode:nil | 19 cell.reset([[BookmarkBarFolderButtonCell buttonCellForNode:nil |
| 20 menuController:nil | 20 text:nil |
| 21 cellText:nil | 21 image:nil |
| 22 cellImage: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 scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]); |
| 29 scoped_nsobject<NSButton> folder_view( | 29 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 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 scoped_nsobject<BookmarkButtonCell> cell( |
| 41 [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); | 41 [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); |
| 42 scoped_nsobject<BookmarkBarFolderButtonCell> folder_cell( | 42 scoped_nsobject<BookmarkBarFolderButtonCell> folder_cell( |
| 43 [[BookmarkBarFolderButtonCell buttonCellForNode:nil | 43 [[BookmarkBarFolderButtonCell buttonCellForNode:nil |
| 44 menuController:nil | 44 text:@"Testing" |
|
Alexei Svitkine (slow)
2013/03/11 21:06:43
Align the :'s.
beaudoin
2013/03/11 21:29:56
Done.
| |
| 45 cellText:@"Testing" | 45 image:image |
| 46 cellImage:image] 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()]; |
| 53 | 53 |
| 54 [[test_window() contentView] addSubview:view]; | 54 [[test_window() contentView] addSubview:view]; |
| 55 [[test_window() contentView] addSubview:folder_view]; | 55 [[test_window() contentView] addSubview:folder_view]; |
| 56 | 56 |
| (...skipping 16 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 |