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/common/session/session_controller.h" |
| 11 #include "ash/common/wm_shell.h" |
10 #include "ash/mus/root_window_controller.h" | 12 #include "ash/mus/root_window_controller.h" |
11 #include "ash/mus/test/wm_test_helper.h" | 13 #include "ash/mus/test/wm_test_helper.h" |
12 #include "ash/mus/window_manager.h" | 14 #include "ash/mus/window_manager.h" |
13 #include "ash/mus/window_manager_application.h" | 15 #include "ash/mus/window_manager_application.h" |
| 16 #include "ash/public/cpp/session_types.h" |
| 17 #include "ash/public/interfaces/session_controller.mojom.h" |
14 #include "ash/test/wm_window_aura_test_api.h" | 18 #include "ash/test/wm_window_aura_test_api.h" |
15 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
16 #include "services/ui/public/cpp/property_type_converters.h" | 20 #include "services/ui/public/cpp/property_type_converters.h" |
17 #include "ui/aura/mus/property_converter.h" | 21 #include "ui/aura/mus/property_converter.h" |
18 #include "ui/aura/mus/window_tree_client.h" | 22 #include "ui/aura/mus/window_tree_client.h" |
19 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
20 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
21 #include "ui/display/display.h" | 25 #include "ui/display/display.h" |
22 | 26 |
23 namespace ash { | 27 namespace ash { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 void WmTestBase::SetUp() { | 162 void WmTestBase::SetUp() { |
159 setup_called_ = true; | 163 setup_called_ = true; |
160 // Disable animations during tests. | 164 // Disable animations during tests. |
161 zero_duration_mode_ = base::MakeUnique<ui::ScopedAnimationDurationScaleMode>( | 165 zero_duration_mode_ = base::MakeUnique<ui::ScopedAnimationDurationScaleMode>( |
162 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); | 166 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); |
163 // Most tests expect a minimum size of 0x0. | 167 // Most tests expect a minimum size of 0x0. |
164 minimum_size_lock_ = | 168 minimum_size_lock_ = |
165 base::MakeUnique<WmWindowAuraTestApi::GlobalMinimumSizeLock>(); | 169 base::MakeUnique<WmWindowAuraTestApi::GlobalMinimumSizeLock>(); |
166 test_helper_.reset(new WmTestHelper); | 170 test_helper_.reset(new WmTestHelper); |
167 test_helper_->Init(); | 171 test_helper_->Init(); |
| 172 |
| 173 // Most tests assume the user is logged in (and hence the shelf is created). |
| 174 SimulateUserLogin(); |
168 } | 175 } |
169 | 176 |
170 void WmTestBase::TearDown() { | 177 void WmTestBase::TearDown() { |
171 teardown_called_ = true; | 178 teardown_called_ = true; |
172 test_helper_.reset(); | 179 test_helper_.reset(); |
173 minimum_size_lock_.reset(); | 180 minimum_size_lock_.reset(); |
174 zero_duration_mode_.reset(); | 181 zero_duration_mode_.reset(); |
175 } | 182 } |
176 | 183 |
| 184 void WmTestBase::SimulateUserLogin() { |
| 185 SessionController* session_controller = WmShell::Get()->session_controller(); |
| 186 |
| 187 // Simulate the first user logging in. |
| 188 mojom::UserSessionPtr session = mojom::UserSession::New(); |
| 189 session->session_id = 1; |
| 190 session->type = user_manager::USER_TYPE_REGULAR; |
| 191 const std::string email("ash.user@example.com"); |
| 192 session->serialized_account_id = AccountId::FromUserEmail(email).Serialize(); |
| 193 session->display_name = "Ash User"; |
| 194 session->display_email = email; |
| 195 session_controller->UpdateUserSession(std::move(session)); |
| 196 |
| 197 // Simulate the user session becoming active. |
| 198 mojom::SessionInfoPtr info = mojom::SessionInfo::New(); |
| 199 info->max_users = 10; |
| 200 info->can_lock_screen = true; |
| 201 info->should_lock_screen_automatically = false; |
| 202 info->add_user_session_policy = AddUserSessionPolicy::ALLOWED; |
| 203 info->state = session_manager::SessionState::ACTIVE; |
| 204 session_controller->SetSessionInfo(std::move(info)); |
| 205 } |
| 206 |
| 207 |
177 } // namespace mus | 208 } // namespace mus |
178 } // namespace ash | 209 } // namespace ash |
OLD | NEW |