summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/shill_manager_client_unittest.cc
diff options
context:
space:
mode:
authorgspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-27 04:07:05 +0000
committergspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-27 04:07:05 +0000
commit3c34dd58e21ea33424c635afaf22c82476f56afb (patch)
treeef57c251ae5f3cef33365659a6e9aa1535fc5a32 /chromeos/dbus/shill_manager_client_unittest.cc
parent2bab166de6e6cdcbd9168a138a5dca1f266d14c3 (diff)
downloadchromium_src-3c34dd58e21ea33424c635afaf22c82476f56afb.zip
chromium_src-3c34dd58e21ea33424c635afaf22c82476f56afb.tar.gz
chromium_src-3c34dd58e21ea33424c635afaf22c82476f56afb.tar.bz2
This converts the Shill clients to use an observer pattern
for property change notifications because in a future CL the javascript private API will need to listen directly to shill notifications as well, and the previous implementation was limited to a single handler. BUG=chromium:147620,chromium:146616 TEST=Ran unit tests, ran on device. Review URL: https://chromiumcodereview.appspot.com/10965045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158972 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/shill_manager_client_unittest.cc')
-rw-r--r--chromeos/dbus/shill_manager_client_unittest.cc24
1 files changed, 19 insertions, 5 deletions
diff --git a/chromeos/dbus/shill_manager_client_unittest.cc b/chromeos/dbus/shill_manager_client_unittest.cc
index 9d37aec..e101bf2 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) {