| 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 "app/mac/nsimage_cache.h" | |
| 6 #include "base/memory/scoped_nsobject.h" | 5 #include "base/memory/scoped_nsobject.h" |
| 7 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model.h" | 7 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" | 8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu.h" | 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu.h" |
| 11 #include "chrome/browser/ui/cocoa/browser_test_helper.h" | 10 #include "chrome/browser/ui/cocoa/browser_test_helper.h" |
| 12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
| 15 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
| 15 #include "ui/gfx/mac/nsimage_cache.h" |
| 16 | 16 |
| 17 // Simple class to remember how many mouseEntered: and mouseExited: | 17 // Simple class to remember how many mouseEntered: and mouseExited: |
| 18 // calls it gets. Only used by BookmarkMouseForwarding but placed | 18 // calls it gets. Only used by BookmarkMouseForwarding but placed |
| 19 // at the top of the file to keep it outside the anon namespace. | 19 // at the top of the file to keep it outside the anon namespace. |
| 20 @interface ButtonRemembersMouseEnterExit : NSButton { | 20 @interface ButtonRemembersMouseEnterExit : NSButton { |
| 21 @public | 21 @public |
| 22 int enters_; | 22 int enters_; |
| 23 int exits_; | 23 int exits_; |
| 24 } | 24 } |
| 25 @end | 25 @end |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // Make sure icon-only buttons are squeezed tightly. | 59 // Make sure icon-only buttons are squeezed tightly. |
| 60 TEST_F(BookmarkButtonCellTest, IconOnlySqueeze) { | 60 TEST_F(BookmarkButtonCellTest, IconOnlySqueeze) { |
| 61 NSRect frame = NSMakeRect(0, 0, 50, 30); | 61 NSRect frame = NSMakeRect(0, 0, 50, 30); |
| 62 scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]); | 62 scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]); |
| 63 scoped_nsobject<BookmarkButtonCell> cell( | 63 scoped_nsobject<BookmarkButtonCell> cell( |
| 64 [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); | 64 [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); |
| 65 [view setCell:cell.get()]; | 65 [view setCell:cell.get()]; |
| 66 [[test_window() contentView] addSubview:view]; | 66 [[test_window() contentView] addSubview:view]; |
| 67 | 67 |
| 68 scoped_nsobject<NSImage> image( | 68 scoped_nsobject<NSImage> image( |
| 69 [app::mac::GetCachedImageWithName(@"nav.pdf") retain]); | 69 [gfx::GetCachedImageWithName(@"nav.pdf") retain]); |
| 70 EXPECT_TRUE(image.get()); | 70 EXPECT_TRUE(image.get()); |
| 71 | 71 |
| 72 NSRect r = NSMakeRect(0, 0, 100, 100); | 72 NSRect r = NSMakeRect(0, 0, 100, 100); |
| 73 [cell setBookmarkCellText:@" " image:image]; | 73 [cell setBookmarkCellText:@" " image:image]; |
| 74 CGFloat two_space_width = [cell.get() cellSizeForBounds:r].width; | 74 CGFloat two_space_width = [cell.get() cellSizeForBounds:r].width; |
| 75 [cell setBookmarkCellText:@" " image:image]; | 75 [cell setBookmarkCellText:@" " image:image]; |
| 76 CGFloat one_space_width = [cell.get() cellSizeForBounds:r].width; | 76 CGFloat one_space_width = [cell.get() cellSizeForBounds:r].width; |
| 77 [cell setBookmarkCellText:@"" image:image]; | 77 [cell setBookmarkCellText:@"" image:image]; |
| 78 CGFloat zero_space_width = [cell.get() cellSizeForBounds:r].width; | 78 CGFloat zero_space_width = [cell.get() cellSizeForBounds:r].width; |
| 79 | 79 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 EXPECT_GE(size.width, 2); | 173 EXPECT_GE(size.width, 2); |
| 174 EXPECT_GE(size.height, 2); | 174 EXPECT_GE(size.height, 2); |
| 175 | 175 |
| 176 // Once we turn on arrow drawing make sure there is now room for it. | 176 // Once we turn on arrow drawing make sure there is now room for it. |
| 177 [cell setDrawFolderArrow:YES]; | 177 [cell setDrawFolderArrow:YES]; |
| 178 NSSize arrowSize = [cell cellSize]; | 178 NSSize arrowSize = [cell cellSize]; |
| 179 EXPECT_GT(arrowSize.width, size.width); | 179 EXPECT_GT(arrowSize.width, size.width); |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace | 182 } // namespace |
| OLD | NEW |