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

Unified Diff: chromeos/dbus/shill_profile_client_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: chromeos/dbus/shill_profile_client_unittest.cc
diff --git a/chromeos/dbus/shill_profile_client_unittest.cc b/chromeos/dbus/shill_profile_client_unittest.cc
index 898a9615b17bd6313288566c2b54adfd714bd3a2..54f0c5a09488664a5a45867ada07098b556cd858 100644
--- a/chromeos/dbus/shill_profile_client_unittest.cc
+++ b/chromeos/dbus/shill_profile_client_unittest.cc
@@ -12,6 +12,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
+using testing::_;
+
namespace chromeos {
namespace {
@@ -65,16 +67,29 @@ TEST_F(ShillProfileClientTest, PropertyChanged) {
// Set expectations.
base::ListValue value;
value.Append(base::Value::CreateStringValue(kExampleEntryPath));
+ MockPropertyChangeObserver observer;
+ EXPECT_CALL(observer,
+ OnPropertyChanged(
+ flimflam::kEntriesProperty,
+ ValueEq(value))).Times(1);
+
+ // Add the observer
+ client_->AddPropertyChangedObserver(
+ dbus::ObjectPath(kDefaultProfilePath),
+ &observer);
- client_->SetPropertyChangedHandler(dbus::ObjectPath(kDefaultProfilePath),
- base::Bind(&ExpectPropertyChanged,
- flimflam::kEntriesProperty,
- &value));
// Run the signal callback.
SendPropertyChangedSignal(&signal);
- // Reset the handler.
- client_->ResetPropertyChangedHandler(dbus::ObjectPath(kDefaultProfilePath));
+ // Remove the observer.
+ client_->RemovePropertyChangedObserver(
+ dbus::ObjectPath(kDefaultProfilePath),
+ &observer);
+
+ EXPECT_CALL(observer, OnPropertyChanged(_, _)).Times(0);
+
+ // Run the signal callback again and make sure the observer isn't called.
+ SendPropertyChangedSignal(&signal);
}
TEST_F(ShillProfileClientTest, GetProperties) {
@@ -101,8 +116,11 @@ TEST_F(ShillProfileClientTest, GetProperties) {
base::Bind(&ExpectNoArgument),
response.get());
// Call method.
+ MockErrorCallback error_callback;
client_->GetProperties(dbus::ObjectPath(kDefaultProfilePath),
- base::Bind(&ExpectDictionaryValueResult, &value));
+ base::Bind(&ExpectDictionaryValueResultWithoutStatus,
+ &value),
+ error_callback.GetCallback());
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -130,9 +148,13 @@ TEST_F(ShillProfileClientTest, GetEntry) {
base::Bind(&ExpectStringArgument, kExampleEntryPath),
response.get());
// Call method.
+ MockErrorCallback error_callback;
client_->GetEntry(dbus::ObjectPath(kDefaultProfilePath),
kExampleEntryPath,
- base::Bind(&ExpectDictionaryValueResult, &value));
+ base::Bind(&ExpectDictionaryValueResultWithoutStatus,
+ &value),
+ error_callback.GetCallback());
+ EXPECT_CALL(error_callback, Run(_, _)).Times(0);
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -150,9 +172,15 @@ TEST_F(ShillProfileClientTest, DeleteEntry) {
base::Bind(&ExpectStringArgument, kExampleEntryPath),
response.get());
// Call method.
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
client_->DeleteEntry(dbus::ObjectPath(kDefaultProfilePath),
kExampleEntryPath,
- 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();
}

Powered by Google App Engine
This is Rietveld 408576698