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

Unified Diff: dbus/bus_unittest.cc

Issue 7830009: Add Bus::ShutdownOnDBusThreadAndBlock() and remove bus::Shutdown() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 years, 4 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 | « dbus/bus.cc ('k') | dbus/end_to_end_async_unittest.cc » ('j') | 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 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();
+}
« no previous file with comments | « dbus/bus.cc ('k') | dbus/end_to_end_async_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698