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

Unified Diff: chrome/test/base/interactive_test_utils_cocoa.mm

Issue 2910033002: Fail tests that use ClickOnView() on an inactive window.
Patch Set: Fail more Created 3 years, 7 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 | « no previous file | chrome/test/base/interactive_test_utils_views.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/interactive_test_utils_cocoa.mm
diff --git a/chrome/test/base/interactive_test_utils_cocoa.mm b/chrome/test/base/interactive_test_utils_cocoa.mm
index ee4e8c2da936b9515062ee4fa10c43511e27d684..df4de1af0f5cc1fc7409f9c79aa62cbe44c92708 100644
--- a/chrome/test/base/interactive_test_utils_cocoa.mm
+++ b/chrome/test/base/interactive_test_utils_cocoa.mm
@@ -13,6 +13,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/view_id_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/cocoa/cocoa_base_utils.h"
namespace ui_test_utils {
@@ -75,6 +76,12 @@ bool IsViewFocused(const Browser* browser, ViewID vid) {
void ClickOnView(const Browser* browser, ViewID vid) {
NSWindow* window = browser->window()->GetNativeWindow();
DCHECK(window);
+ // Fail tests that use ClickOnView() on an inactive window. Tests that do will
+ // flake too easily. There seems to be no guarantee that the WindowServer will
+ // send the event to the window, or activate it. It isn't enough just to wait
+ // for NSWindowDidBecomeKeyNotification after this method.
+ EXPECT_TRUE([window isKeyWindow])
+ << "ClickOnView() in an inactive window is not robust.";
NSView* view = view_id_util::GetView(window, vid);
DCHECK(view);
MoveMouseToNSViewCenterAndPress(
« no previous file with comments | « no previous file | chrome/test/base/interactive_test_utils_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698