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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm

Issue 10662041: mac: Remove nav.pdf in favor of IDR_DEFAULT_FAVICON. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: deps Created 8 years, 5 months 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
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 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/bookmarks/bookmark_model.h" 7 #include "chrome/browser/bookmarks/bookmark_model.h"
8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" 8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h"
9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu.h" 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu.h"
10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
12 #include "grit/ui_resources_standard.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/platform_test.h" 14 #include "testing/platform_test.h"
15 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
15 #include "ui/gfx/mac/nsimage_cache.h" 17 #include "ui/gfx/mac/nsimage_cache.h"
16 18
17 // Simple class to remember how many mouseEntered: and mouseExited: 19 // Simple class to remember how many mouseEntered: and mouseExited:
18 // calls it gets. Only used by BookmarkMouseForwarding but placed 20 // calls it gets. Only used by BookmarkMouseForwarding but placed
19 // at the top of the file to keep it outside the anon namespace. 21 // at the top of the file to keep it outside the anon namespace.
20 @interface ButtonRemembersMouseEnterExit : NSButton { 22 @interface ButtonRemembersMouseEnterExit : NSButton {
21 @public 23 @public
22 int enters_; 24 int enters_;
23 int exits_; 25 int exits_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 58
57 // Make sure icon-only buttons are squeezed tightly. 59 // Make sure icon-only buttons are squeezed tightly.
58 TEST_F(BookmarkButtonCellTest, IconOnlySqueeze) { 60 TEST_F(BookmarkButtonCellTest, IconOnlySqueeze) {
59 NSRect frame = NSMakeRect(0, 0, 50, 30); 61 NSRect frame = NSMakeRect(0, 0, 50, 30);
60 scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]); 62 scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]);
61 scoped_nsobject<BookmarkButtonCell> cell( 63 scoped_nsobject<BookmarkButtonCell> cell(
62 [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); 64 [[BookmarkButtonCell alloc] initTextCell:@"Testing"]);
63 [view setCell:cell.get()]; 65 [view setCell:cell.get()];
64 [[test_window() contentView] addSubview:view]; 66 [[test_window() contentView] addSubview:view];
65 67
68 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
66 scoped_nsobject<NSImage> image( 69 scoped_nsobject<NSImage> image(
67 [gfx::GetCachedImageWithName(@"nav.pdf") retain]); 70 [rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON) retain]);
68 EXPECT_TRUE(image.get()); 71 EXPECT_TRUE(image.get());
69 72
70 NSRect r = NSMakeRect(0, 0, 100, 100); 73 NSRect r = NSMakeRect(0, 0, 100, 100);
71 [cell setBookmarkCellText:@" " image:image]; 74 [cell setBookmarkCellText:@" " image:image];
72 CGFloat two_space_width = [cell.get() cellSizeForBounds:r].width; 75 CGFloat two_space_width = [cell.get() cellSizeForBounds:r].width;
73 [cell setBookmarkCellText:@" " image:image]; 76 [cell setBookmarkCellText:@" " image:image];
74 CGFloat one_space_width = [cell.get() cellSizeForBounds:r].width; 77 CGFloat one_space_width = [cell.get() cellSizeForBounds:r].width;
75 [cell setBookmarkCellText:@"" image:image]; 78 [cell setBookmarkCellText:@"" image:image];
76 CGFloat zero_space_width = [cell.get() cellSizeForBounds:r].width; 79 CGFloat zero_space_width = [cell.get() cellSizeForBounds:r].width;
77 80
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 ASSERT_TRUE(bookmark_cell.get()); 199 ASSERT_TRUE(bookmark_cell.get());
197 200
198 EXPECT_EQ(1, [gradient_cell verticalTextOffset]); 201 EXPECT_EQ(1, [gradient_cell verticalTextOffset]);
199 EXPECT_EQ(0, [bookmark_cell verticalTextOffset]); 202 EXPECT_EQ(0, [bookmark_cell verticalTextOffset]);
200 203
201 EXPECT_NE([bookmark_cell verticalTextOffset], 204 EXPECT_NE([bookmark_cell verticalTextOffset],
202 [gradient_cell verticalTextOffset]); 205 [gradient_cell verticalTextOffset]);
203 } 206 }
204 207
205 } // namespace 208 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698