| 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 "ash/test/ash_test_helper.h" | 5 #include "ash/test/ash_test_helper.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller_delegate_aura.h" | 7 #include "ash/accelerators/accelerator_controller_delegate_aura.h" |
| 8 #include "ash/ash_switches.h" | 8 #include "ash/ash_switches.h" |
| 9 #include "ash/aura/shell_port_classic.h" | 9 #include "ash/aura/shell_port_classic.h" |
| 10 #include "ash/mus/bridge/shell_port_mash.h" | 10 #include "ash/mus/bridge/shell_port_mash.h" |
| 11 #include "ash/mus/screen_mus.h" | 11 #include "ash/mus/screen_mus.h" |
| 12 #include "ash/mus/window_manager.h" | 12 #include "ash/mus/window_manager.h" |
| 13 #include "ash/mus/window_manager_application.h" | 13 #include "ash/mus/window_manager_application.h" |
| 14 #include "ash/public/cpp/config.h" | 14 #include "ash/public/cpp/config.h" |
| 15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 16 #include "ash/shell_init_params.h" | 16 #include "ash/shell_init_params.h" |
| 17 #include "ash/shell_port.h" | 17 #include "ash/shell_port.h" |
| 18 #include "ash/system/screen_layout_observer.h" | 18 #include "ash/system/screen_layout_observer.h" |
| 19 #include "ash/test/ash_test_environment.h" | 19 #include "ash/test/ash_test_environment.h" |
| 20 #include "ash/test/ash_test_views_delegate.h" | 20 #include "ash/test/ash_test_views_delegate.h" |
| 21 #include "ash/test/display_configuration_controller_test_api.h" | 21 #include "ash/test/display_configuration_controller_test_api.h" |
| 22 #include "ash/test/test_screenshot_delegate.h" | 22 #include "ash/test/test_screenshot_delegate.h" |
| 23 #include "ash/test/test_session_state_delegate.h" | 23 #include "ash/test/test_session_state_delegate.h" |
| 24 #include "ash/test/test_shell_delegate.h" | 24 #include "ash/test/test_shell_delegate.h" |
| 25 #include "ash/test/test_system_tray_delegate.h" | 25 #include "ash/test/test_system_tray_delegate.h" |
| 26 #include "ash/wm_window.h" | |
| 27 #include "base/memory/ptr_util.h" | 26 #include "base/memory/ptr_util.h" |
| 28 #include "base/run_loop.h" | 27 #include "base/run_loop.h" |
| 29 #include "base/strings/string_split.h" | 28 #include "base/strings/string_split.h" |
| 30 #include "base/test/sequenced_worker_pool_owner.h" | 29 #include "base/test/sequenced_worker_pool_owner.h" |
| 31 #include "chromeos/audio/cras_audio_handler.h" | 30 #include "chromeos/audio/cras_audio_handler.h" |
| 32 #include "chromeos/cryptohome/system_salt_getter.h" | 31 #include "chromeos/cryptohome/system_salt_getter.h" |
| 33 #include "chromeos/dbus/dbus_thread_manager.h" | 32 #include "chromeos/dbus/dbus_thread_manager.h" |
| 34 #include "chromeos/network/network_handler.h" | 33 #include "chromeos/network/network_handler.h" |
| 35 #include "device/bluetooth/bluetooth_adapter_factory.h" | 34 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 36 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | 35 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| 37 #include "services/ui/public/cpp/input_devices/input_device_client.h" | 36 #include "services/ui/public/cpp/input_devices/input_device_client.h" |
| 38 #include "ui/aura/env.h" | 37 #include "ui/aura/env.h" |
| 39 #include "ui/aura/input_state_lookup.h" | 38 #include "ui/aura/input_state_lookup.h" |
| 40 #include "ui/aura/mus/window_tree_client.h" | 39 #include "ui/aura/mus/window_tree_client.h" |
| 41 #include "ui/aura/test/env_test_helper.h" | 40 #include "ui/aura/test/env_test_helper.h" |
| 42 #include "ui/aura/test/event_generator_delegate_aura.h" | 41 #include "ui/aura/test/event_generator_delegate_aura.h" |
| 43 #include "ui/aura/test/mus/window_tree_client_private.h" | 42 #include "ui/aura/test/mus/window_tree_client_private.h" |
| 44 #include "ui/base/ime/input_method_initializer.h" | 43 #include "ui/base/ime/input_method_initializer.h" |
| 45 #include "ui/base/material_design/material_design_controller.h" | 44 #include "ui/base/material_design/material_design_controller.h" |
| 46 #include "ui/base/platform_window_defaults.h" | 45 #include "ui/base/platform_window_defaults.h" |
| 47 #include "ui/base/test/material_design_controller_test_api.h" | 46 #include "ui/base/test/material_design_controller_test_api.h" |
| 48 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 47 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 49 #include "ui/compositor/test/context_factories_for_test.h" | 48 #include "ui/compositor/test/context_factories_for_test.h" |
| 49 #include "ui/display/display.h" |
| 50 #include "ui/display/display_switches.h" | 50 #include "ui/display/display_switches.h" |
| 51 #include "ui/display/manager/display_manager.h" | 51 #include "ui/display/manager/display_manager.h" |
| 52 #include "ui/display/manager/managed_display_info.h" | 52 #include "ui/display/manager/managed_display_info.h" |
| 53 #include "ui/display/screen.h" |
| 53 #include "ui/display/test/display_manager_test_api.h" | 54 #include "ui/display/test/display_manager_test_api.h" |
| 54 #include "ui/message_center/message_center.h" | 55 #include "ui/message_center/message_center.h" |
| 55 #include "ui/wm/core/capture_controller.h" | 56 #include "ui/wm/core/capture_controller.h" |
| 56 #include "ui/wm/core/cursor_manager.h" | 57 #include "ui/wm/core/cursor_manager.h" |
| 57 #include "ui/wm/core/wm_state.h" | 58 #include "ui/wm/core/wm_state.h" |
| 58 | 59 |
| 59 using display::ManagedDisplayInfo; | 60 using display::ManagedDisplayInfo; |
| 60 | 61 |
| 61 namespace ash { | 62 namespace ash { |
| 62 namespace test { | 63 namespace test { |
| 63 namespace { | 64 namespace { |
| 64 | 65 |
| 66 const display::Display GetDisplayNearestWindow(aura::Window* window) { |
| 67 return display::Screen::GetScreen()->GetDisplayNearestWindow(window); |
| 68 } |
| 69 |
| 65 bool CompareByDisplayId(RootWindowController* root1, | 70 bool CompareByDisplayId(RootWindowController* root1, |
| 66 RootWindowController* root2) { | 71 RootWindowController* root2) { |
| 67 return root1->GetWindow()->GetDisplayNearestWindow().id() < | 72 return GetDisplayNearestWindow(root1->GetRootWindow()).id() < |
| 68 root2->GetWindow()->GetDisplayNearestWindow().id(); | 73 GetDisplayNearestWindow(root2->GetRootWindow()).id(); |
| 69 } | 74 } |
| 70 | 75 |
| 71 } // namespace | 76 } // namespace |
| 72 | 77 |
| 73 // static | 78 // static |
| 74 Config AshTestHelper::config_ = Config::CLASSIC; | 79 Config AshTestHelper::config_ = Config::CLASSIC; |
| 75 | 80 |
| 76 AshTestHelper::AshTestHelper(AshTestEnvironment* ash_test_environment) | 81 AshTestHelper::AshTestHelper(AshTestEnvironment* ash_test_environment) |
| 77 : ash_test_environment_(ash_test_environment), | 82 : ash_test_environment_(ash_test_environment), |
| 78 test_shell_delegate_(nullptr), | 83 test_shell_delegate_(nullptr), |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 } | 317 } |
| 313 } | 318 } |
| 314 | 319 |
| 315 display::Display AshTestHelper::GetSecondaryDisplay() { | 320 display::Display AshTestHelper::GetSecondaryDisplay() { |
| 316 if (config_ != Config::MASH) | 321 if (config_ != Config::MASH) |
| 317 return Shell::Get()->display_manager()->GetSecondaryDisplay(); | 322 return Shell::Get()->display_manager()->GetSecondaryDisplay(); |
| 318 | 323 |
| 319 std::vector<RootWindowController*> roots = GetRootsOrderedByDisplayId(); | 324 std::vector<RootWindowController*> roots = GetRootsOrderedByDisplayId(); |
| 320 CHECK_LE(2U, roots.size()); | 325 CHECK_LE(2U, roots.size()); |
| 321 return roots.size() < 2 ? display::Display() | 326 return roots.size() < 2 ? display::Display() |
| 322 : roots[1]->GetWindow()->GetDisplayNearestWindow(); | 327 : GetDisplayNearestWindow(roots[1]->GetRootWindow()); |
| 323 } | 328 } |
| 324 | 329 |
| 325 void AshTestHelper::CreateMashWindowManager() { | 330 void AshTestHelper::CreateMashWindowManager() { |
| 326 CHECK(config_ != Config::CLASSIC); | 331 CHECK(config_ != Config::CLASSIC); |
| 327 const bool show_primary_root_on_connect = false; | 332 const bool show_primary_root_on_connect = false; |
| 328 window_manager_app_ = base::MakeUnique<mus::WindowManagerApplication>( | 333 window_manager_app_ = base::MakeUnique<mus::WindowManagerApplication>( |
| 329 show_primary_root_on_connect); | 334 show_primary_root_on_connect); |
| 330 | 335 |
| 331 window_manager_app_->window_manager_.reset( | 336 window_manager_app_->window_manager_.reset( |
| 332 new mus::WindowManager(nullptr, config_, show_primary_root_on_connect)); | 337 new mus::WindowManager(nullptr, config_, show_primary_root_on_connect)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 401 |
| 397 void AshTestHelper::UpdateDisplay(RootWindowController* root_window_controller, | 402 void AshTestHelper::UpdateDisplay(RootWindowController* root_window_controller, |
| 398 const std::string& display_spec, | 403 const std::string& display_spec, |
| 399 int* next_x) { | 404 int* next_x) { |
| 400 ManagedDisplayInfo display_info = | 405 ManagedDisplayInfo display_info = |
| 401 ManagedDisplayInfo::CreateFromSpec(display_spec); | 406 ManagedDisplayInfo::CreateFromSpec(display_spec); |
| 402 gfx::Rect bounds = display_info.bounds_in_native(); | 407 gfx::Rect bounds = display_info.bounds_in_native(); |
| 403 bounds.set_x(*next_x); | 408 bounds.set_x(*next_x); |
| 404 *next_x += bounds.size().width(); | 409 *next_x += bounds.size().width(); |
| 405 display::Display updated_display = | 410 display::Display updated_display = |
| 406 root_window_controller->GetWindow()->GetDisplayNearestWindow(); | 411 GetDisplayNearestWindow(root_window_controller->GetRootWindow()); |
| 407 gfx::Insets work_area_insets = updated_display.GetWorkAreaInsets(); | 412 gfx::Insets work_area_insets = updated_display.GetWorkAreaInsets(); |
| 408 updated_display.set_bounds(bounds); | 413 updated_display.set_bounds(bounds); |
| 409 updated_display.UpdateWorkAreaFromInsets(work_area_insets); | 414 updated_display.UpdateWorkAreaFromInsets(work_area_insets); |
| 410 updated_display.set_device_scale_factor(display_info.device_scale_factor()); | 415 updated_display.set_device_scale_factor(display_info.device_scale_factor()); |
| 411 window_manager_app_->window_manager()->OnWmDisplayModified(updated_display); | 416 window_manager_app_->window_manager()->OnWmDisplayModified(updated_display); |
| 412 } | 417 } |
| 413 | 418 |
| 414 std::vector<RootWindowController*> AshTestHelper::GetRootsOrderedByDisplayId() { | 419 std::vector<RootWindowController*> AshTestHelper::GetRootsOrderedByDisplayId() { |
| 415 std::set<RootWindowController*> roots = | 420 std::set<RootWindowController*> roots = |
| 416 window_manager_app_->window_manager()->GetRootWindowControllers(); | 421 window_manager_app_->window_manager()->GetRootWindowControllers(); |
| 417 std::vector<RootWindowController*> ordered_roots; | 422 std::vector<RootWindowController*> ordered_roots; |
| 418 ordered_roots.insert(ordered_roots.begin(), roots.begin(), roots.end()); | 423 ordered_roots.insert(ordered_roots.begin(), roots.begin(), roots.end()); |
| 419 std::sort(ordered_roots.begin(), ordered_roots.end(), &CompareByDisplayId); | 424 std::sort(ordered_roots.begin(), ordered_roots.end(), &CompareByDisplayId); |
| 420 return ordered_roots; | 425 return ordered_roots; |
| 421 } | 426 } |
| 422 | 427 |
| 423 } // namespace test | 428 } // namespace test |
| 424 } // namespace ash | 429 } // namespace ash |
| OLD | NEW |