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

Unified Diff: dbus/bus_unittest.cc

Issue 12088068: DBus: Bus::AddMatch and RemoveMatch support repeated rules. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: RemoveMatch returns a bool. Created 7 years, 11 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
« no previous file with comments | « dbus/bus.cc ('k') | dbus/mock_bus.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/bus_unittest.cc
diff --git a/dbus/bus_unittest.cc b/dbus/bus_unittest.cc
index bc155e75686dc05ce3248bc4524a4d2f981c6056..de879afb6ac80f0f8ebcf556eeb08acd69ba3b8a 100644
--- a/dbus/bus_unittest.cc
+++ b/dbus/bus_unittest.cc
@@ -11,6 +11,7 @@
#include "dbus/exported_object.h"
#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
+#include "dbus/scoped_dbus_error.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -197,3 +198,42 @@ TEST(BusTest, AddFilterFunction) {
bus->ShutdownAndBlock();
}
+
+TEST(BusTest, DoubleAddAndRemoveMatch) {
+ dbus::Bus::Options options;
+ scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
+ dbus::ScopedDBusError error;
+
+ bus->Connect();
+
+ // Adds the same rule twice.
+ bus->AddMatch(
+ "type='signal',interface='org.chromium.TestService',path='/'",
+ error.get());
+ ASSERT_FALSE(error.is_set());
+
+ bus->AddMatch(
+ "type='signal',interface='org.chromium.TestService',path='/'",
+ error.get());
+ ASSERT_FALSE(error.is_set());
+
+ // Removes the same rule twice.
+ ASSERT_TRUE(bus->RemoveMatch(
+ "type='signal',interface='org.chromium.TestService',path='/'",
+ error.get()));
+ ASSERT_FALSE(error.is_set());
+
+ // The rule should be still in the bus since it was removed only once.
+ // A second removal shouldn't give an error.
+ ASSERT_TRUE(bus->RemoveMatch(
+ "type='signal',interface='org.chromium.TestService',path='/'",
+ error.get()));
+ ASSERT_FALSE(error.is_set());
+
+ // A third attemp to remove the same rule should fail.
+ ASSERT_FALSE(bus->RemoveMatch(
+ "type='signal',interface='org.chromium.TestService',path='/'",
+ error.get()));
+
+ bus->ShutdownAndBlock();
+}
« no previous file with comments | « dbus/bus.cc ('k') | dbus/mock_bus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698