| Index: ash/system/session/tray_session_length_limit_unittest.cc
|
| diff --git a/ash/system/session/tray_session_length_limit_unittest.cc b/ash/system/session/tray_session_length_limit_unittest.cc
|
| index 19df0ccc214ecaf60fc6238a69b007635605ea3d..ee907d1a4f7a98356dfca07dce83af40108d947f 100644
|
| --- a/ash/system/session/tray_session_length_limit_unittest.cc
|
| +++ b/ash/system/session/tray_session_length_limit_unittest.cc
|
| @@ -4,9 +4,11 @@
|
|
|
| #include "ash/system/session/tray_session_length_limit.h"
|
|
|
| +#include "ash/session/session_controller.h"
|
| +#include "ash/shell.h"
|
| +#include "ash/system/tray/label_tray_view.h"
|
| #include "ash/system/tray/system_tray.h"
|
| #include "ash/test/ash_test_base.h"
|
| -#include "ash/test/test_system_tray_delegate.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/time/time.h"
|
| #include "ui/message_center/message_center.h"
|
| @@ -18,26 +20,19 @@ namespace test {
|
|
|
| class TraySessionLengthLimitTest : public AshTestBase {
|
| public:
|
| - TraySessionLengthLimitTest() {}
|
| - ~TraySessionLengthLimitTest() override {}
|
| -
|
| - void SetUp() override {
|
| - AshTestBase::SetUp();
|
| - SystemTray* system_tray = GetPrimarySystemTray();
|
| - tray_session_length_limit_ = new TraySessionLengthLimit(system_tray);
|
| - system_tray->AddTrayItem(base::WrapUnique(tray_session_length_limit_));
|
| - }
|
| + TraySessionLengthLimitTest() = default;
|
| + ~TraySessionLengthLimitTest() override = default;
|
|
|
| - void TearDown() override {
|
| - ClearSessionLengthLimit();
|
| - AshTestBase::TearDown();
|
| + protected:
|
| + LabelTrayView* GetSessionLengthLimitTrayView() {
|
| + return GetPrimarySystemTray()
|
| + ->GetTraySessionLengthLimitForTesting()
|
| + ->tray_bubble_view_;
|
| }
|
|
|
| - protected:
|
| void UpdateSessionLengthLimitInMin(int mins) {
|
| - GetSystemTrayDelegate()->SetSessionLengthLimitForTest(
|
| - base::TimeDelta::FromMinutes(mins));
|
| - tray_session_length_limit_->OnSessionLengthLimitChanged();
|
| + Shell::Get()->session_controller()->SetSessionLengthLimit(
|
| + base::TimeDelta::FromMinutes(mins), base::TimeTicks::Now());
|
| }
|
|
|
| message_center::Notification* GetNotification() {
|
| @@ -53,8 +48,8 @@ class TraySessionLengthLimitTest : public AshTestBase {
|
| }
|
|
|
| void ClearSessionLengthLimit() {
|
| - GetSystemTrayDelegate()->ClearSessionLengthLimit();
|
| - tray_session_length_limit_->OnSessionLengthLimitChanged();
|
| + Shell::Get()->session_controller()->SetSessionLengthLimit(
|
| + base::TimeDelta(), base::TimeTicks());
|
| }
|
|
|
| void RemoveNotification() {
|
| @@ -62,17 +57,32 @@ class TraySessionLengthLimitTest : public AshTestBase {
|
| TraySessionLengthLimit::kNotificationId, false /* by_user */);
|
| }
|
|
|
| - TraySessionLengthLimit* tray_session_length_limit() {
|
| - return tray_session_length_limit_;
|
| - }
|
| -
|
| private:
|
| - // Weak reference, owned by the SystemTray.
|
| - TraySessionLengthLimit* tray_session_length_limit_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(TraySessionLengthLimitTest);
|
| };
|
|
|
| +TEST_F(TraySessionLengthLimitTest, Visibility) {
|
| + SystemTray* system_tray = GetPrimarySystemTray();
|
| +
|
| + // By default there is no session length limit item.
|
| + system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
|
| + EXPECT_FALSE(GetSessionLengthLimitTrayView());
|
| + system_tray->CloseSystemBubble();
|
| +
|
| + // Setting a length limit shows an item in the system tray menu.
|
| + UpdateSessionLengthLimitInMin(10);
|
| + system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
|
| + ASSERT_TRUE(GetSessionLengthLimitTrayView());
|
| + EXPECT_TRUE(GetSessionLengthLimitTrayView()->visible());
|
| + system_tray->CloseSystemBubble();
|
| +
|
| + // Removing the session length limit removes the tray menu item.
|
| + UpdateSessionLengthLimitInMin(0);
|
| + system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
|
| + EXPECT_FALSE(GetSessionLengthLimitTrayView());
|
| + system_tray->CloseSystemBubble();
|
| +}
|
| +
|
| TEST_F(TraySessionLengthLimitTest, Notification) {
|
| // No notifications when no session limit.
|
| EXPECT_FALSE(GetNotification());
|
|
|