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

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

Issue 1328233002: Ramove use of JSONReader::DeprecatedRead from chromeos/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 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 "chromeos/network/auto_connect_handler.h" 5 #include "chromeos/network/auto_connect_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 test_nssdb_.slot())); 207 test_nssdb_.slot()));
208 return client_cert; 208 return client_cert;
209 } 209 }
210 210
211 void SetupPolicy(const std::string& network_configs_json, 211 void SetupPolicy(const std::string& network_configs_json,
212 const base::DictionaryValue& global_config, 212 const base::DictionaryValue& global_config,
213 bool user_policy) { 213 bool user_policy) {
214 scoped_ptr<base::ListValue> network_configs(new base::ListValue); 214 scoped_ptr<base::ListValue> network_configs(new base::ListValue);
215 if (!network_configs_json.empty()) { 215 if (!network_configs_json.empty()) {
216 std::string error; 216 std::string error;
217 base::Value* network_configs_value = 217 scoped_ptr<base::Value> network_configs_value =
218 base::JSONReader::DeprecatedReadAndReturnError( 218 base::JSONReader::ReadAndReturnError(network_configs_json,
219 network_configs_json, base::JSON_ALLOW_TRAILING_COMMAS, nullptr, 219 base::JSON_ALLOW_TRAILING_COMMAS,
220 &error); 220 nullptr, &error);
221 ASSERT_TRUE(network_configs_value) << error; 221 ASSERT_TRUE(network_configs_value.get()) << error;
pneubeck (no reviews) 2015/09/09 11:49:51 it's common to drop the ".get()" for boolean check
222 base::ListValue* network_configs_list = nullptr; 222 base::ListValue* network_configs_list = nullptr;
223 ASSERT_TRUE(network_configs_value->GetAsList(&network_configs_list)); 223 ASSERT_TRUE(
224 network_configs_value.release()->GetAsList(&network_configs_list));
pneubeck (no reviews) 2015/09/09 11:49:51 can you do the release after we ensured that netwo
224 network_configs.reset(network_configs_list); 225 network_configs.reset(network_configs_list);
225 } 226 }
226 227
227 if (user_policy) { 228 if (user_policy) {
228 managed_config_handler_->SetPolicy(::onc::ONC_SOURCE_USER_POLICY, 229 managed_config_handler_->SetPolicy(::onc::ONC_SOURCE_USER_POLICY,
229 kUserHash, *network_configs, 230 kUserHash, *network_configs,
230 global_config); 231 global_config);
231 } else { 232 } else {
232 managed_config_handler_->SetPolicy(::onc::ONC_SOURCE_DEVICE_POLICY, 233 managed_config_handler_->SetPolicy(::onc::ONC_SOURCE_DEVICE_POLICY,
233 std::string(), // no username hash 234 std::string(), // no username hash
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 // Applying the user policy after login would usually trigger connecting to 463 // Applying the user policy after login would usually trigger connecting to
463 // the 'best' network. But the manual connect prevents this. 464 // the 'best' network. But the manual connect prevents this.
464 SetupPolicy(std::string(), // no network configs 465 SetupPolicy(std::string(), // no network configs
465 base::DictionaryValue(), // no global config 466 base::DictionaryValue(), // no global config
466 true); // load as user policy 467 true); // load as user policy
467 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); 468 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0"));
468 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); 469 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1"));
469 } 470 }
470 471
471 } // namespace chromeos 472 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698