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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/chromeos/login/login_manager_test.h" | 8 #include "chrome/browser/chromeos/login/login_manager_test.h" |
9 #include "chrome/browser/chromeos/login/startup_utils.h" | 9 #include "chrome/browser/chromeos/login/startup_utils.h" |
10 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 10 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 class LoginStateNotificationBlockerChromeOSBrowserTest | 24 class LoginStateNotificationBlockerChromeOSBrowserTest |
25 : public chromeos::LoginManagerTest, | 25 : public chromeos::LoginManagerTest, |
26 public message_center::NotificationBlocker::Observer { | 26 public message_center::NotificationBlocker::Observer { |
27 public: | 27 public: |
28 LoginStateNotificationBlockerChromeOSBrowserTest() | 28 LoginStateNotificationBlockerChromeOSBrowserTest() |
29 : chromeos::LoginManagerTest(false), | 29 : chromeos::LoginManagerTest(false), |
30 state_changed_count_(0) {} | 30 state_changed_count_(0) {} |
31 virtual ~LoginStateNotificationBlockerChromeOSBrowserTest() {} | 31 virtual ~LoginStateNotificationBlockerChromeOSBrowserTest() {} |
32 | 32 |
33 virtual void SetUpOnMainThread() OVERRIDE { | 33 virtual void SetUpOnMainThread() override { |
34 chromeos::LoginState::Get()->set_always_logged_in(false); | 34 chromeos::LoginState::Get()->set_always_logged_in(false); |
35 chromeos::LoginManagerTest::SetUpOnMainThread(); | 35 chromeos::LoginManagerTest::SetUpOnMainThread(); |
36 } | 36 } |
37 | 37 |
38 virtual void TearDownOnMainThread() OVERRIDE { | 38 virtual void TearDownOnMainThread() override { |
39 if (blocker_) | 39 if (blocker_) |
40 blocker_->RemoveObserver(this); | 40 blocker_->RemoveObserver(this); |
41 blocker_.reset(); | 41 blocker_.reset(); |
42 chromeos::LoginManagerTest::TearDownOnMainThread(); | 42 chromeos::LoginManagerTest::TearDownOnMainThread(); |
43 } | 43 } |
44 | 44 |
45 protected: | 45 protected: |
46 void CreateBlocker() { | 46 void CreateBlocker() { |
47 blocker_.reset(new LoginStateNotificationBlockerChromeOS( | 47 blocker_.reset(new LoginStateNotificationBlockerChromeOS( |
48 message_center::MessageCenter::Get())); | 48 message_center::MessageCenter::Get())); |
49 blocker_->AddObserver(this); | 49 blocker_->AddObserver(this); |
50 } | 50 } |
51 | 51 |
52 // message_center::NotificationBlocker::Observer ovverrides: | 52 // message_center::NotificationBlocker::Observer ovverrides: |
53 virtual void OnBlockingStateChanged( | 53 virtual void OnBlockingStateChanged( |
54 message_center::NotificationBlocker* blocker) OVERRIDE { | 54 message_center::NotificationBlocker* blocker) override { |
55 state_changed_count_++; | 55 state_changed_count_++; |
56 } | 56 } |
57 | 57 |
58 int GetStateChangedCountAndReset() { | 58 int GetStateChangedCountAndReset() { |
59 int result = state_changed_count_; | 59 int result = state_changed_count_; |
60 state_changed_count_ = 0; | 60 state_changed_count_ = 0; |
61 return result; | 61 return result; |
62 } | 62 } |
63 | 63 |
64 bool ShouldShowNotificationAsPopup( | 64 bool ShouldShowNotificationAsPopup( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 content::RunAllPendingInMessageLoop(); | 132 content::RunAllPendingInMessageLoop(); |
133 EXPECT_EQ(1, GetStateChangedCountAndReset()); | 133 EXPECT_EQ(1, GetStateChangedCountAndReset()); |
134 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); | 134 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); |
135 | 135 |
136 // Multi-login user switch off. | 136 // Multi-login user switch off. |
137 chromeos::UserAddingScreen::Get()->Cancel(); | 137 chromeos::UserAddingScreen::Get()->Cancel(); |
138 content::RunAllPendingInMessageLoop(); | 138 content::RunAllPendingInMessageLoop(); |
139 EXPECT_EQ(1, GetStateChangedCountAndReset()); | 139 EXPECT_EQ(1, GetStateChangedCountAndReset()); |
140 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); | 140 EXPECT_TRUE(ShouldShowNotificationAsPopup(notifier_id)); |
141 } | 141 } |
OLD | NEW |