OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/test/ash_test_base.h" | 5 #include "ash/test/ash_test_base.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/common/test/test_session_state_delegate.h" | 10 #include "ash/common/test/test_session_state_delegate.h" |
11 #include "ash/common/test/test_system_tray_delegate.h" | 11 #include "ash/common/test/test_system_tray_delegate.h" |
12 #include "ash/common/wm/window_positioner.h" | 12 #include "ash/common/wm/window_positioner.h" |
13 #include "ash/common/wm_lookup.h" | |
13 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
14 #include "ash/common/wm_window.h" | 15 #include "ash/common/wm_window.h" |
15 #include "ash/display/extended_mouse_warp_controller.h" | 16 #include "ash/display/extended_mouse_warp_controller.h" |
16 #include "ash/display/mouse_cursor_event_filter.h" | 17 #include "ash/display/mouse_cursor_event_filter.h" |
17 #include "ash/display/unified_mouse_warp_controller.h" | 18 #include "ash/display/unified_mouse_warp_controller.h" |
18 #include "ash/display/window_tree_host_manager.h" | 19 #include "ash/display/window_tree_host_manager.h" |
19 #include "ash/ime/input_method_event_handler.h" | 20 #include "ash/ime/input_method_event_handler.h" |
20 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
21 #include "ash/shell.h" | 22 #include "ash/shell.h" |
22 #include "ash/shell/toplevel_window.h" | 23 #include "ash/shell/toplevel_window.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 : public aura::test::EventGeneratorDelegateAura { | 57 : public aura::test::EventGeneratorDelegateAura { |
57 public: | 58 public: |
58 AshEventGeneratorDelegate() {} | 59 AshEventGeneratorDelegate() {} |
59 ~AshEventGeneratorDelegate() override {} | 60 ~AshEventGeneratorDelegate() override {} |
60 | 61 |
61 // aura::test::EventGeneratorDelegateAura overrides: | 62 // aura::test::EventGeneratorDelegateAura overrides: |
62 aura::WindowTreeHost* GetHostAt( | 63 aura::WindowTreeHost* GetHostAt( |
63 const gfx::Point& point_in_screen) const override { | 64 const gfx::Point& point_in_screen) const override { |
64 display::Screen* screen = display::Screen::GetScreen(); | 65 display::Screen* screen = display::Screen::GetScreen(); |
65 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); | 66 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); |
66 return Shell::GetInstance() | 67 return WmShell::Get() |
67 ->window_tree_host_manager() | |
68 ->GetRootWindowForDisplayId(display.id()) | 68 ->GetRootWindowForDisplayId(display.id()) |
69 ->aura_window() | |
69 ->GetHost(); | 70 ->GetHost(); |
70 } | 71 } |
71 | 72 |
72 aura::client::ScreenPositionClient* GetScreenPositionClient( | 73 aura::client::ScreenPositionClient* GetScreenPositionClient( |
73 const aura::Window* window) const override { | 74 const aura::Window* window) const override { |
74 return aura::client::GetScreenPositionClient(window->GetRootWindow()); | 75 return aura::client::GetScreenPositionClient(window->GetRootWindow()); |
75 } | 76 } |
76 | 77 |
77 void DispatchKeyEventToIME(ui::EventTarget* target, | 78 void DispatchKeyEventToIME(ui::EventTarget* target, |
78 ui::KeyEvent* event) override { | 79 ui::KeyEvent* event) override { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 "1+1-800x600"); | 128 "1+1-800x600"); |
128 } | 129 } |
129 | 130 |
130 ash_test_helper_->SetUp(start_session_); | 131 ash_test_helper_->SetUp(start_session_); |
131 | 132 |
132 Shell::GetPrimaryRootWindow()->Show(); | 133 Shell::GetPrimaryRootWindow()->Show(); |
133 Shell::GetPrimaryRootWindow()->GetHost()->Show(); | 134 Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
134 // Move the mouse cursor to far away so that native events doesn't | 135 // Move the mouse cursor to far away so that native events doesn't |
135 // interfere test expectations. | 136 // interfere test expectations. |
136 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); | 137 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); |
137 Shell::GetInstance()->cursor_manager()->EnableMouseEvents(); | 138 if (!WmShell::Get()->IsRunningInMash()) |
msw
2017/02/19 21:49:20
nit: cite a bug? 637853?
sky
2017/02/21 17:06:50
Done.
| |
139 Shell::GetInstance()->cursor_manager()->EnableMouseEvents(); | |
138 | 140 |
139 // Changing GestureConfiguration shouldn't make tests fail. These values | 141 // Changing GestureConfiguration shouldn't make tests fail. These values |
140 // prevent unexpected events from being generated during tests. Such as | 142 // prevent unexpected events from being generated during tests. Such as |
141 // delayed events which create race conditions on slower tests. | 143 // delayed events which create race conditions on slower tests. |
142 ui::GestureConfiguration* gesture_config = | 144 ui::GestureConfiguration* gesture_config = |
143 ui::GestureConfiguration::GetInstance(); | 145 ui::GestureConfiguration::GetInstance(); |
144 gesture_config->set_max_touch_down_duration_for_click_in_ms(800); | 146 gesture_config->set_max_touch_down_duration_for_click_in_ms(800); |
145 gesture_config->set_long_press_time_in_ms(1000); | 147 gesture_config->set_long_press_time_in_ms(1000); |
146 gesture_config->set_max_touch_move_in_pixels_for_click(5); | 148 gesture_config->set_max_touch_move_in_pixels_for_click(5); |
147 } | 149 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 .GetActiveRotation(); | 191 .GetActiveRotation(); |
190 } | 192 } |
191 | 193 |
192 // static | 194 // static |
193 display::Display::Rotation AshTestBase::GetCurrentInternalDisplayRotation() { | 195 display::Display::Rotation AshTestBase::GetCurrentInternalDisplayRotation() { |
194 return GetActiveDisplayRotation(display::Display::InternalDisplayId()); | 196 return GetActiveDisplayRotation(display::Display::InternalDisplayId()); |
195 } | 197 } |
196 | 198 |
197 // static | 199 // static |
198 void AshTestBase::UpdateDisplay(const std::string& display_specs) { | 200 void AshTestBase::UpdateDisplay(const std::string& display_specs) { |
199 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | 201 if (WmShell::Get()->IsRunningInMash()) { |
200 .UpdateDisplay(display_specs); | 202 ash_test_helper_->UpdateDisplayForMash(display_specs); |
203 } else { | |
204 display::test::DisplayManagerTestApi( | |
205 Shell::GetInstance()->display_manager()) | |
206 .UpdateDisplay(display_specs); | |
207 } | |
201 } | 208 } |
202 | 209 |
203 aura::Window* AshTestBase::CurrentContext() { | 210 aura::Window* AshTestBase::CurrentContext() { |
204 return ash_test_helper_->CurrentContext(); | 211 return ash_test_helper_->CurrentContext(); |
205 } | 212 } |
206 | 213 |
207 // static | 214 // static |
208 std::unique_ptr<views::Widget> AshTestBase::CreateTestWidget( | 215 std::unique_ptr<views::Widget> AshTestBase::CreateTestWidget( |
209 views::WidgetDelegate* delegate, | 216 views::WidgetDelegate* delegate, |
210 int container_id, | 217 int container_id, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 window->set_id(id); | 264 window->set_id(id); |
258 window->SetType(type); | 265 window->SetType(type); |
259 window->Init(ui::LAYER_TEXTURED); | 266 window->Init(ui::LAYER_TEXTURED); |
260 window->Show(); | 267 window->Show(); |
261 | 268 |
262 if (bounds.IsEmpty()) { | 269 if (bounds.IsEmpty()) { |
263 ParentWindowInPrimaryRootWindow(window); | 270 ParentWindowInPrimaryRootWindow(window); |
264 } else { | 271 } else { |
265 display::Display display = | 272 display::Display display = |
266 display::Screen::GetScreen()->GetDisplayMatching(bounds); | 273 display::Screen::GetScreen()->GetDisplayMatching(bounds); |
267 aura::Window* root = Shell::GetInstance() | 274 aura::Window* root = |
268 ->window_tree_host_manager() | 275 WmLookup::Get() |
msw
2017/02/19 21:49:20
optional nit: avoid WmLookup via WmShell::GetRootW
sky
2017/02/21 17:06:50
Done.
| |
269 ->GetRootWindowForDisplayId(display.id()); | 276 ->GetRootWindowControllerWithDisplayId(display.id()) |
277 ->GetRootWindow(); | |
270 gfx::Point origin = bounds.origin(); | 278 gfx::Point origin = bounds.origin(); |
271 ::wm::ConvertPointFromScreen(root, &origin); | 279 ::wm::ConvertPointFromScreen(root, &origin); |
272 window->SetBounds(gfx::Rect(origin, bounds.size())); | 280 window->SetBounds(gfx::Rect(origin, bounds.size())); |
273 aura::client::ParentWindowWithContext(window, root, bounds); | 281 aura::client::ParentWindowWithContext(window, root, bounds); |
274 } | 282 } |
275 window->SetProperty(aura::client::kResizeBehaviorKey, | 283 window->SetProperty(aura::client::kResizeBehaviorKey, |
276 ui::mojom::kResizeBehaviorCanMaximize | | 284 ui::mojom::kResizeBehaviorCanMaximize | |
277 ui::mojom::kResizeBehaviorCanMinimize | | 285 ui::mojom::kResizeBehaviorCanMinimize | |
278 ui::mojom::kResizeBehaviorCanResize); | 286 ui::mojom::kResizeBehaviorCanResize); |
279 | 287 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 .id(); | 389 .id(); |
382 } | 390 } |
383 | 391 |
384 void AshTestBase::SwapPrimaryDisplay() { | 392 void AshTestBase::SwapPrimaryDisplay() { |
385 if (display::Screen::GetScreen()->GetNumDisplays() <= 1) | 393 if (display::Screen::GetScreen()->GetNumDisplays() <= 1) |
386 return; | 394 return; |
387 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( | 395 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( |
388 display_manager()->GetSecondaryDisplay().id()); | 396 display_manager()->GetSecondaryDisplay().id()); |
389 } | 397 } |
390 | 398 |
399 display::Display AshTestBase::GetSecondaryDisplay() { | |
400 return ash_test_helper_->GetSecondaryDisplay(); | |
401 } | |
402 | |
391 } // namespace test | 403 } // namespace test |
392 } // namespace ash | 404 } // namespace ash |
OLD | NEW |