const char* kTechnologyUnavailable = "unavailable";
const char* kNetworkActivated = "activated";
const char* kNetworkDisabled = "disabled";
+const char* kCellularServicePath = "/service/cellular1";
} // namespace
// static
-const char FakeShillManagerClient::kFakeEthernetNetworkPath[] = "/service/eth1";
+const char FakeShillManagerClient::kFakeEthernetNetworkGuid[] = "eth1_guid";
FakeShillManagerClient::FakeShillManagerClient()
: interactive_delay_(0),
guid /* guid */,
guid /* name */,
type,
- shill::kStateIdle, ipconfig_path,
+ shill::kStateIdle,
+ ipconfig_path,
true /* visible */);
existing_properties = service_client->GetServiceProperties(service_path);
}
// ShillManagerClient::TestInterface overrides.
void FakeShillManagerClient::AddDevice(const std::string& device_path) {
- if (GetListProperty(shill::kDevicesProperty)->AppendIfNotPresent(
- base::Value::CreateStringValue(device_path))) {
+ if (GetListProperty(shill::kDevicesProperty)
+ ->AppendIfNotPresent(new base::StringValue(device_path))) {
CallNotifyObserversPropertyChanged(shill::kDevicesProperty);
}
}
void FakeShillManagerClient::AddTechnology(const std::string& type,
bool enabled) {
- if (GetListProperty(shill::kAvailableTechnologiesProperty)->
- AppendIfNotPresent(base::Value::CreateStringValue(type))) {
+ if (GetListProperty(shill::kAvailableTechnologiesProperty)
+ ->AppendIfNotPresent(new base::StringValue(type))) {
CallNotifyObserversPropertyChanged(
shill::kAvailableTechnologiesProperty);
}
if (enabled &&
- GetListProperty(shill::kEnabledTechnologiesProperty)->
- AppendIfNotPresent(base::Value::CreateStringValue(type))) {
+ GetListProperty(shill::kEnabledTechnologiesProperty)
+ ->AppendIfNotPresent(new base::StringValue(type))) {
CallNotifyObserversPropertyChanged(
shill::kEnabledTechnologiesProperty);
}
void FakeShillManagerClient::SetTechnologyInitializing(const std::string& type,
bool initializing) {
if (initializing) {
- if (GetListProperty(shill::kUninitializedTechnologiesProperty)->
- AppendIfNotPresent(base::Value::CreateStringValue(type))) {
+ if (GetListProperty(shill::kUninitializedTechnologiesProperty)
+ ->AppendIfNotPresent(new base::StringValue(type))) {
CallNotifyObserversPropertyChanged(
shill::kUninitializedTechnologiesProperty);
}
const std::string& service_path,
bool notify_observers) {
DVLOG(2) << "AddManagerService: " << service_path;
- GetListProperty(shill::kServiceCompleteListProperty)->AppendIfNotPresent(
- base::Value::CreateStringValue(service_path));
+ GetListProperty(shill::kServiceCompleteListProperty)
+ ->AppendIfNotPresent(new base::StringValue(service_path));
SortManagerServices(false);
if (notify_observers)
CallNotifyObserversPropertyChanged(shill::kServiceCompleteListProperty);
void FakeShillManagerClient::SortManagerServices(bool notify) {
DVLOG(1) << "SortManagerServices";
static const char* ordered_types[] = {shill::kTypeEthernet,
+ shill::kTypeEthernetEap,
shill::kTypeWifi,
shill::kTypeCellular,
shill::kTypeWimax,
const bool add_to_visible = true;
- bool enabled;
- std::string state;
-
// IPConfigs
base::DictionaryValue ipconfig_v4_dictionary;
ipconfig_v4_dictionary.SetStringWithoutPathExpansion(
shill::kMethodProperty, shill::kTypeIPv6);
ip_configs->AddIPConfig("ipconfig_v6_path", ipconfig_v6_dictionary);
+ bool enabled;
+ std::string state;
+
// Ethernet
state = GetInitialStateForType(shill::kTypeEthernet, &enabled);
if (state == shill::kStateOnline) {
devices->SetDeviceProperty("/device/eth1",
shill::kIPConfigsProperty,
eth_ip_configs);
- services->AddService(kFakeEthernetNetworkPath, "eth1",
+ const std::string kFakeEthernetNetworkPath = "/service/eth1";
+ services->AddService(kFakeEthernetNetworkPath,
+ kFakeEthernetNetworkGuid,
+ "eth1" /* name */,
shill::kTypeEthernet,
state,
add_to_visible);
shill::kIPConfigsProperty,
wifi_ip_configs);
- services->AddService("/service/wifi1",
- "wifi1",
+ const std::string kWifi1Path = "/service/wifi1";
+ services->AddService(kWifi1Path,
+ "wifi1_guid",
+ "wifi1" /* name */,
shill::kTypeWifi,
state,
add_to_visible);
- services->SetServiceProperty("/service/wifi1",
+ services->SetServiceProperty(kWifi1Path,
shill::kSecurityProperty,
base::StringValue(shill::kSecurityWep));
- profiles->AddService(shared_profile, "/service/wifi1");
+ services->SetServiceProperty(kWifi1Path,
+ shill::kConnectableProperty,
+ base::FundamentalValue(true));
+ profiles->AddService(shared_profile, kWifi1Path);
- services->AddService("/service/wifi2",
- "wifi2_PSK",
+ const std::string kWifi2Path = "/service/wifi2";
+ services->AddService(kWifi2Path,
+ "wifi2_PSK_guid",
+ "wifi2_PSK" /* name */,
shill::kTypeWifi,
shill::kStateIdle,
add_to_visible);
- services->SetServiceProperty("/service/wifi2",
+ services->SetServiceProperty(kWifi2Path,
shill::kSecurityProperty,
base::StringValue(shill::kSecurityPsk));
base::FundamentalValue strength_value(80);
services->SetServiceProperty(
- "/service/wifi2", shill::kSignalStrengthProperty, strength_value);
- profiles->AddService(shared_profile, "/service/wifi2");
+ kWifi2Path, shill::kSignalStrengthProperty, strength_value);
+ profiles->AddService(shared_profile, kWifi2Path);
if (portaled) {
const std::string kPortaledWifiPath = "/service/portaled_wifi";
services->AddService(kPortaledWifiPath,
- "Portaled Wifi",
+ "portaled_wifi_guid",
+ "Portaled Wifi" /* name */,
shill::kTypeWifi,
shill::kStatePortal,
add_to_visible);
"/device/wimax1", shill::kTypeWimax, "stub_wimax_device1");
services->AddService("/service/wimax1",
- "wimax1",
+ "wimax1_guid",
+ "wimax1" /* name */,
shill::kTypeWimax,
state,
add_to_visible);
shill::kCarrierProperty,
base::StringValue(shill::kCarrierSprint));
- services->AddService("/service/cellular1",
- "cellular1",
+ services->AddService(kCellularServicePath,
+ "cellular1_guid",
+ "cellular1" /* name */,
shill::kTypeCellular,
state,
add_to_visible);
base::StringValue technology_value(shill::kNetworkTechnologyGsm);
- services->SetServiceProperty("/service/cellular1",
+ services->SetServiceProperty(kCellularServicePath,
shill::kNetworkTechnologyProperty,
technology_value);
if (activated) {
services->SetServiceProperty(
- "/service/cellular1",
+ kCellularServicePath,
shill::kActivationStateProperty,
base::StringValue(shill::kActivationStateActivated));
- services->SetServiceProperty("/service/cellular1",
+ services->SetServiceProperty(kCellularServicePath,
shill::kConnectableProperty,
base::FundamentalValue(true));
} else {
services->SetServiceProperty(
- "/service/cellular1",
+ kCellularServicePath,
shill::kActivationStateProperty,
base::StringValue(shill::kActivationStateNotActivated));
}
- services->SetServiceProperty("/service/cellular1",
+ services->SetServiceProperty(kCellularServicePath,
shill::kRoamingStateProperty,
base::StringValue(shill::kRoamingStateHome));
}
provider_properties.SetString(shill::kHostProperty, "vpn_host");
services->AddService("/service/vpn1",
- "vpn1",
+ "vpn1_guid",
+ "vpn1" /* name */,
shill::kTypeVPN,
state,
add_to_visible);
profiles->AddService(shared_profile, "/service/vpn1");
services->AddService("/service/vpn2",
- "vpn2",
+ "vpn2_guid",
+ "vpn2" /* name */,
shill::kTypeVPN,
shill::kStateIdle,
add_to_visible);
"/service/vpn2", shill::kProviderProperty, provider_properties);
}
+ // Additional device states
+ for (DevicePropertyMap::iterator iter1 = shill_device_property_map_.begin();
+ iter1 != shill_device_property_map_.end(); ++iter1) {
+ std::string device_type = iter1->first;
+ std::string device_path = devices->GetDevicePathForType(device_type);
+ for (ShillPropertyMap::iterator iter2 = iter1->second.begin();
+ iter2 != iter1->second.end(); ++iter2) {
+ devices->SetDeviceProperty(device_path, iter2->first, *(iter2->second));
+ delete iter2->second;
+ }
+ }
+
SortManagerServices(true);
}
bool FakeShillManagerClient::TechnologyEnabled(const std::string& type) const {
if (type == shill::kTypeVPN)
return true; // VPN is always "enabled" since there is no associated device
+ if (type == shill::kTypeEthernetEap)
+ return true;
bool enabled = false;
const base::ListValue* technologies;
if (stub_properties_.GetListWithoutPathExpansion(
}
void FakeShillManagerClient::ParseCommandLineSwitch() {
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kShillStub)) {
- std::string option_str =
- command_line->GetSwitchValueASCII(switches::kShillStub);
- base::StringPairs string_pairs;
- base::SplitStringIntoKeyValuePairs(option_str, '=', ',', &string_pairs);
- for (base::StringPairs::iterator iter = string_pairs.begin();
- iter != string_pairs.end(); ++iter) {
- ParseOption((*iter).first, (*iter).second);
- }
- return;
- }
// Default setup
SetInitialNetworkState(shill::kTypeEthernet, shill::kStateOnline);
SetInitialNetworkState(shill::kTypeWifi, shill::kStateOnline);
SetInitialNetworkState(shill::kTypeCellular, shill::kStateIdle);
SetInitialNetworkState(shill::kTypeVPN, shill::kStateIdle);
+
+ // Parse additional options
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (!command_line->HasSwitch(switches::kShillStub))
+ return;
+
+ std::string option_str =
+ command_line->GetSwitchValueASCII(switches::kShillStub);
+ VLOG(1) << "Parsing command line:" << option_str;
+ base::StringPairs string_pairs;
+ base::SplitStringIntoKeyValuePairs(option_str, '=', ',', &string_pairs);
+ for (base::StringPairs::iterator iter = string_pairs.begin();
+ iter != string_pairs.end(); ++iter) {
+ ParseOption((*iter).first, (*iter).second);
+ }
}
bool FakeShillManagerClient::ParseOption(const std::string& arg0,
const std::string& arg1) {
- if (arg0 == "interactive") {
+ VLOG(1) << "Parsing command line option: '" << arg0 << "=" << arg1 << "'";
+ if ((arg0 == "clear" || arg0 == "reset") && arg1 == "1") {
+ shill_initial_state_map_.clear();
+ return true;
+ } else if (arg0 == "interactive") {
int seconds = 3;
if (!arg1.empty())
base::StringToInt(arg1, &seconds);
interactive_delay_ = seconds;
return true;
+ } else if (arg0 == "sim_lock") {
+ bool locked = (arg1 == "1") ? true : false;
+ base::DictionaryValue* simlock_dict = new base::DictionaryValue;
+ simlock_dict->Set(shill::kSIMLockEnabledProperty,
+ new base::FundamentalValue(locked));
+ // TODO(stevenjb): Investigate why non-empty value breaks UI.
+ std::string lock_type = ""; // shill::kSIMLockPin
+ simlock_dict->SetString(shill::kSIMLockTypeProperty, lock_type);
+ simlock_dict->SetInteger(shill::kSIMLockRetriesLeftProperty, 5);
+
+ shill_device_property_map_
+ [shill::kTypeCellular][shill::kSIMLockStatusProperty] = simlock_dict;
+ shill_device_property_map_
+ [shill::kTypeCellular][shill::kTechnologyFamilyProperty] =
+ new base::StringValue(shill::kNetworkTechnologyGsm);
+ return true;
}
return SetInitialNetworkState(arg0, arg1);
}
bool FakeShillManagerClient::SetInitialNetworkState(std::string type_arg,
std::string state_arg) {
std::string state;
- state_arg = StringToLowerASCII(state_arg);
+ state_arg = base::StringToLowerASCII(state_arg);
if (state_arg.empty() || state_arg == "1" || state_arg == "on" ||
state_arg == "enabled" || state_arg == "connected" ||
state_arg == "online") {
return false;
}
- type_arg = StringToLowerASCII(type_arg);
+ type_arg = base::StringToLowerASCII(type_arg);
// Special cases
if (type_arg == "wireless") {
shill_initial_state_map_[shill::kTypeWifi] = state;