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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_unittest.mm

Issue 10538039: Renamed BrowserWindow::GetNativeHandle() to GetNativeWindow() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update copyrights Created 8 years, 6 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) 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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6 6
7 #include "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #import "base/memory/scoped_nsobject.h" 8 #import "base/memory/scoped_nsobject.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // Make sure a normal BrowserWindowController is, uh, normal. 116 // Make sure a normal BrowserWindowController is, uh, normal.
117 EXPECT_TRUE([controller_ isTabbedWindow]); 117 EXPECT_TRUE([controller_ isTabbedWindow]);
118 EXPECT_TRUE([controller_ hasTabStrip]); 118 EXPECT_TRUE([controller_ hasTabStrip]);
119 EXPECT_FALSE([controller_ hasTitleBar]); 119 EXPECT_FALSE([controller_ hasTitleBar]);
120 EXPECT_TRUE([controller_ isBookmarkBarVisible]); 120 EXPECT_TRUE([controller_ isBookmarkBarVisible]);
121 121
122 // And make sure a controller for a pop-up window is not normal. 122 // And make sure a controller for a pop-up window is not normal.
123 // popup_browser will be owned by its window. 123 // popup_browser will be owned by its window.
124 Browser* popup_browser(Browser::CreateWithParams( 124 Browser* popup_browser(Browser::CreateWithParams(
125 Browser::CreateParams(Browser::TYPE_POPUP, profile()))); 125 Browser::CreateParams(Browser::TYPE_POPUP, profile())));
126 NSWindow *cocoaWindow = popup_browser->window()->GetNativeHandle(); 126 NSWindow *cocoaWindow = popup_browser->window()->GetNativeWindow();
127 BrowserWindowController* controller = 127 BrowserWindowController* controller =
128 static_cast<BrowserWindowController*>([cocoaWindow windowController]); 128 static_cast<BrowserWindowController*>([cocoaWindow windowController]);
129 ASSERT_TRUE([controller isKindOfClass:[BrowserWindowController class]]); 129 ASSERT_TRUE([controller isKindOfClass:[BrowserWindowController class]]);
130 EXPECT_FALSE([controller isTabbedWindow]); 130 EXPECT_FALSE([controller isTabbedWindow]);
131 EXPECT_FALSE([controller hasTabStrip]); 131 EXPECT_FALSE([controller hasTabStrip]);
132 EXPECT_TRUE([controller hasTitleBar]); 132 EXPECT_TRUE([controller hasTitleBar]);
133 EXPECT_FALSE([controller isBookmarkBarVisible]); 133 EXPECT_FALSE([controller isBookmarkBarVisible]);
134 [controller close]; 134 [controller close];
135 } 135 }
136 136
137 TEST_F(BrowserWindowControllerTest, TestSetBounds) { 137 TEST_F(BrowserWindowControllerTest, TestSetBounds) {
138 // Create a normal browser with bounds smaller than the minimum. 138 // Create a normal browser with bounds smaller than the minimum.
139 Browser::CreateParams params(Browser::TYPE_TABBED, profile()); 139 Browser::CreateParams params(Browser::TYPE_TABBED, profile());
140 params.initial_bounds = gfx::Rect(0, 0, 50, 50); 140 params.initial_bounds = gfx::Rect(0, 0, 50, 50);
141 Browser* browser = Browser::CreateWithParams(params); 141 Browser* browser = Browser::CreateWithParams(params);
142 NSWindow *cocoaWindow = browser->window()->GetNativeHandle(); 142 NSWindow *cocoaWindow = browser->window()->GetNativeWindow();
143 BrowserWindowController* controller = 143 BrowserWindowController* controller =
144 static_cast<BrowserWindowController*>([cocoaWindow windowController]); 144 static_cast<BrowserWindowController*>([cocoaWindow windowController]);
145 145
146 ASSERT_TRUE([controller isTabbedWindow]); 146 ASSERT_TRUE([controller isTabbedWindow]);
147 BrowserWindow* browser_window = [controller browserWindow]; 147 BrowserWindow* browser_window = [controller browserWindow];
148 EXPECT_EQ(browser_window, browser->window()); 148 EXPECT_EQ(browser_window, browser->window());
149 gfx::Rect bounds = browser_window->GetBounds(); 149 gfx::Rect bounds = browser_window->GetBounds();
150 EXPECT_EQ(400, bounds.width()); 150 EXPECT_EQ(400, bounds.width());
151 EXPECT_EQ(272, bounds.height()); 151 EXPECT_EQ(272, bounds.height());
152 152
153 // Try to set the bounds smaller than the minimum. 153 // Try to set the bounds smaller than the minimum.
154 browser_window->SetBounds(gfx::Rect(0, 0, 50, 50)); 154 browser_window->SetBounds(gfx::Rect(0, 0, 50, 50));
155 bounds = browser_window->GetBounds(); 155 bounds = browser_window->GetBounds();
156 EXPECT_EQ(400, bounds.width()); 156 EXPECT_EQ(400, bounds.width());
157 EXPECT_EQ(272, bounds.height()); 157 EXPECT_EQ(272, bounds.height());
158 158
159 [controller close]; 159 [controller close];
160 } 160 }
161 161
162 TEST_F(BrowserWindowControllerTest, TestSetBoundsPopup) { 162 TEST_F(BrowserWindowControllerTest, TestSetBoundsPopup) {
163 // Create a popup with bounds smaller than the minimum. 163 // Create a popup with bounds smaller than the minimum.
164 Browser::CreateParams params(Browser::TYPE_POPUP, profile()); 164 Browser::CreateParams params(Browser::TYPE_POPUP, profile());
165 params.initial_bounds = gfx::Rect(0, 0, 50, 50); 165 params.initial_bounds = gfx::Rect(0, 0, 50, 50);
166 Browser* browser = Browser::CreateWithParams(params); 166 Browser* browser = Browser::CreateWithParams(params);
167 NSWindow *cocoaWindow = browser->window()->GetNativeHandle(); 167 NSWindow *cocoaWindow = browser->window()->GetNativeWindow();
168 BrowserWindowController* controller = 168 BrowserWindowController* controller =
169 static_cast<BrowserWindowController*>([cocoaWindow windowController]); 169 static_cast<BrowserWindowController*>([cocoaWindow windowController]);
170 170
171 ASSERT_FALSE([controller isTabbedWindow]); 171 ASSERT_FALSE([controller isTabbedWindow]);
172 BrowserWindow* browser_window = [controller browserWindow]; 172 BrowserWindow* browser_window = [controller browserWindow];
173 EXPECT_EQ(browser_window, browser->window()); 173 EXPECT_EQ(browser_window, browser->window());
174 gfx::Rect bounds = browser_window->GetBounds(); 174 gfx::Rect bounds = browser_window->GetBounds();
175 EXPECT_EQ(100, bounds.width()); 175 EXPECT_EQ(100, bounds.width());
176 EXPECT_EQ(122, bounds.height()); 176 EXPECT_EQ(122, bounds.height());
177 177
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 testFullscreenWindow_.reset( 729 testFullscreenWindow_.reset(
730 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) 730 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400)
731 styleMask:NSBorderlessWindowMask 731 styleMask:NSBorderlessWindowMask
732 backing:NSBackingStoreBuffered 732 backing:NSBackingStoreBuffered
733 defer:NO]); 733 defer:NO]);
734 return testFullscreenWindow_.get(); 734 return testFullscreenWindow_.get();
735 } 735 }
736 @end 736 @end
737 737
738 /* TODO(???): test other methods of BrowserWindowController */ 738 /* TODO(???): test other methods of BrowserWindowController */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698