summaryrefslogtreecommitdiffstats
path: root/dbus/message_unittest.cc
diff options
context:
space:
mode:
authorrharrison@chromium.org <rharrison@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-09 18:14:08 +0000
committerrharrison@chromium.org <rharrison@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-09 18:14:08 +0000
commitc033c5087d504ce089ec51763292b11bc1c6850d (patch)
tree8016ffc595f4106afd4c9c950e920d88f7a6d0cf /dbus/message_unittest.cc
parentb23c3bce93b8749c5b8c9b37e8859f4dd66e7b36 (diff)
downloadchromium_src-c033c5087d504ce089ec51763292b11bc1c6850d.zip
chromium_src-c033c5087d504ce089ec51763292b11bc1c6850d.tar.gz
chromium_src-c033c5087d504ce089ec51763292b11bc1c6850d.tar.bz2
Adding support for sending/receiving proto bufs to dbus library.
This CL add in support to dbus wrapping classes to send and receive protocol buffers. They take in a generic MessageLite, which all protocol buffers inherit from. It will then serialize the buffer and send it out as an array of bytes. On receiving the array of bytes will be parsed back into a protocol buffer. The operations for doing this are very canned and these methods are designed to allow devs to skip writing boilerplate. The methods are just wrappers around the appopriate byte array methods. BUG=chromium:112127 TEST=Ran new unittests Review URL: http://codereview.chromium.org/9315006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121248 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/message_unittest.cc')
-rw-r--r--dbus/message_unittest.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/dbus/message_unittest.cc b/dbus/message_unittest.cc
index 7ef49fe..1e6d668 100644
--- a/dbus/message_unittest.cc
+++ b/dbus/message_unittest.cc
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "dbus/test_proto.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
// Test that a byte can be properly written and read. We only have this
@@ -226,6 +227,22 @@ TEST(MessageTest, ArrayOfObjectPaths) {
EXPECT_EQ("/object/path/3", output_object_paths[2]);
}
+TEST(MessageTest, ProtoBuf) {
+ scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty());
+ dbus::MessageWriter writer(message.get());
+ TestProto send_message;
+ send_message.set_text("testing");
+ send_message.set_number(123);
+ writer.AppendProtoAsArrayOfBytes(send_message);
+
+ dbus::MessageReader reader(message.get());
+ TestProto receive_message;
+ ASSERT_TRUE(reader.PopArrayOfBytesAsProto(&receive_message));
+ EXPECT_EQ(receive_message.text(), send_message.text());
+ EXPECT_EQ(receive_message.number(), send_message.number());
+}
+
+
// Test that an array can be properly written and read. We only have this
// test for array, as repeating this for other container types is too
// redundant.