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

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

Issue 2861883002: [CrOS Tether] Transform NetworkConnectionHandler to an interface. (Closed)
Patch Set: stevenjb@ comments. Created 3 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/network_connection_handler.h" 5 #include "chromeos/network/network_connection_handler_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 network_profile_handler_.reset(new NetworkProfileHandler()); 146 network_profile_handler_.reset(new NetworkProfileHandler());
147 network_profile_handler_->Init(); 147 network_profile_handler_->Init();
148 148
149 managed_config_handler_.reset(new ManagedNetworkConfigurationHandlerImpl()); 149 managed_config_handler_.reset(new ManagedNetworkConfigurationHandlerImpl());
150 managed_config_handler_->Init( 150 managed_config_handler_->Init(
151 network_state_handler(), network_profile_handler_.get(), 151 network_state_handler(), network_profile_handler_.get(),
152 network_config_handler_.get(), nullptr /* network_device_handler */, 152 network_config_handler_.get(), nullptr /* network_device_handler */,
153 nullptr /* prohibited_tecnologies_handler */); 153 nullptr /* prohibited_tecnologies_handler */);
154 154
155 network_connection_handler_.reset(new NetworkConnectionHandler); 155 network_connection_handler_.reset(new NetworkConnectionHandlerImpl());
156 network_connection_handler_->Init(network_state_handler(), 156 network_connection_handler_->Init(network_state_handler(),
157 network_config_handler_.get(), 157 network_config_handler_.get(),
158 managed_config_handler_.get()); 158 managed_config_handler_.get());
159 network_connection_observer_.reset(new TestNetworkConnectionObserver); 159 network_connection_observer_.reset(new TestNetworkConnectionObserver);
160 network_connection_handler_->AddObserver( 160 network_connection_handler_->AddObserver(
161 network_connection_observer_.get()); 161 network_connection_observer_.get());
162 162
163 base::RunLoop().RunUntilIdle(); 163 base::RunLoop().RunUntilIdle();
164 164
165 fake_tether_delegate_.reset(new FakeTetherDelegate()); 165 fake_tether_delegate_.reset(new FakeTetherDelegate());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void Disconnect(const std::string& service_path) { 202 void Disconnect(const std::string& service_path) {
203 network_connection_handler_->DisconnectNetwork( 203 network_connection_handler_->DisconnectNetwork(
204 service_path, 204 service_path,
205 base::Bind(&NetworkConnectionHandlerTest::SuccessCallback, 205 base::Bind(&NetworkConnectionHandlerTest::SuccessCallback,
206 base::Unretained(this)), 206 base::Unretained(this)),
207 base::Bind(&NetworkConnectionHandlerTest::ErrorCallback, 207 base::Bind(&NetworkConnectionHandlerTest::ErrorCallback,
208 base::Unretained(this))); 208 base::Unretained(this)));
209 base::RunLoop().RunUntilIdle(); 209 base::RunLoop().RunUntilIdle();
210 } 210 }
211 211
212 void SuccessCallback() { 212 void SuccessCallback() { result_ = kSuccessResult; }
213 result_ = kSuccessResult;
214 }
215 213
216 void ErrorCallback(const std::string& error_name, 214 void ErrorCallback(const std::string& error_name,
217 std::unique_ptr<base::DictionaryValue> error_data) { 215 std::unique_ptr<base::DictionaryValue> error_data) {
218 result_ = error_name; 216 result_ = error_name;
219 } 217 }
220 218
221 std::string GetResultAndReset() { 219 std::string GetResultAndReset() {
222 std::string result; 220 std::string result;
223 result.swap(result_); 221 result.swap(result_);
224 return result; 222 return result;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 base::ListValue* network_configs = nullptr; 270 base::ListValue* network_configs = nullptr;
273 ASSERT_TRUE(network_configs_value->GetAsList(&network_configs)); 271 ASSERT_TRUE(network_configs_value->GetAsList(&network_configs));
274 272
275 if (user_policy) { 273 if (user_policy) {
276 managed_config_handler_->SetPolicy(::onc::ONC_SOURCE_USER_POLICY, 274 managed_config_handler_->SetPolicy(::onc::ONC_SOURCE_USER_POLICY,
277 kUserHash, *network_configs, 275 kUserHash, *network_configs,
278 global_config); 276 global_config);
279 } else { 277 } else {
280 managed_config_handler_->SetPolicy(::onc::ONC_SOURCE_DEVICE_POLICY, 278 managed_config_handler_->SetPolicy(::onc::ONC_SOURCE_DEVICE_POLICY,
281 std::string(), // no username hash 279 std::string(), // no username hash
282 *network_configs, 280 *network_configs, global_config);
283 global_config);
284 } 281 }
285 base::RunLoop().RunUntilIdle(); 282 base::RunLoop().RunUntilIdle();
286 } 283 }
287 284
288 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; 285 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_;
289 std::unique_ptr<NetworkConnectionHandler> network_connection_handler_; 286 std::unique_ptr<NetworkConnectionHandler> network_connection_handler_;
290 std::unique_ptr<TestNetworkConnectionObserver> network_connection_observer_; 287 std::unique_ptr<TestNetworkConnectionObserver> network_connection_observer_;
291 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> 288 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl>
292 managed_config_handler_; 289 managed_config_handler_;
293 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; 290 std::unique_ptr<NetworkProfileHandler> network_profile_handler_;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 EXPECT_EQ( 531 EXPECT_EQ(
535 NetworkConnectionHandler::kErrorTetherConnectionAttemptWithNoDelegate, 532 NetworkConnectionHandler::kErrorTetherConnectionAttemptWithNoDelegate,
536 GetResultAndReset()); 533 GetResultAndReset());
537 EXPECT_TRUE(network_connection_observer_->GetRequested(kTetherGuid)); 534 EXPECT_TRUE(network_connection_observer_->GetRequested(kTetherGuid));
538 EXPECT_EQ( 535 EXPECT_EQ(
539 NetworkConnectionHandler::kErrorTetherConnectionAttemptWithNoDelegate, 536 NetworkConnectionHandler::kErrorTetherConnectionAttemptWithNoDelegate,
540 network_connection_observer_->GetResult(kTetherGuid)); 537 network_connection_observer_->GetResult(kTetherGuid));
541 } 538 }
542 539
543 } // namespace chromeos 540 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_connection_handler_impl.cc ('k') | chromeos/network/network_connection_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698