Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ash / test / test_system_tray_delegate.cc
blob19daea2b14f7ef2ffff29c51a4921ff635083c98
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/test/test_system_tray_delegate.h"
7 #include <string>
9 #include "ash/session/session_state_delegate.h"
10 #include "ash/shell.h"
11 #include "ash/system/user/login_status.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/time/time.h"
15 namespace ash {
16 namespace test {
18 namespace {
20 user::LoginStatus g_initial_status = user::LOGGED_IN_USER;
22 } // namespace
24 TestSystemTrayDelegate::TestSystemTrayDelegate()
25 : should_show_display_notification_(false),
26 login_status_(g_initial_status),
27 session_length_limit_set_(false) {
30 TestSystemTrayDelegate::~TestSystemTrayDelegate() {
33 // static
34 void TestSystemTrayDelegate::SetInitialLoginStatus(
35 user::LoginStatus login_status) {
36 g_initial_status = login_status;
39 void TestSystemTrayDelegate::SetLoginStatus(user::LoginStatus login_status) {
40 login_status_ = login_status;
41 Shell::GetInstance()->UpdateAfterLoginStatusChange(login_status);
44 void TestSystemTrayDelegate::SetSessionLengthLimitForTest(
45 const base::TimeDelta& new_limit) {
46 session_length_limit_ = new_limit;
47 session_length_limit_set_ = true;
50 void TestSystemTrayDelegate::ClearSessionLengthLimit() {
51 session_length_limit_set_ = false;
54 user::LoginStatus TestSystemTrayDelegate::GetUserLoginStatus() const {
55 // Initial login status has been changed for testing.
56 if (g_initial_status != user::LOGGED_IN_USER &&
57 g_initial_status == login_status_) {
58 return login_status_;
61 // At new user image screen manager->IsUserLoggedIn() would return true
62 // but there's no browser session available yet so use SessionStarted().
63 SessionStateDelegate* delegate =
64 Shell::GetInstance()->session_state_delegate();
66 if (!delegate->IsActiveUserSessionStarted())
67 return ash::user::LOGGED_IN_NONE;
68 if (delegate->IsScreenLocked())
69 return user::LOGGED_IN_LOCKED;
70 return login_status_;
73 bool TestSystemTrayDelegate::IsUserSupervised() const {
74 return login_status_ == ash::user::LOGGED_IN_SUPERVISED;
77 bool TestSystemTrayDelegate::ShouldShowDisplayNotification() {
78 return should_show_display_notification_;
81 bool TestSystemTrayDelegate::GetSessionStartTime(
82 base::TimeTicks* session_start_time) {
83 // Just returns TimeTicks::Now(), so the remaining time is always the
84 // specified limit. This is useful for testing.
85 if (session_length_limit_set_)
86 *session_start_time = base::TimeTicks::Now();
87 return session_length_limit_set_;
90 bool TestSystemTrayDelegate::GetSessionLengthLimit(
91 base::TimeDelta* session_length_limit) {
92 if (session_length_limit_set_)
93 *session_length_limit = session_length_limit_;
94 return session_length_limit_set_;
97 void TestSystemTrayDelegate::SignOut() {
98 base::MessageLoop::current()->Quit();
101 } // namespace test
102 } // namespace ash