| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/mus/test/wm_test_base.h" | 5 #include "ash/mus/test/wm_test_base.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/display/window_tree_host_manager.h" | |
| 11 #include "ash/mus/test/wm_test_helper.h" | 10 #include "ash/mus/test/wm_test_helper.h" |
| 12 #include "ash/mus/top_level_window_factory.h" | 11 #include "ash/mus/top_level_window_factory.h" |
| 13 #include "ash/mus/window_manager.h" | 12 #include "ash/mus/window_manager.h" |
| 14 #include "ash/mus/window_manager_application.h" | 13 #include "ash/mus/window_manager_application.h" |
| 15 #include "ash/public/cpp/config.h" | |
| 16 #include "ash/public/cpp/session_types.h" | 14 #include "ash/public/cpp/session_types.h" |
| 17 #include "ash/public/interfaces/session_controller.mojom.h" | 15 #include "ash/public/interfaces/session_controller.mojom.h" |
| 18 #include "ash/session/session_controller.h" | 16 #include "ash/session/session_controller.h" |
| 19 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 20 #include "ash/test/wm_window_test_api.h" | 18 #include "ash/test/wm_window_test_api.h" |
| 21 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
| 22 #include "services/ui/public/cpp/property_type_converters.h" | 20 #include "services/ui/public/cpp/property_type_converters.h" |
| 23 #include "ui/aura/mus/property_converter.h" | 21 #include "ui/aura/mus/property_converter.h" |
| 24 #include "ui/aura/mus/window_tree_client.h" | 22 #include "ui/aura/mus/window_tree_client.h" |
| 25 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 27 #include "ui/display/display.h" | 25 #include "ui/display/display.h" |
| 28 #include "ui/display/manager/display_manager.h" | |
| 29 | 26 |
| 30 namespace ash { | 27 namespace ash { |
| 31 namespace mus { | 28 namespace mus { |
| 32 namespace { | 29 namespace { |
| 33 | 30 |
| 34 ui::mojom::WindowType MusWindowTypeFromWmWindowType( | 31 ui::mojom::WindowType MusWindowTypeFromWmWindowType( |
| 35 ui::wm::WindowType wm_window_type) { | 32 ui::wm::WindowType wm_window_type) { |
| 36 switch (wm_window_type) { | 33 switch (wm_window_type) { |
| 37 case ui::wm::WINDOW_TYPE_UNKNOWN: | 34 case ui::wm::WINDOW_TYPE_UNKNOWN: |
| 38 break; | 35 break; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 69 << "You have overridden SetUp but never called WmTestBase::SetUp"; | 66 << "You have overridden SetUp but never called WmTestBase::SetUp"; |
| 70 CHECK(teardown_called_) | 67 CHECK(teardown_called_) |
| 71 << "You have overridden TearDown but never called WmTestBase::TearDown"; | 68 << "You have overridden TearDown but never called WmTestBase::TearDown"; |
| 72 } | 69 } |
| 73 | 70 |
| 74 void WmTestBase::UpdateDisplay(const std::string& display_spec) { | 71 void WmTestBase::UpdateDisplay(const std::string& display_spec) { |
| 75 test_helper_->UpdateDisplay(display_spec); | 72 test_helper_->UpdateDisplay(display_spec); |
| 76 } | 73 } |
| 77 | 74 |
| 78 aura::Window* WmTestBase::GetPrimaryRootWindow() { | 75 aura::Window* WmTestBase::GetPrimaryRootWindow() { |
| 79 return Shell::Get()->GetPrimaryRootWindow(); | 76 std::vector<RootWindowController*> roots = |
| 77 test_helper_->GetRootsOrderedByDisplayId(); |
| 78 DCHECK(!roots.empty()); |
| 79 return roots[0]->GetRootWindow(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 aura::Window* WmTestBase::GetSecondaryRootWindow() { | 82 aura::Window* WmTestBase::GetSecondaryRootWindow() { |
| 83 if (Shell::GetAshConfig() == Config::MUS) { | |
| 84 return Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId( | |
| 85 GetSecondaryDisplay().id()); | |
| 86 } | |
| 87 | |
| 88 std::vector<RootWindowController*> roots = | 83 std::vector<RootWindowController*> roots = |
| 89 test_helper_->GetRootsOrderedByDisplayId(); | 84 test_helper_->GetRootsOrderedByDisplayId(); |
| 90 return roots.size() < 2 ? nullptr : roots[1]->GetRootWindow(); | 85 return roots.size() < 2 ? nullptr : roots[1]->GetRootWindow(); |
| 91 } | 86 } |
| 92 | 87 |
| 93 display::Display WmTestBase::GetPrimaryDisplay() { | 88 display::Display WmTestBase::GetPrimaryDisplay() { |
| 94 if (Shell::GetAshConfig() == Config::MUS) { | |
| 95 return display::Screen::GetScreen()->GetDisplayNearestWindow( | |
| 96 Shell::Get()->GetPrimaryRootWindow()); | |
| 97 } | |
| 98 | |
| 99 std::vector<RootWindowController*> roots = | 89 std::vector<RootWindowController*> roots = |
| 100 test_helper_->GetRootsOrderedByDisplayId(); | 90 test_helper_->GetRootsOrderedByDisplayId(); |
| 101 DCHECK(!roots.empty()); | 91 DCHECK(!roots.empty()); |
| 102 return roots[0]->GetWindow()->GetDisplayNearestWindow(); | 92 return roots[0]->GetWindow()->GetDisplayNearestWindow(); |
| 103 } | 93 } |
| 104 | 94 |
| 105 display::Display WmTestBase::GetSecondaryDisplay() { | 95 display::Display WmTestBase::GetSecondaryDisplay() { |
| 106 if (Shell::GetAshConfig() == Config::MUS) | |
| 107 return Shell::Get()->display_manager()->GetSecondaryDisplay(); | |
| 108 | |
| 109 std::vector<RootWindowController*> roots = | 96 std::vector<RootWindowController*> roots = |
| 110 test_helper_->GetRootsOrderedByDisplayId(); | 97 test_helper_->GetRootsOrderedByDisplayId(); |
| 111 return roots.size() < 2 ? display::Display() | 98 return roots.size() < 2 ? display::Display() |
| 112 : roots[1]->GetWindow()->GetDisplayNearestWindow(); | 99 : roots[1]->GetWindow()->GetDisplayNearestWindow(); |
| 113 } | 100 } |
| 114 | 101 |
| 115 aura::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds) { | 102 aura::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds) { |
| 116 return CreateTestWindow(bounds, ui::wm::WINDOW_TYPE_NORMAL); | 103 return CreateTestWindow(bounds, ui::wm::WINDOW_TYPE_NORMAL); |
| 117 } | 104 } |
| 118 | 105 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 info->can_lock_screen = true; | 179 info->can_lock_screen = true; |
| 193 info->should_lock_screen_automatically = false; | 180 info->should_lock_screen_automatically = false; |
| 194 info->add_user_session_policy = AddUserSessionPolicy::ALLOWED; | 181 info->add_user_session_policy = AddUserSessionPolicy::ALLOWED; |
| 195 info->state = session_manager::SessionState::ACTIVE; | 182 info->state = session_manager::SessionState::ACTIVE; |
| 196 session_controller->SetSessionInfo(std::move(info)); | 183 session_controller->SetSessionInfo(std::move(info)); |
| 197 } | 184 } |
| 198 | 185 |
| 199 | 186 |
| 200 } // namespace mus | 187 } // namespace mus |
| 201 } // namespace ash | 188 } // namespace ash |
| OLD | NEW |