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

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

Issue 2382963002: Views: Add two disabled tests for invoking the CC unmask prompt dialog. (Closed)
Patch Set: Initial approach for invoking UI tests. 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
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 #include "chrome/test/base/move_test_process_to_front_mac.h"
12 #import "ui/base/test/windowed_nsnotification_observer.h" 13 #import "ui/base/test/windowed_nsnotification_observer.h"
13 14
14 namespace ui_test_utils { 15 namespace ui_test_utils {
15 16
16 void HideNativeWindow(gfx::NativeWindow window) { 17 void HideNativeWindow(gfx::NativeWindow window) {
17 [window orderOut:nil]; 18 [window orderOut:nil];
18 } 19 }
19 20
20 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) { 21 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) {
21 // Make sure an unbundled program can get the input focus. 22 // Make sure an unbundled program can get the input focus.
22 ProcessSerialNumber psn = { 0, kCurrentProcess }; 23 SetProcessToFront();
23 TransformProcessType(&psn,kProcessTransformToForegroundApplication);
24 SetFrontProcess(&psn);
25 24
26 base::scoped_nsobject<WindowedNSNotificationObserver> async_waiter; 25 base::scoped_nsobject<WindowedNSNotificationObserver> async_waiter;
27 if (![window isKeyWindow]) { 26 if (![window isKeyWindow]) {
28 // Only wait when expecting a change to actually occur. 27 // Only wait when expecting a change to actually occur.
29 async_waiter.reset([[WindowedNSNotificationObserver alloc] 28 async_waiter.reset([[WindowedNSNotificationObserver alloc]
30 initForNotification:NSWindowDidBecomeKeyNotification 29 initForNotification:NSWindowDidBecomeKeyNotification
31 object:window]); 30 object:window]);
32 } 31 }
33 [window makeKeyAndOrderFront:nil]; 32 [window makeKeyAndOrderFront:nil];
34 33
35 // Wait until |window| becomes key window, then make sure the shortcuts for 34 // Wait until |window| becomes key window, then make sure the shortcuts for
36 // "Close Window" and "Close Tab" are updated. 35 // "Close Window" and "Close Tab" are updated.
37 // This is because normal AppKit menu updating does not get invoked when 36 // This is because normal AppKit menu updating does not get invoked when
38 // events are sent via ui_test_utils::SendKeyPressSync. 37 // events are sent via ui_test_utils::SendKeyPressSync.
39 BOOL notification_observed = [async_waiter wait]; 38 BOOL notification_observed = [async_waiter wait];
40 base::RunLoop().RunUntilIdle(); // There may be other events queued. Flush. 39 base::RunLoop().RunUntilIdle(); // There may be other events queued. Flush.
41 NSMenu* file_menu = [[[NSApp mainMenu] itemWithTag:IDC_FILE_MENU] submenu]; 40 NSMenu* file_menu = [[[NSApp mainMenu] itemWithTag:IDC_FILE_MENU] submenu];
42 [[file_menu delegate] menuNeedsUpdate:file_menu]; 41 [[file_menu delegate] menuNeedsUpdate:file_menu];
43 42
44 return !async_waiter || notification_observed; 43 return !async_waiter || notification_observed;
45 } 44 }
46 45
47 } // namespace ui_test_utils 46 } // namespace ui_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698