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

Side by Side Diff: dbus/bus_unittest.cc

Issue 9691025: dbus: allow unregistering of exported objects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update doc from nit Created 8 years, 9 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') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // This should not. 101 // This should not.
102 dbus::ExportedObject* object_proxy3 = 102 dbus::ExportedObject* object_proxy3 =
103 bus->GetExportedObject( 103 bus->GetExportedObject(
104 dbus::ObjectPath("/org/chromium/DifferentTestObject")); 104 dbus::ObjectPath("/org/chromium/DifferentTestObject"));
105 ASSERT_TRUE(object_proxy3); 105 ASSERT_TRUE(object_proxy3);
106 EXPECT_NE(object_proxy1, object_proxy3); 106 EXPECT_NE(object_proxy1, object_proxy3);
107 107
108 bus->ShutdownAndBlock(); 108 bus->ShutdownAndBlock();
109 } 109 }
110 110
111 TEST(BusTest, UnregisterExportedObject) {
112 // Start the D-Bus thread.
113 base::Thread::Options thread_options;
114 thread_options.message_loop_type = MessageLoop::TYPE_IO;
115 base::Thread dbus_thread("D-Bus thread");
116 dbus_thread.StartWithOptions(thread_options);
117
118 // Create the bus.
119 dbus::Bus::Options options;
120 options.dbus_thread_message_loop_proxy = dbus_thread.message_loop_proxy();
121 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
122 ASSERT_FALSE(bus->shutdown_completed());
123
124 dbus::ExportedObject* object_proxy1 =
125 bus->GetExportedObject(dbus::ObjectPath("/org/chromium/TestObject"));
126 ASSERT_TRUE(object_proxy1);
127
128 bus->UnregisterExportedObject(dbus::ObjectPath("/org/chromium/TestObject"));
129
130 // This should return a new object.
131 dbus::ExportedObject* object_proxy2 =
132 bus->GetExportedObject(dbus::ObjectPath("/org/chromium/TestObject"));
133 ASSERT_TRUE(object_proxy2);
134 EXPECT_NE(object_proxy1, object_proxy2);
135
136 // Shut down synchronously.
137 bus->ShutdownOnDBusThreadAndBlock();
138 EXPECT_TRUE(bus->shutdown_completed());
139 dbus_thread.Stop();
140 }
141
111 TEST(BusTest, ShutdownAndBlock) { 142 TEST(BusTest, ShutdownAndBlock) {
112 dbus::Bus::Options options; 143 dbus::Bus::Options options;
113 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); 144 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
114 ASSERT_FALSE(bus->shutdown_completed()); 145 ASSERT_FALSE(bus->shutdown_completed());
115 146
116 // Shut down synchronously. 147 // Shut down synchronously.
117 bus->ShutdownAndBlock(); 148 bus->ShutdownAndBlock();
118 EXPECT_TRUE(bus->shutdown_completed()); 149 EXPECT_TRUE(bus->shutdown_completed());
119 } 150 }
120 151
(...skipping 29 matching lines...) Expand all
150 ASSERT_FALSE(bus->AddFilterFunction(&DummyHandler, &data1)); 181 ASSERT_FALSE(bus->AddFilterFunction(&DummyHandler, &data1));
151 // Can add the same function with different data. 182 // Can add the same function with different data.
152 ASSERT_TRUE(bus->AddFilterFunction(&DummyHandler, &data2)); 183 ASSERT_TRUE(bus->AddFilterFunction(&DummyHandler, &data2));
153 184
154 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data1)); 185 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data1));
155 ASSERT_FALSE(bus->RemoveFilterFunction(&DummyHandler, &data1)); 186 ASSERT_FALSE(bus->RemoveFilterFunction(&DummyHandler, &data1));
156 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data2)); 187 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data2));
157 188
158 bus->ShutdownAndBlock(); 189 bus->ShutdownAndBlock();
159 } 190 }
OLDNEW
« no previous file with comments | « dbus/bus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698