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

Side by Side Diff: chrome/browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm

Issue 1023083002: [MacViews] Implement size constraints for app windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // This file tests whichever implementation of NativeAppWindow is used. 5 // This file tests whichever implementation of NativeAppWindow is used.
6 // I.e. it could be NativeAppWindowCocoa or ChromeNativeAppWindowViewsMac. 6 // I.e. it could be NativeAppWindowCocoa or ChromeNativeAppWindowViewsMac.
7 #include "extensions/browser/app_window/native_app_window.h" 7 #include "extensions/browser/app_window/native_app_window.h"
8 8
9 #import <Cocoa/Cocoa.h> 9 #import <Cocoa/Cocoa.h>
10 10
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 // Since the window has no constraints, it should have all of the following 234 // Since the window has no constraints, it should have all of the following
235 // style mask bits. 235 // style mask bits.
236 NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | 236 NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask |
237 NSMiniaturizableWindowMask | NSResizableWindowMask | 237 NSMiniaturizableWindowMask | NSResizableWindowMask |
238 NSTexturedBackgroundWindowMask; 238 NSTexturedBackgroundWindowMask;
239 EXPECT_EQ(style_mask, [ns_window styleMask]); 239 EXPECT_EQ(style_mask, [ns_window styleMask]);
240 240
241 CloseAppWindow(app_window); 241 CloseAppWindow(app_window);
242 } 242 }
243
244 namespace {
245
246 // Test that resize and fullscreen controls are correctly enabled/disabled.
247 void TestControls(extensions::AppWindow* app_window) {
248 NSWindow* ns_window = app_window->GetNativeWindow();
249
250 // The window is resizable.
251 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask);
252 if (base::mac::IsOSSnowLeopard())
253 EXPECT_TRUE([ns_window showsResizeIndicator]);
254
255 // The window can fullscreen and maximize.
256 if (base::mac::IsOSLionOrLater())
257 EXPECT_TRUE([ns_window collectionBehavior] &
258 NSWindowCollectionBehaviorFullScreenPrimary);
259 EXPECT_TRUE([[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]);
260
261 // Set a maximum size.
262 app_window->SetContentSizeConstraints(gfx::Size(), gfx::Size(200, 201));
263 EXPECT_EQ(200, [ns_window contentMaxSize].width);
264 EXPECT_EQ(201, [ns_window contentMaxSize].height);
265 NSView* web_contents = app_window->web_contents()->GetNativeView();
266 EXPECT_EQ(200, [web_contents frame].size.width);
267 EXPECT_EQ(201, [web_contents frame].size.height);
268
269 // Still resizable.
270 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask);
271 if (base::mac::IsOSSnowLeopard())
272 EXPECT_TRUE([ns_window showsResizeIndicator]);
273
274 // Fullscreen and maximize are disabled.
275 if (base::mac::IsOSLionOrLater())
276 EXPECT_FALSE([ns_window collectionBehavior] &
277 NSWindowCollectionBehaviorFullScreenPrimary);
278 EXPECT_FALSE([[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]);
279
280 // Set a minimum size equal to the maximum size.
281 app_window->SetContentSizeConstraints(gfx::Size(200, 201),
282 gfx::Size(200, 201));
283 EXPECT_EQ(200, [ns_window contentMinSize].width);
284 EXPECT_EQ(201, [ns_window contentMinSize].height);
285
286 // No longer resizable.
287 EXPECT_FALSE([ns_window styleMask] & NSResizableWindowMask);
288 if (base::mac::IsOSSnowLeopard())
289 EXPECT_FALSE([ns_window showsResizeIndicator]);
290 }
291
292 } // namespace
293
294 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, Controls) {
295 TestControls(CreateTestAppWindow("{}"));
296 }
297
298 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, ControlsFrameless) {
299 TestControls(CreateTestAppWindow("{\"frame\": \"none\"}"));
300 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698