summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/shill_ipconfig_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_ipconfig_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_ipconfig_client_unittest.cc')
-rw-r--r--chromeos/dbus/shill_ipconfig_client_unittest.cc27
1 files changed, 21 insertions, 6 deletions
diff --git a/chromeos/dbus/shill_ipconfig_client_unittest.cc b/chromeos/dbus/shill_ipconfig_client_unittest.cc
index 60bca25..a89a450 100644
--- a/chromeos/dbus/shill_ipconfig_client_unittest.cc
+++ b/chromeos/dbus/shill_ipconfig_client_unittest.cc
@@ -11,6 +11,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 {
@@ -54,15 +57,27 @@ TEST_F(ShillIPConfigClientTest, PropertyChanged) {
dbus::AppendBasicTypeValueDataAsVariant(&writer, kConnected);
// Set expectations.
- client_->SetPropertyChangedHandler(dbus::ObjectPath(kExampleIPConfigPath),
- base::Bind(&ExpectPropertyChanged,
- flimflam::kConnectedProperty,
- &kConnected));
+ MockPropertyChangeObserver observer;
+ EXPECT_CALL(observer, OnPropertyChanged(flimflam::kConnectedProperty,
+ ValueEq(ByRef(kConnected)))).Times(1);
+
+ // Add the observer
+ client_->AddPropertyChangedObserver(
+ dbus::ObjectPath(kExampleIPConfigPath),
+ &observer);
+
// Run the signal callback.
SendPropertyChangedSignal(&signal);
- // Reset the handler.
- client_->ResetPropertyChangedHandler(dbus::ObjectPath(kExampleIPConfigPath));
+ // Remove the observer.
+ client_->RemovePropertyChangedObserver(
+ dbus::ObjectPath(kExampleIPConfigPath),
+ &observer);
+
+ EXPECT_CALL(observer, OnPropertyChanged(_, _)).Times(0);
+
+ // Run the signal callback again and make sure the observer isn't called.
+ SendPropertyChangedSignal(&signal);
}
TEST_F(ShillIPConfigClientTest, GetProperties) {