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

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

Issue 1186803003: Mac: Give packaged app windows their own window cycle list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase (overlap with r335812 and I want a fresh CQ run) Created 5 years, 5 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/common/chrome_switches.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | 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/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #import "chrome/browser/ui/cocoa/view_id_util.h" 16 #import "chrome/browser/ui/cocoa/view_id_util.h"
17 #include "ui/base/test/ui_controls.h" 17 #include "ui/base/test/ui_controls.h"
18 #import "ui/base/test/windowed_nsnotification_observer.h"
18 19
19 namespace ui_test_utils { 20 namespace ui_test_utils {
20 21
21 namespace { 22 namespace {
22 23
23 void MoveMouseToNSViewCenterAndPress( 24 void MoveMouseToNSViewCenterAndPress(
24 NSView* view, 25 NSView* view,
25 ui_controls::MouseButton button, 26 ui_controls::MouseButton button,
26 int state, 27 int state,
27 const base::Closure& task) { 28 const base::Closure& task) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 void HideNativeWindow(gfx::NativeWindow window) { 98 void HideNativeWindow(gfx::NativeWindow window) {
98 [window orderOut:nil]; 99 [window orderOut:nil];
99 } 100 }
100 101
101 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) { 102 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) {
102 // Make sure an unbundled program can get the input focus. 103 // Make sure an unbundled program can get the input focus.
103 ProcessSerialNumber psn = { 0, kCurrentProcess }; 104 ProcessSerialNumber psn = { 0, kCurrentProcess };
104 TransformProcessType(&psn,kProcessTransformToForegroundApplication); 105 TransformProcessType(&psn,kProcessTransformToForegroundApplication);
105 SetFrontProcess(&psn); 106 SetFrontProcess(&psn);
106 107
108 base::scoped_nsobject<WindowedNSNotificationObserver> async_waiter;
109 if (![window isKeyWindow]) {
110 // Only wait when expecting a change to actually occur.
111 async_waiter.reset([[WindowedNSNotificationObserver alloc]
112 initForNotification:NSWindowDidBecomeKeyNotification
113 object:window]);
114 }
107 [window makeKeyAndOrderFront:nil]; 115 [window makeKeyAndOrderFront:nil];
108 116
109 // Wait until |window| becomes key window, then make sure the shortcuts for 117 // Wait until |window| becomes key window, then make sure the shortcuts for
110 // "Close Window" and "Close Tab" are updated. 118 // "Close Window" and "Close Tab" are updated.
111 // This is because normal AppKit menu updating does not get invoked when 119 // This is because normal AppKit menu updating does not get invoked when
112 // events are sent via ui_test_utils::SendKeyPressSync. 120 // events are sent via ui_test_utils::SendKeyPressSync.
113 base::RunLoop().RunUntilIdle(); 121 BOOL notification_observed = [async_waiter wait];
122 base::RunLoop().RunUntilIdle(); // There may be other events queued. Flush.
114 NSMenu* file_menu = [[[NSApp mainMenu] itemWithTag:IDC_FILE_MENU] submenu]; 123 NSMenu* file_menu = [[[NSApp mainMenu] itemWithTag:IDC_FILE_MENU] submenu];
115 [[file_menu delegate] menuNeedsUpdate:file_menu]; 124 [[file_menu delegate] menuNeedsUpdate:file_menu];
116 125
117 return true; 126 return !async_waiter || notification_observed;
118 } 127 }
119 128
120 } // namespace ui_test_utils 129 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698