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/wm/window_positioner.h" | 10 #include "ash/common/wm/window_positioner.h" |
11 #include "ash/common/wm_root_window_controller.h" | 11 #include "ash/common/wm_root_window_controller.h" |
12 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
13 #include "ash/common/wm_window.h" | 13 #include "ash/common/wm_window.h" |
| 14 #include "ash/display/extended_mouse_warp_controller.h" |
| 15 #include "ash/display/mouse_cursor_event_filter.h" |
| 16 #include "ash/display/unified_mouse_warp_controller.h" |
14 #include "ash/display/window_tree_host_manager.h" | 17 #include "ash/display/window_tree_host_manager.h" |
15 #include "ash/ime/input_method_event_handler.h" | 18 #include "ash/ime/input_method_event_handler.h" |
16 #include "ash/shell.h" | 19 #include "ash/shell.h" |
17 #include "ash/shell/toplevel_window.h" | 20 #include "ash/shell/toplevel_window.h" |
18 #include "ash/test/ash_test_environment.h" | 21 #include "ash/test/ash_test_environment.h" |
19 #include "ash/test/ash_test_helper.h" | 22 #include "ash/test/ash_test_helper.h" |
20 #include "ash/test/display_manager_test_api.h" | 23 #include "ash/test/display_manager_test_api.h" |
21 #include "ash/test/test_session_state_delegate.h" | 24 #include "ash/test/test_session_state_delegate.h" |
22 #include "ash/test/test_shell_delegate.h" | 25 #include "ash/test/test_shell_delegate.h" |
23 #include "ash/test/test_system_tray_delegate.h" | 26 #include "ash/test/test_system_tray_delegate.h" |
24 #include "base/command_line.h" | 27 #include "base/command_line.h" |
25 #include "ui/aura/client/aura_constants.h" | 28 #include "ui/aura/client/aura_constants.h" |
26 #include "ui/aura/client/screen_position_client.h" | 29 #include "ui/aura/client/screen_position_client.h" |
27 #include "ui/aura/client/window_tree_client.h" | 30 #include "ui/aura/client/window_tree_client.h" |
| 31 #include "ui/aura/env.h" |
28 #include "ui/aura/test/event_generator_delegate_aura.h" | 32 #include "ui/aura/test/event_generator_delegate_aura.h" |
29 #include "ui/aura/test/test_window_delegate.h" | 33 #include "ui/aura/test/test_window_delegate.h" |
30 #include "ui/aura/window.h" | 34 #include "ui/aura/window.h" |
31 #include "ui/aura/window_delegate.h" | 35 #include "ui/aura/window_delegate.h" |
32 #include "ui/aura/window_tree_host.h" | 36 #include "ui/aura/window_tree_host.h" |
33 #include "ui/base/ime/input_method_initializer.h" | 37 #include "ui/base/ime/input_method_initializer.h" |
34 #include "ui/display/display.h" | 38 #include "ui/display/display.h" |
35 #include "ui/display/display_switches.h" | 39 #include "ui/display/display_switches.h" |
36 #include "ui/display/screen.h" | 40 #include "ui/display/screen.h" |
37 #include "ui/events/gesture_detection/gesture_configuration.h" | 41 #include "ui/events/gesture_detection/gesture_configuration.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 return GetActiveDisplayRotation(display::Display::InternalDisplayId()); | 206 return GetActiveDisplayRotation(display::Display::InternalDisplayId()); |
203 } | 207 } |
204 | 208 |
205 // static | 209 // static |
206 bool AshTestBase::SupportsMultipleDisplays() { | 210 bool AshTestBase::SupportsMultipleDisplays() { |
207 return AshTestHelper::SupportsMultipleDisplays(); | 211 return AshTestHelper::SupportsMultipleDisplays(); |
208 } | 212 } |
209 | 213 |
210 // static | 214 // static |
211 void AshTestBase::UpdateDisplay(const std::string& display_specs) { | 215 void AshTestBase::UpdateDisplay(const std::string& display_specs) { |
212 DisplayManagerTestApi().UpdateDisplay(display_specs); | 216 DisplayManagerTestApi(Shell::GetInstance()->display_manager()) |
| 217 .UpdateDisplay(display_specs); |
213 } | 218 } |
214 | 219 |
215 aura::Window* AshTestBase::CurrentContext() { | 220 aura::Window* AshTestBase::CurrentContext() { |
216 return ash_test_helper_->CurrentContext(); | 221 return ash_test_helper_->CurrentContext(); |
217 } | 222 } |
218 | 223 |
219 // static | 224 // static |
220 std::unique_ptr<views::Widget> AshTestBase::CreateTestWidget( | 225 std::unique_ptr<views::Widget> AshTestBase::CreateTestWidget( |
221 views::WidgetDelegate* delegate, | 226 views::WidgetDelegate* delegate, |
222 int container_id, | 227 int container_id, |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 SetUserAddingScreenRunning(false); | 370 SetUserAddingScreenRunning(false); |
366 } | 371 } |
367 | 372 |
368 void AshTestBase::DisableIME() { | 373 void AshTestBase::DisableIME() { |
369 Shell::GetInstance()->RemovePreTargetHandler( | 374 Shell::GetInstance()->RemovePreTargetHandler( |
370 Shell::GetInstance() | 375 Shell::GetInstance() |
371 ->window_tree_host_manager() | 376 ->window_tree_host_manager() |
372 ->input_method_event_handler()); | 377 ->input_method_event_handler()); |
373 } | 378 } |
374 | 379 |
| 380 DisplayManager* AshTestBase::display_manager() { |
| 381 return Shell::GetInstance()->display_manager(); |
| 382 } |
| 383 |
| 384 bool AshTestBase::TestIfMouseWarpsAt(ui::test::EventGenerator& event_generator, |
| 385 const gfx::Point& point_in_screen) { |
| 386 DCHECK(!Shell::GetInstance()->display_manager()->IsInUnifiedMode()); |
| 387 static_cast<ExtendedMouseWarpController*>( |
| 388 Shell::GetInstance() |
| 389 ->mouse_cursor_filter() |
| 390 ->mouse_warp_controller_for_test()) |
| 391 ->allow_non_native_event_for_test(); |
| 392 display::Screen* screen = display::Screen::GetScreen(); |
| 393 display::Display original_display = |
| 394 screen->GetDisplayNearestPoint(point_in_screen); |
| 395 event_generator.MoveMouseTo(point_in_screen); |
| 396 return original_display.id() != |
| 397 screen |
| 398 ->GetDisplayNearestPoint( |
| 399 aura::Env::GetInstance()->last_mouse_location()) |
| 400 .id(); |
| 401 } |
| 402 |
| 403 void AshTestBase::SwapPrimaryDisplay() { |
| 404 if (display::Screen::GetScreen()->GetNumDisplays() <= 1) |
| 405 return; |
| 406 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( |
| 407 display_manager()->GetSecondaryDisplay().id()); |
| 408 } |
| 409 |
375 } // namespace test | 410 } // namespace test |
376 } // namespace ash | 411 } // namespace ash |
OLD | NEW |