summaryrefslogtreecommitdiffstats
path: root/dbus/end_to_end_async_unittest.cc
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-23 06:55:22 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-23 06:55:22 +0000
commitca72ff29277e39031e2b409e2a593b25d0066e8a (patch)
treebfadc8aeb37312310f8743ae4ff5e9a631c1c625 /dbus/end_to_end_async_unittest.cc
parentf9cb2108d32497ca7688db99f144e0dbe73537da (diff)
downloadchromium_src-ca72ff29277e39031e2b409e2a593b25d0066e8a.zip
chromium_src-ca72ff29277e39031e2b409e2a593b25d0066e8a.tar.gz
chromium_src-ca72ff29277e39031e2b409e2a593b25d0066e8a.tar.bz2
Change setters of dbus::Message to return false instead of aborting on errors
With this change, we can safely return error for invalid object path and service name. It still crashes on invalid method name and interface name if we use MethodCall::MethodCall for setting those parameters. BUG=128967 TEST=dbus_unittests Review URL: https://chromiumcodereview.appspot.com/10409065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/end_to_end_async_unittest.cc')
-rw-r--r--dbus/end_to_end_async_unittest.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/dbus/end_to_end_async_unittest.cc b/dbus/end_to_end_async_unittest.cc
index a4438e4..d5e278f 100644
--- a/dbus/end_to_end_async_unittest.cc
+++ b/dbus/end_to_end_async_unittest.cc
@@ -453,6 +453,44 @@ TEST_F(EndToEndAsyncTest, BrokenMethodWithErrorCallback) {
ASSERT_EQ(DBUS_ERROR_FAILED, error_names_[0]);
}
+TEST_F(EndToEndAsyncTest, InvalidObjectPath) {
+ // Trailing '/' is only allowed for the root path.
+ const dbus::ObjectPath invalid_object_path("/org/chromium/TestObject/");
+
+ // Replace object proxy with new one.
+ object_proxy_ = bus_->GetObjectProxy("org.chromium.TestService",
+ invalid_object_path);
+
+ dbus::MethodCall method_call("org.chromium.TestInterface", "Echo");
+
+ const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT;
+ CallMethodWithErrorCallback(&method_call, timeout_ms);
+ WaitForErrors(1);
+
+ // Should fail because of the invalid path.
+ ASSERT_TRUE(response_strings_.empty());
+ ASSERT_EQ("", error_names_[0]);
+}
+
+TEST_F(EndToEndAsyncTest, InvalidServiceName) {
+ // Bus name cannot contain '/'.
+ const std::string invalid_service_name = ":1/2";
+
+ // Replace object proxy with new one.
+ object_proxy_ = bus_->GetObjectProxy(
+ invalid_service_name, dbus::ObjectPath("org.chromium.TestObject"));
+
+ dbus::MethodCall method_call("org.chromium.TestInterface", "Echo");
+
+ const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT;
+ CallMethodWithErrorCallback(&method_call, timeout_ms);
+ WaitForErrors(1);
+
+ // Should fail because of the invalid bus name.
+ ASSERT_TRUE(response_strings_.empty());
+ ASSERT_EQ("", error_names_[0]);
+}
+
TEST_F(EndToEndAsyncTest, EmptyResponseCallback) {
const char* kHello = "hello";