Index: chrome/browser/chromeos/cros/cros_network_functions_unittest.cc |
diff --git a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc |
index 6dc13afa8eec23088a9f8013d2dde9f7656b4ef8..d52aa19e10c0cabdb6d4d8769d25b4b76c3d7f50 100644 |
--- a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc |
+++ b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc |
@@ -38,20 +38,20 @@ class MockNetworkPropertiesCallback { |
public: |
// Creates a NetworkPropertiesCallback with expectations. |
static NetworkPropertiesCallback CreateCallback( |
- const char* expected_path, |
+ const std::string& expected_path, |
const base::DictionaryValue& expected_result) { |
MockNetworkPropertiesCallback* mock_callback = |
new MockNetworkPropertiesCallback; |
EXPECT_CALL(*mock_callback, |
- Run(StrEq(expected_path), Pointee(IsEqualTo(&expected_result)))) |
+ Run(expected_path, Pointee(IsEqualTo(&expected_result)))) |
.Times(1); |
return base::Bind(&MockNetworkPropertiesCallback::Run, |
base::Owned(mock_callback)); |
} |
- MOCK_METHOD2(Run, void(const char* path, |
+ MOCK_METHOD2(Run, void(const std::string& path, |
const base::DictionaryValue* result)); |
}; |
@@ -188,7 +188,7 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkServiceProperty) { |
const char property[] = "property"; |
EXPECT_CALL( |
*MockChromeOSNetwork::Get(), |
- SetNetworkServicePropertyGValue(service_path, property, _)) |
+ SetNetworkServicePropertyGValue(StrEq(service_path), StrEq(property), _)) |
.WillOnce(Invoke( |
this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); |
const char key1[] = "key1"; |
@@ -214,7 +214,8 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosClearNetworkServiceProperty) { |
const char service_path[] = "/"; |
const char property[] = "property"; |
stevenjb
2012/04/20 17:18:28
Shouldn't we use std::string here and elsewhere?
hashimoto
2012/04/22 05:44:50
Sounds good.
Done.
|
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
- ClearNetworkServiceProperty(service_path, property)).Times(1); |
+ ClearNetworkServiceProperty(StrEq(service_path), |
+ StrEq(property))).Times(1); |
CrosClearNetworkServiceProperty(service_path, property); |
} |
@@ -223,7 +224,7 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkDeviceProperty) { |
const char property[] = "property"; |
EXPECT_CALL( |
*MockChromeOSNetwork::Get(), |
- SetNetworkDevicePropertyGValue(device_path, property, _)) |
+ SetNetworkDevicePropertyGValue(StrEq(device_path), StrEq(property), _)) |
.WillOnce(Invoke( |
this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); |
const bool kBool = true; |
@@ -237,7 +238,8 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkIPConfigProperty) { |
const char property[] = "property"; |
EXPECT_CALL( |
*MockChromeOSNetwork::Get(), |
- SetNetworkIPConfigPropertyGValue(ipconfig_path, property, _)) |
+ SetNetworkIPConfigPropertyGValue(StrEq(ipconfig_path), |
+ StrEq(property), _)) |
.WillOnce(Invoke( |
this, &CrosNetworkFunctionsLibcrosTest::OnSetNetworkPropertyGValue)); |
const int kInt = 1234; |
@@ -250,7 +252,7 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkManagerProperty) { |
const char property[] = "property"; |
EXPECT_CALL( |
*MockChromeOSNetwork::Get(), |
- SetNetworkManagerPropertyGValue(property, _)) |
+ SetNetworkManagerPropertyGValue(StrEq(property), _)) |
.WillOnce(Invoke( |
this, |
&CrosNetworkFunctionsLibcrosTest::OnSetNetworkManagerPropertyGValue)); |
@@ -263,7 +265,7 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetNetworkManagerProperty) { |
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestCellularDataPlanUpdate) { |
const char kModemServicePath[] = "/modem/service/path"; |
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
- RequestCellularDataPlanUpdate(kModemServicePath)).Times(1); |
+ RequestCellularDataPlanUpdate(StrEq(kModemServicePath))).Times(1); |
CrosRequestCellularDataPlanUpdate(kModemServicePath); |
} |
@@ -302,7 +304,7 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkServiceProperties) { |
// Start monitoring. |
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
- MonitorNetworkServiceProperties(_, path.c_str(), _)) |
+ MonitorNetworkServiceProperties(_, StrEq(path.c_str()), _)) |
stevenjb
2012/04/20 17:18:28
Do we need to use StrEq and .c_str() here and else
hashimoto
2012/04/22 05:44:50
I didn't know that StrEq can take a std::string as
|
.WillOnce(Invoke( |
this, |
&CrosNetworkFunctionsLibcrosTest::OnMonitorNetworkProperties)); |
@@ -330,7 +332,7 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkDeviceProperties) { |
// Start monitoring. |
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
- MonitorNetworkDeviceProperties(_, path.c_str(), _)) |
+ MonitorNetworkDeviceProperties(_, StrEq(path.c_str()), _)) |
.WillOnce(Invoke( |
this, |
&CrosNetworkFunctionsLibcrosTest::OnMonitorNetworkProperties)); |
@@ -374,7 +376,8 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorSMS) { |
// Start monitoring. |
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
- MonitorSMS(modem_device_path.c_str(), callback, object)).Times(1); |
+ MonitorSMS(StrEq(modem_device_path.c_str()), callback, object)) |
+ .Times(1); |
CrosNetworkWatcher* watcher = CrosMonitorSMS( |
modem_device_path, callback, object); |
@@ -421,12 +424,12 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkServiceProperties) { |
// Set expectations. |
EXPECT_CALL( |
*MockChromeOSNetwork::Get(), |
- RequestNetworkServiceProperties(service_path.c_str(), _, _)) |
+ RequestNetworkServiceProperties(StrEq(service_path.c_str()), _, _)) |
.WillOnce(Invoke( |
this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); |
CrosRequestNetworkServiceProperties( |
- service_path.c_str(), |
+ service_path, |
MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
} |
@@ -445,12 +448,12 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceProperties) { |
// Set expectations. |
EXPECT_CALL( |
*MockChromeOSNetwork::Get(), |
- RequestNetworkDeviceProperties(device_path.c_str(), _, _)) |
+ RequestNetworkDeviceProperties(StrEq(device_path.c_str()), _, _)) |
.WillOnce(Invoke( |
this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); |
CrosRequestNetworkDeviceProperties( |
- device_path.c_str(), |
+ device_path, |
MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
} |
@@ -469,12 +472,12 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkProfileProperties) { |
// Set expectations. |
EXPECT_CALL( |
*MockChromeOSNetwork::Get(), |
- RequestNetworkProfileProperties(profile_path.c_str(), _, _)) |
+ RequestNetworkProfileProperties(StrEq(profile_path.c_str()), _, _)) |
.WillOnce(Invoke( |
this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties3)); |
CrosRequestNetworkProfileProperties( |
- profile_path.c_str(), |
+ profile_path, |
MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
} |
@@ -495,14 +498,14 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, |
// Set expectations. |
EXPECT_CALL( |
*MockChromeOSNetwork::Get(), |
- RequestNetworkProfileEntryProperties(profile_path.c_str(), |
- profile_entry_path.c_str(), _, _)) |
+ RequestNetworkProfileEntryProperties( |
+ StrEq(profile_path.c_str()), StrEq(profile_entry_path.c_str()), _, _)) |
.WillOnce(Invoke( |
this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties4)); |
CrosRequestNetworkProfileEntryProperties( |
- profile_path.c_str(), |
- profile_entry_path.c_str(), |
+ profile_path, |
+ profile_entry_path, |
MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
} |
@@ -523,12 +526,13 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, |
// Set expectations. |
EXPECT_CALL( |
*MockChromeOSNetwork::Get(), |
- RequestHiddenWifiNetworkProperties(ssid.c_str(), security.c_str(), _, _)) |
+ RequestHiddenWifiNetworkProperties( |
+ StrEq(ssid.c_str()), StrEq(security.c_str()), _, _)) |
.WillOnce(Invoke( |
this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties4)); |
CrosRequestHiddenWifiNetworkProperties( |
- ssid.c_str(), security.c_str(), |
+ ssid, security, |
MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
} |
@@ -548,43 +552,43 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestVirtualNetworkProperties) { |
ConvertDictionaryValueToStringValueGHashTable(result)); |
// Set expectations. |
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
- RequestVirtualNetworkProperties(service_name.c_str(), |
- server_hostname.c_str(), |
- provider_name.c_str(), _, _)) |
+ RequestVirtualNetworkProperties( |
+ StrEq(service_name.c_str()), StrEq(server_hostname.c_str()), |
+ StrEq(provider_name.c_str()), _, _)) |
.WillOnce(Invoke( |
this, &CrosNetworkFunctionsLibcrosTest::OnRequestNetworkProperties5)); |
CrosRequestVirtualNetworkProperties( |
- service_name.c_str(), |
- server_hostname.c_str(), |
- provider_name.c_str(), |
+ service_name, |
+ server_hostname, |
+ provider_name, |
MockNetworkPropertiesCallback::CreateCallback(kExamplePath, result)); |
} |
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkServiceDisconnect) { |
const char kServicePath[] = "/service/path"; |
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
- RequestNetworkServiceDisconnect(kServicePath)).Times(1); |
+ RequestNetworkServiceDisconnect(StrEq(kServicePath))).Times(1); |
CrosRequestNetworkServiceDisconnect(kServicePath); |
} |
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestRemoveNetworkService) { |
const char kServicePath[] = "/service/path"; |
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
- RequestRemoveNetworkService(kServicePath)).Times(1); |
+ RequestRemoveNetworkService(StrEq(kServicePath))).Times(1); |
CrosRequestRemoveNetworkService(kServicePath); |
} |
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkScan) { |
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
- RequestNetworkScan(flimflam::kTypeWifi)).Times(1); |
+ RequestNetworkScan(StrEq(flimflam::kTypeWifi))).Times(1); |
CrosRequestNetworkScan(flimflam::kTypeWifi); |
} |
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceEnable) { |
const bool kEnable = true; |
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
- RequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable)) |
+ RequestNetworkDeviceEnable(StrEq(flimflam::kTypeWifi), kEnable)) |
.Times(1); |
CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); |
} |
@@ -592,7 +596,7 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceEnable) { |
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosConfigureService) { |
const char identifier[] = "identifier"; |
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
- ConfigureService(identifier, _, &OnNetworkAction, this)) |
+ ConfigureService(StrEq(identifier), _, &OnNetworkAction, this)) |
.WillOnce(Invoke( |
this, &CrosNetworkFunctionsLibcrosTest::OnConfigureService)); |
const char key1[] = "key1"; |
@@ -702,7 +706,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkDeviceProperty) { |
const bool kBool = true; |
const base::FundamentalValue value(kBool); |
EXPECT_CALL(*mock_device_client_, |
- SetProperty(dbus::ObjectPath(device_path), property, |
+ SetProperty(dbus::ObjectPath(device_path), StrEq(property), |
IsEqualTo(&value), _)).Times(1); |
CrosSetNetworkDeviceProperty(device_path, property, value); |
@@ -724,7 +728,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosDeleteServiceFromProfile) { |
EXPECT_CALL(*mock_profile_client_, |
DeleteEntry(dbus::ObjectPath(profile_path), service_path, _)) |
.Times(1); |
- CrosDeleteServiceFromProfile(profile_path.c_str(), service_path.c_str()); |
+ CrosDeleteServiceFromProfile(profile_path, service_path); |
} |
TEST_F(CrosNetworkFunctionsTest, CrosRequestCellularDataPlanUpdate) { |
@@ -762,10 +766,10 @@ TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkServiceProperties) { |
EXPECT_CALL(*mock_service_client_, SetPropertyChangedHandler(path, _)) |
.WillOnce(SaveArg<1>(&handler)); |
NetworkPropertiesWatcherCallback callback = |
- MockNetworkPropertiesWatcherCallback::CreateCallback(path.value().c_str(), |
+ MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(), |
key, value); |
CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties( |
- callback, path.value().c_str()); |
+ callback, path.value()); |
// Call callback. |
handler.Run(key, value); |
// Stop monitoring. |
@@ -784,10 +788,10 @@ TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkDeviceProperties) { |
EXPECT_CALL(*mock_device_client_, SetPropertyChangedHandler(path, _)) |
.WillOnce(SaveArg<1>(&handler)); |
NetworkPropertiesWatcherCallback callback = |
- MockNetworkPropertiesWatcherCallback::CreateCallback(path.value().c_str(), |
+ MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(), |
key, value); |
CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties( |
- callback, path.value().c_str()); |
+ callback, path.value()); |
// Call callback. |
handler.Run(key, value); |
// Stop monitoring. |
@@ -834,9 +838,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceProperties) { |
Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); |
CrosRequestNetworkServiceProperties( |
- service_path.c_str(), |
- MockNetworkPropertiesCallback::CreateCallback(service_path.c_str(), |
- result)); |
+ service_path, |
+ MockNetworkPropertiesCallback::CreateCallback(service_path, result)); |
} |
TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceProperties) { |
@@ -856,9 +859,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceProperties) { |
Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); |
CrosRequestNetworkDeviceProperties( |
- device_path.c_str(), |
- MockNetworkPropertiesCallback::CreateCallback(device_path.c_str(), |
- result)); |
+ device_path, |
+ MockNetworkPropertiesCallback::CreateCallback(device_path, result)); |
} |
TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileProperties) { |
@@ -878,9 +880,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileProperties) { |
Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); |
CrosRequestNetworkProfileProperties( |
- profile_path.c_str(), |
- MockNetworkPropertiesCallback::CreateCallback(profile_path.c_str(), |
- result)); |
+ profile_path, |
+ MockNetworkPropertiesCallback::CreateCallback(profile_path, result)); |
} |
TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { |
@@ -901,8 +902,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { |
.WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry)); |
CrosRequestNetworkProfileEntryProperties( |
- profile_path.c_str(), profile_entry_path.c_str(), |
- MockNetworkPropertiesCallback::CreateCallback(profile_entry_path.c_str(), |
+ profile_path, profile_entry_path, |
+ MockNetworkPropertiesCallback::CreateCallback(profile_entry_path, |
result)); |
} |