OLD | NEW |
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 Loading... |
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 // Test that resize and fullscreen controls are correctly enabled/disabled. |
| 245 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, Controls) { |
| 246 extensions::AppWindow* app_window = CreateTestAppWindow("{}"); |
| 247 NSWindow* ns_window = app_window->GetNativeWindow(); |
| 248 |
| 249 // The window is resizable. |
| 250 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask); |
| 251 if (base::mac::IsOSSnowLeopard()) |
| 252 EXPECT_TRUE([ns_window showsResizeIndicator]); |
| 253 |
| 254 // The window can fullscreen and maximize. |
| 255 if (base::mac::IsOSLionOrLater()) |
| 256 EXPECT_TRUE([ns_window collectionBehavior] & |
| 257 NSWindowCollectionBehaviorFullScreenPrimary); |
| 258 EXPECT_TRUE([[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]); |
| 259 |
| 260 // Set a maximum size. |
| 261 app_window->SetContentSizeConstraints(gfx::Size(), gfx::Size(200, 201)); |
| 262 EXPECT_EQ(200, [ns_window frame].size.width); |
| 263 EXPECT_EQ(201, [ns_window frame].size.height); |
| 264 EXPECT_EQ(200, [ns_window contentMaxSize].width); |
| 265 EXPECT_EQ(201, [ns_window contentMaxSize].height); |
| 266 |
| 267 // Still resizable. |
| 268 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask); |
| 269 if (base::mac::IsOSSnowLeopard()) |
| 270 EXPECT_TRUE([ns_window showsResizeIndicator]); |
| 271 |
| 272 // Fullscreen and maximize are disabled. |
| 273 if (base::mac::IsOSLionOrLater()) |
| 274 EXPECT_FALSE([ns_window collectionBehavior] & |
| 275 NSWindowCollectionBehaviorFullScreenPrimary); |
| 276 EXPECT_FALSE([[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]); |
| 277 |
| 278 // Set a minimum size equal to the maximum size. |
| 279 app_window->SetContentSizeConstraints(gfx::Size(200, 201), |
| 280 gfx::Size(200, 201)); |
| 281 EXPECT_EQ(200, [ns_window contentMinSize].width); |
| 282 EXPECT_EQ(201, [ns_window contentMinSize].height); |
| 283 |
| 284 // No longer resizable. |
| 285 EXPECT_FALSE([ns_window styleMask] & NSResizableWindowMask); |
| 286 if (base::mac::IsOSSnowLeopard()) |
| 287 EXPECT_FALSE([ns_window showsResizeIndicator]); |
| 288 } |
OLD | NEW |