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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_unittest.mm

Issue 2742813003: [Mac] Lay out the browser window when adding the download shelf. (Closed)
Patch Set: Put a stray word away. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 Browser::CreateParams params(Browser::TYPE_TABBED, profile(), true); 144 Browser::CreateParams params(Browser::TYPE_TABBED, profile(), true);
145 params.initial_bounds = gfx::Rect(0, 0, 50, 50); 145 params.initial_bounds = gfx::Rect(0, 0, 50, 50);
146 Browser* browser = new Browser(params); 146 Browser* browser = new Browser(params);
147 NSWindow* cocoaWindow = browser->window()->GetNativeWindow(); 147 NSWindow* cocoaWindow = browser->window()->GetNativeWindow();
148 BrowserWindowController* controller = 148 BrowserWindowController* controller =
149 static_cast<BrowserWindowController*>([cocoaWindow windowController]); 149 static_cast<BrowserWindowController*>([cocoaWindow windowController]);
150 150
151 ASSERT_TRUE([controller isTabbedWindow]); 151 ASSERT_TRUE([controller isTabbedWindow]);
152 BrowserWindow* browser_window = [controller browserWindow]; 152 BrowserWindow* browser_window = [controller browserWindow];
153 EXPECT_EQ(browser_window, browser->window()); 153 EXPECT_EQ(browser_window, browser->window());
154 gfx::Rect bounds = browser_window->GetBounds(); 154 EXPECT_EQ(browser_window->GetBounds().size(), kMinCocoaTabbedWindowSize);
155 EXPECT_EQ(400, bounds.width());
156 EXPECT_EQ(272, bounds.height());
157 155
158 // Try to set the bounds smaller than the minimum. 156 // Try to set the bounds smaller than the minimum.
159 browser_window->SetBounds(gfx::Rect(0, 0, 50, 50)); 157 browser_window->SetBounds(gfx::Rect(0, 0, 50, 50));
160 bounds = browser_window->GetBounds(); 158 EXPECT_EQ(browser_window->GetBounds().size(), kMinCocoaTabbedWindowSize);
161 EXPECT_EQ(400, bounds.width());
162 EXPECT_EQ(272, bounds.height());
163 159
164 [controller close]; 160 [controller close];
165 } 161 }
166 162
163 // https://crbug.com/667698 - When Auto Layout is in use, adding the download
164 // shelf without ever showing it shouldn't prevent the window from being
165 // resized to its minimum width.
166 TEST_F(BrowserWindowControllerTest, TestSetBoundsWithDownloadShelf) {
167 BrowserWindow* browser_window = [controller_ browserWindow];
168 browser_window->SetBounds(gfx::Rect(0, 0, 1000, 50));
169
170 // Auto Layout only acts on the window if it's visible.
171 browser_window->ShowInactive();
172
173 // The browser window should lazily create the download shelf when requested.
174 EXPECT_NE(nullptr, browser_window->GetDownloadShelf());
175
176 // The controller should now have a download shelf, which should have a view.
177 EXPECT_NE(nil, [[controller_ downloadShelf] view]);
178
179 // But, just requesting the download shelf shouldn't make it visible.
180 EXPECT_FALSE([controller_ isDownloadShelfVisible]);
181
182 browser_window->SetBounds(gfx::Rect(0, 0, 50, 50));
183
184 // When linking against an SDK >= 10.11, AppKit may lay out the window
185 // asynchronously (CFExecutableLinkedOnOrAfter check in -[NSThemeFrame
186 // handleSetFrameCommonRedisplay]). Do layout now instead.
187 [[controller_ window] layoutIfNeeded];
188
189 // The window should have returned to its minimum size.
190 EXPECT_EQ(browser_window->GetBounds().size(), kMinCocoaTabbedWindowSize);
191
192 browser_window->Close();
193 }
194
167 TEST_F(BrowserWindowControllerTest, TestSetBoundsPopup) { 195 TEST_F(BrowserWindowControllerTest, TestSetBoundsPopup) {
168 // Create a popup with bounds smaller than the minimum. 196 // Create a popup with bounds smaller than the minimum.
169 Browser::CreateParams params(Browser::TYPE_POPUP, profile(), true); 197 Browser::CreateParams params(Browser::TYPE_POPUP, profile(), true);
170 params.initial_bounds = gfx::Rect(0, 0, 50, 50); 198 params.initial_bounds = gfx::Rect(0, 0, 50, 50);
171 Browser* browser = new Browser(params); 199 Browser* browser = new Browser(params);
172 NSWindow* cocoaWindow = browser->window()->GetNativeWindow(); 200 NSWindow* cocoaWindow = browser->window()->GetNativeWindow();
173 BrowserWindowController* controller = 201 BrowserWindowController* controller =
174 static_cast<BrowserWindowController*>([cocoaWindow windowController]); 202 static_cast<BrowserWindowController*>([cocoaWindow windowController]);
175 203
176 ASSERT_FALSE([controller isTabbedWindow]); 204 ASSERT_FALSE([controller isTabbedWindow]);
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) 844 [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400)
817 styleMask:NSBorderlessWindowMask 845 styleMask:NSBorderlessWindowMask
818 backing:NSBackingStoreBuffered 846 backing:NSBackingStoreBuffered
819 defer:NO]); 847 defer:NO]);
820 [[testFullscreenWindow_ contentView] setWantsLayer:YES]; 848 [[testFullscreenWindow_ contentView] setWantsLayer:YES];
821 return testFullscreenWindow_.get(); 849 return testFullscreenWindow_.get();
822 } 850 }
823 @end 851 @end
824 852
825 /* TODO(???): test other methods of BrowserWindowController */ 853 /* TODO(???): test other methods of BrowserWindowController */
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698