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

Unified Diff: dbus/bus_unittest.cc

Issue 12022004: D-Bus: ObjectProxy remove function for Bus object. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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
« dbus/bus.cc ('K') | « dbus/bus.cc ('k') | no next file » | 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 ca24041f86c309a07989cc379d6c6a197dc13059..c632d85a4c30af29b4da6e41c65b3b7b39ba8f59 100644
--- a/dbus/bus_unittest.cc
+++ b/dbus/bus_unittest.cc
@@ -84,6 +84,38 @@ TEST(BusTest, GetObjectProxyIgnoreUnknownService) {
bus->ShutdownAndBlock();
}
+TEST(BusTest, RemoveObjectProxy) {
+ dbus::Bus::Options options;
+ scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
+
+ dbus::ObjectProxy* object_proxy1 =
+ bus->GetObjectProxy("org.chromium.TestService",
+ dbus::ObjectPath("/org/chromium/TestObject"));
+ ASSERT_TRUE(object_proxy1);
+
+ // Increment the reference count to the object proxy to avoid destroying it
+ // while removing the object.
+ object_proxy1->AddRef();
+
+ // Remove the object from the bus. This will invalidate any other usage of
+ // object_proxy1 other than destroy it.
+ bus->RemoveObjectProxy("org.chromium.TestService",
+ dbus::ObjectPath("/org/chromium/TestObject"));
+
+ // This should return a different object because the first object still
+ // exists thanks to the increased reference.
+ dbus::ObjectProxy* object_proxy2 =
+ bus->GetObjectProxy("org.chromium.TestService",
+ dbus::ObjectPath("/org/chromium/TestObject"));
+ ASSERT_TRUE(object_proxy2);
+ EXPECT_NE(object_proxy1, object_proxy2);
+
+ // Release object_proxy1.
+ object_proxy1->Release();
+
+ bus->ShutdownAndBlock();
+}
+
TEST(BusTest, GetExportedObject) {
dbus::Bus::Options options;
scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
« dbus/bus.cc ('K') | « dbus/bus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698