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

Side by Side Diff: ui/views/widget/window_reorderer_unittest.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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
« no previous file with comments | « ui/views/widget/window_reorderer.h ('k') | ui/views/win/fullscreen_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <memory>
6
5 #include "ui/aura/test/aura_test_base.h" 7 #include "ui/aura/test/aura_test_base.h"
6 #include "ui/aura/test/test_windows.h" 8 #include "ui/aura/test/test_windows.h"
7 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
8 #include "ui/aura/window_event_dispatcher.h" 10 #include "ui/aura/window_event_dispatcher.h"
9 #include "ui/compositor/layer.h" 11 #include "ui/compositor/layer.h"
10 #include "ui/compositor/test/test_layers.h" 12 #include "ui/compositor/test/test_layers.h"
11 #include "ui/views/view.h" 13 #include "ui/views/view.h"
12 #include "ui/views/view_constants_aura.h" 14 #include "ui/views/view_constants_aura.h"
13 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
14 16
(...skipping 30 matching lines...) Expand all
45 names += (*it)->name(); 47 names += (*it)->name();
46 } 48 }
47 return names; 49 return names;
48 } 50 }
49 51
50 typedef aura::test::AuraTestBase WindowReordererTest; 52 typedef aura::test::AuraTestBase WindowReordererTest;
51 53
52 // Test that views with layers and views with associated windows are reordered 54 // Test that views with layers and views with associated windows are reordered
53 // according to the view hierarchy. 55 // according to the view hierarchy.
54 TEST_F(WindowReordererTest, Basic) { 56 TEST_F(WindowReordererTest, Basic) {
55 scoped_ptr<Widget> parent(CreateControlWidget(root_window(), 57 std::unique_ptr<Widget> parent(
56 gfx::Rect(0, 0, 100, 100))); 58 CreateControlWidget(root_window(), gfx::Rect(0, 0, 100, 100)));
57 parent->Show(); 59 parent->Show();
58 aura::Window* parent_window = parent->GetNativeWindow(); 60 aura::Window* parent_window = parent->GetNativeWindow();
59 61
60 View* contents_view = new View(); 62 View* contents_view = new View();
61 parent->SetContentsView(contents_view); 63 parent->SetContentsView(contents_view);
62 64
63 // 1) Test that layers for views and layers for windows associated to a host 65 // 1) Test that layers for views and layers for windows associated to a host
64 // view are stacked below the layers for any windows not associated to a host 66 // view are stacked below the layers for any windows not associated to a host
65 // view. 67 // view.
66 View* v = new View(); 68 View* v = new View();
67 v->SetPaintToLayer(true); 69 v->SetPaintToLayer(true);
68 v->layer()->set_name("v"); 70 v->layer()->set_name("v");
69 contents_view->AddChildView(v); 71 contents_view->AddChildView(v);
70 72
71 scoped_ptr<Widget> w1(CreateControlWidget(parent_window, 73 std::unique_ptr<Widget> w1(
72 gfx::Rect(0, 1, 100, 101))); 74 CreateControlWidget(parent_window, gfx::Rect(0, 1, 100, 101)));
73 SetWindowAndLayerName(w1->GetNativeView(), "w1"); 75 SetWindowAndLayerName(w1->GetNativeView(), "w1");
74 w1->Show(); 76 w1->Show();
75 scoped_ptr<Widget> w2(CreateControlWidget(parent_window, 77 std::unique_ptr<Widget> w2(
76 gfx::Rect(0, 2, 100, 102))); 78 CreateControlWidget(parent_window, gfx::Rect(0, 2, 100, 102)));
77 SetWindowAndLayerName(w2->GetNativeView(), "w2"); 79 SetWindowAndLayerName(w2->GetNativeView(), "w2");
78 w2->Show(); 80 w2->Show();
79 81
80 EXPECT_EQ("w1 w2", ChildWindowNamesAsString(*parent_window)); 82 EXPECT_EQ("w1 w2", ChildWindowNamesAsString(*parent_window));
81 EXPECT_EQ("v w1 w2", 83 EXPECT_EQ("v w1 w2",
82 ui::test::ChildLayerNamesAsString(*parent_window->layer())); 84 ui::test::ChildLayerNamesAsString(*parent_window->layer()));
83 85
84 View* host_view2 = new View(); 86 View* host_view2 = new View();
85 contents_view->AddChildView(host_view2); 87 contents_view->AddChildView(host_view2);
86 w2->GetNativeView()->SetProperty(kHostViewKey, host_view2); 88 w2->GetNativeView()->SetProperty(kHostViewKey, host_view2);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // TODO: fix bug and remove this. 125 // TODO: fix bug and remove this.
124 parent->Close(); 126 parent->Close();
125 } 127 }
126 128
127 // Test that different orderings of: 129 // Test that different orderings of:
128 // - adding a window to a parent widget 130 // - adding a window to a parent widget
129 // - adding a "host" view to a parent widget 131 // - adding a "host" view to a parent widget
130 // - associating the "host" view and window 132 // - associating the "host" view and window
131 // all correctly reorder the child windows and layers. 133 // all correctly reorder the child windows and layers.
132 TEST_F(WindowReordererTest, Association) { 134 TEST_F(WindowReordererTest, Association) {
133 scoped_ptr<Widget> parent(CreateControlWidget(root_window(), 135 std::unique_ptr<Widget> parent(
134 gfx::Rect(0, 0, 100, 100))); 136 CreateControlWidget(root_window(), gfx::Rect(0, 0, 100, 100)));
135 parent->Show(); 137 parent->Show();
136 aura::Window* parent_window = parent->GetNativeWindow(); 138 aura::Window* parent_window = parent->GetNativeWindow();
137 139
138 View* contents_view = new View(); 140 View* contents_view = new View();
139 parent->SetContentsView(contents_view); 141 parent->SetContentsView(contents_view);
140 142
141 aura::Window* w1 = aura::test::CreateTestWindowWithId(0, 143 aura::Window* w1 = aura::test::CreateTestWindowWithId(0,
142 parent->GetNativeWindow()); 144 parent->GetNativeWindow());
143 SetWindowAndLayerName(w1, "w1"); 145 SetWindowAndLayerName(w1, "w1");
144 146
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // Work around for bug in NativeWidgetAura. 186 // Work around for bug in NativeWidgetAura.
185 // TODO: fix bug and remove this. 187 // TODO: fix bug and remove this.
186 parent->Close(); 188 parent->Close();
187 } 189 }
188 190
189 // It is possible to associate a window to a view which has a parent layer 191 // It is possible to associate a window to a view which has a parent layer
190 // (other than the widget layer). In this case, the parent layer of the host 192 // (other than the widget layer). In this case, the parent layer of the host
191 // view and the parent layer of the associated window are different. Test that 193 // view and the parent layer of the associated window are different. Test that
192 // the layers and windows are properly reordered in this case. 194 // the layers and windows are properly reordered in this case.
193 TEST_F(WindowReordererTest, HostViewParentHasLayer) { 195 TEST_F(WindowReordererTest, HostViewParentHasLayer) {
194 scoped_ptr<Widget> parent(CreateControlWidget(root_window(), 196 std::unique_ptr<Widget> parent(
195 gfx::Rect(0, 0, 100, 100))); 197 CreateControlWidget(root_window(), gfx::Rect(0, 0, 100, 100)));
196 parent->Show(); 198 parent->Show();
197 aura::Window* parent_window = parent->GetNativeWindow(); 199 aura::Window* parent_window = parent->GetNativeWindow();
198 200
199 View* contents_view = new View(); 201 View* contents_view = new View();
200 parent->SetContentsView(contents_view); 202 parent->SetContentsView(contents_view);
201 203
202 // Create the following view hierarchy. (*) denotes views which paint to a 204 // Create the following view hierarchy. (*) denotes views which paint to a
203 // layer. 205 // layer.
204 // 206 //
205 // contents_view 207 // contents_view
206 // +-- v1 208 // +-- v1
207 // +-- v11* 209 // +-- v11*
208 // +-- v12 (attached window) 210 // +-- v12 (attached window)
209 // +-- v13* 211 // +-- v13*
210 // +--v2* 212 // +--v2*
211 213
212 View* v1 = new View(); 214 View* v1 = new View();
213 contents_view->AddChildView(v1); 215 contents_view->AddChildView(v1);
214 216
215 View* v11 = new View(); 217 View* v11 = new View();
216 v11->SetPaintToLayer(true); 218 v11->SetPaintToLayer(true);
217 v11->layer()->set_name("v11"); 219 v11->layer()->set_name("v11");
218 v1->AddChildView(v11); 220 v1->AddChildView(v11);
219 221
220 scoped_ptr<Widget> w(CreateControlWidget(parent_window, 222 std::unique_ptr<Widget> w(
221 gfx::Rect(0, 1, 100, 101))); 223 CreateControlWidget(parent_window, gfx::Rect(0, 1, 100, 101)));
222 SetWindowAndLayerName(w->GetNativeView(), "w"); 224 SetWindowAndLayerName(w->GetNativeView(), "w");
223 w->Show(); 225 w->Show();
224 226
225 View* v12 = new View(); 227 View* v12 = new View();
226 v1->AddChildView(v12); 228 v1->AddChildView(v12);
227 w->GetNativeView()->SetProperty(kHostViewKey, v12); 229 w->GetNativeView()->SetProperty(kHostViewKey, v12);
228 230
229 View* v13 = new View(); 231 View* v13 = new View();
230 v13->SetPaintToLayer(true); 232 v13->SetPaintToLayer(true);
231 v13->layer()->set_name("v13"); 233 v13->layer()->set_name("v13");
(...skipping 22 matching lines...) Expand all
254 EXPECT_EQ("v1 v2 w", 256 EXPECT_EQ("v1 v2 w",
255 ui::test::ChildLayerNamesAsString(*parent_window->layer())); 257 ui::test::ChildLayerNamesAsString(*parent_window->layer()));
256 258
257 // Work around for bug in NativeWidgetAura. 259 // Work around for bug in NativeWidgetAura.
258 // TODO: fix bug and remove this. 260 // TODO: fix bug and remove this.
259 parent->Close(); 261 parent->Close();
260 } 262 }
261 263
262 } // namespace 264 } // namespace
263 } // namespace views 265 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/window_reorderer.h ('k') | ui/views/win/fullscreen_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698