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

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: Fix test on CrOS Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 148f811741388d08426ccda87dd005dd9851b961..033c6d5da077b8c3b7e006d81326d00fccae63ff 100644
--- a/ui/views/widget/widget_interactive_uitest.cc
+++ b/ui/views/widget/widget_interactive_uitest.cc
@@ -930,6 +930,54 @@ TEST_F(WidgetCaptureTest, MouseExitOnCaptureGrab) {
}
#endif
+namespace {
+
+// Widget observer which grabs capture when the widget is activated.
+class CaptureOnActivationObserver : public WidgetObserver {
+ public:
+ CaptureOnActivationObserver() {
+ }
+ virtual ~CaptureOnActivationObserver() {
+ }
+
+ // WidgetObserver:
+ virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE {
+ if (active)
+ widget->SetCapture(NULL);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CaptureOnActivationObserver);
+};
+
+} // namespace
+
+// 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 = CreateNativeWidget(true, &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());
+}
+
+
#if defined(OS_WIN)
namespace {
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698