Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 | 157 |
| 158 // Try to set the bounds smaller than the minimum. | 158 // Try to set the bounds smaller than the minimum. |
| 159 browser_window->SetBounds(gfx::Rect(0, 0, 50, 50)); | 159 browser_window->SetBounds(gfx::Rect(0, 0, 50, 50)); |
| 160 bounds = browser_window->GetBounds(); | 160 bounds = browser_window->GetBounds(); |
| 161 EXPECT_EQ(400, bounds.width()); | 161 EXPECT_EQ(400, bounds.width()); |
| 162 EXPECT_EQ(272, bounds.height()); | 162 EXPECT_EQ(272, bounds.height()); |
| 163 | 163 |
| 164 [controller close]; | 164 [controller close]; |
| 165 } | 165 } |
| 166 | 166 |
| 167 // https://crbug.com/667698 - When Auto Layout is in use, adding the download | |
| 168 // shelf without ever showing it shouldn't prevent the window from being | |
| 169 // resized to its minimum width. | |
| 170 TEST_F(BrowserWindowControllerTest, TestSetBoundsWithDownloadsShelf) { | |
| 171 Browser::CreateParams params(Browser::TYPE_TABBED, profile(), true); | |
| 172 params.initial_bounds = gfx::Rect(0, 0, 1000, 50); | |
| 173 Browser* browser = new Browser(params); | |
| 174 BrowserWindow* browser_window = browser->window(); | |
| 175 browser_window->ShowInactive(); | |
| 176 NSWindow* cocoaWindow = browser_window->GetNativeWindow(); | |
|
tapted
2017/03/10 07:22:28
nit: cocoa_window
(I realise other TEST_F use coc
Sidney San Martín
2017/03/10 22:23:41
See below.
| |
| 177 BrowserWindowController* controller = | |
| 178 static_cast<BrowserWindowController*>([cocoaWindow windowController]); | |
| 179 | |
| 180 [controller createAndAddDownloadShelf]; | |
|
tapted
2017/03/10 07:22:28
or perhaps a better alternative, you could just
E
Sidney San Martín
2017/03/10 22:23:42
That's much nicer, thanks!
| |
| 181 | |
| 182 browser_window->SetBounds(gfx::Rect(0, 0, 50, 50)); | |
|
tapted
2017/03/10 07:22:28
Is this subject to autolayout constraints?
If it
Sidney San Martín
2017/03/10 22:23:42
[NSWindow setFrame:] marks the window as needing l
| |
| 183 gfx::Rect bounds = browser_window->GetBounds(); | |
| 184 EXPECT_EQ(400, bounds.width()); | |
| 185 EXPECT_EQ(272, bounds.height()); | |
|
tapted
2017/03/10 07:22:28
400 / 272 are magic numbers. At the very least the
Sidney San Martín
2017/03/10 22:23:41
I was following the surrounding tests here, but th
| |
| 186 | |
| 187 [controller close]; | |
| 188 } | |
| 189 | |
| 167 TEST_F(BrowserWindowControllerTest, TestSetBoundsPopup) { | 190 TEST_F(BrowserWindowControllerTest, TestSetBoundsPopup) { |
| 168 // Create a popup with bounds smaller than the minimum. | 191 // Create a popup with bounds smaller than the minimum. |
| 169 Browser::CreateParams params(Browser::TYPE_POPUP, profile(), true); | 192 Browser::CreateParams params(Browser::TYPE_POPUP, profile(), true); |
| 170 params.initial_bounds = gfx::Rect(0, 0, 50, 50); | 193 params.initial_bounds = gfx::Rect(0, 0, 50, 50); |
| 171 Browser* browser = new Browser(params); | 194 Browser* browser = new Browser(params); |
| 172 NSWindow* cocoaWindow = browser->window()->GetNativeWindow(); | 195 NSWindow* cocoaWindow = browser->window()->GetNativeWindow(); |
| 173 BrowserWindowController* controller = | 196 BrowserWindowController* controller = |
| 174 static_cast<BrowserWindowController*>([cocoaWindow windowController]); | 197 static_cast<BrowserWindowController*>([cocoaWindow windowController]); |
| 175 | 198 |
| 176 ASSERT_FALSE([controller isTabbedWindow]); | 199 ASSERT_FALSE([controller isTabbedWindow]); |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) | 839 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) |
| 817 styleMask:NSBorderlessWindowMask | 840 styleMask:NSBorderlessWindowMask |
| 818 backing:NSBackingStoreBuffered | 841 backing:NSBackingStoreBuffered |
| 819 defer:NO]); | 842 defer:NO]); |
| 820 [[testFullscreenWindow_ contentView] setWantsLayer:YES]; | 843 [[testFullscreenWindow_ contentView] setWantsLayer:YES]; |
| 821 return testFullscreenWindow_.get(); | 844 return testFullscreenWindow_.get(); |
| 822 } | 845 } |
| 823 @end | 846 @end |
| 824 | 847 |
| 825 /* TODO(???): test other methods of BrowserWindowController */ | 848 /* TODO(???): test other methods of BrowserWindowController */ |
| OLD | NEW |