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

Side by Side 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: Address comments. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "ui/base/test/nswindow_fullscreen_notification_waiter.h"
6
7 #import "base/mac/sdk_forward_declarations.h"
8
9 @interface NSWindowFullscreenNotificationWaiter ()
10 // Exit the RunLoop if there is one and the counts being tracked match.
11 - (void)maybeQuitForChangedArg:(int*)changedArg;
12 - (void)onEnter:(NSNotification*)notification;
13 - (void)onExit:(NSNotification*)notification;
14 @end
15
16 @implementation NSWindowFullscreenNotificationWaiter
17
18 @synthesize enterCount = enterCount_;
19 @synthesize exitCount = exitCount_;
20
21 - (id)initWithWindow:(NSWindow*)window {
22 if ((self = [super init])) {
23 window_.reset([window retain]);
24 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
25 [defaultCenter addObserver:self
26 selector:@selector(onEnter:)
27 name:NSWindowDidEnterFullScreenNotification
28 object:window];
29 [defaultCenter addObserver:self
30 selector:@selector(onExit:)
31 name:NSWindowDidExitFullScreenNotification
32 object:window];
33 }
34 return self;
35 }
36
37 - (void)dealloc {
38 DCHECK(!runLoop_);
39 [[NSNotificationCenter defaultCenter] removeObserver:self];
40 [super dealloc];
41 }
42
43 - (void)waitForEnterCount:(int)enterCount exitCount:(int)exitCount {
44 if (enterCount_ >= enterCount && exitCount_ >= exitCount)
45 return;
46
47 targetEnterCount_ = enterCount;
48 targetExitCount_ = exitCount;
49 runLoop_.reset(new base::RunLoop);
50 runLoop_->Run();
51 runLoop_.reset();
52 }
53
54 - (void)maybeQuitForChangedArg:(int*)changedArg {
55 ++*changedArg;
56 if (!runLoop_)
57 return;
58
59 if (enterCount_ >= targetEnterCount_ && exitCount_ >= targetExitCount_)
60 runLoop_->Quit();
61 }
62
63 - (void)onEnter:(NSNotification*)notification {
64 [self maybeQuitForChangedArg:&enterCount_];
65 }
66
67 - (void)onExit:(NSNotification*)notification {
68 [self maybeQuitForChangedArg:&exitCount_];
69 }
70
71 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698