OLD | NEW |
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 actual_resolved_onc.get()); | 160 actual_resolved_onc.get()); |
161 EXPECT_EQ(expected_success, success); | 161 EXPECT_EQ(expected_success, success); |
162 EXPECT_TRUE(test_utils::Equals(expected_resolved_onc, | 162 EXPECT_TRUE(test_utils::Equals(expected_resolved_onc, |
163 actual_resolved_onc.get())); | 163 actual_resolved_onc.get())); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 TEST(ONCUtils, ProxySettingsToProxyConfig) { | 167 TEST(ONCUtils, ProxySettingsToProxyConfig) { |
168 std::unique_ptr<base::Value> test_data(ReadTestJson("proxy_config.json")); | 168 std::unique_ptr<base::Value> test_data(ReadTestJson("proxy_config.json")); |
169 | 169 |
170 base::ListValue* list_of_tests; | 170 base::ListValue* tests1; |
171 test_data->GetAsList(&list_of_tests); | 171 test_data->GetAsList(&tests1); |
172 ASSERT_TRUE(list_of_tests); | 172 ASSERT_TRUE(tests1); |
| 173 |
| 174 std::unique_ptr<base::ListValue> list_of_tests = tests1->CreateDeepCopy(); |
| 175 |
| 176 // Additional ONC -> ProxyConfig test cases to test fixup. |
| 177 test_data = ReadTestJson("proxy_config_from_onc.json"); |
| 178 base::ListValue* tests2; |
| 179 test_data->GetAsList(&tests2); |
| 180 ASSERT_TRUE(tests2); |
| 181 for (auto iter1 = tests2->begin(); iter1 != tests2->end(); ++iter1) |
| 182 list_of_tests->Append((*iter1)->CreateDeepCopy()); |
173 | 183 |
174 int index = 0; | 184 int index = 0; |
175 for (base::ListValue::iterator it = list_of_tests->begin(); | 185 for (auto iter2 = list_of_tests->begin(); iter2 != list_of_tests->end(); |
176 it != list_of_tests->end(); ++it, ++index) { | 186 ++iter2, ++index) { |
177 SCOPED_TRACE("Test case #" + base::IntToString(index)); | 187 SCOPED_TRACE("Test case #" + base::IntToString(index)); |
178 | 188 |
179 base::DictionaryValue* test_case; | 189 base::DictionaryValue* test_case = nullptr; |
180 (*it)->GetAsDictionary(&test_case); | 190 (*iter2)->GetAsDictionary(&test_case); |
| 191 ASSERT_TRUE(test_case); |
181 | 192 |
182 base::DictionaryValue* onc_proxy_settings; | 193 base::DictionaryValue* onc_proxy_settings; |
183 test_case->GetDictionary("ONC_ProxySettings", &onc_proxy_settings); | 194 test_case->GetDictionary("ONC_ProxySettings", &onc_proxy_settings); |
184 | 195 |
185 base::DictionaryValue* expected_proxy_config; | 196 base::DictionaryValue* expected_proxy_config; |
186 test_case->GetDictionary("ProxyConfig", &expected_proxy_config); | 197 test_case->GetDictionary("ProxyConfig", &expected_proxy_config); |
187 | 198 |
188 std::unique_ptr<base::DictionaryValue> actual_proxy_config = | 199 std::unique_ptr<base::DictionaryValue> actual_proxy_config = |
189 ConvertOncProxySettingsToProxyConfig(*onc_proxy_settings); | 200 ConvertOncProxySettingsToProxyConfig(*onc_proxy_settings); |
190 EXPECT_TRUE( | 201 EXPECT_TRUE( |
(...skipping 24 matching lines...) Expand all Loading... |
215 | 226 |
216 std::unique_ptr<base::DictionaryValue> actual_proxy_settings = | 227 std::unique_ptr<base::DictionaryValue> actual_proxy_settings = |
217 ConvertProxyConfigToOncProxySettings(*shill_proxy_config); | 228 ConvertProxyConfigToOncProxySettings(*shill_proxy_config); |
218 EXPECT_TRUE( | 229 EXPECT_TRUE( |
219 test_utils::Equals(onc_proxy_settings, actual_proxy_settings.get())); | 230 test_utils::Equals(onc_proxy_settings, actual_proxy_settings.get())); |
220 } | 231 } |
221 } | 232 } |
222 | 233 |
223 } // namespace onc | 234 } // namespace onc |
224 } // namespace chromeos | 235 } // namespace chromeos |
OLD | NEW |