OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "ui/views/test/widget_test.h" | 5 #include "ui/views/test/widget_test.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
| 12 #if defined(USE_AURA) |
| 13 #include "ui/aura/window.h" |
| 14 #endif |
| 15 |
12 namespace views { | 16 namespace views { |
13 namespace test { | 17 namespace test { |
14 namespace { | 18 namespace { |
15 | 19 |
16 // Insert |widget| into |expected| and ensure it's reported by GetAllWidgets(). | 20 // Insert |widget| into |expected| and ensure it's reported by GetAllWidgets(). |
17 void ExpectAdd(Widget::Widgets* expected, Widget* widget, const char* message) { | 21 void ExpectAdd(Widget::Widgets* expected, Widget* widget, const char* message) { |
18 SCOPED_TRACE(message); | 22 SCOPED_TRACE(message); |
19 EXPECT_TRUE(expected->insert(widget).second); | 23 EXPECT_TRUE(expected->insert(widget).second); |
20 Widget::Widgets actual = WidgetTest::GetAllWidgets(); | 24 Widget::Widgets actual = WidgetTest::GetAllWidgets(); |
21 EXPECT_EQ(expected->size(), actual.size()); | 25 EXPECT_EQ(expected->size(), actual.size()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 66 |
63 Widget* native_child = CreateChildNativeWidgetWithParent(native); | 67 Widget* native_child = CreateChildNativeWidgetWithParent(native); |
64 ExpectAdd(&expected, native_child, "native_child"); | 68 ExpectAdd(&expected, native_child, "native_child"); |
65 | 69 |
66 Widget* desktop = CreateNativeDesktopWidget(); | 70 Widget* desktop = CreateNativeDesktopWidget(); |
67 ExpectAdd(&expected, desktop, "desktop"); | 71 ExpectAdd(&expected, desktop, "desktop"); |
68 | 72 |
69 Widget* desktop_child = CreateChildNativeWidgetWithParent(desktop); | 73 Widget* desktop_child = CreateChildNativeWidgetWithParent(desktop); |
70 ExpectAdd(&expected, desktop_child, "desktop_child"); | 74 ExpectAdd(&expected, desktop_child, "desktop_child"); |
71 | 75 |
| 76 #if defined(USE_AURA) |
| 77 // A DesktopWindowTreeHost has both a root aura::Window and a content window. |
| 78 // DesktopWindowTreeHostX11::GetAllOpenWindows() returns content windows, so |
| 79 // ensure that a Widget parented to the root window is also found. |
| 80 Widget* desktop_cousin = |
| 81 CreateChildPlatformWidget(desktop->GetNativeView()->GetRootWindow()); |
| 82 ExpectAdd(&expected, desktop_cousin, "desktop_cousin"); |
| 83 ExpectClose(&expected, {desktop_cousin}, "desktop_cousin"); |
| 84 #endif // USE_AURA |
| 85 |
72 ExpectClose(&expected, {desktop, desktop_child}, "desktop"); | 86 ExpectClose(&expected, {desktop, desktop_child}, "desktop"); |
73 ExpectClose(&expected, {native, native_child}, "native"); | 87 ExpectClose(&expected, {native, native_child}, "native"); |
74 ExpectClose(&expected, {platform, platform_child}, "platform"); | 88 ExpectClose(&expected, {platform, platform_child}, "platform"); |
75 ExpectClose(&expected, {frameless}, "frameless"); | 89 ExpectClose(&expected, {frameless}, "frameless"); |
76 } | 90 } |
77 | 91 |
78 } // namespace views | 92 } // namespace views |
79 } // namespace test | 93 } // namespace test |
OLD | NEW |