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

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

Issue 2738623002: [Mac] Turn on Auto Layout for browser windows. (Closed)
Patch Set: Add a test. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/chrome_browser_window_unittest.mm
diff --git a/chrome/browser/ui/cocoa/chrome_browser_window_unittest.mm b/chrome/browser/ui/cocoa/chrome_browser_window_unittest.mm
index 6f13830e02876cd8302338c94a833f395c2e38dc..3a61a7714d2a8c224ee32e1d6c669bd5bf01df52 100644
--- a/chrome/browser/ui/cocoa/chrome_browser_window_unittest.mm
+++ b/chrome/browser/ui/cocoa/chrome_browser_window_unittest.mm
@@ -20,10 +20,11 @@ class ChromeBrowserWindowTest : public CocoaTest {
const NSUInteger mask = NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask;
window_ = [[ChromeBrowserWindow alloc]
- initWithContentRect:NSMakeRect(0, 0, 800, 600)
- styleMask:mask
- backing:NSBackingStoreBuffered
- defer:NO];
+ initWithContentRect:NSMakeRect(0, 0, 800, 600)
+ styleMask:mask
+ backing:NSBackingStoreBuffered
+ defer:NO
+ wantsViewsOverTitlebar:YES];
tapted 2017/03/21 02:16:51 Is this needed? It suggests that passing `NO` will
Sidney San Martín 2017/03/22 21:40:22 Where we force Auto Layout is somewhat arbitrary.
if (base::debug::BeingDebugged()) {
[window_ orderFront:nil];
} else {
@@ -45,3 +46,16 @@ TEST_F(ChromeBrowserWindowTest, ShowAndClose) {
[window_ display];
}
+// Verify that browser windows use Auto Layout. Since frame-based layout and
tapted 2017/03/21 02:16:51 This is super nit-picky, but I'm not sure if this
Sidney San Martín 2017/03/22 21:40:22 Heh, great point :). Re-wording the comment like t
+// Auto Layout behave differently in subtle ways, we shouldn't start/stop using
+// it accidentally. If we don't want Auto Layout, this test should be changed
+// to expect constraints.count == 0, not disabled.
+TEST_F(ChromeBrowserWindowTest, UsesAutoLayout) {
+ base::scoped_nsobject<NSView> view(
tapted 2017/03/21 02:16:51 Comment why the extra subview is necessary for the
Sidney San Martín 2017/03/22 21:40:22 Gone.
+ [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 10, 10)]);
+ [view setAutoresizingMask:NSViewWidthSizable];
+ [window_.contentView addSubview:view];
tapted 2017/03/21 02:16:51 nit: [[window contentView] addSubview: view]
Sidney San Martín 2017/03/22 21:40:22 Gone.
+ [window_ orderFront:nil];
+ [window_ layoutIfNeeded];
+ EXPECT_TRUE([[[window_ contentView] constraints] count] > 0);
tapted 2017/03/21 02:16:50 nit: EXPECT_LT(0u, [[[window_ contentView] constr
Sidney San Martín 2017/03/22 21:40:21 Oof, `EXPECT_LT(0u, count)` seems harder to unders
tapted 2017/03/22 22:40:00 looks good!
+}

Powered by Google App Engine
This is Rietveld 408576698