| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "chrome/browser/chromeos/status/data_promo_notification.h" | 5 #include "chrome/browser/chromeos/status/data_promo_notification.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 profile_manager_.reset(); | 79 profile_manager_.reset(); |
| 80 user_manager_enabler_.reset(); | 80 user_manager_enabler_.reset(); |
| 81 data_promo_notification_.reset(); | 81 data_promo_notification_.reset(); |
| 82 NetworkHandler::Shutdown(); | 82 NetworkHandler::Shutdown(); |
| 83 DBusThreadManager::Shutdown(); | 83 DBusThreadManager::Shutdown(); |
| 84 testing::Test::TearDown(); | 84 testing::Test::TearDown(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 protected: | 87 protected: |
| 88 void SetupUser() { | 88 void SetupUser() { |
| 89 scoped_ptr<FakeChromeUserManager> user_manager(new FakeChromeUserManager()); | 89 std::unique_ptr<FakeChromeUserManager> user_manager( |
| 90 new FakeChromeUserManager()); |
| 90 const AccountId test_account_id(AccountId::FromUserEmail(kTestUserName)); | 91 const AccountId test_account_id(AccountId::FromUserEmail(kTestUserName)); |
| 91 user_manager->AddUser(test_account_id); | 92 user_manager->AddUser(test_account_id); |
| 92 user_manager->LoginUser(test_account_id); | 93 user_manager->LoginUser(test_account_id); |
| 93 user_manager_enabler_.reset( | 94 user_manager_enabler_.reset( |
| 94 new ScopedUserManagerEnabler(user_manager.release())); | 95 new ScopedUserManagerEnabler(user_manager.release())); |
| 95 | 96 |
| 96 profile_manager_.reset( | 97 profile_manager_.reset( |
| 97 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 98 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
| 98 ASSERT_TRUE(profile_manager_->SetUp()); | 99 ASSERT_TRUE(profile_manager_->SetUp()); |
| 99 profile_manager_->SetLoggedIn(true); | 100 profile_manager_->SetLoggedIn(true); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 127 "cellular1" /* name */, shill::kTypeCellular, | 128 "cellular1" /* name */, shill::kTypeCellular, |
| 128 "activated", true /* visible */); | 129 "activated", true /* visible */); |
| 129 service_test->SetServiceProperty( | 130 service_test->SetServiceProperty( |
| 130 kCellularServicePath, shill::kActivationStateProperty, | 131 kCellularServicePath, shill::kActivationStateProperty, |
| 131 base::StringValue(shill::kActivationStateActivated)); | 132 base::StringValue(shill::kActivationStateActivated)); |
| 132 service_test->SetServiceProperty(kCellularServicePath, | 133 service_test->SetServiceProperty(kCellularServicePath, |
| 133 shill::kConnectableProperty, | 134 shill::kConnectableProperty, |
| 134 base::FundamentalValue(true)); | 135 base::FundamentalValue(true)); |
| 135 } | 136 } |
| 136 | 137 |
| 137 scoped_ptr<DataPromoNotification> data_promo_notification_; | 138 std::unique_ptr<DataPromoNotification> data_promo_notification_; |
| 138 scoped_ptr<NetworkConnectTestDelegate> network_connect_delegate_; | 139 std::unique_ptr<NetworkConnectTestDelegate> network_connect_delegate_; |
| 139 scoped_ptr<ScopedUserManagerEnabler> user_manager_enabler_; | 140 std::unique_ptr<ScopedUserManagerEnabler> user_manager_enabler_; |
| 140 scoped_ptr<TestingProfileManager> profile_manager_; | 141 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 141 base::MessageLoop message_loop_; | 142 base::MessageLoop message_loop_; |
| 142 | 143 |
| 143 private: | 144 private: |
| 144 DISALLOW_COPY_AND_ASSIGN(DataPromoNotificationTest); | 145 DISALLOW_COPY_AND_ASSIGN(DataPromoNotificationTest); |
| 145 }; | 146 }; |
| 146 | 147 |
| 147 TEST_F(DataPromoNotificationTest, DataSaverNotification) { | 148 TEST_F(DataPromoNotificationTest, DataSaverNotification) { |
| 148 message_center::MessageCenter* message_center = | 149 message_center::MessageCenter* message_center = |
| 149 message_center::MessageCenter::Get(); | 150 message_center::MessageCenter::Get(); |
| 150 | 151 |
| 151 // Network setup shouldn't be enough to activate notification. | 152 // Network setup shouldn't be enough to activate notification. |
| 152 EXPECT_FALSE(message_center->FindVisibleNotificationById(kNotificationId)); | 153 EXPECT_FALSE(message_center->FindVisibleNotificationById(kNotificationId)); |
| 153 | 154 |
| 154 ui::NetworkConnect::Get()->ConnectToNetwork(kCellularServicePath); | 155 ui::NetworkConnect::Get()->ConnectToNetwork(kCellularServicePath); |
| 155 base::RunLoop().RunUntilIdle(); | 156 base::RunLoop().RunUntilIdle(); |
| 156 // Connecting to cellular network (which here makes it the default network) | 157 // Connecting to cellular network (which here makes it the default network) |
| 157 // should trigger the Data Saver notification. | 158 // should trigger the Data Saver notification. |
| 158 EXPECT_TRUE(message_center->FindVisibleNotificationById(kNotificationId)); | 159 EXPECT_TRUE(message_center->FindVisibleNotificationById(kNotificationId)); |
| 159 } | 160 } |
| 160 | 161 |
| 161 } // namespace test | 162 } // namespace test |
| 162 } // namespace chromeos | 163 } // namespace chromeos |
| OLD | NEW |