Index: chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
index b7e6785c71def384fc5ea799185b0f3f816ed159..ee5897df6387f6358e1c8ad000e86e6b8e770676 100644 |
--- a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
+++ b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
@@ -135,7 +135,8 @@ class ExtensionNetworkingPrivateApiTest |
public: |
ExtensionNetworkingPrivateApiTest() |
#if defined(OS_CHROMEOS) |
- : detector_(NULL) |
+ : detector_(NULL), |
+ service_test_(NULL) |
#endif |
{ |
} |
@@ -158,8 +159,8 @@ class ExtensionNetworkingPrivateApiTest |
#if defined(OS_CHROMEOS) |
static void AssignString(std::string* out, |
- DBusMethodCallStatus call_status, |
- const std::string& result) { |
+ DBusMethodCallStatus call_status, |
+ const std::string& result) { |
CHECK_EQ(call_status, DBUS_METHOD_CALL_SUCCESS); |
*out = result; |
} |
@@ -195,6 +196,19 @@ class ExtensionNetworkingPrivateApiTest |
CHECK(!userhash_.empty()); |
} |
+ void AddService(const std::string& service_path, |
+ const std::string& name, |
+ const std::string& type, |
+ const std::string& state) { |
+ const bool add_to_watchlist = true; |
+ const bool add_to_visible = true; |
+ // Tests need a known GUID, so use 'service_path'. |
+ service_test_->AddServiceWithIPConfig( |
+ service_path, service_path /* guid */, name, |
+ type, state, "" /* ipconfig_path */, |
+ add_to_visible, add_to_watchlist); |
+ } |
+ |
virtual void SetUpOnMainThread() OVERRIDE { |
detector_ = new NetworkPortalDetectorTestImpl(); |
NetworkPortalDetector::InitializeForTesting(detector_); |
@@ -213,11 +227,11 @@ class ExtensionNetworkingPrivateApiTest |
dbus_manager->GetShillDeviceClient()->GetTestInterface(); |
ShillProfileClient::TestInterface* profile_test = |
dbus_manager->GetShillProfileClient()->GetTestInterface(); |
- ShillServiceClient::TestInterface* service_test = |
- dbus_manager->GetShillServiceClient()->GetTestInterface(); |
+ |
+ service_test_ = dbus_manager->GetShillServiceClient()->GetTestInterface(); |
device_test->ClearDevices(); |
- service_test->ClearServices(); |
+ service_test_->ClearServices(); |
// Sends a notification about the added profile. |
profile_test->AddProfile(kUser1ProfilePath, userhash_); |
@@ -242,93 +256,82 @@ class ExtensionNetworkingPrivateApiTest |
kCellularDevicePath, shill::kTypeCellular, "stub_cellular_device1"); |
// Add Services |
- const bool add_to_watchlist = true; |
- const bool add_to_visible = true; |
- service_test->AddService("stub_ethernet", "eth0", |
- shill::kTypeEthernet, shill::kStateOnline, |
- add_to_visible, add_to_watchlist); |
- service_test->SetServiceProperty( |
+ AddService("stub_ethernet", "eth0", |
+ shill::kTypeEthernet, shill::kStateOnline); |
+ service_test_->SetServiceProperty( |
"stub_ethernet", |
shill::kProfileProperty, |
base::StringValue(ShillProfileClient::GetSharedProfilePath())); |
profile_test->AddService(ShillProfileClient::GetSharedProfilePath(), |
"stub_ethernet"); |
- service_test->AddService("stub_wifi1", "wifi1", |
- shill::kTypeWifi, shill::kStateOnline, |
- add_to_visible, add_to_watchlist); |
- service_test->SetServiceProperty("stub_wifi1", |
- shill::kSecurityProperty, |
- base::StringValue(shill::kSecurityWep)); |
- service_test->SetServiceProperty("stub_wifi1", |
- shill::kProfileProperty, |
- base::StringValue(kUser1ProfilePath)); |
- service_test->SetServiceProperty("stub_wifi1", |
- shill::kConnectableProperty, |
- base::FundamentalValue(true)); |
- service_test->SetServiceProperty("stub_wifi1", |
- shill::kDeviceProperty, |
- base::StringValue(kWifiDevicePath)); |
+ AddService("stub_wifi1", "wifi1", shill::kTypeWifi, shill::kStateOnline); |
+ service_test_->SetServiceProperty("stub_wifi1", |
+ shill::kSecurityProperty, |
+ base::StringValue(shill::kSecurityWep)); |
+ service_test_->SetServiceProperty("stub_wifi1", |
+ shill::kProfileProperty, |
+ base::StringValue(kUser1ProfilePath)); |
+ service_test_->SetServiceProperty("stub_wifi1", |
+ shill::kConnectableProperty, |
+ base::FundamentalValue(true)); |
+ service_test_->SetServiceProperty("stub_wifi1", |
+ shill::kDeviceProperty, |
+ base::StringValue(kWifiDevicePath)); |
profile_test->AddService(kUser1ProfilePath, "stub_wifi1"); |
base::ListValue frequencies1; |
frequencies1.AppendInteger(2400); |
- service_test->SetServiceProperty("stub_wifi1", |
- shill::kWifiFrequencyListProperty, |
- frequencies1); |
- service_test->SetServiceProperty("stub_wifi1", |
- shill::kWifiFrequency, |
- base::FundamentalValue(2400)); |
- |
- service_test->AddService("stub_wifi2", "wifi2_PSK", |
- shill::kTypeWifi, shill::kStateIdle, |
- add_to_visible, add_to_watchlist); |
- service_test->SetServiceProperty("stub_wifi2", |
- shill::kGuidProperty, |
- base::StringValue("stub_wifi2")); |
- service_test->SetServiceProperty("stub_wifi2", |
- shill::kSecurityProperty, |
- base::StringValue(shill::kSecurityPsk)); |
- service_test->SetServiceProperty("stub_wifi2", |
- shill::kSignalStrengthProperty, |
- base::FundamentalValue(80)); |
- service_test->SetServiceProperty("stub_wifi2", |
- shill::kConnectableProperty, |
- base::FundamentalValue(true)); |
+ service_test_->SetServiceProperty("stub_wifi1", |
+ shill::kWifiFrequencyListProperty, |
+ frequencies1); |
+ service_test_->SetServiceProperty("stub_wifi1", |
+ shill::kWifiFrequency, |
+ base::FundamentalValue(2400)); |
+ |
+ AddService("stub_wifi2", "wifi2_PSK", shill::kTypeWifi, shill::kStateIdle); |
+ service_test_->SetServiceProperty("stub_wifi2", |
+ shill::kGuidProperty, |
+ base::StringValue("stub_wifi2")); |
+ service_test_->SetServiceProperty("stub_wifi2", |
+ shill::kSecurityProperty, |
+ base::StringValue(shill::kSecurityPsk)); |
+ service_test_->SetServiceProperty("stub_wifi2", |
+ shill::kSignalStrengthProperty, |
+ base::FundamentalValue(80)); |
+ service_test_->SetServiceProperty("stub_wifi2", |
+ shill::kConnectableProperty, |
+ base::FundamentalValue(true)); |
base::ListValue frequencies2; |
frequencies2.AppendInteger(2400); |
frequencies2.AppendInteger(5000); |
- service_test->SetServiceProperty("stub_wifi2", |
- shill::kWifiFrequencyListProperty, |
- frequencies2); |
- service_test->SetServiceProperty("stub_wifi2", |
- shill::kWifiFrequency, |
- base::FundamentalValue(5000)); |
- service_test->SetServiceProperty("stub_wifi2", |
- shill::kProfileProperty, |
- base::StringValue(kUser1ProfilePath)); |
+ service_test_->SetServiceProperty("stub_wifi2", |
+ shill::kWifiFrequencyListProperty, |
+ frequencies2); |
+ service_test_->SetServiceProperty("stub_wifi2", |
+ shill::kWifiFrequency, |
+ base::FundamentalValue(5000)); |
+ service_test_->SetServiceProperty("stub_wifi2", |
+ shill::kProfileProperty, |
+ base::StringValue(kUser1ProfilePath)); |
profile_test->AddService(kUser1ProfilePath, "stub_wifi2"); |
- service_test->AddService("stub_cellular1", "cellular1", |
- shill::kTypeCellular, shill::kStateIdle, |
- add_to_visible, add_to_watchlist); |
- service_test->SetServiceProperty( |
+ AddService("stub_cellular1", "cellular1", |
+ shill::kTypeCellular, shill::kStateIdle); |
+ service_test_->SetServiceProperty( |
"stub_cellular1", |
shill::kNetworkTechnologyProperty, |
base::StringValue(shill::kNetworkTechnologyGsm)); |
- service_test->SetServiceProperty( |
+ service_test_->SetServiceProperty( |
"stub_cellular1", |
shill::kActivationStateProperty, |
base::StringValue(shill::kActivationStateNotActivated)); |
- service_test->SetServiceProperty( |
+ service_test_->SetServiceProperty( |
"stub_cellular1", |
shill::kRoamingStateProperty, |
base::StringValue(shill::kRoamingStateHome)); |
- service_test->AddService("stub_vpn1", "vpn1", |
- shill::kTypeVPN, |
- shill::kStateOnline, |
- add_to_visible, add_to_watchlist); |
+ AddService("stub_vpn1", "vpn1", shill::kTypeVPN, shill::kStateOnline); |
manager_test->SortManagerServices(); |
@@ -364,6 +367,7 @@ class ExtensionNetworkingPrivateApiTest |
NetworkPortalDetectorTestImpl* detector() { return detector_; } |
NetworkPortalDetectorTestImpl* detector_; |
+ ShillServiceClient::TestInterface* service_test_; |
policy::MockConfigurationPolicyProvider provider_; |
std::string userhash_; |
#endif |
@@ -436,20 +440,18 @@ IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, |
GetManagedProperties) { |
#if defined(OS_CHROMEOS) |
// TODO(mef): Move this to ChromeOS-specific helper or SetUpOnMainThread. |
- ShillServiceClient::TestInterface* service_test = |
- DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
const std::string uidata_blob = |
"{ \"user_settings\": {" |
" \"WiFi\": {" |
" \"Passphrase\": \"FAKE_CREDENTIAL_VPaJDV9x\" }" |
" }" |
"}"; |
- service_test->SetServiceProperty("stub_wifi2", |
- shill::kUIDataProperty, |
- base::StringValue(uidata_blob)); |
- service_test->SetServiceProperty("stub_wifi2", |
- shill::kAutoConnectProperty, |
- base::FundamentalValue(false)); |
+ service_test_->SetServiceProperty("stub_wifi2", |
+ shill::kUIDataProperty, |
+ base::StringValue(uidata_blob)); |
+ service_test_->SetServiceProperty("stub_wifi2", |
+ shill::kAutoConnectProperty, |
+ base::FundamentalValue(false)); |
ShillProfileClient::TestInterface* profile_test = |
DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); |