Commit d7a5cefa authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

FakeShill*Client: Elim DictionaryValue

This removes DictionaryValue from the fake Manager, Device, and IPConfig
classes.

Bug: 1137487
Change-Id: I823c7cb6b6fd3620e750931dc9ac983365884b83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2465777Reviewed-by: default avatarPavol Marko <pmarko@chromium.org>
Reviewed-by: default avatarAzeem Arshad <azeemarshad@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818489}
parent 9d752a10
...@@ -152,7 +152,8 @@ class COMPONENT_EXPORT(SHILL_CLIENT) FakeShillDeviceClient ...@@ -152,7 +152,8 @@ class COMPONENT_EXPORT(SHILL_CLIENT) FakeShillDeviceClient
PropertyObserverList& GetObserverList(const dbus::ObjectPath& device_path); PropertyObserverList& GetObserverList(const dbus::ObjectPath& device_path);
// Dictionary of <device_name, Dictionary>. // Dictionary of <device_name, Dictionary>.
base::DictionaryValue stub_devices_; base::Value stub_devices_{base::Value::Type::DICTIONARY};
// Observer list for each device. // Observer list for each device.
std::map<dbus::ObjectPath, std::unique_ptr<PropertyObserverList>> std::map<dbus::ObjectPath, std::unique_ptr<PropertyObserverList>>
observer_list_; observer_list_;
......
...@@ -48,8 +48,7 @@ void FakeShillIPConfigClient::SetProperty(const dbus::ObjectPath& ipconfig_path, ...@@ -48,8 +48,7 @@ void FakeShillIPConfigClient::SetProperty(const dbus::ObjectPath& ipconfig_path,
const std::string& name, const std::string& name,
const base::Value& value, const base::Value& value,
VoidDBusMethodCallback callback) { VoidDBusMethodCallback callback) {
base::Value* dict = ipconfigs_.FindKeyOfType(ipconfig_path.value(), base::Value* dict = ipconfigs_.FindDictKey(ipconfig_path.value());
base::Value::Type::DICTIONARY);
if (!dict) { if (!dict) {
dict = ipconfigs_.SetKey(ipconfig_path.value(), dict = ipconfigs_.SetKey(ipconfig_path.value(),
base::Value(base::Value::Type::DICTIONARY)); base::Value(base::Value::Type::DICTIONARY));
...@@ -82,9 +81,8 @@ FakeShillIPConfigClient::GetTestInterface() { ...@@ -82,9 +81,8 @@ FakeShillIPConfigClient::GetTestInterface() {
// ShillIPConfigClient::TestInterface overrides // ShillIPConfigClient::TestInterface overrides
void FakeShillIPConfigClient::AddIPConfig( void FakeShillIPConfigClient::AddIPConfig(const std::string& ip_config_path,
const std::string& ip_config_path, const base::Value& properties) {
const base::DictionaryValue& properties) {
ipconfigs_.SetKey(ip_config_path, properties.Clone()); ipconfigs_.SetKey(ip_config_path, properties.Clone());
} }
......
...@@ -44,11 +44,11 @@ class COMPONENT_EXPORT(SHILL_CLIENT) FakeShillIPConfigClient ...@@ -44,11 +44,11 @@ class COMPONENT_EXPORT(SHILL_CLIENT) FakeShillIPConfigClient
// ShillIPConfigClient::TestInterface overrides. // ShillIPConfigClient::TestInterface overrides.
void AddIPConfig(const std::string& ip_config_path, void AddIPConfig(const std::string& ip_config_path,
const base::DictionaryValue& properties) override; const base::Value& properties) override;
private: private:
// Dictionary of <ipconfig_path, property dictionaries> // Dictionary of <ipconfig_path, property dictionaries>
base::DictionaryValue ipconfigs_; base::Value ipconfigs_{base::Value::Type::DICTIONARY};
// Note: This should remain the last member so it'll be destroyed and // Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed. // invalidate its weak pointers before any other members are destroyed.
......
...@@ -774,7 +774,7 @@ void FakeShillManagerClient::SetupDefaultEnvironment() { ...@@ -774,7 +774,7 @@ void FakeShillManagerClient::SetupDefaultEnvironment() {
const bool add_to_visible = true; const bool add_to_visible = true;
// IPConfigs // IPConfigs
base::DictionaryValue ipconfig_v4_dictionary; base::Value ipconfig_v4_dictionary(base::Value::Type::DICTIONARY);
ipconfig_v4_dictionary.SetKey(shill::kAddressProperty, ipconfig_v4_dictionary.SetKey(shill::kAddressProperty,
base::Value("100.0.0.1")); base::Value("100.0.0.1"));
ipconfig_v4_dictionary.SetKey(shill::kGatewayProperty, ipconfig_v4_dictionary.SetKey(shill::kGatewayProperty,
...@@ -785,7 +785,7 @@ void FakeShillManagerClient::SetupDefaultEnvironment() { ...@@ -785,7 +785,7 @@ void FakeShillManagerClient::SetupDefaultEnvironment() {
ipconfig_v4_dictionary.SetKey(shill::kWebProxyAutoDiscoveryUrlProperty, ipconfig_v4_dictionary.SetKey(shill::kWebProxyAutoDiscoveryUrlProperty,
base::Value("http://wpad.com/wpad.dat")); base::Value("http://wpad.com/wpad.dat"));
ip_configs->AddIPConfig("ipconfig_v4_path", ipconfig_v4_dictionary); ip_configs->AddIPConfig("ipconfig_v4_path", ipconfig_v4_dictionary);
base::DictionaryValue ipconfig_v6_dictionary; base::Value ipconfig_v6_dictionary(base::Value::Type::DICTIONARY);
ipconfig_v6_dictionary.SetKey(shill::kAddressProperty, ipconfig_v6_dictionary.SetKey(shill::kAddressProperty,
base::Value("0:0:0:0:100:0:0:1")); base::Value("0:0:0:0:100:0:0:1"));
ipconfig_v6_dictionary.SetKey(shill::kMethodProperty, ipconfig_v6_dictionary.SetKey(shill::kMethodProperty,
...@@ -977,7 +977,7 @@ void FakeShillManagerClient::SetupDefaultEnvironment() { ...@@ -977,7 +977,7 @@ void FakeShillManagerClient::SetupDefaultEnvironment() {
shill::kRoamingStateProperty, shill::kRoamingStateProperty,
base::Value(shill_roaming_state)); base::Value(shill_roaming_state));
base::DictionaryValue apn; base::Value apn(base::Value::Type::DICTIONARY);
apn.SetKey(shill::kApnProperty, base::Value("testapn")); apn.SetKey(shill::kApnProperty, base::Value("testapn"));
apn.SetKey(shill::kApnNameProperty, base::Value("Test APN")); apn.SetKey(shill::kApnNameProperty, base::Value("Test APN"));
apn.SetKey(shill::kApnLocalizedNameProperty, apn.SetKey(shill::kApnLocalizedNameProperty,
...@@ -985,15 +985,15 @@ void FakeShillManagerClient::SetupDefaultEnvironment() { ...@@ -985,15 +985,15 @@ void FakeShillManagerClient::SetupDefaultEnvironment() {
apn.SetKey(shill::kApnUsernameProperty, base::Value("User1")); apn.SetKey(shill::kApnUsernameProperty, base::Value("User1"));
apn.SetKey(shill::kApnPasswordProperty, base::Value("password")); apn.SetKey(shill::kApnPasswordProperty, base::Value("password"));
apn.SetKey(shill::kApnAuthenticationProperty, base::Value("chap")); apn.SetKey(shill::kApnAuthenticationProperty, base::Value("chap"));
base::DictionaryValue apn2; base::Value apn2(base::Value::Type::DICTIONARY);
apn2.SetKey(shill::kApnProperty, base::Value("testapn2")); apn2.SetKey(shill::kApnProperty, base::Value("testapn2"));
services->SetServiceProperty(kCellularServicePath, services->SetServiceProperty(kCellularServicePath,
shill::kCellularApnProperty, apn); shill::kCellularApnProperty, apn);
services->SetServiceProperty(kCellularServicePath, services->SetServiceProperty(kCellularServicePath,
shill::kCellularLastGoodApnProperty, apn); shill::kCellularLastGoodApnProperty, apn);
base::ListValue apn_list; base::ListValue apn_list;
apn_list.Append(apn.CreateDeepCopy()); apn_list.Append(std::move(apn));
apn_list.Append(apn2.CreateDeepCopy()); apn_list.Append(std::move(apn2));
SetInitialDeviceProperty("/device/cellular1", SetInitialDeviceProperty("/device/cellular1",
shill::kCellularApnListProperty, apn_list); shill::kCellularApnListProperty, apn_list);
...@@ -1008,10 +1008,10 @@ void FakeShillManagerClient::SetupDefaultEnvironment() { ...@@ -1008,10 +1008,10 @@ void FakeShillManagerClient::SetupDefaultEnvironment() {
// Shill, "Provider.Type", etc keys are used, but when reading the values // Shill, "Provider.Type", etc keys are used, but when reading the values
// "Provider" . "Type", etc keys are used. Here we are setting the values // "Provider" . "Type", etc keys are used. Here we are setting the values
// that will be read (by the UI, tests, etc). // that will be read (by the UI, tests, etc).
base::DictionaryValue provider_properties_openvpn; base::Value provider_properties_openvpn(base::Value::Type::DICTIONARY);
provider_properties_openvpn.SetString(shill::kTypeProperty, provider_properties_openvpn.SetStringKey(shill::kTypeProperty,
shill::kProviderOpenVpn); shill::kProviderOpenVpn);
provider_properties_openvpn.SetString(shill::kHostProperty, "vpn_host"); provider_properties_openvpn.SetStringKey(shill::kHostProperty, "vpn_host");
services->AddService("/service/vpn1", "vpn1_guid", "vpn1" /* name */, services->AddService("/service/vpn1", "vpn1_guid", "vpn1" /* name */,
shill::kTypeVPN, state, add_to_visible); shill::kTypeVPN, state, add_to_visible);
...@@ -1019,10 +1019,10 @@ void FakeShillManagerClient::SetupDefaultEnvironment() { ...@@ -1019,10 +1019,10 @@ void FakeShillManagerClient::SetupDefaultEnvironment() {
provider_properties_openvpn); provider_properties_openvpn);
profiles->AddService(shared_profile, "/service/vpn1"); profiles->AddService(shared_profile, "/service/vpn1");
base::DictionaryValue provider_properties_l2tp; base::Value provider_properties_l2tp(base::Value::Type::DICTIONARY);
provider_properties_l2tp.SetString(shill::kTypeProperty, provider_properties_l2tp.SetStringKey(shill::kTypeProperty,
shill::kProviderL2tpIpsec); shill::kProviderL2tpIpsec);
provider_properties_l2tp.SetString(shill::kHostProperty, "vpn_host2"); provider_properties_l2tp.SetStringKey(shill::kHostProperty, "vpn_host2");
services->AddService("/service/vpn2", "vpn2_guid", "vpn2" /* name */, services->AddService("/service/vpn2", "vpn2_guid", "vpn2" /* name */,
shill::kTypeVPN, shill::kStateIdle, add_to_visible); shill::kTypeVPN, shill::kStateIdle, add_to_visible);
...@@ -1031,16 +1031,13 @@ void FakeShillManagerClient::SetupDefaultEnvironment() { ...@@ -1031,16 +1031,13 @@ void FakeShillManagerClient::SetupDefaultEnvironment() {
} }
// Additional device states // Additional device states
for (DevicePropertyMap::iterator iter1 = shill_device_property_map_.begin(); for (const auto& iter1 : shill_device_property_map_) {
iter1 != shill_device_property_map_.end(); ++iter1) { std::string device_type = iter1.first;
std::string device_type = iter1->first;
std::string device_path = devices->GetDevicePathForType(device_type); std::string device_path = devices->GetDevicePathForType(device_type);
for (ShillPropertyMap::iterator iter2 = iter1->second.begin(); for (const auto& iter2 : iter1.second)
iter2 != iter1->second.end(); ++iter2) { SetInitialDeviceProperty(device_path, iter2.first, iter2.second);
SetInitialDeviceProperty(device_path, iter2->first, *(iter2->second));
delete iter2->second;
}
} }
shill_device_property_map_.clear();
SortManagerServices(true); SortManagerServices(true);
} }
...@@ -1198,28 +1195,28 @@ bool FakeShillManagerClient::ParseOption(const std::string& arg0, ...@@ -1198,28 +1195,28 @@ bool FakeShillManagerClient::ParseOption(const std::string& arg0,
return true; return true;
} else if (arg0 == "sim_lock") { } else if (arg0 == "sim_lock") {
bool locked = (arg1 == "1"); bool locked = (arg1 == "1");
base::DictionaryValue* simlock_dict = new base::DictionaryValue; base::Value simlock_dict(base::Value::Type::DICTIONARY);
simlock_dict->SetBoolean(shill::kSIMLockEnabledProperty, true); simlock_dict.SetBoolKey(shill::kSIMLockEnabledProperty, true);
std::string lock_type = locked ? shill::kSIMLockPin : ""; std::string lock_type = locked ? shill::kSIMLockPin : "";
simlock_dict->SetString(shill::kSIMLockTypeProperty, lock_type); simlock_dict.SetStringKey(shill::kSIMLockTypeProperty, lock_type);
if (locked) { if (locked) {
simlock_dict->SetInteger(shill::kSIMLockRetriesLeftProperty, simlock_dict.SetIntKey(shill::kSIMLockRetriesLeftProperty,
FakeShillDeviceClient::kSimPinRetryCount); FakeShillDeviceClient::kSimPinRetryCount);
} }
shill_device_property_map_[shill::kTypeCellular] shill_device_property_map_[shill::kTypeCellular]
[shill::kSIMPresentProperty] = [shill::kSIMPresentProperty] = base::Value(true);
new base::Value(true);
shill_device_property_map_[shill::kTypeCellular] shill_device_property_map_[shill::kTypeCellular]
[shill::kSIMLockStatusProperty] = simlock_dict; [shill::kSIMLockStatusProperty] =
std::move(simlock_dict);
shill_device_property_map_[shill::kTypeCellular] shill_device_property_map_[shill::kTypeCellular]
[shill::kTechnologyFamilyProperty] = [shill::kTechnologyFamilyProperty] =
new base::Value(shill::kNetworkTechnologyGsm); base::Value(shill::kNetworkTechnologyGsm);
return true; return true;
} else if (arg0 == "sim_present") { } else if (arg0 == "sim_present") {
bool present = (arg1 == "1"); bool present = (arg1 == "1");
base::Value* sim_present = new base::Value(present);
shill_device_property_map_[shill::kTypeCellular] shill_device_property_map_[shill::kTypeCellular]
[shill::kSIMPresentProperty] = sim_present; [shill::kSIMPresentProperty] =
base::Value(present);
if (!present) if (!present)
shill_initial_state_map_[shill::kTypeCellular] = kNetworkDisabled; shill_initial_state_map_[shill::kTypeCellular] = kNetworkDisabled;
return true; return true;
......
...@@ -149,7 +149,7 @@ class COMPONENT_EXPORT(SHILL_CLIENT) FakeShillManagerClient ...@@ -149,7 +149,7 @@ class COMPONENT_EXPORT(SHILL_CLIENT) FakeShillManagerClient
// Current network throttling status. // Current network throttling status.
NetworkThrottlingStatus network_throttling_status_ = {false, 0, 0}; NetworkThrottlingStatus network_throttling_status_ = {false, 0, 0};
typedef std::map<std::string, base::Value*> ShillPropertyMap; typedef std::map<std::string, base::Value> ShillPropertyMap;
typedef std::map<std::string, ShillPropertyMap> DevicePropertyMap; typedef std::map<std::string, ShillPropertyMap> DevicePropertyMap;
DevicePropertyMap shill_device_property_map_; DevicePropertyMap shill_device_property_map_;
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
namespace base { namespace base {
class Value; class Value;
class DictionaryValue; }
} // namespace base
namespace dbus { namespace dbus {
class Bus; class Bus;
...@@ -35,7 +34,7 @@ class COMPONENT_EXPORT(SHILL_CLIENT) ShillIPConfigClient { ...@@ -35,7 +34,7 @@ class COMPONENT_EXPORT(SHILL_CLIENT) ShillIPConfigClient {
public: public:
// Adds an IPConfig entry. // Adds an IPConfig entry.
virtual void AddIPConfig(const std::string& ip_config_path, virtual void AddIPConfig(const std::string& ip_config_path,
const base::DictionaryValue& properties) = 0; const base::Value& properties) = 0;
protected: protected:
virtual ~TestInterface() {} virtual ~TestInterface() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment