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

Unified Diff: ui/views/widget/widget_interactive_uitest.cc

Issue 789763002: MacViews: Implement capture using NSEvent local+global monitors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20140812-MacViews-LAYERS2-PRESQUASH
Patch Set: selfnits Created 6 years 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
Index: ui/views/widget/widget_interactive_uitest.cc
diff --git a/ui/views/widget/widget_interactive_uitest.cc b/ui/views/widget/widget_interactive_uitest.cc
index c37236e427ce7cb05f14b3bcf70e49b984a93b64..adb99aebab58a0a1a2f69bacd85b4e3cc7719002 100644
--- a/ui/views/widget/widget_interactive_uitest.cc
+++ b/ui/views/widget/widget_interactive_uitest.cc
@@ -990,10 +990,11 @@ TEST_F(WidgetCaptureTest, FailedCaptureRequestIsNoop) {
EXPECT_TRUE(mouse_view2->pressed());
}
-#if !defined(OS_CHROMEOS) && !defined(OS_WIN)
+#if !defined(OS_CHROMEOS) && !defined(OS_WIN) && !defined(OS_MACOSX)
// Test that a synthetic mouse exit is sent to the widget which was handling
// mouse events when a different widget grabs capture.
// TODO(pkotwicz): Make test pass on CrOS and Windows.
+// TODO(tapted): Investigate for toolkit-views on Mac http;//crbug.com/441064.
TEST_F(WidgetCaptureTest, MouseExitOnCaptureGrab) {
Widget widget1;
Widget::InitParams params1 =
@@ -1015,7 +1016,7 @@ TEST_F(WidgetCaptureTest, MouseExitOnCaptureGrab) {
widget2.Show();
widget2.SetBounds(gfx::Rect(400, 0, 300, 300));
- ui::test::EventGenerator generator(widget1.GetNativeWindow());
+ ui::test::EventGenerator generator(GetContext(), widget1.GetNativeWindow());
generator.set_current_location(gfx::Point(100, 100));
generator.MoveMouseBy(0, 0);
@@ -1035,17 +1036,22 @@ namespace {
// Widget observer which grabs capture when the widget is activated.
class CaptureOnActivationObserver : public WidgetObserver {
public:
- CaptureOnActivationObserver() {
- }
+ CaptureOnActivationObserver() : activation_observed_(false) {}
~CaptureOnActivationObserver() override {}
// WidgetObserver:
void OnWidgetActivationChanged(Widget* widget, bool active) override {
- if (active)
- widget->SetCapture(NULL);
+ if (active) {
+ widget->SetCapture(nullptr);
+ activation_observed_ = true;
+ }
}
+ bool activation_observed() const { return activation_observed_; }
+
private:
+ bool activation_observed_;
+
DISALLOW_COPY_AND_ASSIGN(CaptureOnActivationObserver);
};
@@ -1073,6 +1079,15 @@ TEST_F(WidgetCaptureTest, SetCaptureToNonToplevel) {
child->AddObserver(&observer);
child->Show();
+#if defined(OS_MACOSX) && !defined(USE_AURA)
+ // On Mac, activation is asynchronous. A single trip to the runloop should be
+ // sufficient. On Aura platforms, note that since the child widget isn't top-
+ // level, the aura window manager gets asked whether the widget is active, not
+ // the OS.
+ base::RunLoop().RunUntilIdle();
+#endif
+
+ EXPECT_TRUE(observer.activation_observed());
EXPECT_TRUE(child->HasCapture());
}

Powered by Google App Engine
This is Rietveld 408576698