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() { |