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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <memory> 6 #include <memory>
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 3072 matching lines...) Expand 10 before | Expand all | Expand 10 after
3083 DestroyChildWidgetsInOrderWithDesktopNativeWidgetForBoth) { 3083 DestroyChildWidgetsInOrderWithDesktopNativeWidgetForBoth) {
3084 RunDestroyChildWidgetsTest(true, true); 3084 RunDestroyChildWidgetsTest(true, true);
3085 } 3085 }
3086 #endif // !defined(OS_CHROMEOS) 3086 #endif // !defined(OS_CHROMEOS)
3087 3087
3088 // See description of RunDestroyChildWidgetsTest(). 3088 // See description of RunDestroyChildWidgetsTest().
3089 TEST_F(WidgetChildDestructionTest, DestroyChildWidgetsInOrder) { 3089 TEST_F(WidgetChildDestructionTest, DestroyChildWidgetsInOrder) {
3090 RunDestroyChildWidgetsTest(false, false); 3090 RunDestroyChildWidgetsTest(false, false);
3091 } 3091 }
3092 3092
3093 // Ensure that if a Widget is created with parent and is created using a
3094 // top-level Widget, then it is destroyed when the parent Widget goes away.
3095 TEST_F(WidgetTest, TopLevelChildWindowDestroyedWithParent) {
3096 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
3097 params.bounds = gfx::Rect(100, 100, 100, 100);
3098
3099 Widget* parent_widget = new Widget(); // Owned by Native Widget.
3100 bool parent_destroyed = false;
3101 params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
3102 params, parent_widget, &parent_destroyed);
3103 parent_widget->Init(params);
3104 parent_widget->Show();
3105
3106 Widget* child_widget = new Widget();
3107 bool child_destroyed = false;
3108 params.parent = parent_widget->GetNativeView();
3109 params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
3110 params, child_widget, &child_destroyed);
3111 child_widget->Init(params);
3112 child_widget->Show();
3113
3114 // |child_widget| is destroyed when |parent_widget| goes away, so it should be
3115 // considered "owned".
3116 std::set<Widget*> owned_widgets;
3117 Widget::GetAllOwnedWidgets(parent_widget->GetNativeView(), &owned_widgets);
3118 EXPECT_EQ(1u, owned_widgets.count(child_widget));
tapted 2017/01/23 10:52:55 This fails on desktop linux and windows (and mus)
3119
3120 // Trigger child destruction via a call to one of the following on the parent
3121 // window: DesktopWindowTreeHostX11::CloseNow(), ::DestroyWindow(),
3122 // DesktopWindowTreeHostMus::CloseNow(), or BridgedNativeWidget::
3123 // OnWindowWillClose().
3124 parent_widget->CloseNow();
3125 EXPECT_TRUE(parent_destroyed);
3126 EXPECT_TRUE(child_destroyed);
tapted 2017/01/23 10:52:55 This already passes - it's just to assert that the
3127 }
3128
3093 // Verifies nativeview visbility matches that of Widget visibility when 3129 // Verifies nativeview visbility matches that of Widget visibility when
3094 // SetFullscreen is invoked. 3130 // SetFullscreen is invoked.
3095 TEST_F(WidgetTest, FullscreenStatePropagated) { 3131 TEST_F(WidgetTest, FullscreenStatePropagated) {
3096 Widget::InitParams init_params = 3132 Widget::InitParams init_params =
3097 CreateParams(Widget::InitParams::TYPE_WINDOW); 3133 CreateParams(Widget::InitParams::TYPE_WINDOW);
3098 init_params.show_state = ui::SHOW_STATE_NORMAL; 3134 init_params.show_state = ui::SHOW_STATE_NORMAL;
3099 init_params.bounds = gfx::Rect(0, 0, 500, 500); 3135 init_params.bounds = gfx::Rect(0, 0, 500, 500);
3100 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 3136 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
3101 3137
3102 Widget top_level_widget; 3138 Widget top_level_widget;
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
3872 } 3908 }
3873 3909
3874 TEST_F(CompositingWidgetTest, Transparency_DesktopWidgetTranslucent) { 3910 TEST_F(CompositingWidgetTest, Transparency_DesktopWidgetTranslucent) {
3875 CheckAllWidgetsForOpacity(Widget::InitParams::TRANSLUCENT_WINDOW); 3911 CheckAllWidgetsForOpacity(Widget::InitParams::TRANSLUCENT_WINDOW);
3876 } 3912 }
3877 3913
3878 #endif // !defined(OS_CHROMEOS) 3914 #endif // !defined(OS_CHROMEOS)
3879 3915
3880 } // namespace test 3916 } // namespace test
3881 } // namespace views 3917 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698