Index: dbus/bus_unittest.cc |
diff --git a/dbus/bus_unittest.cc b/dbus/bus_unittest.cc |
index 5cd198d9f50757f4bf614c5ce17b9d7b14fcf38d..7d477e2a2e6ab093b99906886b7fcb60ea0e4174 100644 |
--- a/dbus/bus_unittest.cc |
+++ b/dbus/bus_unittest.cc |
@@ -4,7 +4,10 @@ |
#include "dbus/bus.h" |
+#include "base/bind.h" |
+#include "base/message_loop.h" |
#include "base/memory/ref_counted.h" |
+#include "base/threading/thread.h" |
#include "dbus/exported_object.h" |
#include "dbus/object_proxy.h" |
@@ -57,3 +60,32 @@ TEST(BusTest, GetExportedObject) { |
ASSERT_TRUE(object_proxy3); |
EXPECT_NE(object_proxy1, object_proxy3); |
} |
+ |
+TEST(BusTest, ShutdownAndBlock) { |
+ dbus::Bus::Options options; |
+ scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); |
+ ASSERT_FALSE(bus->shutdown_completed()); |
+ |
+ // Shut down synchronously. |
+ bus->ShutdownAndBlock(); |
+ EXPECT_TRUE(bus->shutdown_completed()); |
+} |
+ |
+TEST(BusTest, ShutdownAndBlockWithDBusThread) { |
+ // Start the D-Bus thread. |
+ base::Thread::Options thread_options; |
+ thread_options.message_loop_type = MessageLoop::TYPE_IO; |
+ base::Thread dbus_thread("D-Bus thread"); |
+ dbus_thread.StartWithOptions(thread_options); |
+ |
+ // Create the bus. |
+ dbus::Bus::Options options; |
+ options.dbus_thread = &dbus_thread; |
+ scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); |
+ ASSERT_FALSE(bus->shutdown_completed()); |
+ |
+ // Shut down synchronously. |
+ bus->ShutdownOnDBusThreadAndBlock(); |
+ EXPECT_TRUE(bus->shutdown_completed()); |
+ dbus_thread.Stop(); |
+} |