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

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

Issue 2924873007: Don't activate aura::Window on creation from DesktopNativeWidgetAura if NativeWidgetDelegate prohib… (Closed)
Patch Set: Comment Created 3 years, 6 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/desktop_aura/desktop_native_widget_aura.cc ('k') | no next file » | 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 "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 "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "ui/aura/client/aura_constants.h" 13 #include "ui/aura/client/aura_constants.h"
14 #include "ui/aura/client/cursor_client.h" 14 #include "ui/aura/client/cursor_client.h"
15 #include "ui/aura/client/focus_client.h"
15 #include "ui/aura/client/window_parenting_client.h" 16 #include "ui/aura/client/window_parenting_client.h"
16 #include "ui/aura/test/test_window_delegate.h" 17 #include "ui/aura/test/test_window_delegate.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/aura/window_tree_host.h" 19 #include "ui/aura/window_tree_host.h"
19 #include "ui/display/screen.h" 20 #include "ui/display/screen.h"
20 #include "ui/events/event_processor.h" 21 #include "ui/events/event_processor.h"
21 #include "ui/events/event_utils.h" 22 #include "ui/events/event_utils.h"
22 #include "ui/events/test/event_generator.h" 23 #include "ui/events/test/event_generator.h"
23 #include "ui/views/test/native_widget_factory.h" 24 #include "ui/views/test/native_widget_factory.h"
24 #include "ui/views/test/test_views.h" 25 #include "ui/views/test/test_views.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 TEST_F(DesktopNativeWidgetAuraTest, NativeViewInitiallyHidden) { 97 TEST_F(DesktopNativeWidgetAuraTest, NativeViewInitiallyHidden) {
97 Widget widget; 98 Widget widget;
98 Widget::InitParams init_params = 99 Widget::InitParams init_params =
99 CreateParams(Widget::InitParams::TYPE_WINDOW); 100 CreateParams(Widget::InitParams::TYPE_WINDOW);
100 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 101 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
101 init_params.native_widget = new DesktopNativeWidgetAura(&widget); 102 init_params.native_widget = new DesktopNativeWidgetAura(&widget);
102 widget.Init(init_params); 103 widget.Init(init_params);
103 EXPECT_FALSE(widget.GetNativeView()->IsVisible()); 104 EXPECT_FALSE(widget.GetNativeView()->IsVisible());
104 } 105 }
105 106
107 // Verifies that the native view isn't activated if Widget requires that.
108 TEST_F(DesktopNativeWidgetAuraTest, NativeViewNoActivate) {
109 // Widget of TYPE_POPUP can't be activated.
110 Widget widget;
111 Widget::InitParams init_params = CreateParams(Widget::InitParams::TYPE_POPUP);
112 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
113 DesktopNativeWidgetAura* widget_aura = new DesktopNativeWidgetAura(&widget);
114 init_params.native_widget = widget_aura;
115 widget.Init(init_params);
116
117 EXPECT_FALSE(widget.CanActivate());
118 EXPECT_EQ(nullptr, aura::client::GetFocusClient(widget_aura->content_window())
119 ->GetFocusedWindow());
120 }
121
106 // Verifies that if the DesktopWindowTreeHost is already shown, the native view 122 // Verifies that if the DesktopWindowTreeHost is already shown, the native view
107 // still reports not visible as we haven't shown the content window. 123 // still reports not visible as we haven't shown the content window.
108 TEST_F(DesktopNativeWidgetAuraTest, WidgetNotVisibleOnlyWindowTreeHostShown) { 124 TEST_F(DesktopNativeWidgetAuraTest, WidgetNotVisibleOnlyWindowTreeHostShown) {
109 Widget widget; 125 Widget widget;
110 Widget::InitParams init_params = 126 Widget::InitParams init_params =
111 CreateParams(Widget::InitParams::TYPE_WINDOW); 127 CreateParams(Widget::InitParams::TYPE_WINDOW);
112 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 128 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
113 init_params.native_widget = new DesktopNativeWidgetAura(&widget); 129 init_params.native_widget = new DesktopNativeWidgetAura(&widget);
114 widget.Init(init_params); 130 widget.Init(init_params);
115 DesktopNativeWidgetAura* desktop_native_widget_aura = 131 DesktopNativeWidgetAura* desktop_native_widget_aura =
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 target->HandleKeyboardMessage(WM_CHAR, 0, 0, &handled); 693 target->HandleKeyboardMessage(WM_CHAR, 0, 0, &handled);
678 target->HandleKeyboardMessage(WM_SYSCHAR, 0, 0, &handled); 694 target->HandleKeyboardMessage(WM_SYSCHAR, 0, 0, &handled);
679 target->HandleKeyboardMessage(WM_SYSDEADCHAR, 0, 0, &handled); 695 target->HandleKeyboardMessage(WM_SYSDEADCHAR, 0, 0, &handled);
680 widget.CloseNow(); 696 widget.CloseNow();
681 } 697 }
682 698
683 #endif // defined(OS_WIN) 699 #endif // defined(OS_WIN)
684 700
685 } // namespace test 701 } // namespace test
686 } // namespace views 702 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698