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

Side by Side Diff: chrome/browser/ui/test/scoped_fake_nswindow_main_status.mm

Issue 1268293002: [MacViews] Fix AccessiblePaneViewTest.SetPaneFocusAndRestore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove roque delta. Created 5 years, 4 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
« no previous file with comments | « chrome/browser/ui/test/scoped_fake_nswindow_main_status.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/test/scoped_fake_nswindow_main_status.h"
6
7 #import <Cocoa/Cocoa.h>
8
9 #import "base/mac/foundation_util.h"
10 #import "base/mac/scoped_objc_class_swizzler.h"
11
12 namespace {
13
14 NSWindow* g_fake_main_window = nil;
15
16 }
17
18 // Donates a testing implementation of [NSWindow isMainWindow].
19 @interface IsMainWindowDonorForWindow : NSObject
20 @end
21
22 @implementation IsMainWindowDonorForWindow
23 - (BOOL)isMainWindow {
24 NSWindow* selfAsWindow = base::mac::ObjCCastStrict<NSWindow>(self);
25 return selfAsWindow == g_fake_main_window;
26 }
27 @end
28
29 ScopedFakeNSWindowMainStatus::ScopedFakeNSWindowMainStatus(NSWindow* window)
30 : swizzler_(new base::mac::ScopedObjCClassSwizzler(
31 [NSWindow class],
32 [IsMainWindowDonorForWindow class],
33 @selector(isMainWindow))) {
34 DCHECK(!g_fake_main_window);
35 g_fake_main_window = window;
36 [[NSNotificationCenter defaultCenter]
37 postNotificationName:NSWindowDidBecomeMainNotification
38 object:g_fake_main_window];
39 }
40
41 ScopedFakeNSWindowMainStatus::~ScopedFakeNSWindowMainStatus() {
42 NSWindow* window = g_fake_main_window;
43 g_fake_main_window = nil;
44 [[NSNotificationCenter defaultCenter]
45 postNotificationName:NSWindowDidResignMainNotification
46 object:window];
47 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/test/scoped_fake_nswindow_main_status.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698