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

Side by Side Diff: dbus/end_to_end_async_unittest.cc

Issue 8681002: dbus: Fix a bug where we were emitting spurious error messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 years 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 | « no previous file | dbus/object_proxy.h » ('j') | 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) 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 dbus::Bus::Options bus_options; 48 dbus::Bus::Options bus_options;
49 bus_options.bus_type = dbus::Bus::SESSION; 49 bus_options.bus_type = dbus::Bus::SESSION;
50 bus_options.connection_type = dbus::Bus::PRIVATE; 50 bus_options.connection_type = dbus::Bus::PRIVATE;
51 bus_options.dbus_thread_message_loop_proxy = 51 bus_options.dbus_thread_message_loop_proxy =
52 dbus_thread_->message_loop_proxy(); 52 dbus_thread_->message_loop_proxy();
53 bus_ = new dbus::Bus(bus_options); 53 bus_ = new dbus::Bus(bus_options);
54 object_proxy_ = bus_->GetObjectProxy("org.chromium.TestService", 54 object_proxy_ = bus_->GetObjectProxy("org.chromium.TestService",
55 "/org/chromium/TestObject"); 55 "/org/chromium/TestObject");
56 ASSERT_TRUE(bus_->HasDBusThread()); 56 ASSERT_TRUE(bus_->HasDBusThread());
57 57
58 // Connect to the "Test" signal from the remote object. 58 // Connect to the "Test" signal of "org.chromium.TestInterface" from
59 // the remote object.
59 object_proxy_->ConnectToSignal( 60 object_proxy_->ConnectToSignal(
60 "org.chromium.TestInterface", 61 "org.chromium.TestInterface",
61 "Test", 62 "Test",
62 base::Bind(&EndToEndAsyncTest::OnTestSignal, 63 base::Bind(&EndToEndAsyncTest::OnTestSignal,
63 base::Unretained(this)), 64 base::Unretained(this)),
64 base::Bind(&EndToEndAsyncTest::OnConnected, 65 base::Bind(&EndToEndAsyncTest::OnConnected,
65 base::Unretained(this))); 66 base::Unretained(this)));
67 // Connect to the "Test2" signal of "org.chromium.TestInterface" from
68 // the remote object. There was a bug where we were emitting error
69 // messages like "Requested to remove an unknown match rule: ..." at
70 // the shutdown of Bus when an object proxy is connected to more than
71 // one signal of the same interface. See crosbug.com/23382 for details.
72 object_proxy_->ConnectToSignal(
73 "org.chromium.TestInterface",
74 "Test2",
75 base::Bind(&EndToEndAsyncTest::OnTest2Signal,
76 base::Unretained(this)),
77 base::Bind(&EndToEndAsyncTest::OnConnected,
78 base::Unretained(this)));
66 // Wait until the object proxy is connected to the signal. 79 // Wait until the object proxy is connected to the signal.
67 message_loop_.Run(); 80 message_loop_.Run();
68 } 81 }
69 82
70 virtual void TearDown() { 83 virtual void TearDown() {
71 bus_->ShutdownOnDBusThreadAndBlock(); 84 bus_->ShutdownOnDBusThreadAndBlock();
72 85
73 // Shut down the service. 86 // Shut down the service.
74 test_service_->ShutdownAndBlock(); 87 test_service_->ShutdownAndBlock();
75 88
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 }; 128 };
116 129
117 // Called when the "Test" signal is received, in the main thread. 130 // Called when the "Test" signal is received, in the main thread.
118 // Copy the string payload to |test_signal_string_|. 131 // Copy the string payload to |test_signal_string_|.
119 void OnTestSignal(dbus::Signal* signal) { 132 void OnTestSignal(dbus::Signal* signal) {
120 dbus::MessageReader reader(signal); 133 dbus::MessageReader reader(signal);
121 ASSERT_TRUE(reader.PopString(&test_signal_string_)); 134 ASSERT_TRUE(reader.PopString(&test_signal_string_));
122 message_loop_.Quit(); 135 message_loop_.Quit();
123 } 136 }
124 137
138 // Called when the "Test2" signal is received, in the main thread.
139 void OnTest2Signal(dbus::Signal* signal) {
140 dbus::MessageReader reader(signal);
141 message_loop_.Quit();
142 }
143
125 // Called when connected to the signal. 144 // Called when connected to the signal.
126 void OnConnected(const std::string& interface_name, 145 void OnConnected(const std::string& interface_name,
127 const std::string& signal_name, 146 const std::string& signal_name,
128 bool success) { 147 bool success) {
129 ASSERT_TRUE(success); 148 ASSERT_TRUE(success);
130 message_loop_.Quit(); 149 message_loop_.Quit();
131 } 150 }
132 151
133 // Wait for the hey signal to be received. 152 // Wait for the hey signal to be received.
134 void WaitForTestSignal() { 153 void WaitForTestSignal() {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 TEST_F(EndToEndAsyncTest, TestSignalFromRoot) { 280 TEST_F(EndToEndAsyncTest, TestSignalFromRoot) {
262 const char kMessage[] = "hello, world"; 281 const char kMessage[] = "hello, world";
263 // Send the test signal from the root object path, to see if we can 282 // Send the test signal from the root object path, to see if we can
264 // handle signals sent from "/", like dbus-send does. 283 // handle signals sent from "/", like dbus-send does.
265 test_service_->SendTestSignalFromRoot(kMessage); 284 test_service_->SendTestSignalFromRoot(kMessage);
266 // Receive the signal with the object proxy. The signal is handled in 285 // Receive the signal with the object proxy. The signal is handled in
267 // EndToEndAsyncTest::OnTestSignal() in the main thread. 286 // EndToEndAsyncTest::OnTestSignal() in the main thread.
268 WaitForTestSignal(); 287 WaitForTestSignal();
269 ASSERT_EQ(kMessage, test_signal_string_); 288 ASSERT_EQ(kMessage, test_signal_string_);
270 } 289 }
OLDNEW
« no previous file with comments | « no previous file | dbus/object_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698