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

Side by Side Diff: chrome/test/base/interactive_test_utils_mac.mm

Issue 2419673002: Fix a deprecated declaration warning in interactive_test_utils_mac.mm. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/base/interactive_test_utils.h" 5 #include "chrome/test/base/interactive_test_utils.h"
6 6
7 #include <Carbon/Carbon.h> 7 #include <Carbon/Carbon.h>
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #import "ui/base/test/windowed_nsnotification_observer.h" 12 #import "ui/base/test/windowed_nsnotification_observer.h"
13 13
14 namespace ui_test_utils { 14 namespace ui_test_utils {
15 15
16 void HideNativeWindow(gfx::NativeWindow window) { 16 void HideNativeWindow(gfx::NativeWindow window) {
17 [window orderOut:nil]; 17 [window orderOut:nil];
18 } 18 }
19 19
20 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) { 20 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) {
21 // Make sure an unbundled program can get the input focus. 21 // Make sure an unbundled program can get the input focus.
22 ProcessSerialNumber psn = { 0, kCurrentProcess }; 22 ProcessSerialNumber psn = { 0, kCurrentProcess };
23 TransformProcessType(&psn,kProcessTransformToForegroundApplication); 23 TransformProcessType(&psn,kProcessTransformToForegroundApplication);
24 SetFrontProcess(&psn); 24 [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
25 25
26 base::scoped_nsobject<WindowedNSNotificationObserver> async_waiter; 26 base::scoped_nsobject<WindowedNSNotificationObserver> async_waiter;
27 if (![window isKeyWindow]) { 27 if (![window isKeyWindow]) {
28 // Only wait when expecting a change to actually occur. 28 // Only wait when expecting a change to actually occur.
29 async_waiter.reset([[WindowedNSNotificationObserver alloc] 29 async_waiter.reset([[WindowedNSNotificationObserver alloc]
30 initForNotification:NSWindowDidBecomeKeyNotification 30 initForNotification:NSWindowDidBecomeKeyNotification
31 object:window]); 31 object:window]);
32 } 32 }
33 [window makeKeyAndOrderFront:nil]; 33 [window makeKeyAndOrderFront:nil];
34 34
35 // Wait until |window| becomes key window, then make sure the shortcuts for 35 // Wait until |window| becomes key window, then make sure the shortcuts for
36 // "Close Window" and "Close Tab" are updated. 36 // "Close Window" and "Close Tab" are updated.
37 // This is because normal AppKit menu updating does not get invoked when 37 // This is because normal AppKit menu updating does not get invoked when
38 // events are sent via ui_test_utils::SendKeyPressSync. 38 // events are sent via ui_test_utils::SendKeyPressSync.
39 BOOL notification_observed = [async_waiter wait]; 39 BOOL notification_observed = [async_waiter wait];
40 base::RunLoop().RunUntilIdle(); // There may be other events queued. Flush. 40 base::RunLoop().RunUntilIdle(); // There may be other events queued. Flush.
41 NSMenu* file_menu = [[[NSApp mainMenu] itemWithTag:IDC_FILE_MENU] submenu]; 41 NSMenu* file_menu = [[[NSApp mainMenu] itemWithTag:IDC_FILE_MENU] submenu];
42 [[file_menu delegate] menuNeedsUpdate:file_menu]; 42 [[file_menu delegate] menuNeedsUpdate:file_menu];
43 43
44 return !async_waiter || notification_observed; 44 return !async_waiter || notification_observed;
45 } 45 }
46 46
47 } // namespace ui_test_utils 47 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698