OLD | NEW |
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" | 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 28 matching lines...) Expand all Loading... |
39 "/org/chromium/TestObject"); | 39 "/org/chromium/TestObject"); |
40 ASSERT_TRUE(object_proxy2); | 40 ASSERT_TRUE(object_proxy2); |
41 EXPECT_EQ(object_proxy1, object_proxy2); | 41 EXPECT_EQ(object_proxy1, object_proxy2); |
42 | 42 |
43 // This should not. | 43 // This should not. |
44 dbus::ObjectProxy* object_proxy3 = | 44 dbus::ObjectProxy* object_proxy3 = |
45 bus->GetObjectProxy("org.chromium.TestService", | 45 bus->GetObjectProxy("org.chromium.TestService", |
46 "/org/chromium/DifferentTestObject"); | 46 "/org/chromium/DifferentTestObject"); |
47 ASSERT_TRUE(object_proxy3); | 47 ASSERT_TRUE(object_proxy3); |
48 EXPECT_NE(object_proxy1, object_proxy3); | 48 EXPECT_NE(object_proxy1, object_proxy3); |
| 49 |
| 50 bus->ShutdownAndBlock(); |
49 } | 51 } |
50 | 52 |
51 TEST(BusTest, GetExportedObject) { | 53 TEST(BusTest, GetExportedObject) { |
52 dbus::Bus::Options options; | 54 dbus::Bus::Options options; |
53 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); | 55 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); |
54 | 56 |
55 dbus::ExportedObject* object_proxy1 = | 57 dbus::ExportedObject* object_proxy1 = |
56 bus->GetExportedObject("org.chromium.TestService", | 58 bus->GetExportedObject("org.chromium.TestService", |
57 "/org/chromium/TestObject"); | 59 "/org/chromium/TestObject"); |
58 ASSERT_TRUE(object_proxy1); | 60 ASSERT_TRUE(object_proxy1); |
59 | 61 |
60 // This should return the same object. | 62 // This should return the same object. |
61 dbus::ExportedObject* object_proxy2 = | 63 dbus::ExportedObject* object_proxy2 = |
62 bus->GetExportedObject("org.chromium.TestService", | 64 bus->GetExportedObject("org.chromium.TestService", |
63 "/org/chromium/TestObject"); | 65 "/org/chromium/TestObject"); |
64 ASSERT_TRUE(object_proxy2); | 66 ASSERT_TRUE(object_proxy2); |
65 EXPECT_EQ(object_proxy1, object_proxy2); | 67 EXPECT_EQ(object_proxy1, object_proxy2); |
66 | 68 |
67 // This should not. | 69 // This should not. |
68 dbus::ExportedObject* object_proxy3 = | 70 dbus::ExportedObject* object_proxy3 = |
69 bus->GetExportedObject("org.chromium.TestService", | 71 bus->GetExportedObject("org.chromium.TestService", |
70 "/org/chromium/DifferentTestObject"); | 72 "/org/chromium/DifferentTestObject"); |
71 ASSERT_TRUE(object_proxy3); | 73 ASSERT_TRUE(object_proxy3); |
72 EXPECT_NE(object_proxy1, object_proxy3); | 74 EXPECT_NE(object_proxy1, object_proxy3); |
| 75 |
| 76 bus->ShutdownAndBlock(); |
73 } | 77 } |
74 | 78 |
75 TEST(BusTest, ShutdownAndBlock) { | 79 TEST(BusTest, ShutdownAndBlock) { |
76 dbus::Bus::Options options; | 80 dbus::Bus::Options options; |
77 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); | 81 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); |
78 ASSERT_FALSE(bus->shutdown_completed()); | 82 ASSERT_FALSE(bus->shutdown_completed()); |
79 | 83 |
80 // Shut down synchronously. | 84 // Shut down synchronously. |
81 bus->ShutdownAndBlock(); | 85 bus->ShutdownAndBlock(); |
82 EXPECT_TRUE(bus->shutdown_completed()); | 86 EXPECT_TRUE(bus->shutdown_completed()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 ASSERT_FALSE(bus->AddFilterFunction(&DummyHandler, &data1)); | 118 ASSERT_FALSE(bus->AddFilterFunction(&DummyHandler, &data1)); |
115 // Can add the same function with different data. | 119 // Can add the same function with different data. |
116 ASSERT_TRUE(bus->AddFilterFunction(&DummyHandler, &data2)); | 120 ASSERT_TRUE(bus->AddFilterFunction(&DummyHandler, &data2)); |
117 | 121 |
118 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data1)); | 122 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data1)); |
119 ASSERT_FALSE(bus->RemoveFilterFunction(&DummyHandler, &data1)); | 123 ASSERT_FALSE(bus->RemoveFilterFunction(&DummyHandler, &data1)); |
120 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data2)); | 124 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data2)); |
121 | 125 |
122 bus->ShutdownAndBlock(); | 126 bus->ShutdownAndBlock(); |
123 } | 127 } |
OLD | NEW |