OLD | NEW |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 EXPECT_NE(object_proxy1, object_proxy3); | 82 EXPECT_NE(object_proxy1, object_proxy3); |
83 | 83 |
84 bus->ShutdownAndBlock(); | 84 bus->ShutdownAndBlock(); |
85 } | 85 } |
86 | 86 |
87 TEST(BusTest, GetExportedObject) { | 87 TEST(BusTest, GetExportedObject) { |
88 dbus::Bus::Options options; | 88 dbus::Bus::Options options; |
89 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); | 89 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); |
90 | 90 |
91 dbus::ExportedObject* object_proxy1 = | 91 dbus::ExportedObject* object_proxy1 = |
92 bus->GetExportedObject("org.chromium.TestService", | 92 bus->GetExportedObject(dbus::ObjectPath("/org/chromium/TestObject")); |
93 dbus::ObjectPath("/org/chromium/TestObject")); | |
94 ASSERT_TRUE(object_proxy1); | 93 ASSERT_TRUE(object_proxy1); |
95 | 94 |
96 // This should return the same object. | 95 // This should return the same object. |
97 dbus::ExportedObject* object_proxy2 = | 96 dbus::ExportedObject* object_proxy2 = |
98 bus->GetExportedObject("org.chromium.TestService", | 97 bus->GetExportedObject(dbus::ObjectPath("/org/chromium/TestObject")); |
99 dbus::ObjectPath("/org/chromium/TestObject")); | |
100 ASSERT_TRUE(object_proxy2); | 98 ASSERT_TRUE(object_proxy2); |
101 EXPECT_EQ(object_proxy1, object_proxy2); | 99 EXPECT_EQ(object_proxy1, object_proxy2); |
102 | 100 |
103 // This should not. | 101 // This should not. |
104 dbus::ExportedObject* object_proxy3 = | 102 dbus::ExportedObject* object_proxy3 = |
105 bus->GetExportedObject( | 103 bus->GetExportedObject( |
106 "org.chromium.TestService", | |
107 dbus::ObjectPath("/org/chromium/DifferentTestObject")); | 104 dbus::ObjectPath("/org/chromium/DifferentTestObject")); |
108 ASSERT_TRUE(object_proxy3); | 105 ASSERT_TRUE(object_proxy3); |
109 EXPECT_NE(object_proxy1, object_proxy3); | 106 EXPECT_NE(object_proxy1, object_proxy3); |
110 | 107 |
111 bus->ShutdownAndBlock(); | 108 bus->ShutdownAndBlock(); |
112 } | 109 } |
113 | 110 |
114 TEST(BusTest, ShutdownAndBlock) { | 111 TEST(BusTest, ShutdownAndBlock) { |
115 dbus::Bus::Options options; | 112 dbus::Bus::Options options; |
116 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); | 113 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 ASSERT_FALSE(bus->AddFilterFunction(&DummyHandler, &data1)); | 150 ASSERT_FALSE(bus->AddFilterFunction(&DummyHandler, &data1)); |
154 // Can add the same function with different data. | 151 // Can add the same function with different data. |
155 ASSERT_TRUE(bus->AddFilterFunction(&DummyHandler, &data2)); | 152 ASSERT_TRUE(bus->AddFilterFunction(&DummyHandler, &data2)); |
156 | 153 |
157 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data1)); | 154 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data1)); |
158 ASSERT_FALSE(bus->RemoveFilterFunction(&DummyHandler, &data1)); | 155 ASSERT_FALSE(bus->RemoveFilterFunction(&DummyHandler, &data1)); |
159 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data2)); | 156 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data2)); |
160 | 157 |
161 bus->ShutdownAndBlock(); | 158 bus->ShutdownAndBlock(); |
162 } | 159 } |
OLD | NEW |