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

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

Issue 2736573002: chromeos: Move files in //ash/common to //ash, part 2 (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « ash/common/test/test_system_tray_delegate.h ('k') | ash/common/test/wm_shell_test_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "ash/common/test/test_system_tray_delegate.h"
6
7 #include <string>
8
9 #include "ash/common/login_status.h"
10 #include "ash/common/session/session_state_delegate.h"
11 #include "ash/common/wm_shell.h"
12 #include "base/time/time.h"
13
14 namespace ash {
15 namespace test {
16
17 namespace {
18
19 LoginStatus g_initial_status = LoginStatus::USER;
20
21 } // namespace
22
23 TestSystemTrayDelegate::TestSystemTrayDelegate()
24 : login_status_(g_initial_status), session_length_limit_set_(false) {}
25
26 TestSystemTrayDelegate::~TestSystemTrayDelegate() {}
27
28 void TestSystemTrayDelegate::SetLoginStatus(LoginStatus login_status) {
29 login_status_ = login_status;
30 WmShell::Get()->UpdateAfterLoginStatusChange(login_status);
31 }
32
33 void TestSystemTrayDelegate::SetSessionLengthLimitForTest(
34 const base::TimeDelta& new_limit) {
35 session_length_limit_ = new_limit;
36 session_length_limit_set_ = true;
37 }
38
39 void TestSystemTrayDelegate::ClearSessionLengthLimit() {
40 session_length_limit_set_ = false;
41 }
42
43 void TestSystemTrayDelegate::SetCurrentIME(const IMEInfo& info) {
44 current_ime_ = info;
45 }
46
47 void TestSystemTrayDelegate::SetAvailableIMEList(const IMEInfoList& list) {
48 ime_list_ = list;
49 }
50
51 LoginStatus TestSystemTrayDelegate::GetUserLoginStatus() const {
52 // Initial login status has been changed for testing.
53 if (g_initial_status != LoginStatus::USER &&
54 g_initial_status == login_status_) {
55 return login_status_;
56 }
57
58 // At new user image screen manager->IsUserLoggedIn() would return true
59 // but there's no browser session available yet so use SessionStarted().
60 SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate();
61
62 if (!delegate->IsActiveUserSessionStarted())
63 return LoginStatus::NOT_LOGGED_IN;
64 if (delegate->IsScreenLocked())
65 return LoginStatus::LOCKED;
66 return login_status_;
67 }
68
69 bool TestSystemTrayDelegate::IsUserSupervised() const {
70 return login_status_ == LoginStatus::SUPERVISED;
71 }
72
73 bool TestSystemTrayDelegate::GetSessionStartTime(
74 base::TimeTicks* session_start_time) {
75 // Just returns TimeTicks::Now(), so the remaining time is always the
76 // specified limit. This is useful for testing.
77 if (session_length_limit_set_)
78 *session_start_time = base::TimeTicks::Now();
79 return session_length_limit_set_;
80 }
81
82 bool TestSystemTrayDelegate::GetSessionLengthLimit(
83 base::TimeDelta* session_length_limit) {
84 if (session_length_limit_set_)
85 *session_length_limit = session_length_limit_;
86 return session_length_limit_set_;
87 }
88
89 void TestSystemTrayDelegate::GetCurrentIME(IMEInfo* info) {
90 *info = current_ime_;
91 }
92
93 void TestSystemTrayDelegate::GetAvailableIMEList(IMEInfoList* list) {
94 *list = ime_list_;
95 }
96
97 ////////////////////////////////////////////////////////////////////////////////
98
99 ScopedInitialLoginStatus::ScopedInitialLoginStatus(LoginStatus new_status)
100 : old_status_(g_initial_status) {
101 g_initial_status = new_status;
102 }
103
104 ScopedInitialLoginStatus::~ScopedInitialLoginStatus() {
105 g_initial_status = old_status_;
106 }
107
108 } // namespace test
109 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/test/test_system_tray_delegate.h ('k') | ash/common/test/wm_shell_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698