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
...@@ -105,9 +105,9 @@ void FakeShillDeviceClient::SetPropertyInternal( ...@@ -105,9 +105,9 @@ void FakeShillDeviceClient::SetPropertyInternal(
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback, ErrorCallback error_callback,
bool notify_changed) { bool notify_changed) {
base::DictionaryValue* device_properties = nullptr; base::Value* device_properties =
if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(), stub_devices_.FindDictKey(device_path.value());
&device_properties)) { if (!device_properties) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
} }
...@@ -124,9 +124,9 @@ void FakeShillDeviceClient::SetPropertyInternal( ...@@ -124,9 +124,9 @@ void FakeShillDeviceClient::SetPropertyInternal(
void FakeShillDeviceClient::ClearProperty(const dbus::ObjectPath& device_path, void FakeShillDeviceClient::ClearProperty(const dbus::ObjectPath& device_path,
const std::string& name, const std::string& name,
VoidDBusMethodCallback callback) { VoidDBusMethodCallback callback) {
base::DictionaryValue* device_properties = nullptr; base::Value* device_properties =
if (!stub_devices_.GetDictionaryWithoutPathExpansion(device_path.value(), stub_devices_.FindDictKey(device_path.value());
&device_properties)) { if (!device_properties) {
PostVoidCallback(std::move(callback), false); PostVoidCallback(std::move(callback), false);
return; return;
} }
...@@ -140,7 +140,7 @@ void FakeShillDeviceClient::RequirePin(const dbus::ObjectPath& device_path, ...@@ -140,7 +140,7 @@ void FakeShillDeviceClient::RequirePin(const dbus::ObjectPath& device_path,
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
VLOG(1) << "RequirePin: " << device_path.value(); VLOG(1) << "RequirePin: " << device_path.value();
if (!stub_devices_.HasKey(device_path.value())) { if (!stub_devices_.FindKey(device_path.value())) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
} }
...@@ -162,7 +162,7 @@ void FakeShillDeviceClient::EnterPin(const dbus::ObjectPath& device_path, ...@@ -162,7 +162,7 @@ void FakeShillDeviceClient::EnterPin(const dbus::ObjectPath& device_path,
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
VLOG(1) << "EnterPin: " << device_path.value(); VLOG(1) << "EnterPin: " << device_path.value();
if (!stub_devices_.HasKey(device_path.value())) { if (!stub_devices_.FindKey(device_path.value())) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
} }
...@@ -183,7 +183,7 @@ void FakeShillDeviceClient::UnblockPin(const dbus::ObjectPath& device_path, ...@@ -183,7 +183,7 @@ void FakeShillDeviceClient::UnblockPin(const dbus::ObjectPath& device_path,
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
VLOG(1) << "UnblockPin: " << device_path.value(); VLOG(1) << "UnblockPin: " << device_path.value();
if (!stub_devices_.HasKey(device_path.value())) { if (!stub_devices_.FindKey(device_path.value())) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
} }
...@@ -211,7 +211,7 @@ void FakeShillDeviceClient::ChangePin(const dbus::ObjectPath& device_path, ...@@ -211,7 +211,7 @@ void FakeShillDeviceClient::ChangePin(const dbus::ObjectPath& device_path,
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
VLOG(1) << "ChangePin: " << device_path.value(); VLOG(1) << "ChangePin: " << device_path.value();
if (!stub_devices_.HasKey(device_path.value())) { if (!stub_devices_.FindKey(device_path.value())) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
} }
...@@ -236,8 +236,9 @@ void FakeShillDeviceClient::Register(const dbus::ObjectPath& device_path, ...@@ -236,8 +236,9 @@ void FakeShillDeviceClient::Register(const dbus::ObjectPath& device_path,
const std::string& network_id, const std::string& network_id,
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
base::Value* device_properties = stub_devices_.FindKey(device_path.value()); base::Value* device_properties =
if (!device_properties || !device_properties->is_dict()) { stub_devices_.FindDictKey(device_path.value());
if (!device_properties) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
} }
...@@ -258,7 +259,7 @@ void FakeShillDeviceClient::Register(const dbus::ObjectPath& device_path, ...@@ -258,7 +259,7 @@ void FakeShillDeviceClient::Register(const dbus::ObjectPath& device_path,
void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path, void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path,
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
if (!stub_devices_.HasKey(device_path.value())) { if (!stub_devices_.FindKey(device_path.value())) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
} }
...@@ -270,7 +271,7 @@ void FakeShillDeviceClient::AddWakeOnPacketConnection( ...@@ -270,7 +271,7 @@ void FakeShillDeviceClient::AddWakeOnPacketConnection(
const net::IPEndPoint& ip_endpoint, const net::IPEndPoint& ip_endpoint,
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
if (!stub_devices_.HasKey(device_path.value())) { if (!stub_devices_.FindKey(device_path.value())) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
} }
...@@ -285,7 +286,7 @@ void FakeShillDeviceClient::AddWakeOnPacketOfTypes( ...@@ -285,7 +286,7 @@ void FakeShillDeviceClient::AddWakeOnPacketOfTypes(
const std::vector<std::string>& types, const std::vector<std::string>& types,
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
if (!stub_devices_.HasKey(device_path.value())) { if (!stub_devices_.FindKey(device_path.value())) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
} }
...@@ -300,7 +301,7 @@ void FakeShillDeviceClient::RemoveWakeOnPacketConnection( ...@@ -300,7 +301,7 @@ void FakeShillDeviceClient::RemoveWakeOnPacketConnection(
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
const auto device_iter = wake_on_packet_connections_.find(device_path); const auto device_iter = wake_on_packet_connections_.find(device_path);
if (!stub_devices_.HasKey(device_path.value()) || if (!stub_devices_.FindKey(device_path.value()) ||
device_iter == wake_on_packet_connections_.end()) { device_iter == wake_on_packet_connections_.end()) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
...@@ -322,7 +323,7 @@ void FakeShillDeviceClient::RemoveWakeOnPacketOfTypes( ...@@ -322,7 +323,7 @@ void FakeShillDeviceClient::RemoveWakeOnPacketOfTypes(
const std::vector<std::string>& types, const std::vector<std::string>& types,
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
if (!stub_devices_.HasKey(device_path.value())) { if (!stub_devices_.FindKey(device_path.value())) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
} }
...@@ -345,7 +346,7 @@ void FakeShillDeviceClient::RemoveAllWakeOnPacketConnections( ...@@ -345,7 +346,7 @@ void FakeShillDeviceClient::RemoveAllWakeOnPacketConnections(
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
const auto iter = wake_on_packet_connections_.find(device_path); const auto iter = wake_on_packet_connections_.find(device_path);
if (!stub_devices_.HasKey(device_path.value()) || if (!stub_devices_.FindKey(device_path.value()) ||
iter == wake_on_packet_connections_.end()) { iter == wake_on_packet_connections_.end()) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
...@@ -361,7 +362,7 @@ void FakeShillDeviceClient::SetUsbEthernetMacAddressSource( ...@@ -361,7 +362,7 @@ void FakeShillDeviceClient::SetUsbEthernetMacAddressSource(
const std::string& source, const std::string& source,
base::OnceClosure callback, base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
if (!stub_devices_.HasKey(device_path.value())) { if (!stub_devices_.FindKey(device_path.value())) {
PostNotFoundError(std::move(error_callback)); PostNotFoundError(std::move(error_callback));
return; return;
} }
...@@ -413,7 +414,7 @@ void FakeShillDeviceClient::RemoveDevice(const std::string& device_path) { ...@@ -413,7 +414,7 @@ void FakeShillDeviceClient::RemoveDevice(const std::string& device_path) {
void FakeShillDeviceClient::ClearDevices() { void FakeShillDeviceClient::ClearDevices() {
ShillManagerClient::Get()->GetTestInterface()->ClearDevices(); ShillManagerClient::Get()->GetTestInterface()->ClearDevices();
stub_devices_.Clear(); stub_devices_ = base::Value(base::Value::Type::DICTIONARY);
} }
void FakeShillDeviceClient::SetDeviceProperty(const std::string& device_path, void FakeShillDeviceClient::SetDeviceProperty(const std::string& device_path,
...@@ -429,17 +430,14 @@ void FakeShillDeviceClient::SetDeviceProperty(const std::string& device_path, ...@@ -429,17 +430,14 @@ void FakeShillDeviceClient::SetDeviceProperty(const std::string& device_path,
std::string FakeShillDeviceClient::GetDevicePathForType( std::string FakeShillDeviceClient::GetDevicePathForType(
const std::string& type) { const std::string& type) {
for (base::DictionaryValue::Iterator iter(stub_devices_); !iter.IsAtEnd(); for (auto iter : stub_devices_.DictItems()) {
iter.Advance()) { if (!iter.second.is_dict())
const base::DictionaryValue* properties = nullptr;
if (!iter.value().GetAsDictionary(&properties))
continue; continue;
std::string prop_type; const std::string* prop_type =
if (!properties->GetStringWithoutPathExpansion(shill::kTypeProperty, iter.second.FindStringKey(shill::kTypeProperty);
&prop_type) || if (!prop_type || *prop_type != type)
prop_type != type)
continue; continue;
return iter.key(); return iter.first;
} }
return std::string(); return std::string();
} }
...@@ -454,8 +452,8 @@ void FakeShillDeviceClient::SetSimLocked(const std::string& device_path, ...@@ -454,8 +452,8 @@ void FakeShillDeviceClient::SetSimLocked(const std::string& device_path,
void FakeShillDeviceClient::AddCellularFoundNetwork( void FakeShillDeviceClient::AddCellularFoundNetwork(
const std::string& device_path) { const std::string& device_path) {
base::Value* device_properties = stub_devices_.FindKey(device_path); base::Value* device_properties = stub_devices_.FindDictKey(device_path);
if (!device_properties || !device_properties->is_dict()) { if (!device_properties) {
LOG(ERROR) << "Device path not found: " << device_path; LOG(ERROR) << "Device path not found: " << device_path;
return; return;
} }
...@@ -474,7 +472,7 @@ void FakeShillDeviceClient::AddCellularFoundNetwork( ...@@ -474,7 +472,7 @@ void FakeShillDeviceClient::AddCellularFoundNetwork(
scan_results = device_properties->SetKey(shill::kFoundNetworksProperty, scan_results = device_properties->SetKey(shill::kFoundNetworksProperty,
base::ListValue()); base::ListValue());
} }
base::DictionaryValue new_result; base::Value new_result(base::Value::Type::DICTIONARY);
int idx = static_cast<int>(scan_results->GetList().size()); int idx = static_cast<int>(scan_results->GetList().size());
new_result.SetKey(shill::kNetworkIdProperty, new_result.SetKey(shill::kNetworkIdProperty,
base::Value(base::StringPrintf("network%d", idx))); base::Value(base::StringPrintf("network%d", idx)));
...@@ -502,29 +500,29 @@ void FakeShillDeviceClient::SetUsbEthernetMacAddressSourceError( ...@@ -502,29 +500,29 @@ void FakeShillDeviceClient::SetUsbEthernetMacAddressSourceError(
FakeShillDeviceClient::SimLockStatus FakeShillDeviceClient::GetSimLockStatus( FakeShillDeviceClient::SimLockStatus FakeShillDeviceClient::GetSimLockStatus(
const std::string& device_path) { const std::string& device_path) {
SimLockStatus status; SimLockStatus status;
base::DictionaryValue* device_properties = nullptr; base::Value* device_properties = stub_devices_.FindDictKey(device_path);
base::DictionaryValue* simlock_dict = nullptr; if (!device_properties)
if (stub_devices_.GetDictionaryWithoutPathExpansion(device_path, return status;
&device_properties) && base::Value* simlock_dict =
device_properties->GetDictionaryWithoutPathExpansion( device_properties->FindDictKey(shill::kSIMLockStatusProperty);
shill::kSIMLockStatusProperty, &simlock_dict)) { if (!simlock_dict)
simlock_dict->GetStringWithoutPathExpansion(shill::kSIMLockTypeProperty, return status;
&status.type); const std::string* type =
simlock_dict->GetIntegerWithoutPathExpansion( simlock_dict->FindStringKey(shill::kSIMLockTypeProperty);
shill::kSIMLockRetriesLeftProperty, &status.retries_left); if (type)
simlock_dict->GetBooleanWithoutPathExpansion(shill::kSIMLockEnabledProperty, status.type = *type;
&status.lock_enabled); status.retries_left =
if (status.type == shill::kSIMLockPin && status.retries_left == 0) simlock_dict->FindIntKey(shill::kSIMLockRetriesLeftProperty).value_or(0);
status.retries_left = kSimPinRetryCount; status.lock_enabled =
} simlock_dict->FindBoolKey(shill::kSIMLockEnabledProperty).value_or(false);
if (status.type == shill::kSIMLockPin && status.retries_left == 0)
status.retries_left = kSimPinRetryCount;
return status; return status;
} }
void FakeShillDeviceClient::SetSimLockStatus(const std::string& device_path, void FakeShillDeviceClient::SetSimLockStatus(const std::string& device_path,
const SimLockStatus& status) { const SimLockStatus& status) {
base::Value* device_properties = base::Value* device_properties = stub_devices_.FindDictKey(device_path);
stub_devices_.FindKeyOfType(device_path, base::Value::Type::DICTIONARY);
if (!device_properties) { if (!device_properties) {
NOTREACHED() << "Device not found: " << device_path; NOTREACHED() << "Device not found: " << device_path;
return; return;
...@@ -623,14 +621,14 @@ void FakeShillDeviceClient::PostVoidCallback(VoidDBusMethodCallback callback, ...@@ -623,14 +621,14 @@ void FakeShillDeviceClient::PostVoidCallback(VoidDBusMethodCallback callback,
void FakeShillDeviceClient::NotifyObserversPropertyChanged( void FakeShillDeviceClient::NotifyObserversPropertyChanged(
const dbus::ObjectPath& device_path, const dbus::ObjectPath& device_path,
const std::string& property) { const std::string& property) {
base::DictionaryValue* dict = nullptr;
std::string path = device_path.value(); std::string path = device_path.value();
if (!stub_devices_.GetDictionaryWithoutPathExpansion(path, &dict)) { base::Value* device_properties = stub_devices_.FindDictKey(path);
if (!device_properties) {
LOG(ERROR) << "Notify for unknown device: " << path; LOG(ERROR) << "Notify for unknown device: " << path;
return; return;
} }
base::Value* value = nullptr; base::Value* value = device_properties->FindKey(property);
if (!dict->GetWithoutPathExpansion(property, &value)) { if (!value) {
LOG(ERROR) << "Notify for unknown property: " << path << " : " << property; LOG(ERROR) << "Notify for unknown property: " << path << " : " << property;
return; return;
} }
...@@ -640,12 +638,12 @@ void FakeShillDeviceClient::NotifyObserversPropertyChanged( ...@@ -640,12 +638,12 @@ void FakeShillDeviceClient::NotifyObserversPropertyChanged(
base::Value* FakeShillDeviceClient::GetDeviceProperties( base::Value* FakeShillDeviceClient::GetDeviceProperties(
const std::string& device_path) { const std::string& device_path) {
base::Value* properties = base::Value* properties = stub_devices_.FindDictKey(device_path);
stub_devices_.FindKeyOfType(device_path, base::Value::Type::DICTIONARY); if (!properties) {
if (properties) properties = stub_devices_.SetKey(
return properties; device_path, base::Value(base::Value::Type::DICTIONARY));
return stub_devices_.SetKey(device_path, }
base::Value(base::Value::Type::DICTIONARY)); return properties;
} }
FakeShillDeviceClient::PropertyObserverList& FakeShillDeviceClient::PropertyObserverList&
......
...@@ -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