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

Side by Side Diff: chromeos/network/onc/onc_utils_unittest.cc

Issue 2816513002: Revert of Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « chromeos/network/onc/onc_utils.cc ('k') | chromeos/network/onc/onc_validator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/onc/onc_utils.h" 5 #include "chromeos/network/onc/onc_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/json/json_file_value_serializer.h" 9 #include "base/json/json_file_value_serializer.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 ASSERT_TRUE(tests1); 172 ASSERT_TRUE(tests1);
173 173
174 std::unique_ptr<base::ListValue> list_of_tests = tests1->CreateDeepCopy(); 174 std::unique_ptr<base::ListValue> list_of_tests = tests1->CreateDeepCopy();
175 175
176 // Additional ONC -> ProxyConfig test cases to test fixup. 176 // Additional ONC -> ProxyConfig test cases to test fixup.
177 test_data = ReadTestJson("proxy_config_from_onc.json"); 177 test_data = ReadTestJson("proxy_config_from_onc.json");
178 base::ListValue* tests2; 178 base::ListValue* tests2;
179 test_data->GetAsList(&tests2); 179 test_data->GetAsList(&tests2);
180 ASSERT_TRUE(tests2); 180 ASSERT_TRUE(tests2);
181 for (auto iter1 = tests2->begin(); iter1 != tests2->end(); ++iter1) 181 for (auto iter1 = tests2->begin(); iter1 != tests2->end(); ++iter1)
182 list_of_tests->Append(iter1->CreateDeepCopy()); 182 list_of_tests->Append((*iter1)->CreateDeepCopy());
183 183
184 int index = 0; 184 int index = 0;
185 for (auto iter2 = list_of_tests->begin(); iter2 != list_of_tests->end(); 185 for (auto iter2 = list_of_tests->begin(); iter2 != list_of_tests->end();
186 ++iter2, ++index) { 186 ++iter2, ++index) {
187 SCOPED_TRACE("Test case #" + base::IntToString(index)); 187 SCOPED_TRACE("Test case #" + base::IntToString(index));
188 188
189 base::DictionaryValue* test_case = nullptr; 189 base::DictionaryValue* test_case = nullptr;
190 iter2->GetAsDictionary(&test_case); 190 (*iter2)->GetAsDictionary(&test_case);
191 ASSERT_TRUE(test_case); 191 ASSERT_TRUE(test_case);
192 192
193 base::DictionaryValue* onc_proxy_settings; 193 base::DictionaryValue* onc_proxy_settings;
194 test_case->GetDictionary("ONC_ProxySettings", &onc_proxy_settings); 194 test_case->GetDictionary("ONC_ProxySettings", &onc_proxy_settings);
195 195
196 base::DictionaryValue* expected_proxy_config; 196 base::DictionaryValue* expected_proxy_config;
197 test_case->GetDictionary("ProxyConfig", &expected_proxy_config); 197 test_case->GetDictionary("ProxyConfig", &expected_proxy_config);
198 198
199 std::unique_ptr<base::DictionaryValue> actual_proxy_config = 199 std::unique_ptr<base::DictionaryValue> actual_proxy_config =
200 ConvertOncProxySettingsToProxyConfig(*onc_proxy_settings); 200 ConvertOncProxySettingsToProxyConfig(*onc_proxy_settings);
201 EXPECT_TRUE( 201 EXPECT_TRUE(
202 test_utils::Equals(expected_proxy_config, actual_proxy_config.get())); 202 test_utils::Equals(expected_proxy_config, actual_proxy_config.get()));
203 } 203 }
204 } 204 }
205 205
206 TEST(ONCUtils, ProxyConfigToOncProxySettings) { 206 TEST(ONCUtils, ProxyConfigToOncProxySettings) {
207 std::unique_ptr<base::Value> test_data(ReadTestJson("proxy_config.json")); 207 std::unique_ptr<base::Value> test_data(ReadTestJson("proxy_config.json"));
208 208
209 base::ListValue* list_of_tests; 209 base::ListValue* list_of_tests;
210 test_data->GetAsList(&list_of_tests); 210 test_data->GetAsList(&list_of_tests);
211 ASSERT_TRUE(list_of_tests); 211 ASSERT_TRUE(list_of_tests);
212 212
213 int index = 0; 213 int index = 0;
214 for (base::ListValue::iterator it = list_of_tests->begin(); 214 for (base::ListValue::iterator it = list_of_tests->begin();
215 it != list_of_tests->end(); ++it, ++index) { 215 it != list_of_tests->end(); ++it, ++index) {
216 SCOPED_TRACE("Test case #" + base::IntToString(index)); 216 SCOPED_TRACE("Test case #" + base::IntToString(index));
217 217
218 base::DictionaryValue* test_case; 218 base::DictionaryValue* test_case;
219 it->GetAsDictionary(&test_case); 219 (*it)->GetAsDictionary(&test_case);
220 220
221 base::DictionaryValue* shill_proxy_config; 221 base::DictionaryValue* shill_proxy_config;
222 test_case->GetDictionary("ProxyConfig", &shill_proxy_config); 222 test_case->GetDictionary("ProxyConfig", &shill_proxy_config);
223 223
224 base::DictionaryValue* onc_proxy_settings; 224 base::DictionaryValue* onc_proxy_settings;
225 test_case->GetDictionary("ONC_ProxySettings", &onc_proxy_settings); 225 test_case->GetDictionary("ONC_ProxySettings", &onc_proxy_settings);
226 226
227 std::unique_ptr<base::DictionaryValue> actual_proxy_settings = 227 std::unique_ptr<base::DictionaryValue> actual_proxy_settings =
228 ConvertProxyConfigToOncProxySettings( 228 ConvertProxyConfigToOncProxySettings(
229 shill_proxy_config->CreateDeepCopy()); 229 shill_proxy_config->CreateDeepCopy());
230 EXPECT_TRUE( 230 EXPECT_TRUE(
231 test_utils::Equals(onc_proxy_settings, actual_proxy_settings.get())); 231 test_utils::Equals(onc_proxy_settings, actual_proxy_settings.get()));
232 } 232 }
233 } 233 }
234 234
235 } // namespace onc 235 } // namespace onc
236 } // namespace chromeos 236 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_utils.cc ('k') | chromeos/network/onc/onc_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698