| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // Create a cellular network and activate it. | 128 // Create a cellular network and activate it. |
| 129 ShillServiceClient::TestInterface* service_test = | 129 ShillServiceClient::TestInterface* service_test = |
| 130 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 130 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
| 131 service_test->ClearServices(); | 131 service_test->ClearServices(); |
| 132 service_test->AddService(kCellularServicePath, kCellularGuid, | 132 service_test->AddService(kCellularServicePath, kCellularGuid, |
| 133 "cellular1" /* name */, shill::kTypeCellular, | 133 "cellular1" /* name */, shill::kTypeCellular, |
| 134 "activated", true /* visible */); | 134 "activated", true /* visible */); |
| 135 service_test->SetServiceProperty( | 135 service_test->SetServiceProperty( |
| 136 kCellularServicePath, shill::kActivationStateProperty, | 136 kCellularServicePath, shill::kActivationStateProperty, |
| 137 base::StringValue(shill::kActivationStateActivated)); | 137 base::StringValue(shill::kActivationStateActivated)); |
| 138 service_test->SetServiceProperty(kCellularServicePath, | 138 service_test->SetServiceProperty( |
| 139 shill::kConnectableProperty, | 139 kCellularServicePath, shill::kConnectableProperty, base::Value(true)); |
| 140 base::FundamentalValue(true)); | |
| 141 } | 140 } |
| 142 | 141 |
| 143 content::TestBrowserThreadBundle thread_bundle_; | 142 content::TestBrowserThreadBundle thread_bundle_; |
| 144 std::unique_ptr<DataPromoNotification> data_promo_notification_; | 143 std::unique_ptr<DataPromoNotification> data_promo_notification_; |
| 145 std::unique_ptr<NetworkConnectTestDelegate> network_connect_delegate_; | 144 std::unique_ptr<NetworkConnectTestDelegate> network_connect_delegate_; |
| 146 std::unique_ptr<ScopedUserManagerEnabler> user_manager_enabler_; | 145 std::unique_ptr<ScopedUserManagerEnabler> user_manager_enabler_; |
| 147 std::unique_ptr<TestingProfileManager> profile_manager_; | 146 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 148 | 147 |
| 149 private: | 148 private: |
| 150 DISALLOW_COPY_AND_ASSIGN(DataPromoNotificationTest); | 149 DISALLOW_COPY_AND_ASSIGN(DataPromoNotificationTest); |
| 151 }; | 150 }; |
| 152 | 151 |
| 153 TEST_F(DataPromoNotificationTest, DataSaverNotification) { | 152 TEST_F(DataPromoNotificationTest, DataSaverNotification) { |
| 154 message_center::MessageCenter* message_center = | 153 message_center::MessageCenter* message_center = |
| 155 message_center::MessageCenter::Get(); | 154 message_center::MessageCenter::Get(); |
| 156 | 155 |
| 157 // Network setup shouldn't be enough to activate notification. | 156 // Network setup shouldn't be enough to activate notification. |
| 158 EXPECT_FALSE(message_center->FindVisibleNotificationById(kNotificationId)); | 157 EXPECT_FALSE(message_center->FindVisibleNotificationById(kNotificationId)); |
| 159 | 158 |
| 160 chromeos::NetworkConnect::Get()->ConnectToNetworkId(kCellularGuid); | 159 chromeos::NetworkConnect::Get()->ConnectToNetworkId(kCellularGuid); |
| 161 base::RunLoop().RunUntilIdle(); | 160 base::RunLoop().RunUntilIdle(); |
| 162 // Connecting to cellular network (which here makes it the default network) | 161 // Connecting to cellular network (which here makes it the default network) |
| 163 // should trigger the Data Saver notification. | 162 // should trigger the Data Saver notification. |
| 164 EXPECT_TRUE(message_center->FindVisibleNotificationById(kNotificationId)); | 163 EXPECT_TRUE(message_center->FindVisibleNotificationById(kNotificationId)); |
| 165 } | 164 } |
| 166 | 165 |
| 167 } // namespace test | 166 } // namespace test |
| 168 } // namespace chromeos | 167 } // namespace chromeos |
| OLD | NEW |