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

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

Issue 2416253004: ash: Use session_manager::SessionState (Closed)
Patch Set: add comment about session state in SessionStaetDelegateChromeos 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_(session_manager::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_ == session_manager::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_ ||
155 session_state_ != session_manager::SessionState::ACTIVE;
155 } 156 }
156 157
157 SessionStateDelegate::SessionState TestSessionStateDelegate::GetSessionState() 158 session_manager::SessionState TestSessionStateDelegate::GetSessionState()
158 const { 159 const {
159 return session_state_; 160 return session_state_;
160 } 161 }
161 162
162 void TestSessionStateDelegate::SetHasActiveUser(bool has_active_user) { 163 void TestSessionStateDelegate::SetHasActiveUser(bool has_active_user) {
163 if (!has_active_user) { 164 if (!has_active_user) {
164 session_state_ = SESSION_STATE_LOGIN_PRIMARY; 165 session_state_ = session_manager::SessionState::LOGIN_PRIMARY;
165 } else { 166 } else {
166 session_state_ = SESSION_STATE_ACTIVE; 167 session_state_ = session_manager::SessionState::ACTIVE;
167 WmShell::Get()->ShowShelf(); 168 WmShell::Get()->ShowShelf();
168 } 169 }
169 } 170 }
170 171
171 void TestSessionStateDelegate::SetActiveUserSessionStarted( 172 void TestSessionStateDelegate::SetActiveUserSessionStarted(
172 bool active_user_session_started) { 173 bool active_user_session_started) {
173 if (active_user_session_started) { 174 if (active_user_session_started) {
174 user_manager_->SessionStarted(); 175 user_manager_->SessionStarted();
175 session_state_ = SESSION_STATE_ACTIVE; 176 session_state_ = session_manager::SessionState::ACTIVE;
176 WmShell::Get()->CreateShelf(); 177 WmShell::Get()->CreateShelf();
177 WmShell::Get()->UpdateAfterLoginStatusChange(LoginStatus::USER); 178 WmShell::Get()->UpdateAfterLoginStatusChange(LoginStatus::USER);
178 } else { 179 } else {
179 session_state_ = SESSION_STATE_LOGIN_PRIMARY; 180 session_state_ = session_manager::SessionState::LOGIN_PRIMARY;
180 user_manager_.reset(new TestUserManager()); 181 user_manager_.reset(new TestUserManager());
181 } 182 }
182 } 183 }
183 184
184 // static 185 // static
185 void TestSessionStateDelegate::SetCanLockScreen(bool can_lock_screen) { 186 void TestSessionStateDelegate::SetCanLockScreen(bool can_lock_screen) {
186 CHECK(WmShell::HasInstance()); 187 CHECK(WmShell::HasInstance());
187 static_cast<ash::test::TestSessionStateDelegate*>( 188 static_cast<ash::test::TestSessionStateDelegate*>(
188 WmShell::Get()->GetSessionStateDelegate()) 189 WmShell::Get()->GetSessionStateDelegate())
189 ->can_lock_screen_ = can_lock_screen; 190 ->can_lock_screen_ = can_lock_screen;
190 } 191 }
191 192
192 void TestSessionStateDelegate::SetShouldLockScreenBeforeSuspending( 193 void TestSessionStateDelegate::SetShouldLockScreenBeforeSuspending(
193 bool should_lock) { 194 bool should_lock) {
194 should_lock_screen_before_suspending_ = should_lock; 195 should_lock_screen_before_suspending_ = should_lock;
195 } 196 }
196 197
197 void TestSessionStateDelegate::SetUserAddingScreenRunning( 198 void TestSessionStateDelegate::SetUserAddingScreenRunning(
198 bool user_adding_screen_running) { 199 bool user_adding_screen_running) {
199 user_adding_screen_running_ = user_adding_screen_running; 200 user_adding_screen_running_ = user_adding_screen_running;
200 if (user_adding_screen_running_) 201 if (user_adding_screen_running_)
201 session_state_ = SESSION_STATE_LOGIN_SECONDARY; 202 session_state_ = session_manager::SessionState::LOGIN_SECONDARY;
202 else 203 else
203 session_state_ = SESSION_STATE_ACTIVE; 204 session_state_ = session_manager::SessionState::ACTIVE;
204 } 205 }
205 206
206 void TestSessionStateDelegate::SetUserImage(const gfx::ImageSkia& user_image) { 207 void TestSessionStateDelegate::SetUserImage(const gfx::ImageSkia& user_image) {
207 user_list_[active_user_index_]->SetUserImage(user_image); 208 user_list_[active_user_index_]->SetUserImage(user_image);
208 } 209 }
209 210
210 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo( 211 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo(
211 UserIndex index) const { 212 UserIndex index) const {
212 int max = static_cast<int>(user_list_.size()); 213 int max = static_cast<int>(user_list_.size());
213 return user_list_[index < max ? index : max - 1].get(); 214 return user_list_[index < max ? index : max - 1].get();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 247 }
247 248
248 void TestSessionStateDelegate::AddSessionStateObserver( 249 void TestSessionStateDelegate::AddSessionStateObserver(
249 SessionStateObserver* observer) {} 250 SessionStateObserver* observer) {}
250 251
251 void TestSessionStateDelegate::RemoveSessionStateObserver( 252 void TestSessionStateDelegate::RemoveSessionStateObserver(
252 SessionStateObserver* observer) {} 253 SessionStateObserver* observer) {}
253 254
254 } // namespace test 255 } // namespace test
255 } // namespace ash 256 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/test/test_session_state_delegate.h ('k') | ash/common/wm/maximize_mode/maximize_mode_event_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698