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

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

Issue 1849343003: mac: Remove IsOSSnowLeopard(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 #include "extensions/browser/app_window/native_app_window.h" 5 #include "extensions/browser/app_window/native_app_window.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #import "base/mac/foundation_util.h" 9 #import "base/mac/foundation_util.h"
10 #import "base/mac/mac_util.h" 10 #import "base/mac/mac_util.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 EXPECT_TRUE([ns_window isMiniaturized]); 305 EXPECT_TRUE([ns_window isMiniaturized]);
306 306
307 [ns_window deminiaturize:nil]; 307 [ns_window deminiaturize:nil];
308 EXPECT_NSEQ(initial_frame, [ns_window frame]); 308 EXPECT_NSEQ(initial_frame, [ns_window frame]);
309 EXPECT_FALSE(window->IsMinimized()); 309 EXPECT_FALSE(window->IsMinimized());
310 EXPECT_FALSE([ns_window isMiniaturized]); 310 EXPECT_FALSE([ns_window isMiniaturized]);
311 } 311 }
312 312
313 // Test Maximize, Restore combinations with their native equivalents. 313 // Test Maximize, Restore combinations with their native equivalents.
314 IN_PROC_BROWSER_TEST_P(NativeAppWindowCocoaBrowserTest, Maximize) { 314 IN_PROC_BROWSER_TEST_P(NativeAppWindowCocoaBrowserTest, Maximize) {
315 // This test is flaky on 10.6. Disable it until we're sure we need MacViews on
316 // 10.6. See http://crbug.com/503208
317 if (GetParam() && base::mac::IsOSSnowLeopard())
318 return;
319
320 SetUpAppWithWindows(1); 315 SetUpAppWithWindows(1);
321 AppWindow* app_window = GetFirstAppWindow(); 316 AppWindow* app_window = GetFirstAppWindow();
322 extensions::NativeAppWindow* window = app_window->GetBaseWindow(); 317 extensions::NativeAppWindow* window = app_window->GetBaseWindow();
323 NSWindow* ns_window = app_window->GetNativeWindow(); 318 NSWindow* ns_window = app_window->GetNativeWindow();
324 base::scoped_nsobject<WindowedNSNotificationObserver> watcher; 319 base::scoped_nsobject<WindowedNSNotificationObserver> watcher;
325 320
326 gfx::Rect initial_restored_bounds = window->GetRestoredBounds(); 321 gfx::Rect initial_restored_bounds = window->GetRestoredBounds();
327 NSRect initial_frame = [ns_window frame]; 322 NSRect initial_frame = [ns_window frame];
328 NSRect maximized_frame = [[ns_window screen] visibleFrame]; 323 NSRect maximized_frame = [[ns_window screen] visibleFrame];
329 324
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 app_window->Maximize(); 445 app_window->Maximize();
451 EXPECT_TRUE([ns_window isVisible]); 446 EXPECT_TRUE([ns_window isVisible]);
452 EXPECT_NSEQ(maximized_frame, [ns_window frame]); 447 EXPECT_NSEQ(maximized_frame, [ns_window frame]);
453 EXPECT_TRUE(window->IsMaximized()); 448 EXPECT_TRUE(window->IsMaximized());
454 EXPECT_FALSE(window->IsMinimized()); 449 EXPECT_FALSE(window->IsMinimized());
455 EXPECT_FALSE([ns_window isMiniaturized]); 450 EXPECT_FALSE([ns_window isMiniaturized]);
456 } 451 }
457 452
458 // Test Maximize, Fullscreen, Restore combinations. 453 // Test Maximize, Fullscreen, Restore combinations.
459 IN_PROC_BROWSER_TEST_P(NativeAppWindowCocoaBrowserTest, MaximizeFullscreen) { 454 IN_PROC_BROWSER_TEST_P(NativeAppWindowCocoaBrowserTest, MaximizeFullscreen) {
460 if (base::mac::IsOSSnowLeopard())
461 return;
462
463 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; 455 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen;
464 456
465 SetUpAppWithWindows(1); 457 SetUpAppWithWindows(1);
466 AppWindow* app_window = GetFirstAppWindow(); 458 AppWindow* app_window = GetFirstAppWindow();
467 extensions::NativeAppWindow* window = app_window->GetBaseWindow(); 459 extensions::NativeAppWindow* window = app_window->GetBaseWindow();
468 NSWindow* ns_window = app_window->GetNativeWindow(); 460 NSWindow* ns_window = app_window->GetNativeWindow();
469 base::scoped_nsobject<WindowedNSNotificationObserver> watcher; 461 base::scoped_nsobject<WindowedNSNotificationObserver> watcher;
470 base::scoped_nsobject<NSWindowFullscreenNotificationWaiter> waiter( 462 base::scoped_nsobject<NSWindowFullscreenNotificationWaiter> waiter(
471 [[NSWindowFullscreenNotificationWaiter alloc] initWithWindow:ns_window]); 463 [[NSWindowFullscreenNotificationWaiter alloc] initWithWindow:ns_window]);
472 464
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 } 537 }
546 538
547 namespace { 539 namespace {
548 540
549 // Test that resize and fullscreen controls are correctly enabled/disabled. 541 // Test that resize and fullscreen controls are correctly enabled/disabled.
550 void TestControls(AppWindow* app_window) { 542 void TestControls(AppWindow* app_window) {
551 NSWindow* ns_window = app_window->GetNativeWindow(); 543 NSWindow* ns_window = app_window->GetNativeWindow();
552 544
553 // The window is resizable. 545 // The window is resizable.
554 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask); 546 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask);
555 if (base::mac::IsOSSnowLeopard())
556 EXPECT_TRUE([ns_window showsResizeIndicator]);
557 547
558 // Due to this bug: http://crbug.com/362039, which manifests on the Cocoa 548 // Due to this bug: http://crbug.com/362039, which manifests on the Cocoa
559 // implementation but not the views one, frameless windows should have 549 // implementation but not the views one, frameless windows should have
560 // fullscreen controls disabled. 550 // fullscreen controls disabled.
561 BOOL can_fullscreen = 551 BOOL can_fullscreen =
562 ![NSStringFromClass([ns_window class]) isEqualTo:@"AppFramelessNSWindow"]; 552 ![NSStringFromClass([ns_window class]) isEqualTo:@"AppFramelessNSWindow"];
563 // The window can fullscreen and maximize. 553 // The window can fullscreen and maximize.
564 if (base::mac::IsOSLionOrLater()) { 554 if (base::mac::IsOSLionOrLater()) {
565 EXPECT_EQ(can_fullscreen, !!([ns_window collectionBehavior] & 555 EXPECT_EQ(can_fullscreen, !!([ns_window collectionBehavior] &
566 NSWindowCollectionBehaviorFullScreenPrimary)); 556 NSWindowCollectionBehaviorFullScreenPrimary));
(...skipping 11 matching lines...) Expand all
578 // Set a maximum size. 568 // Set a maximum size.
579 app_window->SetContentSizeConstraints(gfx::Size(), gfx::Size(200, 201)); 569 app_window->SetContentSizeConstraints(gfx::Size(), gfx::Size(200, 201));
580 EXPECT_EQ(200, [ns_window contentMaxSize].width); 570 EXPECT_EQ(200, [ns_window contentMaxSize].width);
581 EXPECT_EQ(201, [ns_window contentMaxSize].height); 571 EXPECT_EQ(201, [ns_window contentMaxSize].height);
582 NSView* web_contents = app_window->web_contents()->GetNativeView(); 572 NSView* web_contents = app_window->web_contents()->GetNativeView();
583 EXPECT_EQ(200, [web_contents frame].size.width); 573 EXPECT_EQ(200, [web_contents frame].size.width);
584 EXPECT_EQ(201, [web_contents frame].size.height); 574 EXPECT_EQ(201, [web_contents frame].size.height);
585 575
586 // Still resizable. 576 // Still resizable.
587 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask); 577 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask);
588 if (base::mac::IsOSSnowLeopard())
589 EXPECT_TRUE([ns_window showsResizeIndicator]);
590 578
591 // Fullscreen and maximize are disabled. 579 // Fullscreen and maximize are disabled.
592 if (base::mac::IsOSLionOrLater()) 580 if (base::mac::IsOSLionOrLater())
593 EXPECT_FALSE([ns_window collectionBehavior] & 581 EXPECT_FALSE([ns_window collectionBehavior] &
594 NSWindowCollectionBehaviorFullScreenPrimary); 582 NSWindowCollectionBehaviorFullScreenPrimary);
595 EXPECT_FALSE([[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]); 583 EXPECT_FALSE([[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]);
596 584
597 // Set a minimum size equal to the maximum size. 585 // Set a minimum size equal to the maximum size.
598 app_window->SetContentSizeConstraints(gfx::Size(200, 201), 586 app_window->SetContentSizeConstraints(gfx::Size(200, 201),
599 gfx::Size(200, 201)); 587 gfx::Size(200, 201));
600 EXPECT_EQ(200, [ns_window contentMinSize].width); 588 EXPECT_EQ(200, [ns_window contentMinSize].width);
601 EXPECT_EQ(201, [ns_window contentMinSize].height); 589 EXPECT_EQ(201, [ns_window contentMinSize].height);
602 590
603 // No longer resizable. 591 // No longer resizable.
604 EXPECT_FALSE([ns_window styleMask] & NSResizableWindowMask); 592 EXPECT_FALSE([ns_window styleMask] & NSResizableWindowMask);
605 if (base::mac::IsOSSnowLeopard())
606 EXPECT_FALSE([ns_window showsResizeIndicator]);
607 593
608 // If a window is made fullscreen by the API, fullscreen should be enabled so 594 // If a window is made fullscreen by the API, fullscreen should be enabled so
609 // the user can exit fullscreen. 595 // the user can exit fullscreen.
610 if (base::mac::IsOSLionOrLater()) { 596 if (base::mac::IsOSLionOrLater()) {
611 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; 597 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen;
612 base::scoped_nsobject<NSWindowFullscreenNotificationWaiter> waiter([ 598 base::scoped_nsobject<NSWindowFullscreenNotificationWaiter> waiter([
613 [NSWindowFullscreenNotificationWaiter alloc] initWithWindow:ns_window]); 599 [NSWindowFullscreenNotificationWaiter alloc] initWithWindow:ns_window]);
614 app_window->SetFullscreen(AppWindow::FULLSCREEN_TYPE_WINDOW_API, true); 600 app_window->SetFullscreen(AppWindow::FULLSCREEN_TYPE_WINDOW_API, true);
615 [waiter waitForEnterCount:1 exitCount:0]; 601 [waiter waitForEnterCount:1 exitCount:0];
616 EXPECT_TRUE([ns_window collectionBehavior] & 602 EXPECT_TRUE([ns_window collectionBehavior] &
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 [expected_color getComponents:expected_components]; 696 [expected_color getComponents:expected_components];
711 [color getComponents:color_components]; 697 [color getComponents:color_components];
712 EXPECT_NEAR(expected_components[0], color_components[0], 0.01); 698 EXPECT_NEAR(expected_components[0], color_components[0], 0.01);
713 EXPECT_NEAR(expected_components[1], color_components[1], 0.01); 699 EXPECT_NEAR(expected_components[1], color_components[1], 0.01);
714 EXPECT_NEAR(expected_components[2], color_components[2], 0.01); 700 EXPECT_NEAR(expected_components[2], color_components[2], 0.01);
715 } 701 }
716 702
717 INSTANTIATE_TEST_CASE_P(NativeAppWindowCocoaBrowserTestInstance, 703 INSTANTIATE_TEST_CASE_P(NativeAppWindowCocoaBrowserTestInstance,
718 NativeAppWindowCocoaBrowserTest, 704 NativeAppWindowCocoaBrowserTest,
719 ::testing::Bool()); 705 ::testing::Bool());
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698