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

Side by Side Diff: chrome/browser/cocoa/bookmark_bar_toolbar_view_unittest.mm

Issue 402066: Moved a whole pile of unittests over to CocoaTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "app/theme_provider.h" 7 #include "app/theme_provider.h"
8 #include "base/scoped_nsobject.h" 8 #include "base/scoped_nsobject.h"
9 #include "chrome/browser/browser_theme_provider.h" 9 #include "chrome/browser/browser_theme_provider.h"
10 #import "chrome/browser/cocoa/bookmark_bar_controller.h" 10 #import "chrome/browser/cocoa/bookmark_bar_controller.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 @property(assign) ThemeProvider* themeProvider; 62 @property(assign) ThemeProvider* themeProvider;
63 @property(assign) BOOL isShownAsDetachedBar; 63 @property(assign) BOOL isShownAsDetachedBar;
64 @end 64 @end
65 65
66 @implementation DrawDetachedBarFakeController 66 @implementation DrawDetachedBarFakeController
67 @synthesize currentTabContentsHeight = current_tab_contents_height_; 67 @synthesize currentTabContentsHeight = current_tab_contents_height_;
68 @synthesize themeProvider = theme_provider_; 68 @synthesize themeProvider = theme_provider_;
69 @synthesize isShownAsDetachedBar = isShownAsDetachedBar_; 69 @synthesize isShownAsDetachedBar = isShownAsDetachedBar_;
70 @end 70 @end
71 71
72 class BookmarkBarToolbarViewTest : public PlatformTest { 72 class BookmarkBarToolbarViewTest : public CocoaTest {
73 public: 73 public:
74 BookmarkBarToolbarViewTest() { 74 BookmarkBarToolbarViewTest() {
75 controller_.reset([[DrawDetachedBarFakeController alloc] init]); 75 controller_.reset([[DrawDetachedBarFakeController alloc] init]);
76 NSRect frame = NSMakeRect(0, 0, 400, 40); 76 NSRect frame = NSMakeRect(0, 0, 400, 40);
77 view_.reset([[BookmarkBarToolbarView alloc] initWithFrame:frame]); 77 scoped_nsobject<BookmarkBarToolbarView> view(
78 [cocoa_helper_.contentView() addSubview:view_.get()]; 78 [[BookmarkBarToolbarView alloc] initWithFrame:frame]);
79 [view_.get() setController:controller_.get()]; 79 view_ = view.get();
80 [[test_window() contentView] addSubview:view_];
81 [view_ setController:controller_.get()];
80 } 82 }
81 83
82 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc...
83 scoped_nsobject<DrawDetachedBarFakeController> controller_; 84 scoped_nsobject<DrawDetachedBarFakeController> controller_;
84 scoped_nsobject<BookmarkBarToolbarView> view_; 85 BookmarkBarToolbarView* view_;
85 }; 86 };
86 87
87 // Test adding/removing from the view hierarchy, mostly to ensure nothing 88 TEST_VIEW(BookmarkBarToolbarViewTest, view_)
88 // leaks or crashes.
89 TEST_F(BookmarkBarToolbarViewTest, AddRemove) {
90 EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]);
91 [view_.get() removeFromSuperview];
92 EXPECT_FALSE([view_ superview]);
93 }
94 89
95 // Test drawing (part 1), mostly to ensure nothing leaks or crashes. 90 // Test drawing (part 1), mostly to ensure nothing leaks or crashes.
96 TEST_F(BookmarkBarToolbarViewTest, DisplayAsNormalBar) { 91 TEST_F(BookmarkBarToolbarViewTest, DisplayAsNormalBar) {
97 [controller_.get() setIsShownAsDetachedBar:NO]; 92 [controller_.get() setIsShownAsDetachedBar:NO];
98 [view_ display]; 93 [view_ display];
99 } 94 }
100 95
101 // Test drawing (part 2), mostly to ensure nothing leaks or crashes. 96 // Test drawing (part 2), mostly to ensure nothing leaks or crashes.
102 TEST_F(BookmarkBarToolbarViewTest, DisplayAsDetachedBarWithNoImage) { 97 TEST_F(BookmarkBarToolbarViewTest, DisplayAsDetachedBarWithNoImage) {
103 [controller_.get() setIsShownAsDetachedBar:YES]; 98 [controller_.get() setIsShownAsDetachedBar:YES];
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 fake_bg.allocPixels(); 146 fake_bg.allocPixels();
152 fake_bg.eraseColor(SK_ColorGREEN); 147 fake_bg.eraseColor(SK_ColorGREEN);
153 EXPECT_CALL(provider, GetBitmapNamed(IDR_THEME_NTP_BACKGROUND)) 148 EXPECT_CALL(provider, GetBitmapNamed(IDR_THEME_NTP_BACKGROUND))
154 .WillRepeatedly(Return(&fake_bg)); 149 .WillRepeatedly(Return(&fake_bg));
155 150
156 [controller_.get() setThemeProvider:&provider]; 151 [controller_.get() setThemeProvider:&provider];
157 [controller_.get() setCurrentTabContentsHeight:200]; 152 [controller_.get() setCurrentTabContentsHeight:200];
158 153
159 [view_ display]; 154 [view_ display];
160 } 155 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_controller_unittest.mm ('k') | chrome/browser/cocoa/bookmark_bar_view_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698