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

Side by Side 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, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dbus/bus.cc ('k') | dbus/end_to_end_async_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "dbus/bus.h" 5 #include "dbus/bus.h"
6 6
7 #include "base/bind.h"
8 #include "base/message_loop.h"
7 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/threading/thread.h"
8 #include "dbus/exported_object.h" 11 #include "dbus/exported_object.h"
9 #include "dbus/object_proxy.h" 12 #include "dbus/object_proxy.h"
10 13
11 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
12 15
13 TEST(BusTest, GetObjectProxy) { 16 TEST(BusTest, GetObjectProxy) {
14 dbus::Bus::Options options; 17 dbus::Bus::Options options;
15 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); 18 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
16 19
17 dbus::ObjectProxy* object_proxy1 = 20 dbus::ObjectProxy* object_proxy1 =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 ASSERT_TRUE(object_proxy2); 53 ASSERT_TRUE(object_proxy2);
51 EXPECT_EQ(object_proxy1, object_proxy2); 54 EXPECT_EQ(object_proxy1, object_proxy2);
52 55
53 // This should not. 56 // This should not.
54 dbus::ExportedObject* object_proxy3 = 57 dbus::ExportedObject* object_proxy3 =
55 bus->GetExportedObject("org.chromium.TestService", 58 bus->GetExportedObject("org.chromium.TestService",
56 "/org/chromium/DifferentTestObject"); 59 "/org/chromium/DifferentTestObject");
57 ASSERT_TRUE(object_proxy3); 60 ASSERT_TRUE(object_proxy3);
58 EXPECT_NE(object_proxy1, object_proxy3); 61 EXPECT_NE(object_proxy1, object_proxy3);
59 } 62 }
63
64 TEST(BusTest, ShutdownAndBlock) {
65 dbus::Bus::Options options;
66 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
67 ASSERT_FALSE(bus->shutdown_completed());
68
69 // Shut down synchronously.
70 bus->ShutdownAndBlock();
71 EXPECT_TRUE(bus->shutdown_completed());
72 }
73
74 TEST(BusTest, ShutdownAndBlockWithDBusThread) {
75 // Start the D-Bus thread.
76 base::Thread::Options thread_options;
77 thread_options.message_loop_type = MessageLoop::TYPE_IO;
78 base::Thread dbus_thread("D-Bus thread");
79 dbus_thread.StartWithOptions(thread_options);
80
81 // Create the bus.
82 dbus::Bus::Options options;
83 options.dbus_thread = &dbus_thread;
84 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
85 ASSERT_FALSE(bus->shutdown_completed());
86
87 // Shut down synchronously.
88 bus->ShutdownOnDBusThreadAndBlock();
89 EXPECT_TRUE(bus->shutdown_completed());
90 dbus_thread.Stop();
91 }
OLDNEW
« 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