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

Side by Side Diff: ash/common/test/test_session_state_delegate.cc

Issue 2416253004: ash: Use session_manager::SessionState (Closed)
Patch Set: fix compile Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/common/test/test_session_state_delegate.h" 5 #include "ash/common/test/test_session_state_delegate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "ash/common/login_status.h" 10 #include "ash/common/login_status.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 }; 86 };
87 87
88 TestSessionStateDelegate::TestSessionStateDelegate() 88 TestSessionStateDelegate::TestSessionStateDelegate()
89 : can_lock_screen_(true), 89 : can_lock_screen_(true),
90 should_lock_screen_before_suspending_(false), 90 should_lock_screen_before_suspending_(false),
91 screen_locked_(false), 91 screen_locked_(false),
92 user_adding_screen_running_(false), 92 user_adding_screen_running_(false),
93 logged_in_users_(1), 93 logged_in_users_(1),
94 active_user_index_(0), 94 active_user_index_(0),
95 user_manager_(new TestUserManager()), 95 user_manager_(new TestUserManager()),
96 session_state_(SESSION_STATE_LOGIN_PRIMARY) { 96 session_state_(SessionState::LOGIN_PRIMARY) {
97 // This is intended to be capitalized. 97 // This is intended to be capitalized.
98 user_list_.push_back(base::MakeUnique<MockUserInfo>("First@tray")); 98 user_list_.push_back(base::MakeUnique<MockUserInfo>("First@tray"));
99 // This is intended to be capitalized. 99 // This is intended to be capitalized.
100 user_list_.push_back(base::MakeUnique<MockUserInfo>("Second@tray")); 100 user_list_.push_back(base::MakeUnique<MockUserInfo>("Second@tray"));
101 user_list_.push_back(base::MakeUnique<MockUserInfo>("third@tray")); 101 user_list_.push_back(base::MakeUnique<MockUserInfo>("third@tray"));
102 user_list_.push_back(base::MakeUnique<MockUserInfo>("someone@tray")); 102 user_list_.push_back(base::MakeUnique<MockUserInfo>("someone@tray"));
103 } 103 }
104 104
105 TestSessionStateDelegate::~TestSessionStateDelegate() {} 105 TestSessionStateDelegate::~TestSessionStateDelegate() {}
106 106
(...skipping 11 matching lines...) Expand all
118 return 3; 118 return 3;
119 } 119 }
120 120
121 int TestSessionStateDelegate::NumberOfLoggedInUsers() const { 121 int TestSessionStateDelegate::NumberOfLoggedInUsers() const {
122 // TODO(skuhne): Add better test framework to test multiple profiles. 122 // TODO(skuhne): Add better test framework to test multiple profiles.
123 return IsActiveUserSessionStarted() ? logged_in_users_ : 0; 123 return IsActiveUserSessionStarted() ? logged_in_users_ : 0;
124 } 124 }
125 125
126 bool TestSessionStateDelegate::IsActiveUserSessionStarted() const { 126 bool TestSessionStateDelegate::IsActiveUserSessionStarted() const {
127 return user_manager_->IsSessionStarted() && 127 return user_manager_->IsSessionStarted() &&
128 session_state_ == SESSION_STATE_ACTIVE; 128 session_state_ == SessionState::ACTIVE;
129 } 129 }
130 130
131 bool TestSessionStateDelegate::CanLockScreen() const { 131 bool TestSessionStateDelegate::CanLockScreen() const {
132 return IsActiveUserSessionStarted() && can_lock_screen_; 132 return IsActiveUserSessionStarted() && can_lock_screen_;
133 } 133 }
134 134
135 bool TestSessionStateDelegate::IsScreenLocked() const { 135 bool TestSessionStateDelegate::IsScreenLocked() const {
136 return screen_locked_; 136 return screen_locked_;
137 } 137 }
138 138
139 bool TestSessionStateDelegate::ShouldLockScreenBeforeSuspending() const { 139 bool TestSessionStateDelegate::ShouldLockScreenBeforeSuspending() const {
140 return should_lock_screen_before_suspending_; 140 return should_lock_screen_before_suspending_;
141 } 141 }
142 142
143 void TestSessionStateDelegate::LockScreen() { 143 void TestSessionStateDelegate::LockScreen() {
144 if (CanLockScreen()) 144 if (CanLockScreen())
145 screen_locked_ = true; 145 screen_locked_ = true;
146 } 146 }
147 147
148 void TestSessionStateDelegate::UnlockScreen() { 148 void TestSessionStateDelegate::UnlockScreen() {
149 screen_locked_ = false; 149 screen_locked_ = false;
150 } 150 }
151 151
152 bool TestSessionStateDelegate::IsUserSessionBlocked() const { 152 bool TestSessionStateDelegate::IsUserSessionBlocked() const {
153 return !IsActiveUserSessionStarted() || IsScreenLocked() || 153 return !IsActiveUserSessionStarted() || IsScreenLocked() ||
154 user_adding_screen_running_ || session_state_ != SESSION_STATE_ACTIVE; 154 user_adding_screen_running_ || session_state_ != SessionState::ACTIVE;
155 } 155 }
156 156
157 SessionStateDelegate::SessionState TestSessionStateDelegate::GetSessionState() 157 SessionState TestSessionStateDelegate::GetSessionState() const {
158 const {
159 return session_state_; 158 return session_state_;
160 } 159 }
161 160
162 void TestSessionStateDelegate::SetHasActiveUser(bool has_active_user) { 161 void TestSessionStateDelegate::SetHasActiveUser(bool has_active_user) {
163 if (!has_active_user) { 162 if (!has_active_user) {
164 session_state_ = SESSION_STATE_LOGIN_PRIMARY; 163 session_state_ = SessionState::LOGIN_PRIMARY;
165 } else { 164 } else {
166 session_state_ = SESSION_STATE_ACTIVE; 165 session_state_ = SessionState::ACTIVE;
167 WmShell::Get()->ShowShelf(); 166 WmShell::Get()->ShowShelf();
168 } 167 }
169 } 168 }
170 169
171 void TestSessionStateDelegate::SetActiveUserSessionStarted( 170 void TestSessionStateDelegate::SetActiveUserSessionStarted(
172 bool active_user_session_started) { 171 bool active_user_session_started) {
173 if (active_user_session_started) { 172 if (active_user_session_started) {
174 user_manager_->SessionStarted(); 173 user_manager_->SessionStarted();
175 session_state_ = SESSION_STATE_ACTIVE; 174 session_state_ = SessionState::ACTIVE;
176 WmShell::Get()->CreateShelf(); 175 WmShell::Get()->CreateShelf();
177 WmShell::Get()->UpdateAfterLoginStatusChange(LoginStatus::USER); 176 WmShell::Get()->UpdateAfterLoginStatusChange(LoginStatus::USER);
178 } else { 177 } else {
179 session_state_ = SESSION_STATE_LOGIN_PRIMARY; 178 session_state_ = SessionState::LOGIN_PRIMARY;
180 user_manager_.reset(new TestUserManager()); 179 user_manager_.reset(new TestUserManager());
181 } 180 }
182 } 181 }
183 182
184 // static 183 // static
185 void TestSessionStateDelegate::SetCanLockScreen(bool can_lock_screen) { 184 void TestSessionStateDelegate::SetCanLockScreen(bool can_lock_screen) {
186 CHECK(WmShell::HasInstance()); 185 CHECK(WmShell::HasInstance());
187 static_cast<ash::test::TestSessionStateDelegate*>( 186 static_cast<ash::test::TestSessionStateDelegate*>(
188 WmShell::Get()->GetSessionStateDelegate()) 187 WmShell::Get()->GetSessionStateDelegate())
189 ->can_lock_screen_ = can_lock_screen; 188 ->can_lock_screen_ = can_lock_screen;
190 } 189 }
191 190
192 void TestSessionStateDelegate::SetShouldLockScreenBeforeSuspending( 191 void TestSessionStateDelegate::SetShouldLockScreenBeforeSuspending(
193 bool should_lock) { 192 bool should_lock) {
194 should_lock_screen_before_suspending_ = should_lock; 193 should_lock_screen_before_suspending_ = should_lock;
195 } 194 }
196 195
197 void TestSessionStateDelegate::SetUserAddingScreenRunning( 196 void TestSessionStateDelegate::SetUserAddingScreenRunning(
198 bool user_adding_screen_running) { 197 bool user_adding_screen_running) {
199 user_adding_screen_running_ = user_adding_screen_running; 198 user_adding_screen_running_ = user_adding_screen_running;
200 if (user_adding_screen_running_) 199 if (user_adding_screen_running_)
201 session_state_ = SESSION_STATE_LOGIN_SECONDARY; 200 session_state_ = SessionState::LOGIN_SECONDARY;
202 else 201 else
203 session_state_ = SESSION_STATE_ACTIVE; 202 session_state_ = SessionState::ACTIVE;
204 } 203 }
205 204
206 void TestSessionStateDelegate::SetUserImage(const gfx::ImageSkia& user_image) { 205 void TestSessionStateDelegate::SetUserImage(const gfx::ImageSkia& user_image) {
207 user_list_[active_user_index_]->SetUserImage(user_image); 206 user_list_[active_user_index_]->SetUserImage(user_image);
208 } 207 }
209 208
210 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo( 209 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo(
211 UserIndex index) const { 210 UserIndex index) const {
212 int max = static_cast<int>(user_list_.size()); 211 int max = static_cast<int>(user_list_.size());
213 return user_list_[index < max ? index : max - 1].get(); 212 return user_list_[index < max ? index : max - 1].get();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 245 }
247 246
248 void TestSessionStateDelegate::AddSessionStateObserver( 247 void TestSessionStateDelegate::AddSessionStateObserver(
249 SessionStateObserver* observer) {} 248 SessionStateObserver* observer) {}
250 249
251 void TestSessionStateDelegate::RemoveSessionStateObserver( 250 void TestSessionStateDelegate::RemoveSessionStateObserver(
252 SessionStateObserver* observer) {} 251 SessionStateObserver* observer) {}
253 252
254 } // namespace test 253 } // namespace test
255 } // namespace ash 254 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698