Index: chromeos/dbus/shill_manager_client_unittest.cc |
diff --git a/chromeos/dbus/shill_manager_client_unittest.cc b/chromeos/dbus/shill_manager_client_unittest.cc |
index 9d37aecf76125618cf02f66edef3fbba2c9b65a7..6f44b7ce6d4048690c95ba97ca6be19a4eb410cd 100644 |
--- a/chromeos/dbus/shill_manager_client_unittest.cc |
+++ b/chromeos/dbus/shill_manager_client_unittest.cc |
@@ -12,6 +12,9 @@ |
#include "testing/gtest/include/gtest/gtest.h" |
#include "third_party/cros_system_api/dbus/service_constants.h" |
+using testing::_; |
+using testing::ByRef; |
+ |
namespace chromeos { |
namespace { |
@@ -131,14 +134,25 @@ TEST_F(ShillManagerClientTest, PropertyChanged) { |
dbus::AppendBasicTypeValueData(&writer, kOfflineMode); |
// Set expectations. |
- client_->SetPropertyChangedHandler(base::Bind(&ExpectPropertyChanged, |
- flimflam::kOfflineModeProperty, |
- &kOfflineMode)); |
+ MockPropertyChangeObserver observer; |
+ EXPECT_CALL(observer, |
+ OnPropertyChanged(flimflam::kOfflineModeProperty, |
+ ValueEq(ByRef(kOfflineMode)))).Times(1); |
+ |
+ // Add the observer |
+ client_->AddPropertyChangedObserver(&observer); |
+ |
// Run the signal callback. |
SendPropertyChangedSignal(&signal); |
- // Reset the handler. |
- client_->ResetPropertyChangedHandler(); |
+ // Remove the observer. |
+ client_->RemovePropertyChangedObserver(&observer); |
+ |
+ // Make sure it's not called anymore. |
+ EXPECT_CALL(observer, OnPropertyChanged(_, _)).Times(0); |
+ |
+ // Run the signal callback again and make sure the observer isn't called. |
+ SendPropertyChangedSignal(&signal); |
} |
TEST_F(ShillManagerClientTest, GetProperties) { |
@@ -207,9 +221,15 @@ TEST_F(ShillManagerClientTest, SetProperty) { |
&value), |
response.get()); |
// Call method. |
+ MockClosure mock_closure; |
+ MockErrorCallback mock_error_callback; |
client_->SetProperty(flimflam::kCheckPortalListProperty, |
value, |
- base::Bind(&ExpectNoResultValue)); |
+ mock_closure.GetCallback(), |
+ mock_error_callback.GetCallback()); |
+ EXPECT_CALL(mock_closure, Run()).Times(1); |
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
+ |
// Run the message loop. |
message_loop_.RunAllPending(); |
} |
@@ -222,7 +242,14 @@ TEST_F(ShillManagerClientTest, RequestScan) { |
base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), |
response.get()); |
// Call method. |
- client_->RequestScan(flimflam::kTypeWifi, base::Bind(&ExpectNoResultValue)); |
+ MockClosure mock_closure; |
+ MockErrorCallback mock_error_callback; |
+ client_->RequestScan(flimflam::kTypeWifi, |
+ mock_closure.GetCallback(), |
+ mock_error_callback.GetCallback()); |
+ EXPECT_CALL(mock_closure, Run()).Times(1); |
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
+ |
// Run the message loop. |
message_loop_.RunAllPending(); |
} |
@@ -235,8 +262,14 @@ TEST_F(ShillManagerClientTest, EnableTechnology) { |
base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), |
response.get()); |
// Call method. |
+ MockClosure mock_closure; |
+ MockErrorCallback mock_error_callback; |
client_->EnableTechnology(flimflam::kTypeWifi, |
- base::Bind(&ExpectNoResultValue)); |
+ mock_closure.GetCallback(), |
+ mock_error_callback.GetCallback()); |
+ EXPECT_CALL(mock_closure, Run()).Times(1); |
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
+ |
// Run the message loop. |
message_loop_.RunAllPending(); |
} |
@@ -249,8 +282,14 @@ TEST_F(ShillManagerClientTest, DisableTechnology) { |
base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), |
response.get()); |
// Call method. |
+ MockClosure mock_closure; |
+ MockErrorCallback mock_error_callback; |
client_->DisableTechnology(flimflam::kTypeWifi, |
- base::Bind(&ExpectNoResultValue)); |
+ mock_closure.GetCallback(), |
+ mock_error_callback.GetCallback()); |
+ EXPECT_CALL(mock_closure, Run()).Times(1); |
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
+ |
// Run the message loop. |
message_loop_.RunAllPending(); |
} |
@@ -265,12 +304,20 @@ TEST_F(ShillManagerClientTest, ConfigureService) { |
base::Bind(&ExpectDictionaryValueArgument, arg.get()), |
response.get()); |
// Call method. |
- client_->ConfigureService(*arg, base::Bind(&ExpectNoResultValue)); |
+ MockClosure mock_closure; |
+ MockErrorCallback mock_error_callback; |
+ client_->ConfigureService(*arg, |
+ mock_closure.GetCallback(), |
+ mock_error_callback.GetCallback()); |
+ EXPECT_CALL(mock_closure, Run()).Times(1); |
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
+ |
// Run the message loop. |
message_loop_.RunAllPending(); |
} |
TEST_F(ShillManagerClientTest, GetService) { |
+ MockErrorCallback error_callback; |
// Create response. |
const dbus::ObjectPath object_path("/"); |
scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
@@ -283,7 +330,9 @@ TEST_F(ShillManagerClientTest, GetService) { |
base::Bind(&ExpectDictionaryValueArgument, arg.get()), |
response.get()); |
// Call method. |
- client_->GetService(*arg, base::Bind(&ExpectObjectPathResult, object_path)); |
+ client_->GetService(*arg, |
+ base::Bind(&ExpectObjectPathResult, object_path), |
+ error_callback.GetCallback()); |
// Run the message loop. |
message_loop_.RunAllPending(); |
} |