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

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

Issue 909293002: Properly set ShelfAlignment during login (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/test/test_session_state_delegate.h" 5 #include "ash/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/shell.h" 10 #include "ash/shell.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // A test user image. 57 // A test user image.
58 gfx::ImageSkia user_image_; 58 gfx::ImageSkia user_image_;
59 59
60 std::string email_; 60 std::string email_;
61 61
62 DISALLOW_COPY_AND_ASSIGN(MockUserInfo); 62 DISALLOW_COPY_AND_ASSIGN(MockUserInfo);
63 }; 63 };
64 64
65 TestSessionStateDelegate::TestSessionStateDelegate() 65 TestSessionStateDelegate::TestSessionStateDelegate()
66 : has_active_user_(false), 66 : has_active_user_(false),
67 active_user_session_started_(false), 67 active_user_session_started_(false),
oshima 2015/02/12 19:07:58 Is it possible to eliminate this flag now?
jonross 2015/02/13 15:29:08 It is not. The SessionStateDelegate can be in a st
oshima 2015/02/13 21:45:44 Can you point me the code path? I couldn't find su
68 can_lock_screen_(true), 68 can_lock_screen_(true),
69 should_lock_screen_before_suspending_(false), 69 should_lock_screen_before_suspending_(false),
70 screen_locked_(false), 70 screen_locked_(false),
71 user_adding_screen_running_(false), 71 user_adding_screen_running_(false),
72 logged_in_users_(1), 72 logged_in_users_(1),
73 active_user_index_(0) { 73 active_user_index_(0),
74 session_state_(SESSION_STATE_LOGIN_PRIMARY) {
74 user_list_.push_back( 75 user_list_.push_back(
75 new MockUserInfo("First@tray")); // This is intended to be capitalized. 76 new MockUserInfo("First@tray")); // This is intended to be capitalized.
76 user_list_.push_back( 77 user_list_.push_back(
77 new MockUserInfo("Second@tray")); // This is intended to be capitalized. 78 new MockUserInfo("Second@tray")); // This is intended to be capitalized.
78 user_list_.push_back(new MockUserInfo("third@tray")); 79 user_list_.push_back(new MockUserInfo("third@tray"));
79 user_list_.push_back(new MockUserInfo("someone@tray")); 80 user_list_.push_back(new MockUserInfo("someone@tray"));
80 } 81 }
81 82
82 TestSessionStateDelegate::~TestSessionStateDelegate() { 83 TestSessionStateDelegate::~TestSessionStateDelegate() {
83 STLDeleteElements(&user_list_); 84 STLDeleteElements(&user_list_);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 screen_locked_ = false; 139 screen_locked_ = false;
139 } 140 }
140 141
141 bool TestSessionStateDelegate::IsUserSessionBlocked() const { 142 bool TestSessionStateDelegate::IsUserSessionBlocked() const {
142 return !IsActiveUserSessionStarted() || IsScreenLocked() || 143 return !IsActiveUserSessionStarted() || IsScreenLocked() ||
143 user_adding_screen_running_; 144 user_adding_screen_running_;
144 } 145 }
145 146
146 SessionStateDelegate::SessionState TestSessionStateDelegate::GetSessionState() 147 SessionStateDelegate::SessionState TestSessionStateDelegate::GetSessionState()
147 const { 148 const {
148 if (user_adding_screen_running_) 149 return session_state_;
149 return SESSION_STATE_LOGIN_SECONDARY;
150
151 // Assuming that if session is not active we're at login.
152 return IsActiveUserSessionStarted() ?
153 SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY;
154 } 150 }
155 151
156 void TestSessionStateDelegate::SetHasActiveUser(bool has_active_user) { 152 void TestSessionStateDelegate::SetHasActiveUser(bool has_active_user) {
157 has_active_user_ = has_active_user; 153 has_active_user_ = has_active_user;
158 if (!has_active_user) 154 if (!has_active_user) {
159 active_user_session_started_ = false; 155 active_user_session_started_ = false;
160 else 156 session_state_ = SESSION_STATE_LOGIN_PRIMARY;
157 } else {
161 Shell::GetInstance()->ShowShelf(); 158 Shell::GetInstance()->ShowShelf();
159 }
162 } 160 }
163 161
164 void TestSessionStateDelegate::SetActiveUserSessionStarted( 162 void TestSessionStateDelegate::SetActiveUserSessionStarted(
165 bool active_user_session_started) { 163 bool active_user_session_started) {
166 active_user_session_started_ = active_user_session_started; 164 active_user_session_started_ = active_user_session_started;
167 if (active_user_session_started) { 165 if (active_user_session_started) {
166 session_state_ = SESSION_STATE_ACTIVE;
168 has_active_user_ = true; 167 has_active_user_ = true;
169 Shell::GetInstance()->CreateShelf(); 168 Shell::GetInstance()->CreateShelf();
170 Shell::GetInstance()->UpdateAfterLoginStatusChange( 169 Shell::GetInstance()->UpdateAfterLoginStatusChange(
171 user::LOGGED_IN_USER); 170 user::LOGGED_IN_USER);
171 } else {
172 session_state_ = SESSION_STATE_LOGIN_PRIMARY;
172 } 173 }
173 } 174 }
174 175
175 void TestSessionStateDelegate::SetCanLockScreen(bool can_lock_screen) { 176 void TestSessionStateDelegate::SetCanLockScreen(bool can_lock_screen) {
176 can_lock_screen_ = can_lock_screen; 177 can_lock_screen_ = can_lock_screen;
177 } 178 }
178 179
179 void TestSessionStateDelegate::SetShouldLockScreenBeforeSuspending( 180 void TestSessionStateDelegate::SetShouldLockScreenBeforeSuspending(
180 bool should_lock) { 181 bool should_lock) {
181 should_lock_screen_before_suspending_ = should_lock; 182 should_lock_screen_before_suspending_ = should_lock;
182 } 183 }
183 184
184 void TestSessionStateDelegate::SetUserAddingScreenRunning( 185 void TestSessionStateDelegate::SetUserAddingScreenRunning(
185 bool user_adding_screen_running) { 186 bool user_adding_screen_running) {
186 user_adding_screen_running_ = user_adding_screen_running; 187 user_adding_screen_running_ = user_adding_screen_running;
188 if (user_adding_screen_running_)
189 session_state_ = SESSION_STATE_LOGIN_SECONDARY;
187 } 190 }
188 191
189 void TestSessionStateDelegate::SetUserImage( 192 void TestSessionStateDelegate::SetUserImage(
190 const gfx::ImageSkia& user_image) { 193 const gfx::ImageSkia& user_image) {
191 user_list_[active_user_index_]->SetUserImage(user_image); 194 user_list_[active_user_index_]->SetUserImage(user_image);
192 } 195 }
193 196
194 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo( 197 const user_manager::UserInfo* TestSessionStateDelegate::GetUserInfo(
195 MultiProfileIndex index) const { 198 MultiProfileIndex index) const {
196 int max = static_cast<int>(user_list_.size()); 199 int max = static_cast<int>(user_list_.size());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 void TestSessionStateDelegate::AddSessionStateObserver( 236 void TestSessionStateDelegate::AddSessionStateObserver(
234 SessionStateObserver* observer) { 237 SessionStateObserver* observer) {
235 } 238 }
236 239
237 void TestSessionStateDelegate::RemoveSessionStateObserver( 240 void TestSessionStateDelegate::RemoveSessionStateObserver(
238 SessionStateObserver* observer) { 241 SessionStateObserver* observer) {
239 } 242 }
240 243
241 } // namespace test 244 } // namespace test
242 } // namespace ash 245 } // namespace ash
OLDNEW
« ash/shelf/shelf_layout_manager.cc ('K') | « ash/test/test_session_state_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698