summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authordeymo@chromium.org <deymo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-24 00:58:35 +0000
committerdeymo@chromium.org <deymo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-24 00:58:35 +0000
commitbda573565d5f1f32fd1674dac23829b3202bef42 (patch)
tree9e7902cad4a455c6030645a4f1bb23afd6b44378 /dbus
parent6ab53f3f5686b970a96bbb3b9526167c75349cd5 (diff)
downloadchromium_src-bda573565d5f1f32fd1674dac23829b3202bef42.zip
chromium_src-bda573565d5f1f32fd1674dac23829b3202bef42.tar.gz
chromium_src-bda573565d5f1f32fd1674dac23829b3202bef42.tar.bz2
DBus: Fixes a flaky test case.
In the UnregisterExportedObject test, an ExportedObject is created, destroyed and created again as a new object. The test assumes the new object is different from the first one just comparing the memory pointers to those objects. Nevertheless, the memory manager could possibly alloc the same memory address for the second object since the first one was already destroyed. This fixes this situation preventing the first object from being destroyed incrementing its reference count. BUG=chromium:137846 TEST=test enabled. Review URL: https://chromiumcodereview.appspot.com/12039033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178450 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus')
-rw-r--r--dbus/bus_unittest.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/dbus/bus_unittest.cc b/dbus/bus_unittest.cc
index ca24041..bc155e7 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());