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

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

Issue 2060003002: ash: Add a unit test for the system update tray item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@movetraydelegate
Patch Set: rebase Created 4 years, 6 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/test/test_system_tray_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/session/session_state_delegate.h" 9 #include "ash/common/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 bool g_system_update_required = false;
20 LoginStatus g_initial_status = LoginStatus::USER; 21 LoginStatus g_initial_status = LoginStatus::USER;
21 22
22 } // namespace 23 } // namespace
23 24
24 TestSystemTrayDelegate::TestSystemTrayDelegate() 25 TestSystemTrayDelegate::TestSystemTrayDelegate()
25 : should_show_display_notification_(false), 26 : should_show_display_notification_(false),
26 login_status_(g_initial_status), 27 login_status_(g_initial_status),
27 session_length_limit_set_(false) { 28 session_length_limit_set_(false) {
28 } 29 }
29 30
30 TestSystemTrayDelegate::~TestSystemTrayDelegate() { 31 TestSystemTrayDelegate::~TestSystemTrayDelegate() {
31 } 32 }
32 33
33 // static 34 // static
34 void TestSystemTrayDelegate::SetInitialLoginStatus(LoginStatus login_status) { 35 void TestSystemTrayDelegate::SetInitialLoginStatus(LoginStatus login_status) {
35 g_initial_status = login_status; 36 g_initial_status = login_status;
36 } 37 }
37 38
39 // static
40 void TestSystemTrayDelegate::SetSystemUpdateRequired(bool required) {
41 g_system_update_required = required;
42 }
43
38 void TestSystemTrayDelegate::SetLoginStatus(LoginStatus login_status) { 44 void TestSystemTrayDelegate::SetLoginStatus(LoginStatus login_status) {
39 login_status_ = login_status; 45 login_status_ = login_status;
40 Shell::GetInstance()->UpdateAfterLoginStatusChange(login_status); 46 Shell::GetInstance()->UpdateAfterLoginStatusChange(login_status);
41 } 47 }
42 48
43 void TestSystemTrayDelegate::SetSessionLengthLimitForTest( 49 void TestSystemTrayDelegate::SetSessionLengthLimitForTest(
44 const base::TimeDelta& new_limit) { 50 const base::TimeDelta& new_limit) {
45 session_length_limit_ = new_limit; 51 session_length_limit_ = new_limit;
46 session_length_limit_set_ = true; 52 session_length_limit_set_ = true;
47 } 53 }
(...skipping 18 matching lines...) Expand all
66 return LoginStatus::NOT_LOGGED_IN; 72 return LoginStatus::NOT_LOGGED_IN;
67 if (delegate->IsScreenLocked()) 73 if (delegate->IsScreenLocked())
68 return LoginStatus::LOCKED; 74 return LoginStatus::LOCKED;
69 return login_status_; 75 return login_status_;
70 } 76 }
71 77
72 bool TestSystemTrayDelegate::IsUserSupervised() const { 78 bool TestSystemTrayDelegate::IsUserSupervised() const {
73 return login_status_ == LoginStatus::SUPERVISED; 79 return login_status_ == LoginStatus::SUPERVISED;
74 } 80 }
75 81
82 void TestSystemTrayDelegate::GetSystemUpdateInfo(UpdateInfo* info) const {
83 DCHECK(info);
84 info->severity = UpdateInfo::UPDATE_NORMAL;
85 info->update_required = g_system_update_required;
86 info->factory_reset_required = false;
87 }
88
76 bool TestSystemTrayDelegate::ShouldShowDisplayNotification() { 89 bool TestSystemTrayDelegate::ShouldShowDisplayNotification() {
77 return should_show_display_notification_; 90 return should_show_display_notification_;
78 } 91 }
79 92
80 bool TestSystemTrayDelegate::GetSessionStartTime( 93 bool TestSystemTrayDelegate::GetSessionStartTime(
81 base::TimeTicks* session_start_time) { 94 base::TimeTicks* session_start_time) {
82 // Just returns TimeTicks::Now(), so the remaining time is always the 95 // Just returns TimeTicks::Now(), so the remaining time is always the
83 // specified limit. This is useful for testing. 96 // specified limit. This is useful for testing.
84 if (session_length_limit_set_) 97 if (session_length_limit_set_)
85 *session_start_time = base::TimeTicks::Now(); 98 *session_start_time = base::TimeTicks::Now();
86 return session_length_limit_set_; 99 return session_length_limit_set_;
87 } 100 }
88 101
89 bool TestSystemTrayDelegate::GetSessionLengthLimit( 102 bool TestSystemTrayDelegate::GetSessionLengthLimit(
90 base::TimeDelta* session_length_limit) { 103 base::TimeDelta* session_length_limit) {
91 if (session_length_limit_set_) 104 if (session_length_limit_set_)
92 *session_length_limit = session_length_limit_; 105 *session_length_limit = session_length_limit_;
93 return session_length_limit_set_; 106 return session_length_limit_set_;
94 } 107 }
95 108
96 void TestSystemTrayDelegate::SignOut() { 109 void TestSystemTrayDelegate::SignOut() {
97 base::MessageLoop::current()->QuitWhenIdle(); 110 base::MessageLoop::current()->QuitWhenIdle();
98 } 111 }
99 112
100 } // namespace test 113 } // namespace test
101 } // namespace ash 114 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/test_system_tray_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698