| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_system_tray_delegate.h" | 5 #include "ash/test/test_system_tray_delegate.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/session/session_state_delegate.h" | 9 #include "ash/session/session_state_delegate.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/system/user/login_status.h" | 11 #include "ash/system/user/login_status.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 | 14 |
| 15 namespace ash { | 15 namespace ash { |
| 16 namespace test { | 16 namespace test { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 user::LoginStatus g_initial_status = user::LOGGED_IN_USER; | 20 LoginStatus g_initial_status = LoginStatus::USER; |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 TestSystemTrayDelegate::TestSystemTrayDelegate() | 24 TestSystemTrayDelegate::TestSystemTrayDelegate() |
| 25 : should_show_display_notification_(false), | 25 : should_show_display_notification_(false), |
| 26 login_status_(g_initial_status), | 26 login_status_(g_initial_status), |
| 27 session_length_limit_set_(false) { | 27 session_length_limit_set_(false) { |
| 28 } | 28 } |
| 29 | 29 |
| 30 TestSystemTrayDelegate::~TestSystemTrayDelegate() { | 30 TestSystemTrayDelegate::~TestSystemTrayDelegate() { |
| 31 } | 31 } |
| 32 | 32 |
| 33 // static | 33 // static |
| 34 void TestSystemTrayDelegate::SetInitialLoginStatus( | 34 void TestSystemTrayDelegate::SetInitialLoginStatus(LoginStatus login_status) { |
| 35 user::LoginStatus login_status) { | |
| 36 g_initial_status = login_status; | 35 g_initial_status = login_status; |
| 37 } | 36 } |
| 38 | 37 |
| 39 void TestSystemTrayDelegate::SetLoginStatus(user::LoginStatus login_status) { | 38 void TestSystemTrayDelegate::SetLoginStatus(LoginStatus login_status) { |
| 40 login_status_ = login_status; | 39 login_status_ = login_status; |
| 41 Shell::GetInstance()->UpdateAfterLoginStatusChange(login_status); | 40 Shell::GetInstance()->UpdateAfterLoginStatusChange(login_status); |
| 42 } | 41 } |
| 43 | 42 |
| 44 void TestSystemTrayDelegate::SetSessionLengthLimitForTest( | 43 void TestSystemTrayDelegate::SetSessionLengthLimitForTest( |
| 45 const base::TimeDelta& new_limit) { | 44 const base::TimeDelta& new_limit) { |
| 46 session_length_limit_ = new_limit; | 45 session_length_limit_ = new_limit; |
| 47 session_length_limit_set_ = true; | 46 session_length_limit_set_ = true; |
| 48 } | 47 } |
| 49 | 48 |
| 50 void TestSystemTrayDelegate::ClearSessionLengthLimit() { | 49 void TestSystemTrayDelegate::ClearSessionLengthLimit() { |
| 51 session_length_limit_set_ = false; | 50 session_length_limit_set_ = false; |
| 52 } | 51 } |
| 53 | 52 |
| 54 user::LoginStatus TestSystemTrayDelegate::GetUserLoginStatus() const { | 53 LoginStatus TestSystemTrayDelegate::GetUserLoginStatus() const { |
| 55 // Initial login status has been changed for testing. | 54 // Initial login status has been changed for testing. |
| 56 if (g_initial_status != user::LOGGED_IN_USER && | 55 if (g_initial_status != LoginStatus::USER && |
| 57 g_initial_status == login_status_) { | 56 g_initial_status == login_status_) { |
| 58 return login_status_; | 57 return login_status_; |
| 59 } | 58 } |
| 60 | 59 |
| 61 // At new user image screen manager->IsUserLoggedIn() would return true | 60 // At new user image screen manager->IsUserLoggedIn() would return true |
| 62 // but there's no browser session available yet so use SessionStarted(). | 61 // but there's no browser session available yet so use SessionStarted(). |
| 63 SessionStateDelegate* delegate = | 62 SessionStateDelegate* delegate = |
| 64 Shell::GetInstance()->session_state_delegate(); | 63 Shell::GetInstance()->session_state_delegate(); |
| 65 | 64 |
| 66 if (!delegate->IsActiveUserSessionStarted()) | 65 if (!delegate->IsActiveUserSessionStarted()) |
| 67 return ash::user::LOGGED_IN_NONE; | 66 return LoginStatus::NOT_LOGGED_IN; |
| 68 if (delegate->IsScreenLocked()) | 67 if (delegate->IsScreenLocked()) |
| 69 return user::LOGGED_IN_LOCKED; | 68 return LoginStatus::LOCKED; |
| 70 return login_status_; | 69 return login_status_; |
| 71 } | 70 } |
| 72 | 71 |
| 73 bool TestSystemTrayDelegate::IsUserSupervised() const { | 72 bool TestSystemTrayDelegate::IsUserSupervised() const { |
| 74 return login_status_ == ash::user::LOGGED_IN_SUPERVISED; | 73 return login_status_ == LoginStatus::SUPERVISED; |
| 75 } | 74 } |
| 76 | 75 |
| 77 bool TestSystemTrayDelegate::ShouldShowDisplayNotification() { | 76 bool TestSystemTrayDelegate::ShouldShowDisplayNotification() { |
| 78 return should_show_display_notification_; | 77 return should_show_display_notification_; |
| 79 } | 78 } |
| 80 | 79 |
| 81 bool TestSystemTrayDelegate::GetSessionStartTime( | 80 bool TestSystemTrayDelegate::GetSessionStartTime( |
| 82 base::TimeTicks* session_start_time) { | 81 base::TimeTicks* session_start_time) { |
| 83 // Just returns TimeTicks::Now(), so the remaining time is always the | 82 // Just returns TimeTicks::Now(), so the remaining time is always the |
| 84 // specified limit. This is useful for testing. | 83 // specified limit. This is useful for testing. |
| 85 if (session_length_limit_set_) | 84 if (session_length_limit_set_) |
| 86 *session_start_time = base::TimeTicks::Now(); | 85 *session_start_time = base::TimeTicks::Now(); |
| 87 return session_length_limit_set_; | 86 return session_length_limit_set_; |
| 88 } | 87 } |
| 89 | 88 |
| 90 bool TestSystemTrayDelegate::GetSessionLengthLimit( | 89 bool TestSystemTrayDelegate::GetSessionLengthLimit( |
| 91 base::TimeDelta* session_length_limit) { | 90 base::TimeDelta* session_length_limit) { |
| 92 if (session_length_limit_set_) | 91 if (session_length_limit_set_) |
| 93 *session_length_limit = session_length_limit_; | 92 *session_length_limit = session_length_limit_; |
| 94 return session_length_limit_set_; | 93 return session_length_limit_set_; |
| 95 } | 94 } |
| 96 | 95 |
| 97 void TestSystemTrayDelegate::SignOut() { | 96 void TestSystemTrayDelegate::SignOut() { |
| 98 base::MessageLoop::current()->QuitWhenIdle(); | 97 base::MessageLoop::current()->QuitWhenIdle(); |
| 99 } | 98 } |
| 100 | 99 |
| 101 } // namespace test | 100 } // namespace test |
| 102 } // namespace ash | 101 } // namespace ash |
| OLD | NEW |