diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-20 01:07:17 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-20 01:07:17 +0000 |
commit | 12f9766f28712f8ec3755db4558dba4db5bd8a70 (patch) | |
tree | 6ab911b0b85b1851bef201f25825911d4a66849e /dbus/end_to_end_async_unittest.cc | |
parent | 940895b5308ace929396a87bd13cf0764f0c16e2 (diff) | |
download | chromium_src-12f9766f28712f8ec3755db4558dba4db5bd8a70.zip chromium_src-12f9766f28712f8ec3755db4558dba4db5bd8a70.tar.gz chromium_src-12f9766f28712f8ec3755db4558dba4db5bd8a70.tar.bz2 |
Rework TestService using asynchronos API of ExportedObject.
This change is to to exercise asynchronos API of ExportedObject.
The asynchronos API is implemented on top the synchronos API,
hence the synchronos API code is also covered.
Along the way, change EndToEndAsyncTest to use the D-Bus thread.
Simplified the test code per phajdan.jr's comments as well.
TEST=dbus_unittests
BUG=90036
Review URL: http://codereview.chromium.org/7671028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97540 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 | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/dbus/end_to_end_async_unittest.cc b/dbus/end_to_end_async_unittest.cc index c3689ad..3ce6b6d 100644 --- a/dbus/end_to_end_async_unittest.cc +++ b/dbus/end_to_end_async_unittest.cc @@ -29,18 +29,21 @@ class EndToEndAsyncTest : public testing::Test { // Make the main thread not to allow IO. base::ThreadRestrictions::SetIOAllowed(false); - // Start the test service; - test_service_.reset(new dbus::TestService); - test_service_->StartService(); - test_service_->WaitUntilServiceIsStarted(); - // Start the D-Bus thread. dbus_thread_.reset(new base::Thread("D-Bus Thread")); base::Thread::Options thread_options; thread_options.message_loop_type = MessageLoop::TYPE_IO; - dbus_thread_->StartWithOptions(thread_options); + ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); + + // Start the test service, using the D-Bus thread. + dbus::TestService::Options options; + options.dbus_thread = dbus_thread_.get(); + test_service_.reset(new dbus::TestService(options)); + ASSERT_TRUE(test_service_->StartService()); + ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); + ASSERT_TRUE(test_service_->HasDBusThread()); - // Create the client. + // Create the client, using the D-Bus thread. dbus::Bus::Options bus_options; bus_options.bus_type = dbus::Bus::SESSION; bus_options.connection_type = dbus::Bus::PRIVATE; @@ -48,6 +51,7 @@ class EndToEndAsyncTest : public testing::Test { bus_ = new dbus::Bus(bus_options); object_proxy_ = bus_->GetObjectProxy("org.chromium.TestService", "/org/chromium/TestObject"); + ASSERT_TRUE(bus_->HasDBusThread()); } void TearDown() { @@ -57,6 +61,10 @@ class EndToEndAsyncTest : public testing::Test { // mesage_loop_. message_loop_.Run(); + // Shut down the service. + test_service_->Shutdown(); + ASSERT_TRUE(test_service_->WaitUntilServiceIsShutdown()); + // Reset to the default. base::ThreadRestrictions::SetIOAllowed(true); @@ -160,8 +168,8 @@ TEST_F(EndToEndAsyncTest, Timeout) { dbus::MessageWriter writer(&method_call); writer.AppendString(kHello); - // Call the method with timeout smaller than TestService::kSlowEchoSleepMs. - const int timeout_ms = dbus::TestService::kSlowEchoSleepMs / 10; + // Call the method with timeout of 0ms. + const int timeout_ms = 0; CallMethod(&method_call, timeout_ms); WaitForResponses(1); |