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

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

Issue 2645253002: DesktopAura: Track windows "owned" via the DesktopWindowTreeHost (Closed)
Patch Set: simpler Created 3 years, 11 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_unittest.cc
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index 52845e5ed925fc9141065f1f52e2ac2e7a8ccfc2..f2345d96ad8917b14e5e796bdb0d900ade440187 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -3090,6 +3090,42 @@ TEST_F(WidgetChildDestructionTest, DestroyChildWidgetsInOrder) {
RunDestroyChildWidgetsTest(false, false);
}
+// Ensure that if a Widget is created with parent and is created using a
+// top-level Widget, then it is destroyed when the parent Widget goes away.
+TEST_F(WidgetTest, TopLevelChildWindowDestroyedWithParent) {
+ Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
+ params.bounds = gfx::Rect(100, 100, 100, 100);
+
+ Widget* parent_widget = new Widget(); // Owned by Native Widget.
+ bool parent_destroyed = false;
+ params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
+ params, parent_widget, &parent_destroyed);
+ parent_widget->Init(params);
+ parent_widget->Show();
+
+ Widget* child_widget = new Widget();
+ bool child_destroyed = false;
+ params.parent = parent_widget->GetNativeView();
+ params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
+ params, child_widget, &child_destroyed);
+ child_widget->Init(params);
+ child_widget->Show();
+
+ // |child_widget| is destroyed when |parent_widget| goes away, so it should be
+ // considered "owned".
+ std::set<Widget*> owned_widgets;
+ Widget::GetAllOwnedWidgets(parent_widget->GetNativeView(), &owned_widgets);
+ EXPECT_EQ(1u, owned_widgets.count(child_widget));
tapted 2017/01/23 10:52:55 This fails on desktop linux and windows (and mus)
+
+ // Trigger child destruction via a call to one of the following on the parent
+ // window: DesktopWindowTreeHostX11::CloseNow(), ::DestroyWindow(),
+ // DesktopWindowTreeHostMus::CloseNow(), or BridgedNativeWidget::
+ // OnWindowWillClose().
+ parent_widget->CloseNow();
+ EXPECT_TRUE(parent_destroyed);
+ EXPECT_TRUE(child_destroyed);
tapted 2017/01/23 10:52:55 This already passes - it's just to assert that the
+}
+
// Verifies nativeview visbility matches that of Widget visibility when
// SetFullscreen is invoked.
TEST_F(WidgetTest, FullscreenStatePropagated) {

Powered by Google App Engine
This is Rietveld 408576698