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