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

Side by Side Diff: chrome/browser/chromeos/arc/intent_helper/arc_settings_service_browsertest.cc

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 provider_.UpdateChromePolicy(policy); 249 provider_.UpdateChromePolicy(policy);
250 RunUntilIdle(); 250 RunUntilIdle();
251 } 251 }
252 252
253 protected: 253 protected:
254 void DisconnectNetworkService(const std::string& service_path) { 254 void DisconnectNetworkService(const std::string& service_path) {
255 chromeos::ShillServiceClient::TestInterface* service_test = 255 chromeos::ShillServiceClient::TestInterface* service_test =
256 chromeos::DBusThreadManager::Get() 256 chromeos::DBusThreadManager::Get()
257 ->GetShillServiceClient() 257 ->GetShillServiceClient()
258 ->GetTestInterface(); 258 ->GetTestInterface();
259 base::StringValue value(shill::kStateIdle); 259 base::Value value(shill::kStateIdle);
260 service_test->SetServiceProperty(service_path, shill::kStateProperty, 260 service_test->SetServiceProperty(service_path, shill::kStateProperty,
261 value); 261 value);
262 RunUntilIdle(); 262 RunUntilIdle();
263 } 263 }
264 264
265 void ConnectWifiNetworkService(const std::string& service_path, 265 void ConnectWifiNetworkService(const std::string& service_path,
266 const std::string& guid, 266 const std::string& guid,
267 const std::string& ssid) { 267 const std::string& ssid) {
268 chromeos::ShillServiceClient::TestInterface* service_test = 268 chromeos::ShillServiceClient::TestInterface* service_test =
269 chromeos::DBusThreadManager::Get() 269 chromeos::DBusThreadManager::Get()
270 ->GetShillServiceClient() 270 ->GetShillServiceClient()
271 ->GetTestInterface(); 271 ->GetTestInterface();
272 272
273 service_test->AddService(service_path, guid, ssid, shill::kTypeWifi, 273 service_test->AddService(service_path, guid, ssid, shill::kTypeWifi,
274 shill::kStateOnline, true /* add_to_visible */); 274 shill::kStateOnline, true /* add_to_visible */);
275 275
276 service_test->SetServiceProperty(service_path, shill::kProfileProperty, 276 service_test->SetServiceProperty(service_path, shill::kProfileProperty,
277 base::StringValue(kUserProfilePath)); 277 base::Value(kUserProfilePath));
278 RunUntilIdle(); 278 RunUntilIdle();
279 } 279 }
280 280
281 void SetProxyConfigForNetworkService( 281 void SetProxyConfigForNetworkService(
282 const std::string& service_path, 282 const std::string& service_path,
283 const base::DictionaryValue* proxy_config) { 283 const base::DictionaryValue* proxy_config) {
284 ProxyConfigDictionary proxy_config_dict(proxy_config); 284 ProxyConfigDictionary proxy_config_dict(proxy_config);
285 const chromeos::NetworkState* network = chromeos::NetworkHandler::Get() 285 const chromeos::NetworkState* network = chromeos::NetworkHandler::Get()
286 ->network_state_handler() 286 ->network_state_handler()
287 ->GetNetworkState(service_path); 287 ->GetNetworkState(service_path);
(...skipping 17 matching lines...) Expand all
305 305
306 profile_test->AddProfile(kUserProfilePath, "user"); 306 profile_test->AddProfile(kUserProfilePath, "user");
307 307
308 service_test->ClearServices(); 308 service_test->ClearServices();
309 309
310 service_test->AddService(kDefaultServicePath, "stub_ethernet_guid", "eth0", 310 service_test->AddService(kDefaultServicePath, "stub_ethernet_guid", "eth0",
311 shill::kTypeEthernet, shill::kStateOnline, 311 shill::kTypeEthernet, shill::kStateOnline,
312 true /* add_to_visible */); 312 true /* add_to_visible */);
313 service_test->SetServiceProperty(kDefaultServicePath, 313 service_test->SetServiceProperty(kDefaultServicePath,
314 shill::kProfileProperty, 314 shill::kProfileProperty,
315 base::StringValue(kUserProfilePath)); 315 base::Value(kUserProfilePath));
316 } 316 }
317 317
318 policy::MockConfigurationPolicyProvider provider_; 318 policy::MockConfigurationPolicyProvider provider_;
319 319
320 DISALLOW_COPY_AND_ASSIGN(ArcSettingsServiceTest); 320 DISALLOW_COPY_AND_ASSIGN(ArcSettingsServiceTest);
321 }; 321 };
322 322
323 IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, BackupRestorePolicyTest) { 323 IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, BackupRestorePolicyTest) {
324 PrefService* const prefs = browser()->profile()->GetPrefs(); 324 PrefService* const prefs = browser()->profile()->GetPrefs();
325 325
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 1); 449 1);
450 } 450 }
451 451
452 IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, ProxyModePolicyTest) { 452 IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, ProxyModePolicyTest) {
453 fake_intent_helper_instance_->clear_broadcasts(); 453 fake_intent_helper_instance_->clear_broadcasts();
454 454
455 policy::PolicyMap policy; 455 policy::PolicyMap policy;
456 policy.Set( 456 policy.Set(
457 policy::key::kProxyMode, policy::POLICY_LEVEL_MANDATORY, 457 policy::key::kProxyMode, policy::POLICY_LEVEL_MANDATORY,
458 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, 458 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
459 base::MakeUnique<base::StringValue>(ProxyPrefs::kAutoDetectProxyModeName), 459 base::MakeUnique<base::Value>(ProxyPrefs::kAutoDetectProxyModeName),
460 nullptr); 460 nullptr);
461 UpdatePolicy(policy); 461 UpdatePolicy(policy);
462 462
463 std::unique_ptr<base::DictionaryValue> expected_proxy_config( 463 std::unique_ptr<base::DictionaryValue> expected_proxy_config(
464 base::MakeUnique<base::DictionaryValue>()); 464 base::MakeUnique<base::DictionaryValue>());
465 expected_proxy_config->SetString("mode", 465 expected_proxy_config->SetString("mode",
466 ProxyPrefs::kAutoDetectProxyModeName); 466 ProxyPrefs::kAutoDetectProxyModeName);
467 expected_proxy_config->SetString("pacUrl", "http://wpad/wpad.dat"); 467 expected_proxy_config->SetString("pacUrl", "http://wpad/wpad.dat");
468 EXPECT_EQ(CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(), 468 EXPECT_EQ(CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(),
469 expected_proxy_config.get()), 469 expected_proxy_config.get()),
470 1); 470 1);
471 } 471 }
472 472
473 IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, ONCProxyPolicyTest) { 473 IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, ONCProxyPolicyTest) {
474 fake_intent_helper_instance_->clear_broadcasts(); 474 fake_intent_helper_instance_->clear_broadcasts();
475 475
476 policy::PolicyMap policy; 476 policy::PolicyMap policy;
477 policy.Set(policy::key::kOpenNetworkConfiguration, 477 policy.Set(policy::key::kOpenNetworkConfiguration,
478 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, 478 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
479 policy::POLICY_SOURCE_CLOUD, 479 policy::POLICY_SOURCE_CLOUD,
480 base::MakeUnique<base::StringValue>(kONCPolicy), nullptr); 480 base::MakeUnique<base::Value>(kONCPolicy), nullptr);
481 UpdatePolicy(policy); 481 UpdatePolicy(policy);
482 482
483 std::unique_ptr<base::DictionaryValue> expected_proxy_config( 483 std::unique_ptr<base::DictionaryValue> expected_proxy_config(
484 base::MakeUnique<base::DictionaryValue>()); 484 base::MakeUnique<base::DictionaryValue>());
485 expected_proxy_config->SetString("mode", ProxyPrefs::kPacScriptProxyModeName); 485 expected_proxy_config->SetString("mode", ProxyPrefs::kPacScriptProxyModeName);
486 expected_proxy_config->SetString("pacUrl", kONCPacUrl); 486 expected_proxy_config->SetString("pacUrl", kONCPacUrl);
487 487
488 EXPECT_EQ(CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(), 488 EXPECT_EQ(CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(),
489 expected_proxy_config.get()), 489 expected_proxy_config.get()),
490 1); 490 1);
491 } 491 }
492 492
493 // Proxy policy has a higher priority than proxy default settings. 493 // Proxy policy has a higher priority than proxy default settings.
494 IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, TwoSourcesTest) { 494 IN_PROC_BROWSER_TEST_F(ArcSettingsServiceTest, TwoSourcesTest) {
495 fake_intent_helper_instance_->clear_broadcasts(); 495 fake_intent_helper_instance_->clear_broadcasts();
496 496
497 policy::PolicyMap policy; 497 policy::PolicyMap policy;
498 // Proxy policy. 498 // Proxy policy.
499 policy.Set(policy::key::kProxyMode, policy::POLICY_LEVEL_MANDATORY, 499 policy.Set(
500 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, 500 policy::key::kProxyMode, policy::POLICY_LEVEL_MANDATORY,
501 base::MakeUnique<base::StringValue>( 501 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
502 ProxyPrefs::kFixedServersProxyModeName), 502 base::MakeUnique<base::Value>(ProxyPrefs::kFixedServersProxyModeName),
503 nullptr); 503 nullptr);
504 policy.Set(policy::key::kProxyServer, policy::POLICY_LEVEL_MANDATORY, 504 policy.Set(policy::key::kProxyServer, policy::POLICY_LEVEL_MANDATORY,
505 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, 505 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
506 base::MakeUnique<base::StringValue>("proxy:8888"), nullptr); 506 base::MakeUnique<base::Value>("proxy:8888"), nullptr);
507 UpdatePolicy(policy); 507 UpdatePolicy(policy);
508 508
509 std::unique_ptr<base::DictionaryValue> proxy_config( 509 std::unique_ptr<base::DictionaryValue> proxy_config(
510 base::MakeUnique<base::DictionaryValue>()); 510 base::MakeUnique<base::DictionaryValue>());
511 proxy_config->SetString("mode", ProxyPrefs::kAutoDetectProxyModeName); 511 proxy_config->SetString("mode", ProxyPrefs::kAutoDetectProxyModeName);
512 ProxyConfigDictionary proxy_config_dict(proxy_config.get()); 512 ProxyConfigDictionary proxy_config_dict(proxy_config.get());
513 const chromeos::NetworkState* network = chromeos::NetworkHandler::Get() 513 const chromeos::NetworkState* network = chromeos::NetworkHandler::Get()
514 ->network_state_handler() 514 ->network_state_handler()
515 ->DefaultNetwork(); 515 ->DefaultNetwork();
516 ASSERT_TRUE(network); 516 ASSERT_TRUE(network);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 634
635 // Disconnect default network. 635 // Disconnect default network.
636 DisconnectNetworkService(kDefaultServicePath); 636 DisconnectNetworkService(kDefaultServicePath);
637 637
638 fake_intent_helper_instance_->clear_broadcasts(); 638 fake_intent_helper_instance_->clear_broadcasts();
639 639
640 policy::PolicyMap policy; 640 policy::PolicyMap policy;
641 policy.Set(policy::key::kOpenNetworkConfiguration, 641 policy.Set(policy::key::kOpenNetworkConfiguration,
642 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, 642 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
643 policy::POLICY_SOURCE_CLOUD, 643 policy::POLICY_SOURCE_CLOUD,
644 base::MakeUnique<base::StringValue>(kUserONCPolicy), nullptr); 644 base::MakeUnique<base::Value>(kUserONCPolicy), nullptr);
645 policy.Set(policy::key::kDeviceOpenNetworkConfiguration, 645 policy.Set(policy::key::kDeviceOpenNetworkConfiguration,
646 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE, 646 policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_MACHINE,
647 policy::POLICY_SOURCE_CLOUD, 647 policy::POLICY_SOURCE_CLOUD,
648 base::MakeUnique<base::StringValue>(kDeviceONCPolicy), nullptr); 648 base::MakeUnique<base::Value>(kDeviceONCPolicy), nullptr);
649 UpdatePolicy(policy); 649 UpdatePolicy(policy);
650 650
651 std::unique_ptr<base::DictionaryValue> expected_proxy_config( 651 std::unique_ptr<base::DictionaryValue> expected_proxy_config(
652 base::MakeUnique<base::DictionaryValue>()); 652 base::MakeUnique<base::DictionaryValue>());
653 expected_proxy_config->SetString("mode", 653 expected_proxy_config->SetString("mode",
654 ProxyPrefs::kFixedServersProxyModeName); 654 ProxyPrefs::kFixedServersProxyModeName);
655 expected_proxy_config->SetString("host", "proxy"); 655 expected_proxy_config->SetString("host", "proxy");
656 expected_proxy_config->SetInteger("port", 5000); 656 expected_proxy_config->SetInteger("port", 5000);
657 657
658 EXPECT_EQ(CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(), 658 EXPECT_EQ(CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(),
(...skipping 10 matching lines...) Expand all
669 ProxyPrefs::kFixedServersProxyModeName); 669 ProxyPrefs::kFixedServersProxyModeName);
670 expected_proxy_config->SetString("host", "proxy-n300"); 670 expected_proxy_config->SetString("host", "proxy-n300");
671 expected_proxy_config->SetInteger("port", 3000); 671 expected_proxy_config->SetInteger("port", 3000);
672 672
673 EXPECT_EQ(CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(), 673 EXPECT_EQ(CountProxyBroadcasts(fake_intent_helper_instance_->broadcasts(),
674 expected_proxy_config.get()), 674 expected_proxy_config.get()),
675 1); 675 1);
676 } 676 }
677 677
678 } // namespace arc 678 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698