| OLD | NEW |
| 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/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "ash/system/system_notifier.h" | 6 #include "ash/system/system_notifier.h" |
| 7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/browser/notifications/login_state_notification_blocker_chromeos
.h" | 9 #include "chrome/browser/notifications/login_state_notification_blocker_chromeos
.h" |
| 10 #include "chromeos/login/login_state.h" | 10 #include "chromeos/login/login_state.h" |
| 11 #include "ui/message_center/message_center.h" | 11 #include "ui/message_center/message_center.h" |
| 12 #include "ui/message_center/notification.h" | 12 #include "ui/message_center/notification.h" |
| 13 | 13 |
| 14 class LoginStateNotificationBlockerChromeOSTest | 14 class LoginStateNotificationBlockerChromeOSTest |
| 15 : public ash::test::AshTestBase, | 15 : public ash::test::AshTestBase, |
| 16 public message_center::NotificationBlocker::Observer { | 16 public message_center::NotificationBlocker::Observer { |
| 17 public: | 17 public: |
| 18 LoginStateNotificationBlockerChromeOSTest() | 18 LoginStateNotificationBlockerChromeOSTest() |
| 19 : state_changed_count_(0) {} | 19 : state_changed_count_(0) {} |
| 20 virtual ~LoginStateNotificationBlockerChromeOSTest() {} | 20 virtual ~LoginStateNotificationBlockerChromeOSTest() {} |
| 21 | 21 |
| 22 // ash::tests::AshTestBase overrides: | 22 // ash::tests::AshTestBase overrides: |
| 23 virtual void SetUp() OVERRIDE { | 23 virtual void SetUp() override { |
| 24 chromeos::LoginState::Initialize(); | 24 chromeos::LoginState::Initialize(); |
| 25 chromeos::LoginState::Get()->set_always_logged_in(false); | 25 chromeos::LoginState::Get()->set_always_logged_in(false); |
| 26 ash::test::AshTestBase::SetUp(); | 26 ash::test::AshTestBase::SetUp(); |
| 27 blocker_.reset(new LoginStateNotificationBlockerChromeOS( | 27 blocker_.reset(new LoginStateNotificationBlockerChromeOS( |
| 28 message_center::MessageCenter::Get())); | 28 message_center::MessageCenter::Get())); |
| 29 blocker_->AddObserver(this); | 29 blocker_->AddObserver(this); |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual void TearDown() OVERRIDE { | 32 virtual void TearDown() override { |
| 33 blocker_->RemoveObserver(this); | 33 blocker_->RemoveObserver(this); |
| 34 blocker_.reset(); | 34 blocker_.reset(); |
| 35 ash::test::AshTestBase::TearDown(); | 35 ash::test::AshTestBase::TearDown(); |
| 36 chromeos::LoginState::Shutdown(); | 36 chromeos::LoginState::Shutdown(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // message_center::NotificationBlocker::Observer overrides: | 39 // message_center::NotificationBlocker::Observer overrides: |
| 40 virtual void OnBlockingStateChanged( | 40 virtual void OnBlockingStateChanged( |
| 41 message_center::NotificationBlocker* blocker) OVERRIDE { | 41 message_center::NotificationBlocker* blocker) override { |
| 42 state_changed_count_++; | 42 state_changed_count_++; |
| 43 } | 43 } |
| 44 | 44 |
| 45 int GetStateChangedCountAndReset() { | 45 int GetStateChangedCountAndReset() { |
| 46 int result = state_changed_count_; | 46 int result = state_changed_count_; |
| 47 state_changed_count_ = 0; | 47 state_changed_count_ = 0; |
| 48 return result; | 48 return result; |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool ShouldShowNotificationAsPopup( | 51 bool ShouldShowNotificationAsPopup( |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Lock. | 117 // Lock. |
| 118 ash::Shell::GetInstance()->OnLockStateChanged(true); | 118 ash::Shell::GetInstance()->OnLockStateChanged(true); |
| 119 EXPECT_EQ(1, GetStateChangedCountAndReset()); | 119 EXPECT_EQ(1, GetStateChangedCountAndReset()); |
| 120 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); | 120 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); |
| 121 | 121 |
| 122 // Unlock. | 122 // Unlock. |
| 123 ash::Shell::GetInstance()->OnLockStateChanged(false); | 123 ash::Shell::GetInstance()->OnLockStateChanged(false); |
| 124 EXPECT_EQ(1, GetStateChangedCountAndReset()); | 124 EXPECT_EQ(1, GetStateChangedCountAndReset()); |
| 125 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); | 125 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); |
| 126 } | 126 } |
| OLD | NEW |