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

Side by Side Diff: chromeos/dbus/fake_shill_manager_client.cc

Issue 2666093002: Remove base::FundamentalValue (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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/dbus/fake_shill_manager_client.h" 5 #include "chromeos/dbus/fake_shill_manager_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 const ErrorCallback& error_callback) { 194 const ErrorCallback& error_callback) {
195 VLOG(1) << "RequestScan: " << type; 195 VLOG(1) << "RequestScan: " << type;
196 // For Stub purposes, default to a Wifi scan. 196 // For Stub purposes, default to a Wifi scan.
197 std::string device_type = shill::kTypeWifi; 197 std::string device_type = shill::kTypeWifi;
198 if (!type.empty()) 198 if (!type.empty())
199 device_type = type; 199 device_type = type;
200 ShillDeviceClient::TestInterface* device_client = 200 ShillDeviceClient::TestInterface* device_client =
201 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); 201 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface();
202 std::string device_path = device_client->GetDevicePathForType(device_type); 202 std::string device_path = device_client->GetDevicePathForType(device_type);
203 if (!device_path.empty()) { 203 if (!device_path.empty()) {
204 device_client->SetDeviceProperty( 204 device_client->SetDeviceProperty(device_path, shill::kScanningProperty,
205 device_path, shill::kScanningProperty, base::FundamentalValue(true)); 205 base::Value(true));
206 } 206 }
207 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 207 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
208 FROM_HERE, 208 FROM_HERE,
209 base::Bind(&FakeShillManagerClient::ScanCompleted, 209 base::Bind(&FakeShillManagerClient::ScanCompleted,
210 weak_ptr_factory_.GetWeakPtr(), device_path, callback), 210 weak_ptr_factory_.GetWeakPtr(), device_path, callback),
211 base::TimeDelta::FromSeconds(interactive_delay_)); 211 base::TimeDelta::FromSeconds(interactive_delay_));
212 } 212 }
213 213
214 void FakeShillManagerClient::EnableTechnology( 214 void FakeShillManagerClient::EnableTechnology(
215 const std::string& type, 215 const std::string& type,
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 const std::string kWifi1Path = "/service/wifi1"; 696 const std::string kWifi1Path = "/service/wifi1";
697 services->AddService(kWifi1Path, 697 services->AddService(kWifi1Path,
698 "wifi1_guid", 698 "wifi1_guid",
699 "wifi1" /* name */, 699 "wifi1" /* name */,
700 shill::kTypeWifi, 700 shill::kTypeWifi,
701 state, 701 state,
702 add_to_visible); 702 add_to_visible);
703 services->SetServiceProperty(kWifi1Path, 703 services->SetServiceProperty(kWifi1Path,
704 shill::kSecurityClassProperty, 704 shill::kSecurityClassProperty,
705 base::StringValue(shill::kSecurityWep)); 705 base::StringValue(shill::kSecurityWep));
706 services->SetServiceProperty(kWifi1Path, 706 services->SetServiceProperty(kWifi1Path, shill::kConnectableProperty,
707 shill::kConnectableProperty, 707 base::Value(true));
708 base::FundamentalValue(true));
709 profiles->AddService(shared_profile, kWifi1Path); 708 profiles->AddService(shared_profile, kWifi1Path);
710 709
711 const std::string kWifi2Path = "/service/wifi2"; 710 const std::string kWifi2Path = "/service/wifi2";
712 services->AddService(kWifi2Path, "wifi2_guid", 711 services->AddService(kWifi2Path, "wifi2_guid",
713 s_dynamic_wep ? "wifi2_WEP" : "wifi2_PSK" /* name */, 712 s_dynamic_wep ? "wifi2_WEP" : "wifi2_PSK" /* name */,
714 shill::kTypeWifi, shill::kStateIdle, add_to_visible); 713 shill::kTypeWifi, shill::kStateIdle, add_to_visible);
715 if (s_dynamic_wep) { 714 if (s_dynamic_wep) {
716 services->SetServiceProperty(kWifi2Path, shill::kSecurityClassProperty, 715 services->SetServiceProperty(kWifi2Path, shill::kSecurityClassProperty,
717 base::StringValue(shill::kSecurityWep)); 716 base::StringValue(shill::kSecurityWep));
718 services->SetServiceProperty( 717 services->SetServiceProperty(
719 kWifi2Path, shill::kEapKeyMgmtProperty, 718 kWifi2Path, shill::kEapKeyMgmtProperty,
720 base::StringValue(shill::kKeyManagementIEEE8021X)); 719 base::StringValue(shill::kKeyManagementIEEE8021X));
721 services->SetServiceProperty(kWifi2Path, shill::kEapMethodProperty, 720 services->SetServiceProperty(kWifi2Path, shill::kEapMethodProperty,
722 base::StringValue(shill::kEapMethodPEAP)); 721 base::StringValue(shill::kEapMethodPEAP));
723 services->SetServiceProperty(kWifi2Path, shill::kEapIdentityProperty, 722 services->SetServiceProperty(kWifi2Path, shill::kEapIdentityProperty,
724 base::StringValue("John Doe")); 723 base::StringValue("John Doe"));
725 } else { 724 } else {
726 services->SetServiceProperty(kWifi2Path, shill::kSecurityClassProperty, 725 services->SetServiceProperty(kWifi2Path, shill::kSecurityClassProperty,
727 base::StringValue(shill::kSecurityPsk)); 726 base::StringValue(shill::kSecurityPsk));
728 } 727 }
729 services->SetServiceProperty( 728 services->SetServiceProperty(kWifi2Path, shill::kSignalStrengthProperty,
730 kWifi2Path, shill::kSignalStrengthProperty, base::FundamentalValue(80)); 729 base::Value(80));
731 profiles->AddService(shared_profile, kWifi2Path); 730 profiles->AddService(shared_profile, kWifi2Path);
732 731
733 const std::string kWifi3Path = "/service/wifi3"; 732 const std::string kWifi3Path = "/service/wifi3";
734 services->AddService(kWifi3Path, 733 services->AddService(kWifi3Path,
735 "", /* empty GUID */ 734 "", /* empty GUID */
736 "wifi3" /* name */, 735 "wifi3" /* name */,
737 shill::kTypeWifi, 736 shill::kTypeWifi,
738 shill::kStateIdle, 737 shill::kStateIdle,
739 add_to_visible); 738 add_to_visible);
740 services->SetServiceProperty( 739 services->SetServiceProperty(kWifi3Path, shill::kSignalStrengthProperty,
741 kWifi3Path, shill::kSignalStrengthProperty, base::FundamentalValue(40)); 740 base::Value(40));
742 741
743 if (portaled) { 742 if (portaled) {
744 const std::string kPortaledWifiPath = "/service/portaled_wifi"; 743 const std::string kPortaledWifiPath = "/service/portaled_wifi";
745 services->AddService(kPortaledWifiPath, "portaled_wifi_guid", 744 services->AddService(kPortaledWifiPath, "portaled_wifi_guid",
746 "Portaled Wifi" /* name */, shill::kTypeWifi, 745 "Portaled Wifi" /* name */, shill::kTypeWifi,
747 shill::kStateIdle, add_to_visible); 746 shill::kStateIdle, add_to_visible);
748 services->SetServiceProperty(kPortaledWifiPath, 747 services->SetServiceProperty(kPortaledWifiPath,
749 shill::kSecurityClassProperty, 748 shill::kSecurityClassProperty,
750 base::StringValue(shill::kSecurityNone)); 749 base::StringValue(shill::kSecurityNone));
751 services->SetConnectBehavior( 750 services->SetConnectBehavior(
752 kPortaledWifiPath, 751 kPortaledWifiPath,
753 base::Bind(&UpdatePortaledWifiState, kPortaledWifiPath)); 752 base::Bind(&UpdatePortaledWifiState, kPortaledWifiPath));
754 services->SetServiceProperty(kPortaledWifiPath, 753 services->SetServiceProperty(
755 shill::kConnectableProperty, 754 kPortaledWifiPath, shill::kConnectableProperty, base::Value(true));
756 base::FundamentalValue(true));
757 profiles->AddService(shared_profile, kPortaledWifiPath); 755 profiles->AddService(shared_profile, kPortaledWifiPath);
758 } 756 }
759 757
760 for (int i = 0; i < s_extra_wifi_networks; ++i) { 758 for (int i = 0; i < s_extra_wifi_networks; ++i) {
761 int id = 4 + i; 759 int id = 4 + i;
762 std::string path = base::StringPrintf("/service/wifi%d", id); 760 std::string path = base::StringPrintf("/service/wifi%d", id);
763 std::string guid = base::StringPrintf("wifi%d_guid", id); 761 std::string guid = base::StringPrintf("wifi%d_guid", id);
764 std::string name = base::StringPrintf("wifi%d", id); 762 std::string name = base::StringPrintf("wifi%d", id);
765 services->AddService(path, guid, name, shill::kTypeWifi, 763 services->AddService(path, guid, name, shill::kTypeWifi,
766 shill::kStateIdle, add_to_visible); 764 shill::kStateIdle, add_to_visible);
767 } 765 }
768 } 766 }
769 767
770 // Wimax 768 // Wimax
771 const std::string kWimaxPath = "/service/wimax1"; 769 const std::string kWimaxPath = "/service/wimax1";
772 state = GetInitialStateForType(shill::kTypeWimax, &enabled); 770 state = GetInitialStateForType(shill::kTypeWimax, &enabled);
773 if (state != kTechnologyUnavailable) { 771 if (state != kTechnologyUnavailable) {
774 AddTechnology(shill::kTypeWimax, enabled); 772 AddTechnology(shill::kTypeWimax, enabled);
775 devices->AddDevice( 773 devices->AddDevice(
776 "/device/wimax1", shill::kTypeWimax, "stub_wimax_device1"); 774 "/device/wimax1", shill::kTypeWimax, "stub_wimax_device1");
777 775
778 services->AddService(kWimaxPath, "wimax1_guid", "wimax1" /* name */, 776 services->AddService(kWimaxPath, "wimax1_guid", "wimax1" /* name */,
779 shill::kTypeWimax, state, add_to_visible); 777 shill::kTypeWimax, state, add_to_visible);
780 services->SetServiceProperty(kWimaxPath, shill::kConnectableProperty, 778 services->SetServiceProperty(kWimaxPath, shill::kConnectableProperty,
781 base::FundamentalValue(true)); 779 base::Value(true));
782 base::FundamentalValue strength_value(80); 780 base::Value strength_value(80);
783 services->SetServiceProperty(kWimaxPath, shill::kSignalStrengthProperty, 781 services->SetServiceProperty(kWimaxPath, shill::kSignalStrengthProperty,
784 strength_value); 782 strength_value);
785 profiles->AddService(shared_profile, kWimaxPath); 783 profiles->AddService(shared_profile, kWimaxPath);
786 } 784 }
787 785
788 // Cellular 786 // Cellular
789 state = GetInitialStateForType(shill::kTypeCellular, &enabled); 787 state = GetInitialStateForType(shill::kTypeCellular, &enabled);
790 if (state != kTechnologyUnavailable) { 788 if (state != kTechnologyUnavailable) {
791 bool activated = false; 789 bool activated = false;
792 if (state == kNetworkActivated) { 790 if (state == kNetworkActivated) {
793 activated = true; 791 activated = true;
794 state = shill::kStateOnline; 792 state = shill::kStateOnline;
795 } 793 }
796 AddTechnology(shill::kTypeCellular, enabled); 794 AddTechnology(shill::kTypeCellular, enabled);
797 devices->AddDevice( 795 devices->AddDevice(
798 "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1"); 796 "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1");
799 devices->SetDeviceProperty("/device/cellular1", 797 devices->SetDeviceProperty("/device/cellular1",
800 shill::kCarrierProperty, 798 shill::kCarrierProperty,
801 base::StringValue(shill::kCarrierSprint)); 799 base::StringValue(shill::kCarrierSprint));
802 base::ListValue carrier_list; 800 base::ListValue carrier_list;
803 carrier_list.AppendString(shill::kCarrierSprint); 801 carrier_list.AppendString(shill::kCarrierSprint);
804 carrier_list.AppendString(shill::kCarrierGenericUMTS); 802 carrier_list.AppendString(shill::kCarrierGenericUMTS);
805 devices->SetDeviceProperty("/device/cellular1", 803 devices->SetDeviceProperty("/device/cellular1",
806 shill::kSupportedCarriersProperty, 804 shill::kSupportedCarriersProperty,
807 carrier_list); 805 carrier_list);
808 devices->SetDeviceProperty("/device/cellular1", 806 devices->SetDeviceProperty("/device/cellular1",
809 shill::kSupportNetworkScanProperty, 807 shill::kSupportNetworkScanProperty,
810 base::FundamentalValue(true)); 808 base::Value(true));
811 if (roaming_state_ == kRoamingRequired) { 809 if (roaming_state_ == kRoamingRequired) {
812 devices->SetDeviceProperty("/device/cellular1", 810 devices->SetDeviceProperty("/device/cellular1",
813 shill::kProviderRequiresRoamingProperty, 811 shill::kProviderRequiresRoamingProperty,
814 base::FundamentalValue(true)); 812 base::Value(true));
815 } 813 }
816 if (cellular_technology_ == shill::kNetworkTechnologyGsm) { 814 if (cellular_technology_ == shill::kNetworkTechnologyGsm) {
817 devices->SetDeviceProperty("/device/cellular1", 815 devices->SetDeviceProperty("/device/cellular1",
818 shill::kSIMPresentProperty, 816 shill::kSIMPresentProperty, base::Value(true));
819 base::FundamentalValue(true));
820 devices->SetSimLocked("/device/cellular1", false); 817 devices->SetSimLocked("/device/cellular1", false);
821 } 818 }
822 819
823 services->AddService(kCellularServicePath, 820 services->AddService(kCellularServicePath,
824 "cellular1_guid", 821 "cellular1_guid",
825 "cellular1" /* name */, 822 "cellular1" /* name */,
826 shill::kTypeCellular, 823 shill::kTypeCellular,
827 state, 824 state,
828 add_to_visible); 825 add_to_visible);
829 base::StringValue technology_value(cellular_technology_); 826 base::StringValue technology_value(cellular_technology_);
830 devices->SetDeviceProperty("/device/cellular1", 827 devices->SetDeviceProperty("/device/cellular1",
831 shill::kTechnologyFamilyProperty, 828 shill::kTechnologyFamilyProperty,
832 technology_value); 829 technology_value);
833 services->SetServiceProperty(kCellularServicePath, 830 services->SetServiceProperty(kCellularServicePath,
834 shill::kNetworkTechnologyProperty, 831 shill::kNetworkTechnologyProperty,
835 technology_value); 832 technology_value);
836 base::FundamentalValue strength_value(50); 833 base::Value strength_value(50);
837 services->SetServiceProperty( 834 services->SetServiceProperty(
838 kCellularServicePath, shill::kSignalStrengthProperty, strength_value); 835 kCellularServicePath, shill::kSignalStrengthProperty, strength_value);
839 836
840 if (activated) { 837 if (activated) {
841 services->SetServiceProperty( 838 services->SetServiceProperty(
842 kCellularServicePath, 839 kCellularServicePath,
843 shill::kActivationStateProperty, 840 shill::kActivationStateProperty,
844 base::StringValue(shill::kActivationStateActivated)); 841 base::StringValue(shill::kActivationStateActivated));
845 services->SetServiceProperty(kCellularServicePath, 842 services->SetServiceProperty(
846 shill::kConnectableProperty, 843 kCellularServicePath, shill::kConnectableProperty, base::Value(true));
847 base::FundamentalValue(true));
848 } else { 844 } else {
849 services->SetServiceProperty( 845 services->SetServiceProperty(
850 kCellularServicePath, 846 kCellularServicePath,
851 shill::kActivationStateProperty, 847 shill::kActivationStateProperty,
852 base::StringValue(shill::kActivationStateNotActivated)); 848 base::StringValue(shill::kActivationStateNotActivated));
853 } 849 }
854 850
855 std::string shill_roaming_state; 851 std::string shill_roaming_state;
856 if (roaming_state_ == kRoamingRequired) 852 if (roaming_state_ == kRoamingRequired)
857 shill_roaming_state = shill::kRoamingStateRoaming; 853 shill_roaming_state = shill::kRoamingStateRoaming;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 if (TechnologyEnabled(type)) 1047 if (TechnologyEnabled(type))
1052 new_service_list->Append((*iter)->CreateDeepCopy()); 1048 new_service_list->Append((*iter)->CreateDeepCopy());
1053 } 1049 }
1054 } 1050 }
1055 return new_service_list; 1051 return new_service_list;
1056 } 1052 }
1057 1053
1058 void FakeShillManagerClient::ScanCompleted(const std::string& device_path, 1054 void FakeShillManagerClient::ScanCompleted(const std::string& device_path,
1059 const base::Closure& callback) { 1055 const base::Closure& callback) {
1060 if (!device_path.empty()) { 1056 if (!device_path.empty()) {
1061 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()-> 1057 DBusThreadManager::Get()
1062 SetDeviceProperty(device_path, 1058 ->GetShillDeviceClient()
1063 shill::kScanningProperty, 1059 ->GetTestInterface()
1064 base::FundamentalValue(false)); 1060 ->SetDeviceProperty(device_path, shill::kScanningProperty,
1061 base::Value(false));
1065 } 1062 }
1066 VLOG(1) << "ScanCompleted"; 1063 VLOG(1) << "ScanCompleted";
1067 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty); 1064 CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty);
1068 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); 1065 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
1069 } 1066 }
1070 1067
1071 void FakeShillManagerClient::ParseCommandLineSwitch() { 1068 void FakeShillManagerClient::ParseCommandLineSwitch() {
1072 // Default setup 1069 // Default setup
1073 SetInitialNetworkState(shill::kTypeEthernet, shill::kStateOnline); 1070 SetInitialNetworkState(shill::kTypeEthernet, shill::kStateOnline);
1074 SetInitialNetworkState(shill::kTypeWifi, shill::kStateOnline); 1071 SetInitialNetworkState(shill::kTypeWifi, shill::kStateOnline);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 FakeShillDeviceClient::kSimPinRetryCount); 1111 FakeShillDeviceClient::kSimPinRetryCount);
1115 } 1112 }
1116 shill_device_property_map_[shill::kTypeCellular] 1113 shill_device_property_map_[shill::kTypeCellular]
1117 [shill::kSIMLockStatusProperty] = simlock_dict; 1114 [shill::kSIMLockStatusProperty] = simlock_dict;
1118 shill_device_property_map_ 1115 shill_device_property_map_
1119 [shill::kTypeCellular][shill::kTechnologyFamilyProperty] = 1116 [shill::kTypeCellular][shill::kTechnologyFamilyProperty] =
1120 new base::StringValue(shill::kNetworkTechnologyGsm); 1117 new base::StringValue(shill::kNetworkTechnologyGsm);
1121 return true; 1118 return true;
1122 } else if (arg0 == "sim_present") { 1119 } else if (arg0 == "sim_present") {
1123 bool present = (arg1 == "1"); 1120 bool present = (arg1 == "1");
1124 base::FundamentalValue* sim_present = new base::FundamentalValue(present); 1121 base::Value* sim_present = new base::Value(present);
1125 shill_device_property_map_[shill::kTypeCellular] 1122 shill_device_property_map_[shill::kTypeCellular]
1126 [shill::kSIMPresentProperty] = sim_present; 1123 [shill::kSIMPresentProperty] = sim_present;
1127 return true; 1124 return true;
1128 } else if (arg0 == "tdls_busy") { 1125 } else if (arg0 == "tdls_busy") {
1129 if (!arg1.empty()) 1126 if (!arg1.empty())
1130 base::StringToInt(arg1, &s_tdls_busy_count); 1127 base::StringToInt(arg1, &s_tdls_busy_count);
1131 else 1128 else
1132 s_tdls_busy_count = 1; 1129 s_tdls_busy_count = 1;
1133 return true; 1130 return true;
1134 } else if (arg0 == "roaming") { 1131 } else if (arg0 == "roaming") {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 LOG(WARNING) << "Invalid state: " << state << " for " << type; 1235 LOG(WARNING) << "Invalid state: " << state << " for " << type;
1239 result = shill::kStateIdle; 1236 result = shill::kStateIdle;
1240 } 1237 }
1241 } 1238 }
1242 VLOG(1) << "Initial state for: " << type << " = " << result 1239 VLOG(1) << "Initial state for: " << type << " = " << result
1243 << " Enabled: " << *enabled; 1240 << " Enabled: " << *enabled;
1244 return result; 1241 return result;
1245 } 1242 }
1246 1243
1247 } // namespace chromeos 1244 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromecast/base/device_capabilities_impl_unittest.cc ('k') | chromeos/dbus/fake_shill_service_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698