OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |