diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-24 03:32:06 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-24 03:32:06 +0000 |
commit | 06ead8788ef8d9ea7e5db736d563a7fb25df059d (patch) | |
tree | 4ddbcc90d432a750f0458b63f2e7f1074d405e48 /dbus/end_to_end_sync_unittest.cc | |
parent | 313bbf5ef2c0a1c428e3d92847c1b4b665b71706 (diff) | |
download | chromium_src-06ead8788ef8d9ea7e5db736d563a7fb25df059d.zip chromium_src-06ead8788ef8d9ea7e5db736d563a7fb25df059d.tar.gz chromium_src-06ead8788ef8d9ea7e5db736d563a7fb25df059d.tar.bz2 |
Fix design shortcomings in Message classes.
- Prohibit to instantiate Message class.
Rationale: this is not corresponding to any D-Bus message types.
- Get rid of Message::reset_raw_message()
Rationale: this was breaking encapsulation. For instance, It was possible
to inject a DBUS_MESSAGE_TYPE_ERROR raw message to a MethodCall message,
which should not be allowed.
- Prohibit to instantiate Response/ErrorResponse with NULL raw message.
Rationale: Message objects should be backed up by valid raw messages.
- Change Object::CallMethodAndBlock() to return Response*.
Rationale: the original API requred a Response object with raw_message_ set
to NULL, which we no longer allow.
- Add message_type header to ToString().
BUG=90036
TEST=dbus_unittests
Review URL: http://codereview.chromium.org/7709009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97983 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/end_to_end_sync_unittest.cc')
-rw-r--r-- | dbus/end_to_end_sync_unittest.cc | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/dbus/end_to_end_sync_unittest.cc b/dbus/end_to_end_sync_unittest.cc index 704845e..fe0489a 100644 --- a/dbus/end_to_end_sync_unittest.cc +++ b/dbus/end_to_end_sync_unittest.cc @@ -58,14 +58,13 @@ TEST_F(EndToEndSyncTest, Echo) { writer.AppendString(kHello); // Call the method. - dbus::Response response; const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; - const bool success = - object_proxy_->CallMethodAndBlock(&method_call, timeout_ms, &response); - ASSERT_TRUE(success); + scoped_ptr<dbus::Response> response( + object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); + ASSERT_TRUE(response.get()); // Check the response. kHello should be echoed back. - dbus::MessageReader reader(&response); + dbus::MessageReader reader(response.get()); std::string returned_message; ASSERT_TRUE(reader.PopString(&returned_message)); EXPECT_EQ(kHello, returned_message); @@ -80,30 +79,27 @@ TEST_F(EndToEndSyncTest, Timeout) { writer.AppendString(kHello); // Call the method with timeout of 0ms. - dbus::Response response; const int timeout_ms = 0; - const bool success = - object_proxy_->CallMethodAndBlock(&method_call, timeout_ms, &response); + scoped_ptr<dbus::Response> response( + object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); // Should fail because of timeout. - ASSERT_FALSE(success); + ASSERT_FALSE(response.get()); } TEST_F(EndToEndSyncTest, NonexistentMethod) { dbus::MethodCall method_call("org.chromium.TestInterface", "Nonexistent"); - dbus::Response response; const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; - const bool success = - object_proxy_->CallMethodAndBlock(&method_call, timeout_ms, &response); - ASSERT_FALSE(success); + scoped_ptr<dbus::Response> response( + object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); + ASSERT_FALSE(response.get()); } TEST_F(EndToEndSyncTest, BrokenMethod) { dbus::MethodCall method_call("org.chromium.TestInterface", "BrokenMethod"); - dbus::Response response; const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; - const bool success = - object_proxy_->CallMethodAndBlock(&method_call, timeout_ms, &response); - ASSERT_FALSE(success); + scoped_ptr<dbus::Response> response( + object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); + ASSERT_FALSE(response.get()); } |