OLD | NEW |
| (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 #ifndef ASH_COMMON_TEST_TEST_SYSTEM_TRAY_DELEGATE_H_ | |
6 #define ASH_COMMON_TEST_TEST_SYSTEM_TRAY_DELEGATE_H_ | |
7 | |
8 #include "ash/system/tray/default_system_tray_delegate.h" | |
9 #include "ash/system/tray/ime_info.h" | |
10 #include "base/macros.h" | |
11 #include "base/time/time.h" | |
12 | |
13 namespace ash { | |
14 namespace test { | |
15 | |
16 class TestSystemTrayDelegate : public DefaultSystemTrayDelegate { | |
17 public: | |
18 TestSystemTrayDelegate(); | |
19 ~TestSystemTrayDelegate() override; | |
20 | |
21 // Changes the current login status in the test. This also invokes | |
22 // UpdateAfterLoginStatusChange(). Usually this is called in the test code to | |
23 // set up a login status. This will fit to most of the test cases, but this | |
24 // cannot be set during the initialization. To test the initialization, | |
25 // consider using SetInitialLoginStatus() instead. | |
26 void SetLoginStatus(LoginStatus login_status); | |
27 | |
28 // Updates the session length limit so that the limit will come from now in | |
29 // |new_limit|. | |
30 void SetSessionLengthLimitForTest(const base::TimeDelta& new_limit); | |
31 | |
32 // Clears the session length limit. | |
33 void ClearSessionLengthLimit(); | |
34 | |
35 // Sets the IME info. | |
36 void SetCurrentIME(const IMEInfo& info); | |
37 | |
38 // Sets the list of available IMEs. | |
39 void SetAvailableIMEList(const IMEInfoList& list); | |
40 | |
41 // Overridden from SystemTrayDelegate: | |
42 LoginStatus GetUserLoginStatus() const override; | |
43 bool IsUserSupervised() const override; | |
44 bool GetSessionStartTime(base::TimeTicks* session_start_time) override; | |
45 bool GetSessionLengthLimit(base::TimeDelta* session_length_limit) override; | |
46 void GetCurrentIME(IMEInfo* info) override; | |
47 void GetAvailableIMEList(IMEInfoList* list) override; | |
48 | |
49 private: | |
50 LoginStatus login_status_; | |
51 base::TimeDelta session_length_limit_; | |
52 bool session_length_limit_set_; | |
53 IMEInfo current_ime_; | |
54 IMEInfoList ime_list_; | |
55 | |
56 DISALLOW_COPY_AND_ASSIGN(TestSystemTrayDelegate); | |
57 }; | |
58 | |
59 // Changes the initial login status before TestSystemTrayDelegate is created. | |
60 // Allows testing the case when chrome is restarted right after login (such as | |
61 // when a flag is set). | |
62 class ScopedInitialLoginStatus { | |
63 public: | |
64 explicit ScopedInitialLoginStatus(LoginStatus status); | |
65 ~ScopedInitialLoginStatus(); | |
66 | |
67 private: | |
68 LoginStatus old_status_; | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(ScopedInitialLoginStatus); | |
71 }; | |
72 | |
73 } // namespace test | |
74 } // namespace ash | |
75 | |
76 #endif // ASH_COMMON_TEST_TEST_SYSTEM_TRAY_DELEGATE_H_ | |
OLD | NEW |