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 #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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 BOOL can_fullscreen = | 549 BOOL can_fullscreen = |
550 ![NSStringFromClass([ns_window class]) isEqualTo:@"AppFramelessNSWindow"]; | 550 ![NSStringFromClass([ns_window class]) isEqualTo:@"AppFramelessNSWindow"]; |
551 // The window can fullscreen and maximize. | 551 // The window can fullscreen and maximize. |
552 EXPECT_EQ(can_fullscreen, !!([ns_window collectionBehavior] & | 552 EXPECT_EQ(can_fullscreen, !!([ns_window collectionBehavior] & |
553 NSWindowCollectionBehaviorFullScreenPrimary)); | 553 NSWindowCollectionBehaviorFullScreenPrimary)); |
554 | 554 |
555 // 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 |
556 // fullscreen action. The above check that collectionBehavior does not include | 556 // fullscreen action. The above check that collectionBehavior does not include |
557 // NSWindowCollectionBehaviorFullScreenPrimary is sufficient to determine that | 557 // NSWindowCollectionBehaviorFullScreenPrimary is sufficient to determine that |
558 // the window can't be fullscreened. | 558 // the window can't be fullscreened. |
559 if (base::mac::IsOSMavericks()) { | 559 if (base::mac::IsOS10_9()) { |
560 EXPECT_EQ(can_fullscreen, | 560 EXPECT_EQ(can_fullscreen, |
561 [[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]); | 561 [[ns_window standardWindowButton:NSWindowZoomButton] isEnabled]); |
562 } | 562 } |
563 | 563 |
564 // Set a maximum size. | 564 // Set a maximum size. |
565 app_window->SetContentSizeConstraints(gfx::Size(), gfx::Size(200, 201)); | 565 app_window->SetContentSizeConstraints(gfx::Size(), gfx::Size(200, 201)); |
566 EXPECT_EQ(200, [ns_window contentMaxSize].width); | 566 EXPECT_EQ(200, [ns_window contentMaxSize].width); |
567 EXPECT_EQ(201, [ns_window contentMaxSize].height); | 567 EXPECT_EQ(201, [ns_window contentMaxSize].height); |
568 NSView* web_contents = app_window->web_contents()->GetNativeView(); | 568 NSView* web_contents = app_window->web_contents()->GetNativeView(); |
569 EXPECT_EQ(200, [web_contents frame].size.width); | 569 EXPECT_EQ(200, [web_contents frame].size.width); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 // to the frame view having a layer with 10.10 SDK, but is probably a bug | 629 // to the frame view having a layer with 10.10 SDK, but is probably a bug |
630 // since it doesn't manifest on 10.10. See http://crbug.com/508722. | 630 // since it doesn't manifest on 10.10. See http://crbug.com/508722. |
631 // In this case, take a screenshot using the CGWindowList API instead. The | 631 // In this case, take a screenshot using the CGWindowList API instead. The |
632 // bitmap is now in the display's color space, so expected colors need to be | 632 // bitmap is now in the display's color space, so expected colors need to be |
633 // converted. | 633 // converted. |
634 // TODO(jackhou): Update this if it is fixed in AppKit, or if other | 634 // TODO(jackhou): Update this if it is fixed in AppKit, or if other |
635 // platform/SDK combinations need it. | 635 // platform/SDK combinations need it. |
636 // NOTE: This doesn't work with Views, but the regular test does, so use that. | 636 // NOTE: This doesn't work with Views, but the regular test does, so use that. |
637 bool mac_views = base::CommandLine::ForCurrentProcess()->HasSwitch( | 637 bool mac_views = base::CommandLine::ForCurrentProcess()->HasSwitch( |
638 switches::kEnableMacViewsNativeAppWindows); | 638 switches::kEnableMacViewsNativeAppWindows); |
639 if (base::mac::IsOSMavericks() && !mac_views) { | 639 if (base::mac::IsOS10_9() && !mac_views) { |
640 // -[NSView setNeedsDisplay:YES] doesn't synchronously display the view, it | 640 // -[NSView setNeedsDisplay:YES] doesn't synchronously display the view, it |
641 // gets drawn by another event in the queue, so let that run first. | 641 // gets drawn by another event in the queue, so let that run first. |
642 content::RunAllPendingInMessageLoop(); | 642 content::RunAllPendingInMessageLoop(); |
643 base::ScopedCFTypeRef<CGImageRef> cg_image(CGWindowListCreateImage( | 643 base::ScopedCFTypeRef<CGImageRef> cg_image(CGWindowListCreateImage( |
644 CGRectNull, kCGWindowListOptionIncludingWindow, [window windowNumber], | 644 CGRectNull, kCGWindowListOptionIncludingWindow, [window windowNumber], |
645 kCGWindowImageBoundsIgnoreFraming)); | 645 kCGWindowImageBoundsIgnoreFraming)); |
646 return [[[NSBitmapImageRep alloc] initWithCGImage:cg_image] autorelease]; | 646 return [[[NSBitmapImageRep alloc] initWithCGImage:cg_image] autorelease]; |
647 } | 647 } |
648 | 648 |
649 NSView* frame_view = [[window contentView] superview]; | 649 NSView* frame_view = [[window contentView] superview]; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 [expected_color getComponents:expected_components]; | 689 [expected_color getComponents:expected_components]; |
690 [color getComponents:color_components]; | 690 [color getComponents:color_components]; |
691 EXPECT_NEAR(expected_components[0], color_components[0], 0.01); | 691 EXPECT_NEAR(expected_components[0], color_components[0], 0.01); |
692 EXPECT_NEAR(expected_components[1], color_components[1], 0.01); | 692 EXPECT_NEAR(expected_components[1], color_components[1], 0.01); |
693 EXPECT_NEAR(expected_components[2], color_components[2], 0.01); | 693 EXPECT_NEAR(expected_components[2], color_components[2], 0.01); |
694 } | 694 } |
695 | 695 |
696 INSTANTIATE_TEST_CASE_P(NativeAppWindowCocoaBrowserTestInstance, | 696 INSTANTIATE_TEST_CASE_P(NativeAppWindowCocoaBrowserTestInstance, |
697 NativeAppWindowCocoaBrowserTest, | 697 NativeAppWindowCocoaBrowserTest, |
698 ::testing::Bool()); | 698 ::testing::Bool()); |
OLD | NEW |