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

Side by Side Diff: chromeos/network/network_configuration_handler_unittest.cc

Issue 2911033002: Remove raw base::DictionaryValue::Set (Closed)
Patch Set: Proper Windows Fix Created 3 years, 6 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/dbus/fake_shill_service_client.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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 }; 333 };
334 334
335 TEST_F(NetworkConfigurationHandlerTest, GetProperties) { 335 TEST_F(NetworkConfigurationHandlerTest, GetProperties) {
336 std::string service_path = "/service/1"; 336 std::string service_path = "/service/1";
337 std::string expected_json = "{\n \"SSID\": \"MyNetwork\"\n}\n"; 337 std::string expected_json = "{\n \"SSID\": \"MyNetwork\"\n}\n";
338 std::string networkName = "MyNetwork"; 338 std::string networkName = "MyNetwork";
339 std::string key = "SSID"; 339 std::string key = "SSID";
340 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); 340 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName));
341 341
342 base::DictionaryValue value; 342 base::DictionaryValue value;
343 value.Set(key, new base::Value(networkName)); 343 value.SetString(key, networkName);
344 dictionary_value_result_ = &value; 344 dictionary_value_result_ = &value;
345 EXPECT_CALL(*mock_service_client_, 345 EXPECT_CALL(*mock_service_client_,
346 SetProperty(dbus::ObjectPath(service_path), key, 346 SetProperty(dbus::ObjectPath(service_path), key,
347 IsEqualTo(networkNameValue.get()), _, _)).Times(1); 347 IsEqualTo(networkNameValue.get()), _, _)).Times(1);
348 mock_service_client_->SetProperty( 348 mock_service_client_->SetProperty(
349 dbus::ObjectPath(service_path), key, *networkNameValue, 349 dbus::ObjectPath(service_path), key, *networkNameValue,
350 base::Bind(&base::DoNothing), base::Bind(&DBusErrorCallback)); 350 base::Bind(&base::DoNothing), base::Bind(&DBusErrorCallback));
351 base::RunLoop().RunUntilIdle(); 351 base::RunLoop().RunUntilIdle();
352 352
353 ShillServiceClient::DictionaryValueCallback get_properties_callback; 353 ShillServiceClient::DictionaryValueCallback get_properties_callback;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 base::Bind(&ErrorCallback)); 397 base::Bind(&ErrorCallback));
398 } 398 }
399 399
400 TEST_F(NetworkConfigurationHandlerTest, SetProperties) { 400 TEST_F(NetworkConfigurationHandlerTest, SetProperties) {
401 std::string service_path = "/service/1"; 401 std::string service_path = "/service/1";
402 std::string networkName = "MyNetwork"; 402 std::string networkName = "MyNetwork";
403 std::string key = "SSID"; 403 std::string key = "SSID";
404 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); 404 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName));
405 405
406 base::DictionaryValue value; 406 base::DictionaryValue value;
407 value.Set(key, new base::Value(networkName)); 407 value.SetString(key, networkName);
408 dictionary_value_result_ = &value; 408 dictionary_value_result_ = &value;
409 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _)) 409 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _))
410 .WillOnce( 410 .WillOnce(
411 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties)); 411 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties));
412 network_configuration_handler_->SetShillProperties( 412 network_configuration_handler_->SetShillProperties(
413 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION, 413 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION,
414 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback)); 414 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback));
415 base::RunLoop().RunUntilIdle(); 415 base::RunLoop().RunUntilIdle();
416 } 416 }
417 417
418 TEST_F(NetworkConfigurationHandlerTest, ClearProperties) { 418 TEST_F(NetworkConfigurationHandlerTest, ClearProperties) {
419 std::string service_path = "/service/1"; 419 std::string service_path = "/service/1";
420 std::string networkName = "MyNetwork"; 420 std::string networkName = "MyNetwork";
421 std::string key = "SSID"; 421 std::string key = "SSID";
422 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); 422 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName));
423 423
424 // First set up a value to clear. 424 // First set up a value to clear.
425 base::DictionaryValue value; 425 base::DictionaryValue value;
426 value.Set(key, new base::Value(networkName)); 426 value.SetString(key, networkName);
427 dictionary_value_result_ = &value; 427 dictionary_value_result_ = &value;
428 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _)) 428 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _))
429 .WillOnce( 429 .WillOnce(
430 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties)); 430 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties));
431 network_configuration_handler_->SetShillProperties( 431 network_configuration_handler_->SetShillProperties(
432 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION, 432 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION,
433 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback)); 433 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback));
434 base::RunLoop().RunUntilIdle(); 434 base::RunLoop().RunUntilIdle();
435 435
436 // Now clear it. 436 // Now clear it.
437 std::vector<std::string> values_to_clear; 437 std::vector<std::string> values_to_clear;
438 values_to_clear.push_back(key); 438 values_to_clear.push_back(key);
439 EXPECT_CALL(*mock_service_client_, ClearProperties(_, _, _, _)) 439 EXPECT_CALL(*mock_service_client_, ClearProperties(_, _, _, _))
440 .WillOnce( 440 .WillOnce(
441 Invoke(this, &NetworkConfigurationHandlerTest::OnClearProperties)); 441 Invoke(this, &NetworkConfigurationHandlerTest::OnClearProperties));
442 network_configuration_handler_->ClearShillProperties( 442 network_configuration_handler_->ClearShillProperties(
443 service_path, values_to_clear, base::Bind(&base::DoNothing), 443 service_path, values_to_clear, base::Bind(&base::DoNothing),
444 base::Bind(&ErrorCallback)); 444 base::Bind(&ErrorCallback));
445 base::RunLoop().RunUntilIdle(); 445 base::RunLoop().RunUntilIdle();
446 } 446 }
447 447
448 TEST_F(NetworkConfigurationHandlerTest, ClearPropertiesError) { 448 TEST_F(NetworkConfigurationHandlerTest, ClearPropertiesError) {
449 std::string service_path = "/service/1"; 449 std::string service_path = "/service/1";
450 std::string networkName = "MyNetwork"; 450 std::string networkName = "MyNetwork";
451 std::string key = "SSID"; 451 std::string key = "SSID";
452 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); 452 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName));
453 453
454 // First set up a value to clear. 454 // First set up a value to clear.
455 base::DictionaryValue value; 455 base::DictionaryValue value;
456 value.Set(key, new base::Value(networkName)); 456 value.SetString(key, networkName);
457 dictionary_value_result_ = &value; 457 dictionary_value_result_ = &value;
458 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _)) 458 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _))
459 .WillOnce( 459 .WillOnce(
460 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties)); 460 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties));
461 network_configuration_handler_->SetShillProperties( 461 network_configuration_handler_->SetShillProperties(
462 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION, 462 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION,
463 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback)); 463 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback));
464 base::RunLoop().RunUntilIdle(); 464 base::RunLoop().RunUntilIdle();
465 465
466 // Now clear it. 466 // Now clear it.
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 EXPECT_FALSE(test_observer->HasConfiguration(service_path)); 912 EXPECT_FALSE(test_observer->HasConfiguration(service_path));
913 EXPECT_FALSE(test_observer->HasConfigurationInProfile( 913 EXPECT_FALSE(test_observer->HasConfigurationInProfile(
914 service_path, NetworkProfileHandler::GetSharedProfilePath())); 914 service_path, NetworkProfileHandler::GetSharedProfilePath()));
915 EXPECT_FALSE( 915 EXPECT_FALSE(
916 test_observer->HasConfigurationInProfile(service_path, user_profile)); 916 test_observer->HasConfigurationInProfile(service_path, user_profile));
917 917
918 network_configuration_handler_->RemoveObserver(test_observer.get()); 918 network_configuration_handler_->RemoveObserver(test_observer.get());
919 } 919 }
920 920
921 } // namespace chromeos 921 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_shill_service_client.cc ('k') | chromeos/network/onc/onc_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698