OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 7 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
8 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 8 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
9 #include "chrome/browser/chromeos/net/network_portal_notification_controller.h" | 9 #include "chrome/browser/chromeos/net/network_portal_notification_controller.h" |
10 #include "chromeos/chromeos_switches.h" | 10 #include "chromeos/chromeos_switches.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 class NetworkPortalNotificationControllerTest : public testing::Test { | 65 class NetworkPortalNotificationControllerTest : public testing::Test { |
66 public: | 66 public: |
67 NetworkPortalNotificationControllerTest() | 67 NetworkPortalNotificationControllerTest() |
68 : user_manager_enabler_(new chromeos::FakeChromeUserManager()), | 68 : user_manager_enabler_(new chromeos::FakeChromeUserManager()), |
69 controller_(nullptr) {} | 69 controller_(nullptr) {} |
70 ~NetworkPortalNotificationControllerTest() override {} | 70 ~NetworkPortalNotificationControllerTest() override {} |
71 | 71 |
72 void SetUp() override { | 72 void SetUp() override { |
73 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | 73 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); |
74 cl->AppendSwitch(switches::kEnableNetworkPortalNotification); | 74 cl->AppendSwitch(switches::kEnableNetworkPortalNotification); |
75 MessageCenter::Initialize(); | |
76 MessageCenter::Get()->AddObserver(&observer_); | 75 MessageCenter::Get()->AddObserver(&observer_); |
77 } | 76 } |
78 | 77 |
79 void TearDown() override { | 78 void TearDown() override { |
80 MessageCenter::Get()->RemoveObserver(&observer_); | 79 MessageCenter::Get()->RemoveObserver(&observer_); |
81 MessageCenter::Shutdown(); | |
82 } | 80 } |
83 | 81 |
84 protected: | 82 protected: |
85 void OnPortalDetectionCompleted( | 83 void OnPortalDetectionCompleted( |
86 const NetworkState* network, | 84 const NetworkState* network, |
87 const NetworkPortalDetector::CaptivePortalState& state) { | 85 const NetworkPortalDetector::CaptivePortalState& state) { |
88 controller_.OnPortalDetectionCompleted(network, state); | 86 controller_.OnPortalDetectionCompleted(network, state); |
89 } | 87 } |
90 | 88 |
91 NotificationObserver& observer() { return observer_; } | 89 NotificationObserver& observer() { return observer_; } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // Network was switched (by shill or by user) to wifi1. Notification | 193 // Network was switched (by shill or by user) to wifi1. Notification |
196 // should be displayed. | 194 // should be displayed. |
197 OnPortalDetectionCompleted(&wifi1, portal_state); | 195 OnPortalDetectionCompleted(&wifi1, portal_state); |
198 ASSERT_TRUE(HasNotification()); | 196 ASSERT_TRUE(HasNotification()); |
199 EXPECT_EQ(2u, observer().add_count()); | 197 EXPECT_EQ(2u, observer().add_count()); |
200 EXPECT_EQ(1u, observer().remove_count()); | 198 EXPECT_EQ(1u, observer().remove_count()); |
201 EXPECT_EQ(1u, observer().update_count()); | 199 EXPECT_EQ(1u, observer().update_count()); |
202 } | 200 } |
203 | 201 |
204 } // namespace chromeos | 202 } // namespace chromeos |
OLD | NEW |