Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1999)

Unified Diff: chrome/browser/chromeos/cros/cros_network_functions_unittest.cc

Issue 10949030: This converts the Shill clients to allow propagation of shill errors (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 f092a57fad7b46198abe9189da14a1ab36fc3432..ce04d7e6a67ca2d0f605606bef09c77f665d047d 100644
--- a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc
+++ b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc
@@ -192,12 +192,22 @@ class CrosNetworkFunctionsTest : public testing::Test {
callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_);
}
+ // Handles responses for GetProperties method calls that return
+ // errors in an error callback.
+ void OnGetPropertiesWithoutStatus(
+ const dbus::ObjectPath& path,
+ const ShillClientHelper::DictionaryValueCallbackWithoutStatus& callback,
+ const ShillClientHelper::ErrorCallback& error_callback) {
+ callback.Run(*dictionary_value_result_);
+ }
+
// Handles responses for GetEntry method calls.
void OnGetEntry(
const dbus::ObjectPath& profile_path,
const std::string& entry_path,
- const ShillClientHelper::DictionaryValueCallback& callback) {
- callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_);
+ const ShillClientHelper::DictionaryValueCallbackWithoutStatus& callback,
+ const ShillClientHelper::ErrorCallback& error_callback) {
+ callback.Run(*dictionary_value_result_);
}
// Mock NetworkOperationCallback.
@@ -244,7 +254,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkServiceProperty) {
value.SetString(key2, string2);
EXPECT_CALL(*mock_service_client_,
SetProperty(dbus::ObjectPath(service_path), property,
- IsEqualTo(&value), _)).Times(1);
+ IsEqualTo(&value), _, _)).Times(1);
CrosSetNetworkServiceProperty(service_path, property, value);
}
@@ -253,7 +263,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosClearNetworkServiceProperty) {
const std::string service_path = "/";
const std::string property = "property";
EXPECT_CALL(*mock_service_client_,
- ClearProperty(dbus::ObjectPath(service_path), property, _))
+ ClearProperty(dbus::ObjectPath(service_path), property, _, _))
.Times(1);
CrosClearNetworkServiceProperty(service_path, property);
@@ -266,7 +276,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkDeviceProperty) {
const base::FundamentalValue value(kBool);
EXPECT_CALL(*mock_device_client_,
SetProperty(dbus::ObjectPath(device_path), StrEq(property),
- IsEqualTo(&value), _)).Times(1);
+ IsEqualTo(&value), _, _)).Times(1);
CrosSetNetworkDeviceProperty(device_path, property, value);
}
@@ -286,7 +296,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkManagerProperty) {
const std::string property = "property";
const base::StringValue value("string");
EXPECT_CALL(*mock_manager_client_,
- SetProperty(property, IsEqualTo(&value), _)).Times(1);
+ SetProperty(property, IsEqualTo(&value), _, _)).Times(1);
CrosSetNetworkManagerProperty(property, value);
}
@@ -295,7 +305,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosDeleteServiceFromProfile) {
const std::string profile_path("/profile/path");
const std::string service_path("/service/path");
EXPECT_CALL(*mock_profile_client_,
- DeleteEntry(dbus::ObjectPath(profile_path), service_path, _))
+ DeleteEntry(dbus::ObjectPath(profile_path), service_path, _, _))
.Times(1);
CrosDeleteServiceFromProfile(profile_path, service_path);
}
@@ -311,17 +321,19 @@ TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkManagerProperties) {
const std::string key = "key";
const int kValue = 42;
const base::FundamentalValue value(kValue);
+
// Start monitoring.
- ShillClientHelper::PropertyChangedHandler handler;
- EXPECT_CALL(*mock_manager_client_, SetPropertyChangedHandler(_))
- .WillOnce(SaveArg<0>(&handler));
+ ShillClientHelper::PropertyChangedObserver* observer;
hashimoto 2012/09/21 11:52:01 Please initialize with NULL.
Greg Spencer (Chromium) 2012/09/21 22:03:47 Done, and the ones below.
+ EXPECT_CALL(*mock_manager_client_, AddPropertyChangedObserver(_))
+ .WillOnce(SaveArg<0>(&observer));
CrosNetworkWatcher* watcher = CrosMonitorNetworkManagerProperties(
MockNetworkPropertiesWatcherCallback::CreateCallback(
flimflam::kFlimflamServicePath, key, value));
// Call callback.
- handler.Run(key, value);
+ observer->OnPropertyChanged(key, value);
// Stop monitoring.
- EXPECT_CALL(*mock_manager_client_, ResetPropertyChangedHandler()).Times(1);
+ EXPECT_CALL(*mock_manager_client_,
+ RemovePropertyChangedObserver(_)).Times(1);
delete watcher;
}
@@ -331,19 +343,19 @@ TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkServiceProperties) {
const int kValue = 42;
const base::FundamentalValue value(kValue);
// Start monitoring.
- ShillClientHelper::PropertyChangedHandler handler;
- EXPECT_CALL(*mock_service_client_, SetPropertyChangedHandler(path, _))
- .WillOnce(SaveArg<1>(&handler));
+ ShillClientHelper::PropertyChangedObserver* observer;
hashimoto 2012/09/21 11:52:01 ditto.
+ EXPECT_CALL(*mock_service_client_, AddPropertyChangedObserver(path, _))
+ .WillOnce(SaveArg<1>(&observer));
NetworkPropertiesWatcherCallback callback =
MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(),
key, value);
CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties(
callback, path.value());
// Call callback.
- handler.Run(key, value);
+ observer->OnPropertyChanged(key, value);
// Stop monitoring.
EXPECT_CALL(*mock_service_client_,
- ResetPropertyChangedHandler(path)).Times(1);
+ RemovePropertyChangedObserver(path, _)).Times(1);
delete watcher;
}
@@ -353,19 +365,19 @@ TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkDeviceProperties) {
const int kValue = 42;
const base::FundamentalValue value(kValue);
// Start monitoring.
- ShillClientHelper::PropertyChangedHandler handler;
- EXPECT_CALL(*mock_device_client_, SetPropertyChangedHandler(path, _))
- .WillOnce(SaveArg<1>(&handler));
+ ShillClientHelper::PropertyChangedObserver* observer;
hashimoto 2012/09/21 11:52:01 ditto.
+ EXPECT_CALL(*mock_device_client_, AddPropertyChangedObserver(path, _))
+ .WillOnce(SaveArg<1>(&observer));
NetworkPropertiesWatcherCallback callback =
MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(),
key, value);
CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties(
callback, path.value());
// Call callback.
- handler.Run(key, value);
+ observer->OnPropertyChanged(key, value);
// Stop monitoring.
EXPECT_CALL(*mock_device_client_,
- ResetPropertyChangedHandler(path)).Times(1);
+ RemovePropertyChangedObserver(path, _)).Times(1);
delete watcher;
}
@@ -619,9 +631,11 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileProperties) {
result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
// Set expectations.
dictionary_value_result_ = &result;
- EXPECT_CALL(*mock_profile_client_,
- GetProperties(dbus::ObjectPath(profile_path), _)).WillOnce(
- Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties));
+ EXPECT_CALL(
+ *mock_profile_client_,
+ GetProperties(dbus::ObjectPath(profile_path), _, _)).WillOnce(
+ Invoke(this,
+ &CrosNetworkFunctionsTest::OnGetPropertiesWithoutStatus));
CrosRequestNetworkProfileProperties(
profile_path,
@@ -642,7 +656,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) {
// Set expectations.
dictionary_value_result_ = &result;
EXPECT_CALL(*mock_profile_client_,
- GetEntry(dbus::ObjectPath(profile_path), profile_entry_path, _))
+ GetEntry(dbus::ObjectPath(profile_path),
+ profile_entry_path, _, _))
.WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry));
CrosRequestNetworkProfileEntryProperties(
@@ -680,7 +695,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestHiddenWifiNetworkProperties) {
// Set expectations.
const dbus::ObjectPath service_path("/service/path");
ObjectPathDBusMethodCallback callback;
- EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _))
+ EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _))
.WillOnce(SaveArg<1>(&callback));
EXPECT_CALL(*mock_service_client_,
GetProperties(service_path, _)).WillOnce(
@@ -728,7 +743,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestVirtualNetworkProperties) {
// Set expectations.
const dbus::ObjectPath service_path("/service/path");
ObjectPathDBusMethodCallback callback;
- EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _))
+ EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _))
.WillOnce(SaveArg<1>(&callback));
EXPECT_CALL(*mock_service_client_,
GetProperties(service_path, _)).WillOnce(
@@ -746,32 +761,32 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestVirtualNetworkProperties) {
TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) {
const std::string service_path = "/service/path";
EXPECT_CALL(*mock_service_client_,
- Disconnect(dbus::ObjectPath(service_path), _)).Times(1);
+ Disconnect(dbus::ObjectPath(service_path), _, _)).Times(1);
CrosRequestNetworkServiceDisconnect(service_path);
}
TEST_F(CrosNetworkFunctionsTest, CrosRequestRemoveNetworkService) {
const std::string service_path = "/service/path";
EXPECT_CALL(*mock_service_client_,
- Remove(dbus::ObjectPath(service_path), _)).Times(1);
+ Remove(dbus::ObjectPath(service_path), _, _)).Times(1);
CrosRequestRemoveNetworkService(service_path);
}
TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkScan) {
EXPECT_CALL(*mock_manager_client_,
- RequestScan(flimflam::kTypeWifi, _)).Times(1);
+ RequestScan(flimflam::kTypeWifi, _, _)).Times(1);
CrosRequestNetworkScan(flimflam::kTypeWifi);
}
TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceEnable) {
const bool kEnable = true;
EXPECT_CALL(*mock_manager_client_,
- EnableTechnology(flimflam::kTypeWifi, _)).Times(1);
+ EnableTechnology(flimflam::kTypeWifi, _, _)).Times(1);
CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable);
const bool kDisable = false;
EXPECT_CALL(*mock_manager_client_,
- DisableTechnology(flimflam::kTypeWifi, _)).Times(1);
+ DisableTechnology(flimflam::kTypeWifi, _, _)).Times(1);
CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kDisable);
}
@@ -882,7 +897,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosSetOfflineMode) {
const bool kOffline = true;
const base::FundamentalValue value(kOffline);
EXPECT_CALL(*mock_manager_client_, SetProperty(
- flimflam::kOfflineModeProperty, IsEqualTo(&value), _)).Times(1);
+ flimflam::kOfflineModeProperty, IsEqualTo(&value), _, _)).Times(1);
CrosSetOfflineMode(kOffline);
}
@@ -1059,7 +1074,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosConfigureService) {
base::DictionaryValue value;
value.SetString(key1, string1);
value.SetString(key2, string2);
- EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _))
+ EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _, _))
.Times(1);
CrosConfigureService(value);
}

Powered by Google App Engine
This is Rietveld 408576698