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

Unified Diff: dbus/end_to_end_async_unittest.cc

Issue 12224139: Supporting callback for Disconnected signal. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comments Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dbus/bus.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/end_to_end_async_unittest.cc
diff --git a/dbus/end_to_end_async_unittest.cc b/dbus/end_to_end_async_unittest.cc
index 7715f7d1826f822f28878f0b327242c7edd36016..b91ea77cd8b4b3e6727a7e53a0506369a83ee9cd 100644
--- a/dbus/end_to_end_async_unittest.cc
+++ b/dbus/end_to_end_async_unittest.cc
@@ -32,8 +32,7 @@ const int kHugePayloadSize = 64 << 20; // 64 MB
// ExportedObject.
class EndToEndAsyncTest : public testing::Test {
public:
- EndToEndAsyncTest() {
- }
+ EndToEndAsyncTest() : on_disconnected_call_count_(0) {}
virtual void SetUp() {
// Make the main thread not to allow IO.
@@ -59,6 +58,8 @@ class EndToEndAsyncTest : public testing::Test {
bus_options.connection_type = dbus::Bus::PRIVATE;
bus_options.dbus_thread_message_loop_proxy =
dbus_thread_->message_loop_proxy();
+ bus_options.disconnected_callback =
+ base::Bind(&EndToEndAsyncTest::OnDisconnected, base::Unretained(this));
bus_ = new dbus::Bus(bus_options);
object_proxy_ = bus_->GetObjectProxy(
"org.chromium.TestService",
@@ -242,6 +243,12 @@ class EndToEndAsyncTest : public testing::Test {
message_loop_.Quit();
}
+ // Called when the connection with dbus-daemon is disconnected.
+ void OnDisconnected() {
+ message_loop_.Quit();
+ ++on_disconnected_call_count_;
+ }
+
// Wait for the hey signal to be received.
void WaitForTestSignal() {
// OnTestSignal() will quit the message loop.
@@ -260,6 +267,7 @@ class EndToEndAsyncTest : public testing::Test {
std::string test_signal_string_;
// Text message from "Test" signal delivered to root.
std::string root_test_signal_string_;
+ int on_disconnected_call_count_;
};
TEST_F(EndToEndAsyncTest, Echo) {
@@ -572,6 +580,15 @@ TEST_F(EndToEndAsyncTest, TestHugeSignal) {
ASSERT_EQ(kHugeMessage, test_signal_string_);
}
+TEST_F(EndToEndAsyncTest, DisconnectedSignal) {
+ bus_->PostTaskToDBusThread(FROM_HERE,
+ base::Bind(&dbus::Bus::ClosePrivateConnection,
+ base::Unretained(bus_.get())));
+ // OnDisconnected callback quits message loop.
+ message_loop_.Run();
+ EXPECT_EQ(1, on_disconnected_call_count_);
+}
+
class SignalReplacementTest : public EndToEndAsyncTest {
public:
SignalReplacementTest() {
« no previous file with comments | « dbus/bus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698