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

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

Issue 334933008: Enable setting capture to a non-toplevel widget when the widget is activated on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
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 c7f9a4a19d0365fe5102207b604cabcb24d1fad1..6497d1e82394bfb9b7e827ab07db4a85c2d69e76 100644
--- a/ui/views/widget/widget_interactive_uitest.cc
+++ b/ui/views/widget/widget_interactive_uitest.cc
@@ -1004,6 +1004,48 @@ TEST_F(WidgetCaptureTest, MAYBE_MouseEventDispatchedToRightWindow) {
EXPECT_TRUE(widget1.GetAndClearGotMouseEvent());
EXPECT_FALSE(widget2.GetAndClearGotMouseEvent());
}
+
+// Widget observer which grabs capture when the widget is activated.
+class CaptureOnActivationObserver : public WidgetObserver {
+ public:
+ CaptureOnActivationObserver() {
+ }
+ virtual ~CaptureOnActivationObserver() {
+ }
+
+ virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE {
sadrul 2014/07/14 16:58:00 // WidgetObserver:
+ if (active)
+ widget->SetCapture(NULL);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CaptureOnActivationObserver);
+};
+
+// Test that setting capture on widget activation of a non-toplevel widget
+// (e.g. a bubble on Linux) succeeds.
+TEST_F(WidgetCaptureTest, SetCaptureToNonToplevel) {
+ Widget toplevel;
+ Widget::InitParams toplevel_params =
+ CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ toplevel_params.native_widget = new DesktopNativeWidgetAura(&toplevel);
+ toplevel_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ toplevel.Init(toplevel_params);
+ toplevel.Show();
+
+ Widget* child = new Widget;
+ Widget::InitParams child_params =
+ CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+ child_params.parent = toplevel.GetNativeView();
+ child_params.context = toplevel.GetNativeView();
+ child->Init(child_params);
+
+ CaptureOnActivationObserver observer;
+ child->AddObserver(&observer);
+ child->Show();
+
+ EXPECT_TRUE(child->HasCapture());
+}
#endif
} // namespace test

Powered by Google App Engine
This is Rietveld 408576698