Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: ash/mus/test/wm_test_base.cc

Issue 2627243003: Manual Revert of Reland: chromeos: Fix shelf appearing at login screen under mash (patchset #7 id:1… (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/mus/test/wm_test_base.h ('k') | ash/mus/window_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
12 #include "ash/mus/root_window_controller.h" 10 #include "ash/mus/root_window_controller.h"
13 #include "ash/mus/test/wm_test_helper.h" 11 #include "ash/mus/test/wm_test_helper.h"
14 #include "ash/mus/window_manager.h" 12 #include "ash/mus/window_manager.h"
15 #include "ash/mus/window_manager_application.h" 13 #include "ash/mus/window_manager_application.h"
16 #include "ash/public/cpp/session_types.h"
17 #include "ash/public/interfaces/session_controller.mojom.h"
18 #include "ash/test/wm_window_aura_test_api.h" 14 #include "ash/test/wm_window_aura_test_api.h"
19 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
20 #include "services/ui/public/cpp/property_type_converters.h" 16 #include "services/ui/public/cpp/property_type_converters.h"
21 #include "ui/aura/mus/property_converter.h" 17 #include "ui/aura/mus/property_converter.h"
22 #include "ui/aura/mus/window_tree_client.h" 18 #include "ui/aura/mus/window_tree_client.h"
23 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 20 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
25 #include "ui/display/display.h" 21 #include "ui/display/display.h"
26 22
27 namespace ash { 23 namespace ash {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 void WmTestBase::SetUp() { 158 void WmTestBase::SetUp() {
163 setup_called_ = true; 159 setup_called_ = true;
164 // Disable animations during tests. 160 // Disable animations during tests.
165 zero_duration_mode_ = base::MakeUnique<ui::ScopedAnimationDurationScaleMode>( 161 zero_duration_mode_ = base::MakeUnique<ui::ScopedAnimationDurationScaleMode>(
166 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); 162 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
167 // Most tests expect a minimum size of 0x0. 163 // Most tests expect a minimum size of 0x0.
168 minimum_size_lock_ = 164 minimum_size_lock_ =
169 base::MakeUnique<WmWindowAuraTestApi::GlobalMinimumSizeLock>(); 165 base::MakeUnique<WmWindowAuraTestApi::GlobalMinimumSizeLock>();
170 test_helper_.reset(new WmTestHelper); 166 test_helper_.reset(new WmTestHelper);
171 test_helper_->Init(); 167 test_helper_->Init();
172
173 // Most tests assume the user is logged in (and hence the shelf is created).
174 SimulateUserLogin();
175 } 168 }
176 169
177 void WmTestBase::TearDown() { 170 void WmTestBase::TearDown() {
178 teardown_called_ = true; 171 teardown_called_ = true;
179 test_helper_.reset(); 172 test_helper_.reset();
180 minimum_size_lock_.reset(); 173 minimum_size_lock_.reset();
181 zero_duration_mode_.reset(); 174 zero_duration_mode_.reset();
182 } 175 }
183 176
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
208 } // namespace mus 177 } // namespace mus
209 } // namespace ash 178 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/test/wm_test_base.h ('k') | ash/mus/window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698