| 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();
|
| +}
|
|
|