OLD | NEW |
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 #include "base/scoped_nsobject.h" | 5 #include "base/scoped_nsobject.h" |
6 #include "base/scoped_nsautorelease_pool.h" | 6 #include "base/scoped_nsautorelease_pool.h" |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/cocoa/browser_test_helper.h" | 9 #include "chrome/browser/cocoa/browser_test_helper.h" |
10 #include "chrome/browser/cocoa/browser_window_controller.h" | 10 #include "chrome/browser/cocoa/browser_window_controller.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 @implementation BrowserWindowControllerResizePong | 173 @implementation BrowserWindowControllerResizePong |
174 @end | 174 @end |
175 | 175 |
176 // Test to make sure resizing and relaying-out subviews works correctly. | 176 // Test to make sure resizing and relaying-out subviews works correctly. |
177 TEST_F(BrowserWindowControllerTest, TestResizeViews) { | 177 TEST_F(BrowserWindowControllerTest, TestResizeViews) { |
178 TabStripView* tabstrip = [controller_ tabStripView]; | 178 TabStripView* tabstrip = [controller_ tabStripView]; |
179 NSView* contentView = [[tabstrip window] contentView]; | 179 NSView* contentView = [[tabstrip window] contentView]; |
180 NSView* toolbar = [controller_ toolbarView]; | 180 NSView* toolbar = [controller_ toolbarView]; |
181 NSView* infobar = [controller_ infoBarContainerView]; | 181 NSView* infobar = [controller_ infoBarContainerView]; |
| 182 NSView* contentArea = [controller_ tabContentArea]; |
182 | 183 |
183 // We need to muck with the views a bit to put us in a consistent state before | 184 // We need to muck with the views a bit to put us in a consistent state before |
184 // we start resizing. In particular, we need to move the tab strip to be | 185 // we start resizing. In particular, we need to move the tab strip to be |
185 // immediately above the content area, since we layout views to be directly | 186 // immediately above the content area, since we layout views to be directly |
186 // under the tab strip. We also explicitly set the contentView's frame to be | 187 // under the tab strip. We also explicitly set the contentView's frame to be |
187 // 800x600. | 188 // 800x600. |
188 [contentView setFrame:NSMakeRect(0, 0, 800, 600)]; | 189 [contentView setFrame:NSMakeRect(0, 0, 800, 600)]; |
189 NSRect tabstripFrame = [tabstrip frame]; | 190 NSRect tabstripFrame = [tabstrip frame]; |
190 tabstripFrame.origin.y = NSMaxY([contentView frame]); | 191 tabstripFrame.origin.y = NSMaxY([contentView frame]); |
191 [tabstrip setFrame:tabstripFrame]; | 192 [tabstrip setFrame:tabstripFrame]; |
192 | 193 |
193 // Make sure each view is as tall as we expect. | 194 // Make sure each view is as tall as we expect. |
194 ASSERT_EQ(36, NSHeight([toolbar frame])); | 195 ASSERT_EQ(39, NSHeight([toolbar frame])); |
195 ASSERT_EQ(0, NSHeight([infobar frame])); | 196 ASSERT_EQ(0, NSHeight([infobar frame])); |
196 | 197 |
197 | |
198 // TODO(rohitrao):rewrite and reenable | |
199 #if 0 | |
200 NSView* contentArea = [controller_ tabContentArea]; | |
201 | |
202 // Force a layout and check each view's frame. | 198 // Force a layout and check each view's frame. |
203 // contentView should be at 0,0 800x600 | 199 // contentView should be at 0,0 800x600 |
204 // contentArea should be at 0,0 800x561 | 200 // contentArea should be at 0,0 800x561 |
205 // infobar should be at 0,561 800x0 | 201 // infobar should be at 0,561 800x0 |
206 // toolbar should be at 0,561 800x39 | 202 // toolbar should be at 0,561 800x39 |
207 [controller_ layoutSubviews]; | 203 [controller_ layoutSubviews]; |
208 EXPECT_TRUE(NSEqualRects([contentView frame], NSMakeRect(0, 0, 800, 600))); | 204 EXPECT_TRUE(NSEqualRects([contentView frame], NSMakeRect(0, 0, 800, 600))); |
209 EXPECT_TRUE(NSEqualRects([contentArea frame], NSMakeRect(0, 0, 800, 561))); | 205 EXPECT_TRUE(NSEqualRects([contentArea frame], NSMakeRect(0, 0, 800, 561))); |
210 EXPECT_TRUE(NSEqualRects([infobar frame], NSMakeRect(0, 561, 800, 0))); | 206 EXPECT_TRUE(NSEqualRects([infobar frame], NSMakeRect(0, 561, 800, 0))); |
211 EXPECT_TRUE(NSEqualRects([toolbar frame], NSMakeRect(0, 561, 800, 39))); | 207 EXPECT_TRUE(NSEqualRects([toolbar frame], NSMakeRect(0, 561, 800, 39))); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 // contentArea should be at 0,30 800x531 | 248 // contentArea should be at 0,30 800x531 |
253 // infobar should be at 0,561 800x0 | 249 // infobar should be at 0,561 800x0 |
254 // toolbar should be at 0,561 800x39 | 250 // toolbar should be at 0,561 800x39 |
255 [controller_ resizeView:infobar newHeight:0]; | 251 [controller_ resizeView:infobar newHeight:0]; |
256 [controller_ resizeView:toolbar newHeight:39]; | 252 [controller_ resizeView:toolbar newHeight:39]; |
257 EXPECT_TRUE(NSEqualRects([contentView frame], NSMakeRect(0, 0, 800, 600))); | 253 EXPECT_TRUE(NSEqualRects([contentView frame], NSMakeRect(0, 0, 800, 600))); |
258 EXPECT_TRUE(NSEqualRects([download frame], NSMakeRect(0, 0, 800, 30))); | 254 EXPECT_TRUE(NSEqualRects([download frame], NSMakeRect(0, 0, 800, 30))); |
259 EXPECT_TRUE(NSEqualRects([contentArea frame], NSMakeRect(0, 30, 800, 531))); | 255 EXPECT_TRUE(NSEqualRects([contentArea frame], NSMakeRect(0, 30, 800, 531))); |
260 EXPECT_TRUE(NSEqualRects([infobar frame], NSMakeRect(0, 561, 800, 0))); | 256 EXPECT_TRUE(NSEqualRects([infobar frame], NSMakeRect(0, 561, 800, 0))); |
261 EXPECT_TRUE(NSEqualRects([toolbar frame], NSMakeRect(0, 561, 800, 39))); | 257 EXPECT_TRUE(NSEqualRects([toolbar frame], NSMakeRect(0, 561, 800, 39))); |
262 #endif | |
263 } | 258 } |
264 | 259 |
265 TEST_F(BrowserWindowControllerTest, TestTopLeftForBubble) { | 260 TEST_F(BrowserWindowControllerTest, TestTopLeftForBubble) { |
266 NSPoint p = [controller_ topLeftForBubble]; | 261 NSPoint p = [controller_ topLeftForBubble]; |
267 NSRect all = [[controller_ window] frame]; | 262 NSRect all = [[controller_ window] frame]; |
268 | 263 |
269 // As a sanity check make sure the point is vaguely in the top left | 264 // As a sanity check make sure the point is vaguely in the top left |
270 // of the window. | 265 // of the window. |
271 EXPECT_GT(p.y, all.origin.y + (all.size.height/2)); | 266 EXPECT_GT(p.y, all.origin.y + (all.size.height/2)); |
272 EXPECT_LT(p.x, all.origin.x + (all.size.width/2)); | 267 EXPECT_LT(p.x, all.origin.x + (all.size.width/2)); |
273 } | 268 } |
274 | 269 |
275 | 270 |
276 /* TODO(???): test other methods of BrowserWindowController */ | 271 /* TODO(???): test other methods of BrowserWindowController */ |
OLD | NEW |