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

Side by Side Diff: chrome/browser/extensions/api/proxy/proxy_api_helpers_unittest.cc

Issue 2785883003: Use unique_ptr<DictionaryValue> in ProxyConfigDictionary (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
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 // Unit tests for helper functions for the Chrome Extensions Proxy Settings API. 5 // Unit tests for helper functions for the Chrome Extensions Proxy Settings API.
6 6
7 #include "chrome/browser/extensions/api/proxy/proxy_api_helpers.h" 7 #include "chrome/browser/extensions/api/proxy/proxy_api_helpers.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 ASSERT_TRUE( 215 ASSERT_TRUE(
216 GetBypassListFromExtensionPref(&proxy_config, &out, &error, 216 GetBypassListFromExtensionPref(&proxy_config, &out, &error,
217 &bad_message)); 217 &bad_message));
218 EXPECT_EQ("host1,host2", out); 218 EXPECT_EQ("host1,host2", out);
219 EXPECT_EQ(std::string(), error); 219 EXPECT_EQ(std::string(), error);
220 EXPECT_FALSE(bad_message); 220 EXPECT_FALSE(bad_message);
221 } 221 }
222 222
223 TEST(ExtensionProxyApiHelpers, CreateProxyConfigDict) { 223 TEST(ExtensionProxyApiHelpers, CreateProxyConfigDict) {
224 std::string error; 224 std::string error;
225 std::unique_ptr<base::DictionaryValue> exp_direct( 225 std::unique_ptr<base::DictionaryValue> exp_direct =
226 ProxyConfigDictionary::CreateDirect()); 226 ProxyConfigDictionary::CreateDirect();
227 std::unique_ptr<base::DictionaryValue> out_direct(CreateProxyConfigDict( 227 std::unique_ptr<base::DictionaryValue> out_direct(CreateProxyConfigDict(
228 ProxyPrefs::MODE_DIRECT, false, std::string(), std::string(), 228 ProxyPrefs::MODE_DIRECT, false, std::string(), std::string(),
229 std::string(), std::string(), &error)); 229 std::string(), std::string(), &error));
230 EXPECT_TRUE(base::Value::Equals(exp_direct.get(), out_direct.get())); 230 EXPECT_TRUE(base::Value::Equals(exp_direct.get(), out_direct.get()));
231 231
232 std::unique_ptr<base::DictionaryValue> exp_auto( 232 std::unique_ptr<base::DictionaryValue> exp_auto =
233 ProxyConfigDictionary::CreateAutoDetect()); 233 ProxyConfigDictionary::CreateAutoDetect();
234 std::unique_ptr<base::DictionaryValue> out_auto(CreateProxyConfigDict( 234 std::unique_ptr<base::DictionaryValue> out_auto(CreateProxyConfigDict(
235 ProxyPrefs::MODE_AUTO_DETECT, false, std::string(), std::string(), 235 ProxyPrefs::MODE_AUTO_DETECT, false, std::string(), std::string(),
236 std::string(), std::string(), &error)); 236 std::string(), std::string(), &error));
237 EXPECT_TRUE(base::Value::Equals(exp_auto.get(), out_auto.get())); 237 EXPECT_TRUE(base::Value::Equals(exp_auto.get(), out_auto.get()));
238 238
239 std::unique_ptr<base::DictionaryValue> exp_pac_url( 239 std::unique_ptr<base::DictionaryValue> exp_pac_url =
240 ProxyConfigDictionary::CreatePacScript(kSamplePacScriptUrl, false)); 240 ProxyConfigDictionary::CreatePacScript(kSamplePacScriptUrl, false);
241 std::unique_ptr<base::DictionaryValue> out_pac_url(CreateProxyConfigDict( 241 std::unique_ptr<base::DictionaryValue> out_pac_url(CreateProxyConfigDict(
242 ProxyPrefs::MODE_PAC_SCRIPT, false, kSamplePacScriptUrl, std::string(), 242 ProxyPrefs::MODE_PAC_SCRIPT, false, kSamplePacScriptUrl, std::string(),
243 std::string(), std::string(), &error)); 243 std::string(), std::string(), &error));
244 EXPECT_TRUE(base::Value::Equals(exp_pac_url.get(), out_pac_url.get())); 244 EXPECT_TRUE(base::Value::Equals(exp_pac_url.get(), out_pac_url.get()));
245 245
246 std::unique_ptr<base::DictionaryValue> exp_pac_data( 246 std::unique_ptr<base::DictionaryValue> exp_pac_data =
247 ProxyConfigDictionary::CreatePacScript(kSamplePacScriptAsDataUrl, false)); 247 ProxyConfigDictionary::CreatePacScript(kSamplePacScriptAsDataUrl, false);
248 std::unique_ptr<base::DictionaryValue> out_pac_data(CreateProxyConfigDict( 248 std::unique_ptr<base::DictionaryValue> out_pac_data(CreateProxyConfigDict(
249 ProxyPrefs::MODE_PAC_SCRIPT, false, std::string(), kSamplePacScript, 249 ProxyPrefs::MODE_PAC_SCRIPT, false, std::string(), kSamplePacScript,
250 std::string(), std::string(), &error)); 250 std::string(), std::string(), &error));
251 EXPECT_TRUE(base::Value::Equals(exp_pac_data.get(), out_pac_data.get())); 251 EXPECT_TRUE(base::Value::Equals(exp_pac_data.get(), out_pac_data.get()));
252 252
253 std::unique_ptr<base::DictionaryValue> exp_fixed( 253 std::unique_ptr<base::DictionaryValue> exp_fixed =
254 ProxyConfigDictionary::CreateFixedServers("foo:80", "localhost")); 254 ProxyConfigDictionary::CreateFixedServers("foo:80", "localhost");
255 std::unique_ptr<base::DictionaryValue> out_fixed(CreateProxyConfigDict( 255 std::unique_ptr<base::DictionaryValue> out_fixed(CreateProxyConfigDict(
256 ProxyPrefs::MODE_FIXED_SERVERS, false, std::string(), std::string(), 256 ProxyPrefs::MODE_FIXED_SERVERS, false, std::string(), std::string(),
257 "foo:80", "localhost", &error)); 257 "foo:80", "localhost", &error));
258 EXPECT_TRUE(base::Value::Equals(exp_fixed.get(), out_fixed.get())); 258 EXPECT_TRUE(base::Value::Equals(exp_fixed.get(), out_fixed.get()));
259 259
260 std::unique_ptr<base::DictionaryValue> exp_system( 260 std::unique_ptr<base::DictionaryValue> exp_system =
261 ProxyConfigDictionary::CreateSystem()); 261 ProxyConfigDictionary::CreateSystem();
262 std::unique_ptr<base::DictionaryValue> out_system(CreateProxyConfigDict( 262 std::unique_ptr<base::DictionaryValue> out_system(CreateProxyConfigDict(
263 ProxyPrefs::MODE_SYSTEM, false, std::string(), std::string(), 263 ProxyPrefs::MODE_SYSTEM, false, std::string(), std::string(),
264 std::string(), std::string(), &error)); 264 std::string(), std::string(), &error));
265 EXPECT_TRUE(base::Value::Equals(exp_system.get(), out_system.get())); 265 EXPECT_TRUE(base::Value::Equals(exp_system.get(), out_system.get()));
266 266
267 // Neither of them should have set an error. 267 // Neither of them should have set an error.
268 EXPECT_EQ(std::string(), error); 268 EXPECT_EQ(std::string(), error);
269 } 269 }
270 270
271 TEST(ExtensionProxyApiHelpers, GetProxyServer) { 271 TEST(ExtensionProxyApiHelpers, GetProxyServer) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 expected.AppendString("s1"); 398 expected.AppendString("s1");
399 expected.AppendString("s2"); 399 expected.AppendString("s2");
400 expected.AppendString("s3"); 400 expected.AppendString("s3");
401 401
402 std::unique_ptr<base::ListValue> out(TokenizeToStringList("s1;s2;s3", ";")); 402 std::unique_ptr<base::ListValue> out(TokenizeToStringList("s1;s2;s3", ";"));
403 EXPECT_TRUE(base::Value::Equals(&expected, out.get())); 403 EXPECT_TRUE(base::Value::Equals(&expected, out.get()));
404 } 404 }
405 405
406 } // namespace proxy_api_helpers 406 } // namespace proxy_api_helpers
407 } // namespace extensions 407 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698