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

Unified Diff: ui/base/test/nswindow_fullscreen_notification_waiter.mm

Issue 1109493002: [MacViews] Fix behavior of non-resizable windows in fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert to Patch Set 7 Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/test/nswindow_fullscreen_notification_waiter.h ('k') | ui/base/ui_base.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/test/nswindow_fullscreen_notification_waiter.mm
diff --git a/ui/base/test/nswindow_fullscreen_notification_waiter.mm b/ui/base/test/nswindow_fullscreen_notification_waiter.mm
new file mode 100644
index 0000000000000000000000000000000000000000..c6bf245bf0549c1215fc3a5ab080ba51a9ecdea8
--- /dev/null
+++ b/ui/base/test/nswindow_fullscreen_notification_waiter.mm
@@ -0,0 +1,71 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ui/base/test/nswindow_fullscreen_notification_waiter.h"
+
+#import "base/mac/sdk_forward_declarations.h"
+
+@interface NSWindowFullscreenNotificationWaiter ()
+// Exit the RunLoop if there is one and the counts being tracked match.
+- (void)maybeQuitForChangedArg:(int*)changedArg;
+- (void)onEnter:(NSNotification*)notification;
+- (void)onExit:(NSNotification*)notification;
+@end
+
+@implementation NSWindowFullscreenNotificationWaiter
+
+@synthesize enterCount = enterCount_;
+@synthesize exitCount = exitCount_;
+
+- (id)initWithWindow:(NSWindow*)window {
+ if ((self = [super init])) {
+ window_.reset([window retain]);
+ NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
+ [defaultCenter addObserver:self
+ selector:@selector(onEnter:)
+ name:NSWindowDidEnterFullScreenNotification
+ object:window];
+ [defaultCenter addObserver:self
+ selector:@selector(onExit:)
+ name:NSWindowDidExitFullScreenNotification
+ object:window];
+ }
+ return self;
+}
+
+- (void)dealloc {
+ DCHECK(!runLoop_);
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [super dealloc];
+}
+
+- (void)waitForEnterCount:(int)enterCount exitCount:(int)exitCount {
+ if (enterCount_ >= enterCount && exitCount_ >= exitCount)
+ return;
+
+ targetEnterCount_ = enterCount;
+ targetExitCount_ = exitCount;
+ runLoop_.reset(new base::RunLoop);
+ runLoop_->Run();
+ runLoop_.reset();
+}
+
+- (void)maybeQuitForChangedArg:(int*)changedArg {
+ ++*changedArg;
+ if (!runLoop_)
+ return;
+
+ if (enterCount_ >= targetEnterCount_ && exitCount_ >= targetExitCount_)
+ runLoop_->Quit();
+}
+
+- (void)onEnter:(NSNotification*)notification {
+ [self maybeQuitForChangedArg:&enterCount_];
+}
+
+- (void)onExit:(NSNotification*)notification {
+ [self maybeQuitForChangedArg:&exitCount_];
+}
+
+@end
« no previous file with comments | « ui/base/test/nswindow_fullscreen_notification_waiter.h ('k') | ui/base/ui_base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698