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

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

Issue 1917973002: mac: Remove IsOSLion(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tapted 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 EXPECT_CALL(*mock, FindHost(_, _)).WillOnce(Return(&mock_host)); 216 EXPECT_CALL(*mock, FindHost(_, _)).WillOnce(Return(&mock_host));
217 native_window->Activate(); 217 native_window->Activate();
218 EXPECT_TRUE([ns_window isVisible]); 218 EXPECT_TRUE([ns_window isVisible]);
219 testing::Mock::VerifyAndClearExpectations(mock); 219 testing::Mock::VerifyAndClearExpectations(mock);
220 testing::Mock::VerifyAndClearExpectations(&mock_host); 220 testing::Mock::VerifyAndClearExpectations(&mock_host);
221 } 221 }
222 222
223 // Test that NativeAppWindow and AppWindow fullscreen state is updated when 223 // Test that NativeAppWindow and AppWindow fullscreen state is updated when
224 // the window is fullscreened natively. 224 // the window is fullscreened natively.
225 IN_PROC_BROWSER_TEST_P(NativeAppWindowCocoaBrowserTest, Fullscreen) { 225 IN_PROC_BROWSER_TEST_P(NativeAppWindowCocoaBrowserTest, Fullscreen) {
226 if (!base::mac::IsOSLionOrLater())
227 return;
228
229 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; 226 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen;
230 227
231 extensions::AppWindow* app_window = 228 extensions::AppWindow* app_window =
232 CreateTestAppWindow("{\"alwaysOnTop\": true }"); 229 CreateTestAppWindow("{\"alwaysOnTop\": true }");
233 extensions::NativeAppWindow* window = app_window->GetBaseWindow(); 230 extensions::NativeAppWindow* window = app_window->GetBaseWindow();
234 NSWindow* ns_window = app_window->GetNativeWindow(); 231 NSWindow* ns_window = app_window->GetNativeWindow();
235 base::scoped_nsobject<NSWindowFullscreenNotificationWaiter> waiter( 232 base::scoped_nsobject<NSWindowFullscreenNotificationWaiter> waiter(
236 [[NSWindowFullscreenNotificationWaiter alloc] initWithWindow:ns_window]); 233 [[NSWindowFullscreenNotificationWaiter alloc] initWithWindow:ns_window]);
237 234
238 EXPECT_EQ(AppWindow::FULLSCREEN_TYPE_NONE, 235 EXPECT_EQ(AppWindow::FULLSCREEN_TYPE_NONE,
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 542
546 // The window is resizable. 543 // The window is resizable.
547 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask); 544 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask);
548 545
549 // Due to this bug: http://crbug.com/362039, which manifests on the Cocoa 546 // Due to this bug: http://crbug.com/362039, which manifests on the Cocoa
550 // implementation but not the views one, frameless windows should have 547 // implementation but not the views one, frameless windows should have
551 // fullscreen controls disabled. 548 // fullscreen controls disabled.
552 BOOL can_fullscreen = 549 BOOL can_fullscreen =
553 ![NSStringFromClass([ns_window class]) isEqualTo:@"AppFramelessNSWindow"]; 550 ![NSStringFromClass([ns_window class]) isEqualTo:@"AppFramelessNSWindow"];
554 // The window can fullscreen and maximize. 551 // The window can fullscreen and maximize.
555 if (base::mac::IsOSLionOrLater()) { 552 EXPECT_EQ(can_fullscreen, !!([ns_window collectionBehavior] &
556 EXPECT_EQ(can_fullscreen, !!([ns_window collectionBehavior] & 553 NSWindowCollectionBehaviorFullScreenPrimary));
557 NSWindowCollectionBehaviorFullScreenPrimary));
558 }
559 554
560 // In OSX 10.10+, the zoom button performs the zoom action rather than the 555 // In OSX 10.10+, the zoom button performs the zoom action rather than the
561 // fullscreen action. The above check that collectionBehavior does not include 556 // fullscreen action. The above check that collectionBehavior does not include
562 // NSWindowCollectionBehaviorFullScreenPrimary is sufficient to determine that 557 // NSWindowCollectionBehaviorFullScreenPrimary is sufficient to determine that
563 // the window can't be fullscreened. 558 // the window can't be fullscreened.
564 if (base::mac::IsOSMavericksOrEarlier()) { 559 if (base::mac::IsOSMavericksOrEarlier()) {
565 EXPECT_EQ(can_fullscreen, 560 EXPECT_EQ(can_fullscreen,
566 [[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]); 561 [[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]);
567 } 562 }
568 563
569 // Set a maximum size. 564 // Set a maximum size.
570 app_window->SetContentSizeConstraints(gfx::Size(), gfx::Size(200, 201)); 565 app_window->SetContentSizeConstraints(gfx::Size(), gfx::Size(200, 201));
571 EXPECT_EQ(200, [ns_window contentMaxSize].width); 566 EXPECT_EQ(200, [ns_window contentMaxSize].width);
572 EXPECT_EQ(201, [ns_window contentMaxSize].height); 567 EXPECT_EQ(201, [ns_window contentMaxSize].height);
573 NSView* web_contents = app_window->web_contents()->GetNativeView(); 568 NSView* web_contents = app_window->web_contents()->GetNativeView();
574 EXPECT_EQ(200, [web_contents frame].size.width); 569 EXPECT_EQ(200, [web_contents frame].size.width);
575 EXPECT_EQ(201, [web_contents frame].size.height); 570 EXPECT_EQ(201, [web_contents frame].size.height);
576 571
577 // Still resizable. 572 // Still resizable.
578 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask); 573 EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask);
579 574
580 // Fullscreen and maximize are disabled. 575 // Fullscreen and maximize are disabled.
581 if (base::mac::IsOSLionOrLater()) 576 EXPECT_FALSE([ns_window collectionBehavior] &
582 EXPECT_FALSE([ns_window collectionBehavior] & 577 NSWindowCollectionBehaviorFullScreenPrimary);
583 NSWindowCollectionBehaviorFullScreenPrimary);
584 EXPECT_FALSE([[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]); 578 EXPECT_FALSE([[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]);
585 579
586 // Set a minimum size equal to the maximum size. 580 // Set a minimum size equal to the maximum size.
587 app_window->SetContentSizeConstraints(gfx::Size(200, 201), 581 app_window->SetContentSizeConstraints(gfx::Size(200, 201),
588 gfx::Size(200, 201)); 582 gfx::Size(200, 201));
589 EXPECT_EQ(200, [ns_window contentMinSize].width); 583 EXPECT_EQ(200, [ns_window contentMinSize].width);
590 EXPECT_EQ(201, [ns_window contentMinSize].height); 584 EXPECT_EQ(201, [ns_window contentMinSize].height);
591 585
592 // No longer resizable. 586 // No longer resizable.
593 EXPECT_FALSE([ns_window styleMask] & NSResizableWindowMask); 587 EXPECT_FALSE([ns_window styleMask] & NSResizableWindowMask);
594 588
595 // If a window is made fullscreen by the API, fullscreen should be enabled so 589 // If a window is made fullscreen by the API, fullscreen should be enabled so
596 // the user can exit fullscreen. 590 // the user can exit fullscreen.
597 if (base::mac::IsOSLionOrLater()) { 591 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen;
598 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; 592 base::scoped_nsobject<NSWindowFullscreenNotificationWaiter> waiter(
599 base::scoped_nsobject<NSWindowFullscreenNotificationWaiter> waiter([ 593 [[NSWindowFullscreenNotificationWaiter alloc] initWithWindow:ns_window]);
600 [NSWindowFullscreenNotificationWaiter alloc] initWithWindow:ns_window]); 594 app_window->SetFullscreen(AppWindow::FULLSCREEN_TYPE_WINDOW_API, true);
601 app_window->SetFullscreen(AppWindow::FULLSCREEN_TYPE_WINDOW_API, true); 595 [waiter waitForEnterCount:1 exitCount:0];
602 [waiter waitForEnterCount:1 exitCount:0]; 596 EXPECT_TRUE([ns_window collectionBehavior] &
603 EXPECT_TRUE([ns_window collectionBehavior] & 597 NSWindowCollectionBehaviorFullScreenPrimary);
604 NSWindowCollectionBehaviorFullScreenPrimary); 598 EXPECT_EQ(NSWidth([[ns_window contentView] frame]),
605 EXPECT_EQ(NSWidth([[ns_window contentView] frame]), 599 NSWidth([ns_window frame]));
606 NSWidth([ns_window frame])); 600 // Once it leaves fullscreen, it is disabled again.
607 // Once it leaves fullscreen, it is disabled again. 601 app_window->SetFullscreen(AppWindow::FULLSCREEN_TYPE_WINDOW_API, false);
608 app_window->SetFullscreen(AppWindow::FULLSCREEN_TYPE_WINDOW_API, false); 602 [waiter waitForEnterCount:1 exitCount:1];
609 [waiter waitForEnterCount:1 exitCount:1]; 603 EXPECT_FALSE([ns_window collectionBehavior] &
610 EXPECT_FALSE([ns_window collectionBehavior] & 604 NSWindowCollectionBehaviorFullScreenPrimary);
611 NSWindowCollectionBehaviorFullScreenPrimary);
612 }
613 } 605 }
614 606
615 } // namespace 607 } // namespace
616 608
617 IN_PROC_BROWSER_TEST_P(NativeAppWindowCocoaBrowserTest, Controls) { 609 IN_PROC_BROWSER_TEST_P(NativeAppWindowCocoaBrowserTest, Controls) {
618 TestControls(CreateTestAppWindow("{}")); 610 TestControls(CreateTestAppWindow("{}"));
619 } 611 }
620 612
621 IN_PROC_BROWSER_TEST_P(NativeAppWindowCocoaBrowserTest, ControlsFrameless) { 613 IN_PROC_BROWSER_TEST_P(NativeAppWindowCocoaBrowserTest, ControlsFrameless) {
622 TestControls(CreateTestAppWindow("{\"frame\": \"none\"}")); 614 TestControls(CreateTestAppWindow("{\"frame\": \"none\"}"));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 [expected_color getComponents:expected_components]; 689 [expected_color getComponents:expected_components];
698 [color getComponents:color_components]; 690 [color getComponents:color_components];
699 EXPECT_NEAR(expected_components[0], color_components[0], 0.01); 691 EXPECT_NEAR(expected_components[0], color_components[0], 0.01);
700 EXPECT_NEAR(expected_components[1], color_components[1], 0.01); 692 EXPECT_NEAR(expected_components[1], color_components[1], 0.01);
701 EXPECT_NEAR(expected_components[2], color_components[2], 0.01); 693 EXPECT_NEAR(expected_components[2], color_components[2], 0.01);
702 } 694 }
703 695
704 INSTANTIATE_TEST_CASE_P(NativeAppWindowCocoaBrowserTestInstance, 696 INSTANTIATE_TEST_CASE_P(NativeAppWindowCocoaBrowserTestInstance,
705 NativeAppWindowCocoaBrowserTest, 697 NativeAppWindowCocoaBrowserTest,
706 ::testing::Bool()); 698 ::testing::Bool());
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/app_menu/app_menu_controller.mm ('k') | chrome/browser/ui/cocoa/base_bubble_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698