| OLD | NEW |
| 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/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 NSRect tabFrame = [[controller_ tabStripView] frame]; | 236 NSRect tabFrame = [[controller_ tabStripView] frame]; |
| 237 [controller_ installIncognitoBadge]; | 237 [controller_ installIncognitoBadge]; |
| 238 NSRect newTabFrame = [[controller_ tabStripView] frame]; | 238 NSRect newTabFrame = [[controller_ tabStripView] frame]; |
| 239 EXPECT_GT(tabFrame.size.width, newTabFrame.size.width); | 239 EXPECT_GT(tabFrame.size.width, newTabFrame.size.width); |
| 240 | 240 |
| 241 controller_.release(); | 241 controller_.release(); |
| 242 } | 242 } |
| 243 #endif | 243 #endif |
| 244 | 244 |
| 245 namespace { | 245 namespace { |
| 246 |
| 246 // Verifies that the toolbar, infobar, tab content area, and download shelf | 247 // Verifies that the toolbar, infobar, tab content area, and download shelf |
| 247 // completely fill the area under the tabstrip. | 248 // completely fill the area under the tabstrip. |
| 248 void CheckViewPositions(BrowserWindowController* controller) { | 249 void CheckViewPositions(BrowserWindowController* controller) { |
| 249 NSRect contentView = [[[controller window] contentView] bounds]; | 250 NSRect contentView = [[[controller window] contentView] bounds]; |
| 250 NSRect tabstrip = [[controller tabStripView] frame]; | 251 NSRect tabstrip = [[controller tabStripView] frame]; |
| 251 NSRect toolbar = [[controller toolbarView] frame]; | 252 NSRect toolbar = [[controller toolbarView] frame]; |
| 252 NSRect infobar = [[controller infoBarContainerView] frame]; | 253 NSRect infobar = [[controller infoBarContainerView] frame]; |
| 253 NSRect contentArea = [[controller tabContentArea] frame]; | 254 NSRect contentArea = [[controller tabContentArea] frame]; |
| 254 NSRect download = [[[controller downloadShelf] view] frame]; | 255 NSRect download = [[[controller downloadShelf] view] frame]; |
| 255 | 256 |
| 256 EXPECT_EQ(NSMinY(contentView), NSMinY(download)); | 257 EXPECT_EQ(NSMinY(contentView), NSMinY(download)); |
| 257 EXPECT_EQ(NSMaxY(download), NSMinY(contentArea)); | 258 EXPECT_EQ(NSMaxY(download), NSMinY(contentArea)); |
| 258 | 259 EXPECT_EQ(NSMaxY(contentArea), NSMinY(infobar)); |
| 259 CGFloat min_toolbar_height = [[controller toolbarController] | |
| 260 desiredHeightForCompression:1]; | |
| 261 EXPECT_EQ(NSMaxY(contentArea), NSMaxY(toolbar) - min_toolbar_height); | |
| 262 | 260 |
| 263 // Bookmark bar frame is random memory when hidden. | 261 // Bookmark bar frame is random memory when hidden. |
| 264 if ([controller bookmarkBarVisible]) { | 262 if ([controller bookmarkBarVisible]) { |
| 265 NSRect bookmark = [[controller bookmarkView] frame]; | 263 NSRect bookmark = [[controller bookmarkView] frame]; |
| 266 EXPECT_EQ(NSMaxY(infobar), NSMinY(bookmark)); | 264 EXPECT_EQ(NSMaxY(infobar), NSMinY(bookmark)); |
| 267 EXPECT_EQ(NSMaxY(bookmark), NSMinY(toolbar)); | 265 EXPECT_EQ(NSMaxY(bookmark), NSMinY(toolbar)); |
| 268 EXPECT_FALSE([[controller bookmarkView] isHidden]); | 266 EXPECT_FALSE([[controller bookmarkView] isHidden]); |
| 269 } else { | 267 } else { |
| 270 EXPECT_EQ(NSMaxY(infobar), NSMinY(toolbar)); | 268 EXPECT_EQ(NSMaxY(infobar), NSMinY(toolbar)); |
| 271 EXPECT_TRUE([[controller bookmarkView] isHidden]); | 269 EXPECT_TRUE([[controller bookmarkView] isHidden]); |
| 272 } | 270 } |
| 273 | 271 |
| 274 // Toolbar should start immediately under the tabstrip, but the tabstrip is | 272 // Toolbar should start immediately under the tabstrip, but the tabstrip is |
| 275 // not necessarily fixed with respect to the content view. | 273 // not necessarily fixed with respect to the content view. |
| 276 EXPECT_EQ(NSMinY(tabstrip), NSMaxY(toolbar)); | 274 EXPECT_EQ(NSMinY(tabstrip), NSMaxY(toolbar)); |
| 277 } | 275 } |
| 276 |
| 278 } // end namespace | 277 } // end namespace |
| 279 | 278 |
| 280 TEST_F(BrowserWindowControllerTest, TestAdjustWindowHeight) { | 279 TEST_F(BrowserWindowControllerTest, TestAdjustWindowHeight) { |
| 281 NSWindow* window = [controller_ window]; | 280 NSWindow* window = [controller_ window]; |
| 282 NSRect workarea = [[window screen] visibleFrame]; | 281 NSRect workarea = [[window screen] visibleFrame]; |
| 283 | 282 |
| 284 // Place the window well above the bottom of the screen and try to adjust its | 283 // Place the window well above the bottom of the screen and try to adjust its |
| 285 // height. It should change appropriately (and only downwards). Then get it to | 284 // height. It should change appropriately (and only downwards). Then get it to |
| 286 // shrink by the same amount; it should return to its original state. | 285 // shrink by the same amount; it should return to its original state. |
| 287 NSRect initialFrame = NSMakeRect(workarea.origin.x, workarea.origin.y + 100, | 286 NSRect initialFrame = NSMakeRect(workarea.origin.x, workarea.origin.y + 100, |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 testFullscreenWindow_.reset( | 898 testFullscreenWindow_.reset( |
| 900 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) | 899 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) |
| 901 styleMask:NSBorderlessWindowMask | 900 styleMask:NSBorderlessWindowMask |
| 902 backing:NSBackingStoreBuffered | 901 backing:NSBackingStoreBuffered |
| 903 defer:NO]); | 902 defer:NO]); |
| 904 return testFullscreenWindow_.get(); | 903 return testFullscreenWindow_.get(); |
| 905 } | 904 } |
| 906 @end | 905 @end |
| 907 | 906 |
| 908 /* TODO(???): test other methods of BrowserWindowController */ | 907 /* TODO(???): test other methods of BrowserWindowController */ |
| OLD | NEW |