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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller_unittest.mm

Issue 1052123006: Prevent bookmarks bar toggling from decreasing window height to 0. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
index e1a1cbf6be7de337b73a268f33f4f38f2ade326e..e9c923fae61969639b34c0c0ed91232c71931a92 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
@@ -203,6 +203,28 @@ TEST_F(BrowserWindowControllerTest, BookmarkBarControllerIndirection) {
EXPECT_TRUE([controller_ isBookmarkBarVisible]);
}
+TEST_F(BrowserWindowControllerTest, BookmarkBarToggleRespectMinWindowHeight) {
+ Browser::CreateParams params(Browser::TYPE_TABBED, profile(),
+ chrome::GetActiveDesktop());
+ params.initial_bounds = gfx::Rect(0, 0, 50, 280);
+ Browser* browser = new Browser(params);
+ NSWindow *cocoaWindow = browser->window()->GetNativeWindow();
Avi (use Gerrit) 2015/04/15 04:27:26 space after * (yeah, fix it elsewhere in the file
shrike 2015/04/15 17:01:33 Sorry about that. Fixed it in other spots too.
+ BrowserWindowController* controller =
+ static_cast<BrowserWindowController*>([cocoaWindow windowController]);
+ BrowserWindow* browser_window = [controller browserWindow];
+ gfx::Rect bounds = browser_window->GetBounds();
+ EXPECT_EQ(280, bounds.height());
+
+ // Try to set the bounds smaller than the minimum.
+ // Explicitly show the bar. Can't use chrome::ToggleBookmarkBarWhenVisible()
+ // because of the notification issues.
+ [controller adjustWindowHeightBy:-20];
+ bounds = browser_window->GetBounds();
+ EXPECT_EQ(272, bounds.height());
+
+ [controller close];
+}
+
#if 0
// TODO(jrg): This crashes trying to create the BookmarkBarController, adding
// an observer to the BookmarkModel.
@@ -311,7 +333,7 @@ TEST_F(BrowserWindowControllerTest, TestAdjustWindowHeight) {
// height. It should change appropriately (and only downwards). Then get it to
// shrink by the same amount; it should return to its original state.
NSRect initialFrame = NSMakeRect(workarea.origin.x, workarea.origin.y + 100,
- 200, 200);
+ 200, 280);
[window setFrame:initialFrame display:YES];
[controller_ resetWindowGrowthState];
[controller_ adjustWindowHeightBy:40];
@@ -328,7 +350,7 @@ TEST_F(BrowserWindowControllerTest, TestAdjustWindowHeight) {
// should still change, but it should not grow down below the work area; it
// should instead move upwards. Then shrink it and make sure it goes back to
// the way it was.
- initialFrame = NSMakeRect(workarea.origin.x, workarea.origin.y, 200, 200);
+ initialFrame = NSMakeRect(workarea.origin.x, workarea.origin.y, 200, 280);
[window setFrame:initialFrame display:YES];
[controller_ resetWindowGrowthState];
[controller_ adjustWindowHeightBy:40];
@@ -343,7 +365,7 @@ TEST_F(BrowserWindowControllerTest, TestAdjustWindowHeight) {
// Put the window slightly offscreen and try again. The height should not
// change this time.
- initialFrame = NSMakeRect(workarea.origin.x - 10, 0, 200, 200);
+ initialFrame = NSMakeRect(workarea.origin.x - 10, 0, 200, 280);
[window setFrame:initialFrame display:YES];
[controller_ resetWindowGrowthState];
[controller_ adjustWindowHeightBy:40];
@@ -365,7 +387,7 @@ TEST_F(BrowserWindowControllerTest, TestAdjustWindowHeight) {
// then continue to grow up. Then shrink it, and it should return to where it
// was.
initialFrame = NSMakeRect(workarea.origin.x, workarea.origin.y + 5,
- 200, 200);
+ 200, 280);
[window setFrame:initialFrame display:YES];
[controller_ resetWindowGrowthState];
[controller_ adjustWindowHeightBy:40];
@@ -394,7 +416,7 @@ TEST_F(BrowserWindowControllerTest, TestAdjustWindowHeight) {
// Place the window at the bottom of the screen and grow; it should grow
// upwards. Move the window off the bottom, then shrink. It should then shrink
// from the bottom.
- initialFrame = NSMakeRect(workarea.origin.x, workarea.origin.y, 200, 200);
+ initialFrame = NSMakeRect(workarea.origin.x, workarea.origin.y, 200, 280);
[window setFrame:initialFrame display:YES];
[controller_ resetWindowGrowthState];
[controller_ adjustWindowHeightBy:40];

Powered by Google App Engine
This is Rietveld 408576698