Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: chromeos/network/prohibited_technologies_handler_unittest.cc

Issue 2314853004: Remove calls to deprecated MessageLoop methods in chromeos. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chromeos/network/prohibited_technologies_handler.h" 5 #include "chromeos/network/prohibited_technologies_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 119
120 std::unique_ptr<ProhibitedTechnologiesHandler> 120 std::unique_ptr<ProhibitedTechnologiesHandler>
121 prohibited_technologies_handler_; 121 prohibited_technologies_handler_;
122 std::unique_ptr<NetworkStateHandler> network_state_handler_; 122 std::unique_ptr<NetworkStateHandler> network_state_handler_;
123 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; 123 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_;
124 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> 124 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl>
125 managed_config_handler_; 125 managed_config_handler_;
126 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; 126 std::unique_ptr<NetworkProfileHandler> network_profile_handler_;
127 ShillManagerClient::TestInterface* test_manager_client_; 127 ShillManagerClient::TestInterface* test_manager_client_;
128 base::MessageLoopForUI message_loop_; 128 base::MessageLoopForUI message_loop_;
armansito 2016/09/06 22:04:32 ditto
129 base::DictionaryValue global_config_disable_wifi; 129 base::DictionaryValue global_config_disable_wifi;
130 base::DictionaryValue global_config_disable_wifi_and_cell; 130 base::DictionaryValue global_config_disable_wifi_and_cell;
131 131
132 private: 132 private:
133 DISALLOW_COPY_AND_ASSIGN(ProhibitedTechnologiesHandlerTest); 133 DISALLOW_COPY_AND_ASSIGN(ProhibitedTechnologiesHandlerTest);
134 }; 134 };
135 135
136 TEST_F(ProhibitedTechnologiesHandlerTest, 136 TEST_F(ProhibitedTechnologiesHandlerTest,
137 ProhibitedTechnologiesAllowedLoginScreen) { 137 ProhibitedTechnologiesAllowedLoginScreen) {
138 EXPECT_TRUE( 138 EXPECT_TRUE(
139 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi())); 139 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi()));
140 EXPECT_TRUE(network_state_handler_->IsTechnologyEnabled( 140 EXPECT_TRUE(network_state_handler_->IsTechnologyEnabled(
141 NetworkTypePattern::Cellular())); 141 NetworkTypePattern::Cellular()));
142 SetupPolicy(global_config_disable_wifi_and_cell, false); 142 SetupPolicy(global_config_disable_wifi_and_cell, false);
143 EXPECT_TRUE( 143 EXPECT_TRUE(
144 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi())); 144 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi()));
145 EXPECT_TRUE(network_state_handler_->IsTechnologyEnabled( 145 EXPECT_TRUE(network_state_handler_->IsTechnologyEnabled(
146 NetworkTypePattern::Cellular())); 146 NetworkTypePattern::Cellular()));
147 }; 147 }
148 148
149 TEST_F(ProhibitedTechnologiesHandlerTest, 149 TEST_F(ProhibitedTechnologiesHandlerTest,
150 ProhibitedTechnologiesNotAllowedUserSession) { 150 ProhibitedTechnologiesNotAllowedUserSession) {
151 EXPECT_TRUE( 151 EXPECT_TRUE(
152 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi())); 152 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi()));
153 EXPECT_TRUE(network_state_handler_->IsTechnologyEnabled( 153 EXPECT_TRUE(network_state_handler_->IsTechnologyEnabled(
154 NetworkTypePattern::Cellular())); 154 NetworkTypePattern::Cellular()));
155 SetupPolicy(global_config_disable_wifi_and_cell, false); 155 SetupPolicy(global_config_disable_wifi_and_cell, false);
156 156
157 LoginToRegularUser(); 157 LoginToRegularUser();
158 EXPECT_TRUE( 158 EXPECT_TRUE(
159 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi())); 159 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi()));
160 EXPECT_TRUE(network_state_handler_->IsTechnologyEnabled( 160 EXPECT_TRUE(network_state_handler_->IsTechnologyEnabled(
161 NetworkTypePattern::Cellular())); 161 NetworkTypePattern::Cellular()));
162 162
163 SetupPolicy(base::DictionaryValue(), true); // wait for user policy 163 SetupPolicy(base::DictionaryValue(), true); // wait for user policy
164 164
165 // Should be disabled after logged in 165 // Should be disabled after logged in
166 EXPECT_FALSE( 166 EXPECT_FALSE(
167 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi())); 167 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi()));
168 EXPECT_FALSE(network_state_handler_->IsTechnologyEnabled( 168 EXPECT_FALSE(network_state_handler_->IsTechnologyEnabled(
169 NetworkTypePattern::Cellular())); 169 NetworkTypePattern::Cellular()));
170 170
171 // Can not enable it back 171 // Can not enable it back
172 network_state_handler_->SetTechnologyEnabled( 172 network_state_handler_->SetTechnologyEnabled(
173 NetworkTypePattern::WiFi(), true, network_handler::ErrorCallback()); 173 NetworkTypePattern::WiFi(), true, network_handler::ErrorCallback());
174 network_state_handler_->SetTechnologyEnabled( 174 network_state_handler_->SetTechnologyEnabled(
175 NetworkTypePattern::Cellular(), true, network_handler::ErrorCallback()); 175 NetworkTypePattern::Cellular(), true, network_handler::ErrorCallback());
176 message_loop_.RunUntilIdle(); 176 base::RunLoop().RunUntilIdle();
177 EXPECT_FALSE( 177 EXPECT_FALSE(
178 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi())); 178 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi()));
179 EXPECT_FALSE(network_state_handler_->IsTechnologyEnabled( 179 EXPECT_FALSE(network_state_handler_->IsTechnologyEnabled(
180 NetworkTypePattern::Cellular())); 180 NetworkTypePattern::Cellular()));
181 181
182 // Can enable Cellular back after modifying policy 182 // Can enable Cellular back after modifying policy
183 SetupPolicy(global_config_disable_wifi, false); 183 SetupPolicy(global_config_disable_wifi, false);
184 network_state_handler_->SetTechnologyEnabled( 184 network_state_handler_->SetTechnologyEnabled(
185 NetworkTypePattern::WiFi(), true, network_handler::ErrorCallback()); 185 NetworkTypePattern::WiFi(), true, network_handler::ErrorCallback());
186 network_state_handler_->SetTechnologyEnabled( 186 network_state_handler_->SetTechnologyEnabled(
187 NetworkTypePattern::Cellular(), true, network_handler::ErrorCallback()); 187 NetworkTypePattern::Cellular(), true, network_handler::ErrorCallback());
188 message_loop_.RunUntilIdle(); 188 base::RunLoop().RunUntilIdle();
189 EXPECT_FALSE( 189 EXPECT_FALSE(
190 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi())); 190 network_state_handler_->IsTechnologyEnabled(NetworkTypePattern::WiFi()));
191 EXPECT_TRUE(network_state_handler_->IsTechnologyEnabled( 191 EXPECT_TRUE(network_state_handler_->IsTechnologyEnabled(
192 NetworkTypePattern::Cellular())); 192 NetworkTypePattern::Cellular()));
193 }; 193 }
194 194
195 } // namespace chromeos 195 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698