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

Side by Side Diff: chrome/browser/chromeos/cros/cros_network_functions_unittest.cc

Issue 11418048: Add copy and assignment to FundamentalValue and StringValue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/chromeos/cros/cros_network_functions.h" 8 #include "chrome/browser/chromeos/cros/cros_network_functions.h"
9 #include "chrome/browser/chromeos/cros/sms_watcher.h" 9 #include "chrome/browser/chromeos/cros/sms_watcher.h"
10 #include "chromeos/dbus/mock_cashew_client.h" 10 #include "chromeos/dbus/mock_cashew_client.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 data_plan->update_time = base::Time::FromInternalValue(kUpdateTime); 394 data_plan->update_time = base::Time::FromInternalValue(kUpdateTime);
395 data_plan->plan_start_time = base::Time::FromInternalValue(kPlanStartTime); 395 data_plan->plan_start_time = base::Time::FromInternalValue(kPlanStartTime);
396 data_plan->plan_end_time = base::Time::FromInternalValue(kPlanEndTime); 396 data_plan->plan_end_time = base::Time::FromInternalValue(kPlanEndTime);
397 data_plan->plan_data_bytes = 1024*1024; 397 data_plan->plan_data_bytes = 1024*1024;
398 data_plan->data_bytes_used = 12345; 398 data_plan->data_bytes_used = 12345;
399 data_plans.push_back(data_plan); 399 data_plans.push_back(data_plan);
400 400
401 base::DictionaryValue* data_plan_dictionary = new base::DictionaryValue; 401 base::DictionaryValue* data_plan_dictionary = new base::DictionaryValue;
402 data_plan_dictionary->SetWithoutPathExpansion( 402 data_plan_dictionary->SetWithoutPathExpansion(
403 cashew::kCellularPlanNameProperty, 403 cashew::kCellularPlanNameProperty,
404 base::Value::CreateStringValue(data_plan->plan_name)); 404 new base::StringValue(data_plan->plan_name));
405 data_plan_dictionary->SetWithoutPathExpansion( 405 data_plan_dictionary->SetWithoutPathExpansion(
406 cashew::kCellularPlanTypeProperty, 406 cashew::kCellularPlanTypeProperty,
407 base::Value::CreateStringValue(cashew::kCellularDataPlanMeteredPaid)); 407 new base::StringValue(cashew::kCellularDataPlanMeteredPaid));
408 data_plan_dictionary->SetWithoutPathExpansion( 408 data_plan_dictionary->SetWithoutPathExpansion(
409 cashew::kCellularPlanUpdateTimeProperty, 409 cashew::kCellularPlanUpdateTimeProperty,
410 base::Value::CreateDoubleValue(kUpdateTime)); 410 base::Value::CreateDoubleValue(kUpdateTime));
411 data_plan_dictionary->SetWithoutPathExpansion( 411 data_plan_dictionary->SetWithoutPathExpansion(
412 cashew::kCellularPlanStartProperty, 412 cashew::kCellularPlanStartProperty,
413 base::Value::CreateDoubleValue(kPlanStartTime)); 413 base::Value::CreateDoubleValue(kPlanStartTime));
414 data_plan_dictionary->SetWithoutPathExpansion( 414 data_plan_dictionary->SetWithoutPathExpansion(
415 cashew::kCellularPlanEndProperty, 415 cashew::kCellularPlanEndProperty,
416 base::Value::CreateDoubleValue(kPlanEndTime)); 416 base::Value::CreateDoubleValue(kPlanEndTime));
417 data_plan_dictionary->SetWithoutPathExpansion( 417 data_plan_dictionary->SetWithoutPathExpansion(
(...skipping 24 matching lines...) Expand all
442 EXPECT_CALL(*mock_cashew_client_, ResetDataPlansUpdateHandler()).Times(1); 442 EXPECT_CALL(*mock_cashew_client_, ResetDataPlansUpdateHandler()).Times(1);
443 delete watcher; 443 delete watcher;
444 } 444 }
445 445
446 TEST_F(CrosNetworkFunctionsTest, CrosMonitorSMS) { 446 TEST_F(CrosNetworkFunctionsTest, CrosMonitorSMS) {
447 const std::string dbus_connection = ":1.1"; 447 const std::string dbus_connection = ":1.1";
448 const dbus::ObjectPath object_path("/object/path"); 448 const dbus::ObjectPath object_path("/object/path");
449 base::DictionaryValue device_properties; 449 base::DictionaryValue device_properties;
450 device_properties.SetWithoutPathExpansion( 450 device_properties.SetWithoutPathExpansion(
451 flimflam::kDBusConnectionProperty, 451 flimflam::kDBusConnectionProperty,
452 base::Value::CreateStringValue(dbus_connection)); 452 new base::StringValue(dbus_connection));
453 device_properties.SetWithoutPathExpansion( 453 device_properties.SetWithoutPathExpansion(
454 flimflam::kDBusObjectProperty, 454 flimflam::kDBusObjectProperty,
455 base::Value::CreateStringValue(object_path.value())); 455 new base::StringValue(object_path.value()));
456 456
457 const std::string number = "0123456789"; 457 const std::string number = "0123456789";
458 const std::string text = "Hello."; 458 const std::string text = "Hello.";
459 const std::string timestamp_string = 459 const std::string timestamp_string =
460 "120424123456+00"; // 2012-04-24 12:34:56 460 "120424123456+00"; // 2012-04-24 12:34:56
461 base::Time::Exploded timestamp_exploded = {}; 461 base::Time::Exploded timestamp_exploded = {};
462 timestamp_exploded.year = 2012; 462 timestamp_exploded.year = 2012;
463 timestamp_exploded.month = 4; 463 timestamp_exploded.month = 4;
464 timestamp_exploded.day_of_month = 24; 464 timestamp_exploded.day_of_month = 24;
465 timestamp_exploded.hour = 12; 465 timestamp_exploded.hour = 12;
466 timestamp_exploded.minute = 34; 466 timestamp_exploded.minute = 34;
467 timestamp_exploded.second = 56; 467 timestamp_exploded.second = 56;
468 const base::Time timestamp = base::Time::FromUTCExploded(timestamp_exploded); 468 const base::Time timestamp = base::Time::FromUTCExploded(timestamp_exploded);
469 const std::string smsc = "9876543210"; 469 const std::string smsc = "9876543210";
470 const uint32 kValidity = 1; 470 const uint32 kValidity = 1;
471 const uint32 kMsgclass = 2; 471 const uint32 kMsgclass = 2;
472 const uint32 kIndex = 0; 472 const uint32 kIndex = 0;
473 const bool kComplete = true; 473 const bool kComplete = true;
474 base::DictionaryValue* sms_dictionary = new base::DictionaryValue; 474 base::DictionaryValue* sms_dictionary = new base::DictionaryValue;
475 sms_dictionary->SetWithoutPathExpansion( 475 sms_dictionary->SetWithoutPathExpansion(
476 SMSWatcher::kNumberKey, base::Value::CreateStringValue(number)); 476 SMSWatcher::kNumberKey, new base::StringValue(number));
477 sms_dictionary->SetWithoutPathExpansion( 477 sms_dictionary->SetWithoutPathExpansion(
478 SMSWatcher::kTextKey, base::Value::CreateStringValue(text)); 478 SMSWatcher::kTextKey, new base::StringValue(text));
479 sms_dictionary->SetWithoutPathExpansion( 479 sms_dictionary->SetWithoutPathExpansion(
480 SMSWatcher::kTimestampKey, 480 SMSWatcher::kTimestampKey,
481 base::Value::CreateStringValue(timestamp_string)); 481 new base::StringValue(timestamp_string));
482 sms_dictionary->SetWithoutPathExpansion(SMSWatcher::kSmscKey, 482 sms_dictionary->SetWithoutPathExpansion(SMSWatcher::kSmscKey,
483 base::Value::CreateStringValue(smsc)); 483 new base::StringValue(smsc));
484 sms_dictionary->SetWithoutPathExpansion( 484 sms_dictionary->SetWithoutPathExpansion(
485 SMSWatcher::kValidityKey, base::Value::CreateDoubleValue(kValidity)); 485 SMSWatcher::kValidityKey, base::Value::CreateDoubleValue(kValidity));
486 sms_dictionary->SetWithoutPathExpansion( 486 sms_dictionary->SetWithoutPathExpansion(
487 SMSWatcher::kClassKey, base::Value::CreateDoubleValue(kMsgclass)); 487 SMSWatcher::kClassKey, base::Value::CreateDoubleValue(kMsgclass));
488 sms_dictionary->SetWithoutPathExpansion( 488 sms_dictionary->SetWithoutPathExpansion(
489 SMSWatcher::kIndexKey, base::Value::CreateDoubleValue(kIndex)); 489 SMSWatcher::kIndexKey, base::Value::CreateDoubleValue(kIndex));
490 490
491 base::ListValue sms_list; 491 base::ListValue sms_list;
492 sms_list.Append(sms_dictionary); 492 sms_list.Append(sms_dictionary);
493 493
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 delete watcher; 556 delete watcher;
557 } 557 }
558 558
559 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkManagerProperties) { 559 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkManagerProperties) {
560 const std::string key1 = "key1"; 560 const std::string key1 = "key1";
561 const std::string value1 = "value1"; 561 const std::string value1 = "value1";
562 const std::string key2 = "key.2."; 562 const std::string key2 = "key.2.";
563 const std::string value2 = "value2"; 563 const std::string value2 = "value2";
564 // Create result value. 564 // Create result value.
565 base::DictionaryValue result; 565 base::DictionaryValue result;
566 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 566 result.SetWithoutPathExpansion(key1, new base::StringValue(value1));
567 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 567 result.SetWithoutPathExpansion(key2, new base::StringValue(value2));
568 // Set expectations. 568 // Set expectations.
569 dictionary_value_result_ = &result; 569 dictionary_value_result_ = &result;
570 EXPECT_CALL(*mock_manager_client_, 570 EXPECT_CALL(*mock_manager_client_,
571 GetProperties(_)).WillOnce( 571 GetProperties(_)).WillOnce(
572 Invoke(this, 572 Invoke(this,
573 &CrosNetworkFunctionsTest::OnGetManagerProperties)); 573 &CrosNetworkFunctionsTest::OnGetManagerProperties));
574 574
575 CrosRequestNetworkManagerProperties( 575 CrosRequestNetworkManagerProperties(
576 MockNetworkPropertiesCallback::CreateCallback( 576 MockNetworkPropertiesCallback::CreateCallback(
577 flimflam::kFlimflamServicePath, result)); 577 flimflam::kFlimflamServicePath, result));
578 } 578 }
579 579
580 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceProperties) { 580 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceProperties) {
581 const std::string service_path = "/service/path"; 581 const std::string service_path = "/service/path";
582 const std::string key1 = "key1"; 582 const std::string key1 = "key1";
583 const std::string value1 = "value1"; 583 const std::string value1 = "value1";
584 const std::string key2 = "key.2."; 584 const std::string key2 = "key.2.";
585 const std::string value2 = "value2"; 585 const std::string value2 = "value2";
586 // Create result value. 586 // Create result value.
587 base::DictionaryValue result; 587 base::DictionaryValue result;
588 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 588 result.SetWithoutPathExpansion(key1, new base::StringValue(value1));
589 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 589 result.SetWithoutPathExpansion(key2, new base::StringValue(value2));
590 // Set expectations. 590 // Set expectations.
591 dictionary_value_result_ = &result; 591 dictionary_value_result_ = &result;
592 EXPECT_CALL(*mock_service_client_, 592 EXPECT_CALL(*mock_service_client_,
593 GetProperties(dbus::ObjectPath(service_path), _)).WillOnce( 593 GetProperties(dbus::ObjectPath(service_path), _)).WillOnce(
594 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); 594 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties));
595 595
596 CrosRequestNetworkServiceProperties( 596 CrosRequestNetworkServiceProperties(
597 service_path, 597 service_path,
598 MockNetworkPropertiesCallback::CreateCallback(service_path, result)); 598 MockNetworkPropertiesCallback::CreateCallback(service_path, result));
599 } 599 }
600 600
601 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceProperties) { 601 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceProperties) {
602 const std::string device_path = "/device/path"; 602 const std::string device_path = "/device/path";
603 const std::string key1 = "key1"; 603 const std::string key1 = "key1";
604 const std::string value1 = "value1"; 604 const std::string value1 = "value1";
605 const std::string key2 = "key.2."; 605 const std::string key2 = "key.2.";
606 const std::string value2 = "value2"; 606 const std::string value2 = "value2";
607 // Create result value. 607 // Create result value.
608 base::DictionaryValue result; 608 base::DictionaryValue result;
609 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 609 result.SetWithoutPathExpansion(key1, new base::StringValue(value1));
610 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 610 result.SetWithoutPathExpansion(key2, new base::StringValue(value2));
611 // Set expectations. 611 // Set expectations.
612 dictionary_value_result_ = &result; 612 dictionary_value_result_ = &result;
613 EXPECT_CALL(*mock_device_client_, 613 EXPECT_CALL(*mock_device_client_,
614 GetProperties(dbus::ObjectPath(device_path), _)).WillOnce( 614 GetProperties(dbus::ObjectPath(device_path), _)).WillOnce(
615 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); 615 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties));
616 616
617 CrosRequestNetworkDeviceProperties( 617 CrosRequestNetworkDeviceProperties(
618 device_path, 618 device_path,
619 MockNetworkPropertiesCallback::CreateCallback(device_path, result)); 619 MockNetworkPropertiesCallback::CreateCallback(device_path, result));
620 } 620 }
621 621
622 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileProperties) { 622 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileProperties) {
623 const std::string profile_path = "/profile/path"; 623 const std::string profile_path = "/profile/path";
624 const std::string key1 = "key1"; 624 const std::string key1 = "key1";
625 const std::string value1 = "value1"; 625 const std::string value1 = "value1";
626 const std::string key2 = "key.2."; 626 const std::string key2 = "key.2.";
627 const std::string value2 = "value2"; 627 const std::string value2 = "value2";
628 // Create result value. 628 // Create result value.
629 base::DictionaryValue result; 629 base::DictionaryValue result;
630 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 630 result.SetWithoutPathExpansion(key1, new base::StringValue(value1));
631 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 631 result.SetWithoutPathExpansion(key2, new base::StringValue(value2));
632 // Set expectations. 632 // Set expectations.
633 dictionary_value_result_ = &result; 633 dictionary_value_result_ = &result;
634 EXPECT_CALL( 634 EXPECT_CALL(
635 *mock_profile_client_, 635 *mock_profile_client_,
636 GetProperties(dbus::ObjectPath(profile_path), _, _)).WillOnce( 636 GetProperties(dbus::ObjectPath(profile_path), _, _)).WillOnce(
637 Invoke(this, 637 Invoke(this,
638 &CrosNetworkFunctionsTest::OnGetPropertiesWithoutStatus)); 638 &CrosNetworkFunctionsTest::OnGetPropertiesWithoutStatus));
639 639
640 CrosRequestNetworkProfileProperties( 640 CrosRequestNetworkProfileProperties(
641 profile_path, 641 profile_path,
642 MockNetworkPropertiesCallback::CreateCallback(profile_path, result)); 642 MockNetworkPropertiesCallback::CreateCallback(profile_path, result));
643 } 643 }
644 644
645 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { 645 TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) {
646 const std::string profile_path = "profile path"; 646 const std::string profile_path = "profile path";
647 const std::string profile_entry_path = "profile entry path"; 647 const std::string profile_entry_path = "profile entry path";
648 const std::string key1 = "key1"; 648 const std::string key1 = "key1";
649 const std::string value1 = "value1"; 649 const std::string value1 = "value1";
650 const std::string key2 = "key.2."; 650 const std::string key2 = "key.2.";
651 const std::string value2 = "value2"; 651 const std::string value2 = "value2";
652 // Create result value. 652 // Create result value.
653 base::DictionaryValue result; 653 base::DictionaryValue result;
654 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 654 result.SetWithoutPathExpansion(key1, new base::StringValue(value1));
655 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 655 result.SetWithoutPathExpansion(key2, new base::StringValue(value2));
656 // Set expectations. 656 // Set expectations.
657 dictionary_value_result_ = &result; 657 dictionary_value_result_ = &result;
658 EXPECT_CALL(*mock_profile_client_, 658 EXPECT_CALL(*mock_profile_client_,
659 GetEntry(dbus::ObjectPath(profile_path), 659 GetEntry(dbus::ObjectPath(profile_path),
660 profile_entry_path, _, _)) 660 profile_entry_path, _, _))
661 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry)); 661 .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry));
662 662
663 CrosRequestNetworkProfileEntryProperties( 663 CrosRequestNetworkProfileEntryProperties(
664 profile_path, profile_entry_path, 664 profile_path, profile_entry_path,
665 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path, 665 MockNetworkPropertiesCallback::CreateCallback(profile_entry_path,
666 result)); 666 result));
667 } 667 }
668 668
669 TEST_F(CrosNetworkFunctionsTest, CrosRequestHiddenWifiNetworkProperties) { 669 TEST_F(CrosNetworkFunctionsTest, CrosRequestHiddenWifiNetworkProperties) {
670 const std::string ssid = "ssid"; 670 const std::string ssid = "ssid";
671 const std::string security = "security"; 671 const std::string security = "security";
672 const std::string key1 = "key1"; 672 const std::string key1 = "key1";
673 const std::string value1 = "value1"; 673 const std::string value1 = "value1";
674 const std::string key2 = "key.2."; 674 const std::string key2 = "key.2.";
675 const std::string value2 = "value2"; 675 const std::string value2 = "value2";
676 // Create result value. 676 // Create result value.
677 base::DictionaryValue result; 677 base::DictionaryValue result;
678 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 678 result.SetWithoutPathExpansion(key1, new base::StringValue(value1));
679 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 679 result.SetWithoutPathExpansion(key2, new base::StringValue(value2));
680 dictionary_value_result_ = &result; 680 dictionary_value_result_ = &result;
681 // Create expected argument to ShillManagerClient::GetService. 681 // Create expected argument to ShillManagerClient::GetService.
682 base::DictionaryValue properties; 682 base::DictionaryValue properties;
683 properties.SetWithoutPathExpansion( 683 properties.SetWithoutPathExpansion(
684 flimflam::kModeProperty, 684 flimflam::kModeProperty,
685 base::Value::CreateStringValue(flimflam::kModeManaged)); 685 new base::StringValue(flimflam::kModeManaged));
686 properties.SetWithoutPathExpansion( 686 properties.SetWithoutPathExpansion(
687 flimflam::kTypeProperty, 687 flimflam::kTypeProperty,
688 base::Value::CreateStringValue(flimflam::kTypeWifi)); 688 new base::StringValue(flimflam::kTypeWifi));
689 properties.SetWithoutPathExpansion( 689 properties.SetWithoutPathExpansion(
690 flimflam::kSSIDProperty, 690 flimflam::kSSIDProperty,
691 base::Value::CreateStringValue(ssid)); 691 new base::StringValue(ssid));
692 properties.SetWithoutPathExpansion( 692 properties.SetWithoutPathExpansion(
693 flimflam::kSecurityProperty, 693 flimflam::kSecurityProperty,
694 base::Value::CreateStringValue(security)); 694 new base::StringValue(security));
695 // Set expectations. 695 // Set expectations.
696 const dbus::ObjectPath service_path("/service/path"); 696 const dbus::ObjectPath service_path("/service/path");
697 ObjectPathCallback callback; 697 ObjectPathCallback callback;
698 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _)) 698 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _))
699 .WillOnce(SaveArg<1>(&callback)); 699 .WillOnce(SaveArg<1>(&callback));
700 EXPECT_CALL(*mock_service_client_, 700 EXPECT_CALL(*mock_service_client_,
701 GetProperties(service_path, _)).WillOnce( 701 GetProperties(service_path, _)).WillOnce(
702 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); 702 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties));
703 703
704 // Call function. 704 // Call function.
705 CrosRequestHiddenWifiNetworkProperties( 705 CrosRequestHiddenWifiNetworkProperties(
706 ssid, security, 706 ssid, security,
707 MockNetworkPropertiesCallback::CreateCallback(service_path.value(), 707 MockNetworkPropertiesCallback::CreateCallback(service_path.value(),
708 result)); 708 result));
709 // Run callback to invoke GetProperties. 709 // Run callback to invoke GetProperties.
710 callback.Run(service_path); 710 callback.Run(service_path);
711 } 711 }
712 712
713 TEST_F(CrosNetworkFunctionsTest, CrosRequestVirtualNetworkProperties) { 713 TEST_F(CrosNetworkFunctionsTest, CrosRequestVirtualNetworkProperties) {
714 const std::string service_name = "service name"; 714 const std::string service_name = "service name";
715 const std::string server_hostname = "server hostname"; 715 const std::string server_hostname = "server hostname";
716 const std::string provider_type = "provider type"; 716 const std::string provider_type = "provider type";
717 const std::string key1 = "key1"; 717 const std::string key1 = "key1";
718 const std::string value1 = "value1"; 718 const std::string value1 = "value1";
719 const std::string key2 = "key.2."; 719 const std::string key2 = "key.2.";
720 const std::string value2 = "value2"; 720 const std::string value2 = "value2";
721 // Create result value. 721 // Create result value.
722 base::DictionaryValue result; 722 base::DictionaryValue result;
723 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 723 result.SetWithoutPathExpansion(key1, new base::StringValue(value1));
724 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 724 result.SetWithoutPathExpansion(key2, new base::StringValue(value2));
725 dictionary_value_result_ = &result; 725 dictionary_value_result_ = &result;
726 // Create expected argument to ShillManagerClient::GetService. 726 // Create expected argument to ShillManagerClient::GetService.
727 base::DictionaryValue properties; 727 base::DictionaryValue properties;
728 properties.SetWithoutPathExpansion( 728 properties.SetWithoutPathExpansion(
729 flimflam::kTypeProperty, base::Value::CreateStringValue("vpn")); 729 flimflam::kTypeProperty, new base::StringValue("vpn"));
730 properties.SetWithoutPathExpansion( 730 properties.SetWithoutPathExpansion(
731 flimflam::kProviderNameProperty, 731 flimflam::kProviderNameProperty,
732 base::Value::CreateStringValue(service_name)); 732 new base::StringValue(service_name));
733 properties.SetWithoutPathExpansion( 733 properties.SetWithoutPathExpansion(
734 flimflam::kProviderHostProperty, 734 flimflam::kProviderHostProperty,
735 base::Value::CreateStringValue(server_hostname)); 735 new base::StringValue(server_hostname));
736 properties.SetWithoutPathExpansion( 736 properties.SetWithoutPathExpansion(
737 flimflam::kProviderTypeProperty, 737 flimflam::kProviderTypeProperty,
738 base::Value::CreateStringValue(provider_type)); 738 new base::StringValue(provider_type));
739 properties.SetWithoutPathExpansion( 739 properties.SetWithoutPathExpansion(
740 flimflam::kVPNDomainProperty, 740 flimflam::kVPNDomainProperty,
741 base::Value::CreateStringValue(service_name)); 741 new base::StringValue(service_name));
742 742
743 // Set expectations. 743 // Set expectations.
744 const dbus::ObjectPath service_path("/service/path"); 744 const dbus::ObjectPath service_path("/service/path");
745 ObjectPathCallback callback; 745 ObjectPathCallback callback;
746 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _)) 746 EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _))
747 .WillOnce(SaveArg<1>(&callback)); 747 .WillOnce(SaveArg<1>(&callback));
748 EXPECT_CALL(*mock_service_client_, 748 EXPECT_CALL(*mock_service_client_,
749 GetProperties(service_path, _)).WillOnce( 749 GetProperties(service_path, _)).WillOnce(
750 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); 750 Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties));
751 751
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 const std::string broadcast = "broadcast"; 913 const std::string broadcast = "broadcast";
914 const std::string peer_address = "peer address"; 914 const std::string peer_address = "peer address";
915 const std::string gateway = "gateway"; 915 const std::string gateway = "gateway";
916 const std::string domainname = "domainname"; 916 const std::string domainname = "domainname";
917 const std::string name_server1 = "nameserver1"; 917 const std::string name_server1 = "nameserver1";
918 const std::string name_server2 = "nameserver2"; 918 const std::string name_server2 = "nameserver2";
919 const std::string name_servers = name_server1 + "," + name_server2; 919 const std::string name_servers = name_server1 + "," + name_server2;
920 const std::string hardware_address = "hardware address"; 920 const std::string hardware_address = "hardware address";
921 921
922 base::ListValue* ipconfigs = new base::ListValue; 922 base::ListValue* ipconfigs = new base::ListValue;
923 ipconfigs->Append(base::Value::CreateStringValue(ipconfig_path)); 923 ipconfigs->Append(new base::StringValue(ipconfig_path));
924 base::DictionaryValue* device_properties = new base::DictionaryValue; 924 base::DictionaryValue* device_properties = new base::DictionaryValue;
925 device_properties->SetWithoutPathExpansion( 925 device_properties->SetWithoutPathExpansion(
926 flimflam::kIPConfigsProperty, ipconfigs); 926 flimflam::kIPConfigsProperty, ipconfigs);
927 device_properties->SetWithoutPathExpansion( 927 device_properties->SetWithoutPathExpansion(
928 flimflam::kAddressProperty, 928 flimflam::kAddressProperty,
929 base::Value::CreateStringValue(hardware_address)); 929 new base::StringValue(hardware_address));
930 930
931 base::ListValue* name_servers_list = new base::ListValue; 931 base::ListValue* name_servers_list = new base::ListValue;
932 name_servers_list->Append(base::Value::CreateStringValue(name_server1)); 932 name_servers_list->Append(new base::StringValue(name_server1));
933 name_servers_list->Append(base::Value::CreateStringValue(name_server2)); 933 name_servers_list->Append(new base::StringValue(name_server2));
934 base::DictionaryValue* ipconfig_properties = new base::DictionaryValue; 934 base::DictionaryValue* ipconfig_properties = new base::DictionaryValue;
935 ipconfig_properties->SetWithoutPathExpansion( 935 ipconfig_properties->SetWithoutPathExpansion(
936 flimflam::kMethodProperty, 936 flimflam::kMethodProperty,
937 base::Value::CreateStringValue(flimflam::kTypeDHCP)); 937 new base::StringValue(flimflam::kTypeDHCP));
938 ipconfig_properties->SetWithoutPathExpansion( 938 ipconfig_properties->SetWithoutPathExpansion(
939 flimflam::kAddressProperty, 939 flimflam::kAddressProperty,
940 base::Value::CreateStringValue(address)); 940 new base::StringValue(address));
941 ipconfig_properties->SetWithoutPathExpansion( 941 ipconfig_properties->SetWithoutPathExpansion(
942 flimflam::kMtuProperty, 942 flimflam::kMtuProperty,
943 base::Value::CreateIntegerValue(kMtu)); 943 base::Value::CreateIntegerValue(kMtu));
944 ipconfig_properties->SetWithoutPathExpansion( 944 ipconfig_properties->SetWithoutPathExpansion(
945 flimflam::kPrefixlenProperty, 945 flimflam::kPrefixlenProperty,
946 base::Value::CreateIntegerValue(kPrefixlen)); 946 base::Value::CreateIntegerValue(kPrefixlen));
947 ipconfig_properties->SetWithoutPathExpansion( 947 ipconfig_properties->SetWithoutPathExpansion(
948 flimflam::kBroadcastProperty, 948 flimflam::kBroadcastProperty,
949 base::Value::CreateStringValue(broadcast)); 949 new base::StringValue(broadcast));
950 ipconfig_properties->SetWithoutPathExpansion( 950 ipconfig_properties->SetWithoutPathExpansion(
951 flimflam::kPeerAddressProperty, 951 flimflam::kPeerAddressProperty,
952 base::Value::CreateStringValue(peer_address)); 952 new base::StringValue(peer_address));
953 ipconfig_properties->SetWithoutPathExpansion( 953 ipconfig_properties->SetWithoutPathExpansion(
954 flimflam::kGatewayProperty, 954 flimflam::kGatewayProperty,
955 base::Value::CreateStringValue(gateway)); 955 new base::StringValue(gateway));
956 ipconfig_properties->SetWithoutPathExpansion( 956 ipconfig_properties->SetWithoutPathExpansion(
957 flimflam::kDomainNameProperty, 957 flimflam::kDomainNameProperty,
958 base::Value::CreateStringValue(domainname)); 958 new base::StringValue(domainname));
959 ipconfig_properties->SetWithoutPathExpansion( 959 ipconfig_properties->SetWithoutPathExpansion(
960 flimflam::kNameServersProperty, name_servers_list); 960 flimflam::kNameServersProperty, name_servers_list);
961 961
962 EXPECT_CALL(*mock_device_client_, 962 EXPECT_CALL(*mock_device_client_,
963 CallGetPropertiesAndBlock(dbus::ObjectPath(device_path))) 963 CallGetPropertiesAndBlock(dbus::ObjectPath(device_path)))
964 .WillOnce(Return(device_properties)); 964 .WillOnce(Return(device_properties));
965 EXPECT_CALL(*mock_ipconfig_client_, 965 EXPECT_CALL(*mock_ipconfig_client_,
966 CallGetPropertiesAndBlock(dbus::ObjectPath(ipconfig_path))) 966 CallGetPropertiesAndBlock(dbus::ObjectPath(ipconfig_path)))
967 .WillOnce(Return(ipconfig_properties)); 967 .WillOnce(Return(ipconfig_properties));
968 968
(...skipping 14 matching lines...) Expand all
983 EXPECT_EQ(netmask, result_ipconfigs[0].netmask); 983 EXPECT_EQ(netmask, result_ipconfigs[0].netmask);
984 EXPECT_EQ(gateway, result_ipconfigs[0].gateway); 984 EXPECT_EQ(gateway, result_ipconfigs[0].gateway);
985 EXPECT_EQ(name_servers, result_ipconfigs[0].name_servers); 985 EXPECT_EQ(name_servers, result_ipconfigs[0].name_servers);
986 ASSERT_EQ(1U, result_ipconfig_paths.size()); 986 ASSERT_EQ(1U, result_ipconfig_paths.size());
987 EXPECT_EQ(ipconfig_path, result_ipconfig_paths[0]); 987 EXPECT_EQ(ipconfig_path, result_ipconfig_paths[0]);
988 } 988 }
989 989
990 TEST_F(CrosNetworkFunctionsTest, CrosGetWifiAccessPoints) { 990 TEST_F(CrosNetworkFunctionsTest, CrosGetWifiAccessPoints) {
991 const std::string device_path = "/device/path"; 991 const std::string device_path = "/device/path";
992 base::ListValue* devices = new base::ListValue; 992 base::ListValue* devices = new base::ListValue;
993 devices->Append(base::Value::CreateStringValue(device_path)); 993 devices->Append(new base::StringValue(device_path));
994 base::DictionaryValue* manager_properties = new base::DictionaryValue; 994 base::DictionaryValue* manager_properties = new base::DictionaryValue;
995 manager_properties->SetWithoutPathExpansion( 995 manager_properties->SetWithoutPathExpansion(
996 flimflam::kDevicesProperty, devices); 996 flimflam::kDevicesProperty, devices);
997 997
998 const int kScanInterval = 42; 998 const int kScanInterval = 42;
999 const std::string network_path = "/network/path"; 999 const std::string network_path = "/network/path";
1000 base::ListValue* networks = new base::ListValue; 1000 base::ListValue* networks = new base::ListValue;
1001 networks->Append(base::Value::CreateStringValue(network_path)); 1001 networks->Append(new base::StringValue(network_path));
1002 base::DictionaryValue* device_properties = new base::DictionaryValue; 1002 base::DictionaryValue* device_properties = new base::DictionaryValue;
1003 device_properties->SetWithoutPathExpansion( 1003 device_properties->SetWithoutPathExpansion(
1004 flimflam::kNetworksProperty, networks); 1004 flimflam::kNetworksProperty, networks);
1005 device_properties->SetWithoutPathExpansion( 1005 device_properties->SetWithoutPathExpansion(
1006 flimflam::kPoweredProperty, base::Value::CreateBooleanValue(true)); 1006 flimflam::kPoweredProperty, base::Value::CreateBooleanValue(true));
1007 device_properties->SetWithoutPathExpansion( 1007 device_properties->SetWithoutPathExpansion(
1008 flimflam::kScanIntervalProperty, 1008 flimflam::kScanIntervalProperty,
1009 base::Value::CreateIntegerValue(kScanInterval)); 1009 base::Value::CreateIntegerValue(kScanInterval));
1010 1010
1011 const int kSignalStrength = 10; 1011 const int kSignalStrength = 10;
1012 const int kWifiChannel = 3; 1012 const int kWifiChannel = 3;
1013 const std::string address = "address"; 1013 const std::string address = "address";
1014 const std::string name = "name"; 1014 const std::string name = "name";
1015 const base::Time expected_timestamp = 1015 const base::Time expected_timestamp =
1016 base::Time::Now() - base::TimeDelta::FromSeconds(kScanInterval); 1016 base::Time::Now() - base::TimeDelta::FromSeconds(kScanInterval);
1017 const base::TimeDelta acceptable_timestamp_range = 1017 const base::TimeDelta acceptable_timestamp_range =
1018 base::TimeDelta::FromSeconds(1); 1018 base::TimeDelta::FromSeconds(1);
1019 1019
1020 base::DictionaryValue* network_properties = new base::DictionaryValue; 1020 base::DictionaryValue* network_properties = new base::DictionaryValue;
1021 network_properties->SetWithoutPathExpansion( 1021 network_properties->SetWithoutPathExpansion(
1022 flimflam::kAddressProperty, base::Value::CreateStringValue(address)); 1022 flimflam::kAddressProperty, new base::StringValue(address));
1023 network_properties->SetWithoutPathExpansion( 1023 network_properties->SetWithoutPathExpansion(
1024 flimflam::kNameProperty, base::Value::CreateStringValue(name)); 1024 flimflam::kNameProperty, new base::StringValue(name));
1025 network_properties->SetWithoutPathExpansion( 1025 network_properties->SetWithoutPathExpansion(
1026 flimflam::kSignalStrengthProperty, 1026 flimflam::kSignalStrengthProperty,
1027 base::Value::CreateIntegerValue(kSignalStrength)); 1027 base::Value::CreateIntegerValue(kSignalStrength));
1028 network_properties->SetWithoutPathExpansion( 1028 network_properties->SetWithoutPathExpansion(
1029 flimflam::kWifiChannelProperty, 1029 flimflam::kWifiChannelProperty,
1030 base::Value::CreateIntegerValue(kWifiChannel)); 1030 base::Value::CreateIntegerValue(kWifiChannel));
1031 1031
1032 // Set expectations. 1032 // Set expectations.
1033 EXPECT_CALL(*mock_manager_client_, CallGetPropertiesAndBlock()) 1033 EXPECT_CALL(*mock_manager_client_, CallGetPropertiesAndBlock())
1034 .WillOnce(Return(manager_properties)); 1034 .WillOnce(Return(manager_properties));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 EXPECT_EQ("192.0.0.0", CrosPrefixLengthToNetmask(2)); 1147 EXPECT_EQ("192.0.0.0", CrosPrefixLengthToNetmask(2));
1148 EXPECT_EQ("128.0.0.0", CrosPrefixLengthToNetmask(1)); 1148 EXPECT_EQ("128.0.0.0", CrosPrefixLengthToNetmask(1));
1149 EXPECT_EQ("0.0.0.0", CrosPrefixLengthToNetmask(0)); 1149 EXPECT_EQ("0.0.0.0", CrosPrefixLengthToNetmask(0));
1150 // Invalid Prefix Lengths 1150 // Invalid Prefix Lengths
1151 EXPECT_EQ("", CrosPrefixLengthToNetmask(-1)); 1151 EXPECT_EQ("", CrosPrefixLengthToNetmask(-1));
1152 EXPECT_EQ("", CrosPrefixLengthToNetmask(33)); 1152 EXPECT_EQ("", CrosPrefixLengthToNetmask(33));
1153 EXPECT_EQ("", CrosPrefixLengthToNetmask(255)); 1153 EXPECT_EQ("", CrosPrefixLengthToNetmask(255));
1154 } 1154 }
1155 1155
1156 } // namespace chromeos 1156 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/cros_network_functions.cc ('k') | chrome/browser/chromeos/cros/network_library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698