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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_native_widget_aura_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
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 "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 22 matching lines...) Expand all
33 #endif 33 #endif
34 34
35 namespace views { 35 namespace views {
36 namespace test { 36 namespace test {
37 37
38 typedef ViewsTestBase DesktopNativeWidgetAuraTest; 38 typedef ViewsTestBase DesktopNativeWidgetAuraTest;
39 39
40 // Verifies creating a Widget with a parent that is not in a RootWindow doesn't 40 // Verifies creating a Widget with a parent that is not in a RootWindow doesn't
41 // crash. 41 // crash.
42 TEST_F(DesktopNativeWidgetAuraTest, CreateWithParentNotInRootWindow) { 42 TEST_F(DesktopNativeWidgetAuraTest, CreateWithParentNotInRootWindow) {
43 scoped_ptr<aura::Window> window(new aura::Window(NULL)); 43 std::unique_ptr<aura::Window> window(new aura::Window(NULL));
44 window->Init(ui::LAYER_NOT_DRAWN); 44 window->Init(ui::LAYER_NOT_DRAWN);
45 Widget widget; 45 Widget widget;
46 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); 46 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
47 params.bounds = gfx::Rect(0, 0, 200, 200); 47 params.bounds = gfx::Rect(0, 0, 200, 200);
48 params.parent = window.get(); 48 params.parent = window.get();
49 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 49 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
50 params.native_widget = new DesktopNativeWidgetAura(&widget); 50 params.native_widget = new DesktopNativeWidgetAura(&widget);
51 widget.Init(params); 51 widget.Init(params);
52 } 52 }
53 53
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // Owned by |widget|. 212 // Owned by |widget|.
213 aura::Window* window = new aura::Window(&delegate); 213 aura::Window* window = new aura::Window(&delegate);
214 window->Init(ui::LAYER_NOT_DRAWN); 214 window->Init(ui::LAYER_NOT_DRAWN);
215 window->Show(); 215 window->Show();
216 widget.GetNativeWindow()->parent()->AddChild(window); 216 widget.GetNativeWindow()->parent()->AddChild(window);
217 217
218 widget.Show(); 218 widget.Show();
219 } 219 }
220 } 220 }
221 221
222 void QuitNestedLoopAndCloseWidget(scoped_ptr<Widget> widget, 222 void QuitNestedLoopAndCloseWidget(std::unique_ptr<Widget> widget,
223 base::Closure* quit_runloop) { 223 base::Closure* quit_runloop) {
224 quit_runloop->Run(); 224 quit_runloop->Run();
225 } 225 }
226 226
227 // Verifies that a widget can be destroyed when running a nested message-loop. 227 // Verifies that a widget can be destroyed when running a nested message-loop.
228 TEST_F(DesktopNativeWidgetAuraTest, WidgetCanBeDestroyedFromNestedLoop) { 228 TEST_F(DesktopNativeWidgetAuraTest, WidgetCanBeDestroyedFromNestedLoop) {
229 scoped_ptr<Widget> widget(new Widget); 229 std::unique_ptr<Widget> widget(new Widget);
230 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); 230 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
231 params.bounds = gfx::Rect(0, 0, 200, 200); 231 params.bounds = gfx::Rect(0, 0, 200, 200);
232 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 232 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
233 params.native_widget = new DesktopNativeWidgetAura(widget.get()); 233 params.native_widget = new DesktopNativeWidgetAura(widget.get());
234 widget->Init(params); 234 widget->Init(params);
235 widget->Show(); 235 widget->Show();
236 236
237 // Post a task that terminates the nested loop and destroyes the widget. This 237 // Post a task that terminates the nested loop and destroyes the widget. This
238 // task will be executed from the nested loop initiated with the call to 238 // task will be executed from the nested loop initiated with the call to
239 // |RunWithDispatcher()| below. 239 // |RunWithDispatcher()| below.
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 target->HandleKeyboardMessage(WM_CHAR, 0, 0, &handled); 652 target->HandleKeyboardMessage(WM_CHAR, 0, 0, &handled);
653 target->HandleKeyboardMessage(WM_SYSCHAR, 0, 0, &handled); 653 target->HandleKeyboardMessage(WM_SYSCHAR, 0, 0, &handled);
654 target->HandleKeyboardMessage(WM_SYSDEADCHAR, 0, 0, &handled); 654 target->HandleKeyboardMessage(WM_SYSDEADCHAR, 0, 0, &handled);
655 widget.CloseNow(); 655 widget.CloseNow();
656 } 656 }
657 657
658 #endif // defined(OS_WIN) 658 #endif // defined(OS_WIN)
659 659
660 } // namespace test 660 } // namespace test
661 } // namespace views 661 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.cc ('k') | ui/views/widget/desktop_aura/desktop_screen_x11.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698