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

Side by Side Diff: dbus/bus_unittest.cc

Issue 9373039: Allow dbus clients to silence logging when a service is unavailable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use pair, factor out error logging logic Created 8 years, 10 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
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" 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
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->GetObjectProxyWithOptions(
59 "org.chromium.TestService",
60 "/org/chromium/TestObject",
61 dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS);
62 ASSERT_TRUE(object_proxy1);
63
64 // This should return the same object.
65 dbus::ObjectProxy* object_proxy2 =
66 bus->GetObjectProxyWithOptions(
67 "org.chromium.TestService",
68 "/org/chromium/TestObject",
69 dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS);
70 ASSERT_TRUE(object_proxy2);
71 EXPECT_EQ(object_proxy1, object_proxy2);
72
73 // This should not.
74 dbus::ObjectProxy* object_proxy3 =
75 bus->GetObjectProxyWithOptions(
76 "org.chromium.TestService",
77 "/org/chromium/DifferentTestObject",
78 dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS);
79 ASSERT_TRUE(object_proxy3);
80 EXPECT_NE(object_proxy1, object_proxy3);
81
82 bus->ShutdownAndBlock();
83 }
84
53 TEST(BusTest, GetExportedObject) { 85 TEST(BusTest, GetExportedObject) {
54 dbus::Bus::Options options; 86 dbus::Bus::Options options;
55 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); 87 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
56 88
57 dbus::ExportedObject* object_proxy1 = 89 dbus::ExportedObject* object_proxy1 =
58 bus->GetExportedObject("org.chromium.TestService", 90 bus->GetExportedObject("org.chromium.TestService",
59 "/org/chromium/TestObject"); 91 "/org/chromium/TestObject");
60 ASSERT_TRUE(object_proxy1); 92 ASSERT_TRUE(object_proxy1);
61 93
62 // This should return the same object. 94 // This should return the same object.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ASSERT_FALSE(bus->AddFilterFunction(&DummyHandler, &data1)); 150 ASSERT_FALSE(bus->AddFilterFunction(&DummyHandler, &data1));
119 // Can add the same function with different data. 151 // Can add the same function with different data.
120 ASSERT_TRUE(bus->AddFilterFunction(&DummyHandler, &data2)); 152 ASSERT_TRUE(bus->AddFilterFunction(&DummyHandler, &data2));
121 153
122 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data1)); 154 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data1));
123 ASSERT_FALSE(bus->RemoveFilterFunction(&DummyHandler, &data1)); 155 ASSERT_FALSE(bus->RemoveFilterFunction(&DummyHandler, &data1));
124 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data2)); 156 ASSERT_TRUE(bus->RemoveFilterFunction(&DummyHandler, &data2));
125 157
126 bus->ShutdownAndBlock(); 158 bus->ShutdownAndBlock();
127 } 159 }
OLDNEW
« no previous file with comments | « dbus/bus.cc ('k') | dbus/mock_bus.h » ('j') | dbus/object_proxy.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698