Commit 7e7bd7c0 authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

Add setPretendIsOccluded to CocoaTestHelperWindow.

This method simulates occlusion of the CocoaTestHelperWindow
(return value of occlusionState and posting
NSWindowDidChangeOcclusionStateNotification).

Bug: 668690
Change-Id: Ie6acab5d9ec2032dac92e8941b754fb42d45f7db
Reviewed-on: https://chromium-review.googlesource.com/802134
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarSidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521787}
parent e365b2b8
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
@interface CocoaTestHelperWindow : NSWindow { @interface CocoaTestHelperWindow : NSWindow {
@private @private
BOOL pretendIsKeyWindow_; BOOL pretendIsKeyWindow_;
BOOL pretendIsOccluded_;
BOOL useDefaultConstraints_; BOOL useDefaultConstraints_;
} }
...@@ -41,12 +42,18 @@ ...@@ -41,12 +42,18 @@
// Set value to return for -isKeyWindow. // Set value to return for -isKeyWindow.
- (void)setPretendIsKeyWindow:(BOOL)isKeyWindow; - (void)setPretendIsKeyWindow:(BOOL)isKeyWindow;
// Set value to return for -occlusionState and posts a
// NSWindowDidChangeOcclusionStateNotification.
- (void)setPretendIsOccluded:(BOOL)isOccluded;
// Whether to use or ignore the default contraints for window sizing and // Whether to use or ignore the default contraints for window sizing and
// placement. // placement.
- (void)setUseDefaultConstraints:(BOOL)useDefaultConstraints; - (void)setUseDefaultConstraints:(BOOL)useDefaultConstraints;
- (BOOL)isKeyWindow; - (BOOL)isKeyWindow;
- (NSWindowOcclusionState)occlusionState;
@end @end
namespace ui { namespace ui {
......
...@@ -66,6 +66,13 @@ void NOINLINE ForceSystemLeaks() { ...@@ -66,6 +66,13 @@ void NOINLINE ForceSystemLeaks() {
pretendIsKeyWindow_ = flag; pretendIsKeyWindow_ = flag;
} }
- (void)setPretendIsOccluded:(BOOL)flag {
pretendIsOccluded_ = flag;
[[NSNotificationCenter defaultCenter]
postNotificationName:NSWindowDidChangeOcclusionStateNotification
object:self];
}
- (void)setUseDefaultConstraints:(BOOL)useDefaultConstraints { - (void)setUseDefaultConstraints:(BOOL)useDefaultConstraints {
useDefaultConstraints_ = useDefaultConstraints; useDefaultConstraints_ = useDefaultConstraints;
} }
...@@ -74,6 +81,10 @@ void NOINLINE ForceSystemLeaks() { ...@@ -74,6 +81,10 @@ void NOINLINE ForceSystemLeaks() {
return pretendIsKeyWindow_; return pretendIsKeyWindow_;
} }
- (NSWindowOcclusionState)occlusionState {
return pretendIsOccluded_ ? 0 : NSWindowOcclusionStateVisible;
}
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen*)screen { - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen*)screen {
if (!useDefaultConstraints_) if (!useDefaultConstraints_)
return frameRect; return frameRect;
......
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