Chromium Code Reviews| 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 b99bc4776b91e7cd8aa3e1728c937b3a302c5118..a1dd480bcb550cc37fe61d16c24a7f688b205b97 100644 |
| --- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm |
| +++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm |
| @@ -29,6 +29,11 @@ |
| #import "third_party/ocmock/OCMock/OCMock.h" |
| #import "ui/base/test/scoped_fake_nswindow_fullscreen.h" |
| +namespace { |
| +const gfx::Size kMinTabbedWindowSize( |
|
tapted
2017/03/13 00:25:36
I'm pretty sure this will add a static initializer
Sidney San Martín
2017/03/14 23:28:39
Hmm, I came very close to making MinWindowSizeForB
|
| + MinWindowSizeForBrowserType(Browser::TYPE_TABBED)); |
| +} // namespace |
| + |
| using ::testing::Return; |
| @interface BrowserWindowController (JustForTesting) |
| @@ -151,19 +156,40 @@ TEST_F(BrowserWindowControllerTest, TestSetBounds) { |
| ASSERT_TRUE([controller isTabbedWindow]); |
| BrowserWindow* browser_window = [controller browserWindow]; |
| EXPECT_EQ(browser_window, browser->window()); |
| - gfx::Rect bounds = browser_window->GetBounds(); |
| - EXPECT_EQ(400, bounds.width()); |
| - EXPECT_EQ(272, bounds.height()); |
| + EXPECT_EQ(browser_window->GetBounds().size(), kMinTabbedWindowSize); |
| // Try to set the bounds smaller than the minimum. |
| browser_window->SetBounds(gfx::Rect(0, 0, 50, 50)); |
| - bounds = browser_window->GetBounds(); |
| - EXPECT_EQ(400, bounds.width()); |
| - EXPECT_EQ(272, bounds.height()); |
| + EXPECT_EQ(browser_window->GetBounds().size(), kMinTabbedWindowSize); |
| [controller close]; |
| } |
| +// https://crbug.com/667698 - When Auto Layout is in use, adding the download |
| +// shelf without ever showing it shouldn't prevent the window from being |
| +// resized to its minimum width. |
| +TEST_F(BrowserWindowControllerTest, TestSetBoundsWithDownloadShelf) { |
| + Browser::CreateParams params(Browser::TYPE_TABBED, profile(), true); |
| + params.initial_bounds = gfx::Rect(0, 0, 1000, 50); |
| + Browser* browser = new Browser(params); |
| + BrowserWindow* browser_window = browser->window(); |
| + browser_window->ShowInactive(); |
| + |
| + EXPECT_TRUE(browser_window->GetDownloadShelf()); |
|
tapted
2017/03/13 00:25:36
nit: comment here. Something like
// Requesting t
Sidney San Martín
2017/03/14 23:28:39
Done.
tapted
2017/03/15 00:49:51
My main thought is that testing layout regressions
Sidney San Martín
2017/03/15 03:13:39
Aw, thanks tapted@.
|
| + EXPECT_FALSE(browser_window->IsDownloadShelfVisible()); |
| + |
| + browser_window->SetBounds(gfx::Rect(0, 0, 50, 50)); |
| + |
| + // When linking against an SDK >= 10.11, AppKit may lay out the window |
| + // asynchronously (CFExecutableLinkedOnOrAfter check in -[NSThemeFrame |
| + // handleSetFrameCommonRedisplay]). Do layout now instead. |
| + [browser_window->GetNativeWindow() layoutIfNeeded]; |
| + |
| + EXPECT_EQ(browser_window->GetBounds().size(), kMinTabbedWindowSize); |
| + |
| + browser_window->Close(); |
| +} |
| + |
| TEST_F(BrowserWindowControllerTest, TestSetBoundsPopup) { |
| // Create a popup with bounds smaller than the minimum. |
| Browser::CreateParams params(Browser::TYPE_POPUP, profile(), true); |