diff options
author | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-15 16:44:40 +0000 |
---|---|---|
committer | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-15 16:44:40 +0000 |
commit | ea5451957df86623f9dd52ad2dd2c12c5ecd70a6 (patch) | |
tree | 8fa3aa300a73b7fd2372f40429ebdc87bcd198a1 /dbus/end_to_end_async_unittest.cc | |
parent | ce88a911017e862c1623c481e41e810330112647 (diff) | |
download | chromium_src-ea5451957df86623f9dd52ad2dd2c12c5ecd70a6.zip chromium_src-ea5451957df86623f9dd52ad2dd2c12c5ecd70a6.tar.gz chromium_src-ea5451957df86623f9dd52ad2dd2c12c5ecd70a6.tar.bz2 |
Supporting callback for Disconnected signal.
If the connection with dbus-daemon is closed, callback function set with
SetDisconnectedCallback will be called.
BUG=None
TEST=ran dbus_unittests
Review URL: https://chromiumcodereview.appspot.com/12224139
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/end_to_end_async_unittest.cc')
-rw-r--r-- | dbus/end_to_end_async_unittest.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/dbus/end_to_end_async_unittest.cc b/dbus/end_to_end_async_unittest.cc index 7715f7d..b91ea77 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() { |