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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 49 |
50 bus->ShutdownAndBlock(); | 50 bus->ShutdownAndBlock(); |
51 } | 51 } |
52 | 52 |
| 53 TEST(BusTest, GetObjectProxyIgnoreUnknownService) { |
| 54 dbus::Bus::Options options; |
| 55 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); |
| 56 |
| 57 dbus::ObjectProxy* object_proxy1 = |
| 58 bus->GetObjectProxyIgnoreUnknownService( |
| 59 "org.chromium.TestService", "/org/chromium/TestObject"); |
| 60 ASSERT_TRUE(object_proxy1); |
| 61 |
| 62 // This should return the same object. |
| 63 dbus::ObjectProxy* object_proxy2 = |
| 64 bus->GetObjectProxyIgnoreUnknownService( |
| 65 "org.chromium.TestService", "/org/chromium/TestObject"); |
| 66 ASSERT_TRUE(object_proxy2); |
| 67 EXPECT_EQ(object_proxy1, object_proxy2); |
| 68 |
| 69 // This should not. |
| 70 dbus::ObjectProxy* object_proxy3 = |
| 71 bus->GetObjectProxyIgnoreUnknownService( |
| 72 "org.chromium.TestService", "/org/chromium/DifferentTestObject"); |
| 73 ASSERT_TRUE(object_proxy3); |
| 74 EXPECT_NE(object_proxy1, object_proxy3); |
| 75 |
| 76 bus->ShutdownAndBlock(); |
| 77 } |
| 78 |
53 TEST(BusTest, GetExportedObject) { | 79 TEST(BusTest, GetExportedObject) { |
54 dbus::Bus::Options options; | 80 dbus::Bus::Options options; |
55 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); | 81 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); |
56 | 82 |
57 dbus::ExportedObject* object_proxy1 = | 83 dbus::ExportedObject* object_proxy1 = |
58 bus->GetExportedObject("org.chromium.TestService", | 84 bus->GetExportedObject("org.chromium.TestService", |
59 "/org/chromium/TestObject"); | 85 "/org/chromium/TestObject"); |
60 ASSERT_TRUE(object_proxy1); | 86 ASSERT_TRUE(object_proxy1); |
61 | 87 |
62 // This should return the same object. | 88 // This should return the same object. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 ASSERT_FALSE(bus->AddFilterFunction(&DummyHandler, &data1)); | 144 ASSERT_FALSE(bus->AddFilterFunction(&DummyHandler, &data1)); |
119 // Can add the same function with different data. | 145 // Can add the same function with different data. |
120 ASSERT_TRUE(bus->AddFilterFunction(&DummyHandler, &data2)); | 146 ASSERT_TRUE(bus->AddFilterFunction(&DummyHandler, &data2)); |
121 | 147 |
122 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data1)); | 148 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data1)); |
123 ASSERT_FALSE(bus->RemoveFilterFunction(&DummyHandler, &data1)); | 149 ASSERT_FALSE(bus->RemoveFilterFunction(&DummyHandler, &data1)); |
124 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data2)); | 150 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data2)); |
125 | 151 |
126 bus->ShutdownAndBlock(); | 152 bus->ShutdownAndBlock(); |
127 } | 153 } |
OLD | NEW |