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

Unified Diff: dbus/bus_unittest.cc

Issue 12039033: DBus: Fixes a flaky test case. (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
« no previous file with comments | « no previous file | 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..bc155e75686dc05ce3248bc4524a4d2f981c6056 100644
--- a/dbus/bus_unittest.cc
+++ b/dbus/bus_unittest.cc
@@ -108,8 +108,7 @@ TEST(BusTest, GetExportedObject) {
bus->ShutdownAndBlock();
}
-// http://crbug.com/137846
-TEST(BusTest, DISABLED_UnregisterExportedObject) {
+TEST(BusTest, UnregisterExportedObject) {
// Start the D-Bus thread.
base::Thread::Options thread_options;
thread_options.message_loop_type = MessageLoop::TYPE_IO;
@@ -126,14 +125,23 @@ TEST(BusTest, DISABLED_UnregisterExportedObject) {
bus->GetExportedObject(dbus::ObjectPath("/org/chromium/TestObject"));
ASSERT_TRUE(object_proxy1);
+ // Increment the reference count to the object proxy to avoid destroying it
+ // calling UnregisterExportedObject. This ensures the dbus::ExportedObject is
+ // not freed from memory. See http://crbug.com/137846 for details.
+ object_proxy1->AddRef();
+
bus->UnregisterExportedObject(dbus::ObjectPath("/org/chromium/TestObject"));
- // This should return a new object.
+ // This should return a new object because the object_proxy1 is still in
+ // alloc'ed memory.
dbus::ExportedObject* object_proxy2 =
bus->GetExportedObject(dbus::ObjectPath("/org/chromium/TestObject"));
ASSERT_TRUE(object_proxy2);
EXPECT_NE(object_proxy1, object_proxy2);
+ // Release the incremented reference.
+ object_proxy1->Release();
+
// Shut down synchronously.
bus->ShutdownOnDBusThreadAndBlock();
EXPECT_TRUE(bus->shutdown_completed());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698