summaryrefslogtreecommitdiffstats
path: root/ash/test/test_system_tray_delegate.h
blob: a8384ca51eaaf95dcd9ddb54f6b332ee12e8a348 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_TEST_TEST_SYSTEM_TRAY_DELEGATE_H_
#define ASH_TEST_TEST_SYSTEM_TRAY_DELEGATE_H_

#include "ash/system/tray/default_system_tray_delegate.h"
#include "base/time/time.h"

namespace ash {
namespace test {

class TestSystemTrayDelegate : public DefaultSystemTrayDelegate {
 public:
  TestSystemTrayDelegate();
  ~TestSystemTrayDelegate() override;

  // Changes the login status when initially the delegate is created. This will
  // be called before AshTestBase::SetUp() to test the case when chrome is
  // restarted right after the login (such like a flag is set).
  // This value will be reset in AshTestHelper::TearDown,  most test fixtures
  // don't need to care its lifecycle.
  static void SetInitialLoginStatus(user::LoginStatus login_status);

  // Changes the current login status in the test. This also invokes
  // UpdateAfterLoginStatusChange(). Usually this is called in the test code to
  // set up a login status. This will fit to most of the test cases, but this
  // cannot be set during the initialization. To test the initialization,
  // consider using SetInitialLoginStatus() instead.
  void SetLoginStatus(user::LoginStatus login_status);

  void set_should_show_display_notification(bool should_show) {
    should_show_display_notification_ = should_show;
  }

  // Updates the session length limit so that the limit will come from now in
  // |new_limit|.
  void SetSessionLengthLimitForTest(const base::TimeDelta& new_limit);

  // Clears the session length limit.
  void ClearSessionLengthLimit();

  // Overridden from SystemTrayDelegate:
  user::LoginStatus GetUserLoginStatus() const override;
  bool IsUserSupervised() const override;
  bool ShouldShowDisplayNotification() override;
  bool GetSessionStartTime(base::TimeTicks* session_start_time) override;
  bool GetSessionLengthLimit(base::TimeDelta* session_length_limit) override;
  void SignOut() override;

 private:
  bool should_show_display_notification_;
  user::LoginStatus login_status_;
  base::TimeDelta session_length_limit_;
  bool session_length_limit_set_;

  DISALLOW_COPY_AND_ASSIGN(TestSystemTrayDelegate);
};

}  // namespace test
}  // namespace ash

#endif  // ASH_TEST_TEST_SYSTEM_TRAY_DELEGATE_H_