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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/interactive_test_utils_mac.mm
diff --git a/chrome/test/base/interactive_test_utils_mac.mm b/chrome/test/base/interactive_test_utils_mac.mm
index 83f3321b4f68b74437b54ec9167929e7f86ae37c..17fa8e88a4e020a7a98ec47422ed75e5a3cad267 100644
--- a/chrome/test/base/interactive_test_utils_mac.mm
+++ b/chrome/test/base/interactive_test_utils_mac.mm
@@ -15,6 +15,7 @@
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/view_id_util.h"
#include "ui/base/test/ui_controls.h"
+#import "ui/base/test/windowed_nsnotification_observer.h"
namespace ui_test_utils {
@@ -104,17 +105,25 @@ bool ShowAndFocusNativeWindow(gfx::NativeWindow window) {
TransformProcessType(&psn,kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
+ base::scoped_nsobject<WindowedNSNotificationObserver> async_waiter;
+ if (![window isKeyWindow]) {
+ // Only wait when expecting a change to actually occur.
+ async_waiter.reset([[WindowedNSNotificationObserver alloc]
+ initForNotification:NSWindowDidBecomeKeyNotification
+ object:window]);
+ }
[window makeKeyAndOrderFront:nil];
// Wait until |window| becomes key window, then make sure the shortcuts for
// "Close Window" and "Close Tab" are updated.
// This is because normal AppKit menu updating does not get invoked when
// events are sent via ui_test_utils::SendKeyPressSync.
- base::RunLoop().RunUntilIdle();
+ BOOL notification_observed = [async_waiter wait];
+ base::RunLoop().RunUntilIdle(); // There may be other events queued. Flush.
NSMenu* file_menu = [[[NSApp mainMenu] itemWithTag:IDC_FILE_MENU] submenu];
[[file_menu delegate] menuNeedsUpdate:file_menu];
- return true;
+ return !async_waiter || notification_observed;
}
} // namespace ui_test_utils
« 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