Commit 4863f1de authored by tapted's avatar tapted Committed by Commit bot

Fix MacViews views_unittest simulate FullScreen test for 10.7+ SDKs

bridged_native_widget_unittest.mm currently fails to compile on 10.7+
SDKs because there is no such thing as
NSWindowDidFailToEnterFullScreenNotification (whoops).

The failures don't go through NSNotificationCenter, but to the
NSWindowDelegate protocol directly. So, add a dummy protocol for 10.6
and, in the simulate fullscreen failure test, send
windowDidFailTo{Enter,Exit}FullScreen to the window delegate directly.

Call via `id` so the test compiles on 10.6 SDKs, but return early so the
tests pass when actually running on 10.6.

BUG=378134
TEST=By tracing the simulation test, and manually to generate an actual
failure.

Review URL: https://codereview.chromium.org/665823002

Cr-Commit-Position: refs/heads/master@{#300366}
parent 7d57bdc3
...@@ -211,11 +211,10 @@ BASE_EXPORT extern "C" NSString* const NSWindowWillExitFullScreenNotification; ...@@ -211,11 +211,10 @@ BASE_EXPORT extern "C" NSString* const NSWindowWillExitFullScreenNotification;
BASE_EXPORT extern "C" NSString* const NSWindowDidEnterFullScreenNotification; BASE_EXPORT extern "C" NSString* const NSWindowDidEnterFullScreenNotification;
BASE_EXPORT extern "C" NSString* const NSWindowDidExitFullScreenNotification; BASE_EXPORT extern "C" NSString* const NSWindowDidExitFullScreenNotification;
BASE_EXPORT extern "C" NSString* const @protocol NSWindowDelegateFullScreenAdditions
NSWindowDidFailToEnterFullScreenNotification; - (void)windowDidFailToEnterFullScreen:(NSWindow*)window;
- (void)windowDidFailToExitFullScreen:(NSWindow*)window;
BASE_EXPORT extern "C" NSString* const @end
NSWindowDidFailToExitFullScreenNotification;
#endif // MAC_OS_X_VERSION_10_7 #endif // MAC_OS_X_VERSION_10_7
......
...@@ -20,12 +20,6 @@ NSString* const NSWindowDidEnterFullScreenNotification = ...@@ -20,12 +20,6 @@ NSString* const NSWindowDidEnterFullScreenNotification =
NSString* const NSWindowDidExitFullScreenNotification = NSString* const NSWindowDidExitFullScreenNotification =
@"NSWindowDidExitFullScreenNotification"; @"NSWindowDidExitFullScreenNotification";
NSString* const NSWindowDidFailToEnterFullScreenNotification =
@"NSWindowDidFailToEnterFullScreenNotification";
NSString* const NSWindowDidFailToExitFullScreenNotification =
@"NSWindowDidFailToExitFullScreenNotification";
#endif // MAC_OS_X_VERSION_10_7 #endif // MAC_OS_X_VERSION_10_7
// Replicate specific 10.10 SDK declarations for building with prior SDKs. // Replicate specific 10.10 SDK declarations for building with prior SDKs.
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "base/mac/foundation_util.h" #import "base/mac/foundation_util.h"
#import "base/mac/mac_util.h"
#import "base/mac/sdk_forward_declarations.h" #import "base/mac/sdk_forward_declarations.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
...@@ -534,6 +535,9 @@ TEST_F(BridgedNativeWidgetTest, TextInput_DeleteForward) { ...@@ -534,6 +535,9 @@ TEST_F(BridgedNativeWidgetTest, TextInput_DeleteForward) {
// by the Widget code or elsewhere (e.g. by the user). // by the Widget code or elsewhere (e.g. by the user).
TEST_F(BridgedNativeWidgetTest, FullscreenSynchronousState) { TEST_F(BridgedNativeWidgetTest, FullscreenSynchronousState) {
EXPECT_FALSE(widget_->IsFullscreen()); EXPECT_FALSE(widget_->IsFullscreen());
if (base::mac::IsOSSnowLeopard())
return;
// Allow user-initiated fullscreen changes on the Window. // Allow user-initiated fullscreen changes on the Window.
[test_window() [test_window()
setCollectionBehavior:[test_window() collectionBehavior] | setCollectionBehavior:[test_window() collectionBehavior] |
...@@ -594,6 +598,12 @@ TEST_F(BridgedNativeWidgetTest, FullscreenEnterAndExit) { ...@@ -594,6 +598,12 @@ TEST_F(BridgedNativeWidgetTest, FullscreenEnterAndExit) {
// Ensure this works without having to change collection behavior as for the // Ensure this works without having to change collection behavior as for the
// test above. // test above.
widget_->SetFullscreen(true); widget_->SetFullscreen(true);
if (base::mac::IsOSSnowLeopard()) {
// On Snow Leopard, SetFullscreen() isn't implemented. But shouldn't crash.
EXPECT_FALSE(widget_->IsFullscreen());
return;
}
EXPECT_TRUE(widget_->IsFullscreen()); EXPECT_TRUE(widget_->IsFullscreen());
EXPECT_EQ(restored_bounds, widget_->GetRestoredBounds()); EXPECT_EQ(restored_bounds, widget_->GetRestoredBounds());
...@@ -625,6 +635,9 @@ typedef BridgedNativeWidgetTestBase BridgedNativeWidgetSimulateFullscreenTest; ...@@ -625,6 +635,9 @@ typedef BridgedNativeWidgetTestBase BridgedNativeWidgetSimulateFullscreenTest;
// mashing Ctrl+Left/Right to keep OSX in a transition between Spaces to cause // mashing Ctrl+Left/Right to keep OSX in a transition between Spaces to cause
// the fullscreen transition to fail. // the fullscreen transition to fail.
TEST_F(BridgedNativeWidgetSimulateFullscreenTest, FailToEnterAndExit) { TEST_F(BridgedNativeWidgetSimulateFullscreenTest, FailToEnterAndExit) {
if (base::mac::IsOSSnowLeopard())
return;
base::scoped_nsobject<NSWindow> owned_window( base::scoped_nsobject<NSWindow> owned_window(
[[BridgedNativeWidgetTestFullScreenWindow alloc] [[BridgedNativeWidgetTestFullScreenWindow alloc]
initWithContentRect:NSMakeRect(50, 50, 400, 300) initWithContentRect:NSMakeRect(50, 50, 400, 300)
...@@ -657,9 +670,11 @@ TEST_F(BridgedNativeWidgetSimulateFullscreenTest, FailToEnterAndExit) { ...@@ -657,9 +670,11 @@ TEST_F(BridgedNativeWidgetSimulateFullscreenTest, FailToEnterAndExit) {
EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); EXPECT_EQ(1, [window ignoredToggleFullScreenCount]);
EXPECT_FALSE(bridge()->target_fullscreen_state()); EXPECT_FALSE(bridge()->target_fullscreen_state());
// Cocoa follows up with a failure notification. // Cocoa follows up with a failure message sent to the NSWindowDelegate (there
[center postNotificationName:NSWindowDidFailToEnterFullScreenNotification // is no equivalent notification for failure). Called via id so that this
object:window]; // compiles on 10.6.
id window_delegate = [window delegate];
[window_delegate windowDidFailToEnterFullScreen:window];
EXPECT_FALSE(bridge()->target_fullscreen_state()); EXPECT_FALSE(bridge()->target_fullscreen_state());
// Now perform a successful fullscreen operation. // Now perform a successful fullscreen operation.
...@@ -675,10 +690,9 @@ TEST_F(BridgedNativeWidgetSimulateFullscreenTest, FailToEnterAndExit) { ...@@ -675,10 +690,9 @@ TEST_F(BridgedNativeWidgetSimulateFullscreenTest, FailToEnterAndExit) {
object:window]; object:window];
EXPECT_FALSE(bridge()->target_fullscreen_state()); EXPECT_FALSE(bridge()->target_fullscreen_state());
// On a failure, Cocoa sends a failure notification, but then just dumps the // On a failure, Cocoa sends a failure message, but then just dumps the window
// Window out of fullscreen anyway (in that order). // out of fullscreen anyway (in that order).
[center postNotificationName:NSWindowDidFailToExitFullScreenNotification [window_delegate windowDidFailToExitFullScreen:window];
object:window];
EXPECT_FALSE(bridge()->target_fullscreen_state()); EXPECT_FALSE(bridge()->target_fullscreen_state());
[center postNotificationName:NSWindowDidExitFullScreenNotification [center postNotificationName:NSWindowDidExitFullScreenNotification
object:window]; object:window];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment