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

Side by Side Diff: chrome/browser/chromeos/proxy_config_service_impl_unittest.cc

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments 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 #include "chromeos/network/proxy/proxy_config_service_impl.h" 5 #include "chromeos/network/proxy/proxy_config_service_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h"
16 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
17 #include "base/run_loop.h" 18 #include "base/run_loop.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
19 #include "chrome/browser/chromeos/settings/cros_settings.h" 20 #include "chrome/browser/chromeos/settings/cros_settings.h"
20 #include "chrome/browser/chromeos/settings/device_settings_service.h" 21 #include "chrome/browser/chromeos/settings/device_settings_service.h"
21 #include "chromeos/dbus/dbus_thread_manager.h" 22 #include "chromeos/dbus/dbus_thread_manager.h"
22 #include "chromeos/dbus/shill_profile_client.h" 23 #include "chromeos/dbus/shill_profile_client.h"
23 #include "chromeos/dbus/shill_service_client.h" 24 #include "chromeos/dbus/shill_service_client.h"
24 #include "chromeos/network/network_handler.h" 25 #include "chromeos/network/network_handler.h"
25 #include "chromeos/network/network_profile_handler.h" 26 #include "chromeos/network/network_profile_handler.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 InitConfigWithTestInput(managed_params.input, &managed_config); 448 InitConfigWithTestInput(managed_params.input, &managed_config);
448 base::DictionaryValue recommended_config; 449 base::DictionaryValue recommended_config;
449 InitConfigWithTestInput(recommended_params.input, &recommended_config); 450 InitConfigWithTestInput(recommended_params.input, &recommended_config);
450 base::DictionaryValue network_config; 451 base::DictionaryValue network_config;
451 InitConfigWithTestInput(network_params.input, &network_config); 452 InitConfigWithTestInput(network_params.input, &network_config);
452 453
453 // Managed proxy pref should take effect over recommended proxy and 454 // Managed proxy pref should take effect over recommended proxy and
454 // non-existent network proxy. 455 // non-existent network proxy.
455 SetUserConfigInShill(nullptr); 456 SetUserConfigInShill(nullptr);
456 pref_service_.SetManagedPref(::proxy_config::prefs::kProxy, 457 pref_service_.SetManagedPref(::proxy_config::prefs::kProxy,
457 managed_config.DeepCopy()); 458 managed_config.CreateDeepCopy());
458 pref_service_.SetRecommendedPref(::proxy_config::prefs::kProxy, 459 pref_service_.SetRecommendedPref(::proxy_config::prefs::kProxy,
459 recommended_config.DeepCopy()); 460 recommended_config.CreateDeepCopy());
460 net::ProxyConfig actual_config; 461 net::ProxyConfig actual_config;
461 SyncGetLatestProxyConfig(&actual_config); 462 SyncGetLatestProxyConfig(&actual_config);
462 EXPECT_EQ(managed_params.auto_detect, actual_config.auto_detect()); 463 EXPECT_EQ(managed_params.auto_detect, actual_config.auto_detect());
463 EXPECT_EQ(managed_params.pac_url, actual_config.pac_url()); 464 EXPECT_EQ(managed_params.pac_url, actual_config.pac_url());
464 EXPECT_TRUE(managed_params.proxy_rules.Matches( 465 EXPECT_TRUE(managed_params.proxy_rules.Matches(
465 actual_config.proxy_rules())); 466 actual_config.proxy_rules()));
466 467
467 // Recommended proxy pref should take effect when managed proxy pref is 468 // Recommended proxy pref should take effect when managed proxy pref is
468 // removed. 469 // removed.
469 pref_service_.RemoveManagedPref(::proxy_config::prefs::kProxy); 470 pref_service_.RemoveManagedPref(::proxy_config::prefs::kProxy);
470 SyncGetLatestProxyConfig(&actual_config); 471 SyncGetLatestProxyConfig(&actual_config);
471 EXPECT_EQ(recommended_params.auto_detect, actual_config.auto_detect()); 472 EXPECT_EQ(recommended_params.auto_detect, actual_config.auto_detect());
472 EXPECT_EQ(recommended_params.pac_url, actual_config.pac_url()); 473 EXPECT_EQ(recommended_params.pac_url, actual_config.pac_url());
473 EXPECT_TRUE(recommended_params.proxy_rules.Matches( 474 EXPECT_TRUE(recommended_params.proxy_rules.Matches(
474 actual_config.proxy_rules())); 475 actual_config.proxy_rules()));
475 476
476 // Network proxy should take take effect over recommended proxy pref. 477 // Network proxy should take take effect over recommended proxy pref.
477 SetUserConfigInShill(&network_config); 478 SetUserConfigInShill(&network_config);
478 SyncGetLatestProxyConfig(&actual_config); 479 SyncGetLatestProxyConfig(&actual_config);
479 EXPECT_EQ(network_params.auto_detect, actual_config.auto_detect()); 480 EXPECT_EQ(network_params.auto_detect, actual_config.auto_detect());
480 EXPECT_EQ(network_params.pac_url, actual_config.pac_url()); 481 EXPECT_EQ(network_params.pac_url, actual_config.pac_url());
481 EXPECT_TRUE(network_params.proxy_rules.Matches( 482 EXPECT_TRUE(network_params.proxy_rules.Matches(
482 actual_config.proxy_rules())); 483 actual_config.proxy_rules()));
483 484
484 // Managed proxy pref should take effect over network proxy. 485 // Managed proxy pref should take effect over network proxy.
485 pref_service_.SetManagedPref(::proxy_config::prefs::kProxy, 486 pref_service_.SetManagedPref(::proxy_config::prefs::kProxy,
486 managed_config.DeepCopy()); 487 managed_config.CreateDeepCopy());
487 SyncGetLatestProxyConfig(&actual_config); 488 SyncGetLatestProxyConfig(&actual_config);
488 EXPECT_EQ(managed_params.auto_detect, actual_config.auto_detect()); 489 EXPECT_EQ(managed_params.auto_detect, actual_config.auto_detect());
489 EXPECT_EQ(managed_params.pac_url, actual_config.pac_url()); 490 EXPECT_EQ(managed_params.pac_url, actual_config.pac_url());
490 EXPECT_TRUE(managed_params.proxy_rules.Matches( 491 EXPECT_TRUE(managed_params.proxy_rules.Matches(
491 actual_config.proxy_rules())); 492 actual_config.proxy_rules()));
492 493
493 // Network proxy should take effect over recommended proxy pref when managed 494 // Network proxy should take effect over recommended proxy pref when managed
494 // proxy pref is removed. 495 // proxy pref is removed.
495 pref_service_.RemoveManagedPref(::proxy_config::prefs::kProxy); 496 pref_service_.RemoveManagedPref(::proxy_config::prefs::kProxy);
496 SyncGetLatestProxyConfig(&actual_config); 497 SyncGetLatestProxyConfig(&actual_config);
(...skipping 19 matching lines...) Expand all
516 SetUpSharedEthernet(); 517 SetUpSharedEthernet();
517 SetUpProxyConfigService(&profile_prefs_); 518 SetUpProxyConfigService(&profile_prefs_);
518 519
519 std::unique_ptr<base::DictionaryValue> ethernet_policy( 520 std::unique_ptr<base::DictionaryValue> ethernet_policy(
520 chromeos::onc::ReadDictionaryFromJson(kEthernetPolicy)); 521 chromeos::onc::ReadDictionaryFromJson(kEthernetPolicy));
521 522
522 std::unique_ptr<base::ListValue> network_configs(new base::ListValue); 523 std::unique_ptr<base::ListValue> network_configs(new base::ListValue);
523 network_configs->Append(std::move(ethernet_policy)); 524 network_configs->Append(std::move(ethernet_policy));
524 525
525 profile_prefs_.SetUserPref(::proxy_config::prefs::kUseSharedProxies, 526 profile_prefs_.SetUserPref(::proxy_config::prefs::kUseSharedProxies,
526 new base::Value(false)); 527 base::MakeUnique<base::Value>(false));
527 profile_prefs_.SetManagedPref(::onc::prefs::kOpenNetworkConfiguration, 528 profile_prefs_.SetManagedPref(::onc::prefs::kOpenNetworkConfiguration,
528 network_configs.release()); 529 std::move(network_configs));
529 530
530 net::ProxyConfig actual_config; 531 net::ProxyConfig actual_config;
531 SyncGetLatestProxyConfig(&actual_config); 532 SyncGetLatestProxyConfig(&actual_config);
532 net::ProxyConfig expected_config = 533 net::ProxyConfig expected_config =
533 net::ProxyConfig::CreateFromCustomPacURL(GURL("http://domain.com/x")); 534 net::ProxyConfig::CreateFromCustomPacURL(GURL("http://domain.com/x"));
534 EXPECT_TRUE(expected_config.Equals(actual_config)); 535 EXPECT_TRUE(expected_config.Equals(actual_config));
535 } 536 }
536 537
537 } // namespace chromeos 538 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698