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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc

Issue 1647933002: ash/wm: Remove dead code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 10 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 "build/build_config.h" 10 #include "build/build_config.h"
10 #include "ui/aura/client/aura_constants.h" 11 #include "ui/aura/client/aura_constants.h"
11 #include "ui/aura/client/cursor_client.h" 12 #include "ui/aura/client/cursor_client.h"
12 #include "ui/aura/client/window_tree_client.h" 13 #include "ui/aura/client/window_tree_client.h"
13 #include "ui/aura/test/test_window_delegate.h" 14 #include "ui/aura/test/test_window_delegate.h"
14 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
15 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
16 #include "ui/events/event_processor.h" 17 #include "ui/events/event_processor.h"
17 #include "ui/events/event_utils.h" 18 #include "ui/events/event_utils.h"
18 #include "ui/events/test/event_generator.h" 19 #include "ui/events/test/event_generator.h"
19 #include "ui/gfx/screen.h" 20 #include "ui/gfx/screen.h"
20 #include "ui/views/test/test_views.h" 21 #include "ui/views/test/test_views.h"
21 #include "ui/views/test/test_views_delegate.h" 22 #include "ui/views/test/test_views_delegate.h"
22 #include "ui/views/test/views_test_base.h" 23 #include "ui/views/test/views_test_base.h"
23 #include "ui/views/test/widget_test.h" 24 #include "ui/views/test/widget_test.h"
24 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
25 #include "ui/views/window/dialog_delegate.h" 26 #include "ui/views/window/dialog_delegate.h"
26 #include "ui/wm/public/dispatcher_client.h"
27 27
28 #if defined(OS_WIN) 28 #if defined(OS_WIN)
29 #include "ui/views/win/hwnd_util.h" 29 #include "ui/views/win/hwnd_util.h"
30 #endif 30 #endif
31 31
32 namespace views { 32 namespace views {
33 namespace test { 33 namespace test {
34 34
35 typedef ViewsTestBase DesktopNativeWidgetAuraTest; 35 typedef ViewsTestBase DesktopNativeWidgetAuraTest;
36 36
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // Verifies that a widget can be destroyed when running a nested message-loop. 224 // Verifies that a widget can be destroyed when running a nested message-loop.
225 TEST_F(DesktopNativeWidgetAuraTest, WidgetCanBeDestroyedFromNestedLoop) { 225 TEST_F(DesktopNativeWidgetAuraTest, WidgetCanBeDestroyedFromNestedLoop) {
226 scoped_ptr<Widget> widget(new Widget); 226 scoped_ptr<Widget> widget(new Widget);
227 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); 227 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
228 params.bounds = gfx::Rect(0, 0, 200, 200); 228 params.bounds = gfx::Rect(0, 0, 200, 200);
229 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 229 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
230 params.native_widget = new DesktopNativeWidgetAura(widget.get()); 230 params.native_widget = new DesktopNativeWidgetAura(widget.get());
231 widget->Init(params); 231 widget->Init(params);
232 widget->Show(); 232 widget->Show();
233 233
234 aura::Window* window = widget->GetNativeView();
235 aura::Window* root = window->GetRootWindow();
236 aura::client::DispatcherClient* client =
237 aura::client::GetDispatcherClient(root);
238
239 // Post a task that terminates the nested loop and destroyes the widget. This 234 // Post a task that terminates the nested loop and destroyes the widget. This
240 // task will be executed from the nested loop initiated with the call to 235 // task will be executed from the nested loop initiated with the call to
241 // |RunWithDispatcher()| below. 236 // |RunWithDispatcher()| below.
242 aura::client::DispatcherRunLoop run_loop(client, NULL); 237 base::RunLoop run_loop;
243 base::Closure quit_runloop = run_loop.QuitClosure(); 238 base::Closure quit_runloop = run_loop.QuitClosure();
244 message_loop()->PostTask(FROM_HERE, 239 message_loop()->PostTask(FROM_HERE,
245 base::Bind(&QuitNestedLoopAndCloseWidget, 240 base::Bind(&QuitNestedLoopAndCloseWidget,
246 base::Passed(&widget), 241 base::Passed(&widget),
247 base::Unretained(&quit_runloop))); 242 base::Unretained(&quit_runloop)));
248 run_loop.Run(); 243 run_loop.Run();
249 } 244 }
250 245
251 // This class provides functionality to create fullscreen and top level popup 246 // This class provides functionality to create fullscreen and top level popup
252 // windows. It additionally tests whether the destruction of these windows 247 // windows. It additionally tests whether the destruction of these windows
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 reinterpret_cast<WPARAM>(win32_window), 622 reinterpret_cast<WPARAM>(win32_window),
628 MAKELPARAM(WM_LBUTTONDOWN, HTCLIENT)); 623 MAKELPARAM(WM_LBUTTONDOWN, HTCLIENT));
629 EXPECT_EQ(activate_result, MA_ACTIVATE); 624 EXPECT_EQ(activate_result, MA_ACTIVATE);
630 625
631 modal_dialog_widget->CloseNow(); 626 modal_dialog_widget->CloseNow();
632 } 627 }
633 #endif // defined(OS_WIN) 628 #endif // defined(OS_WIN)
634 629
635 } // namespace test 630 } // namespace test
636 } // namespace views 631 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698