diff options
author | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-19 18:22:14 +0000 |
---|---|---|
committer | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-19 18:22:14 +0000 |
commit | 8bc83fd407b76025b411004554fb410789512fc4 (patch) | |
tree | 005f411f7aa09b324ae535af8eb7b5bc7fd9b031 /dbus/message_unittest.cc | |
parent | 9e0ce17c8308d897b7fadf7b1164c4c5234cfe98 (diff) | |
download | chromium_src-8bc83fd407b76025b411004554fb410789512fc4.zip chromium_src-8bc83fd407b76025b411004554fb410789512fc4.tar.gz chromium_src-8bc83fd407b76025b411004554fb410789512fc4.tar.bz2 |
Linux: add two new DBus client library utility functions, to be used by KWallet.
The new functions are AppendArrayOfStrings and PopArrayOfStrings, which have
self-explanatory names. Currently the KWallet code does this looping itself.
Review URL: http://codereview.chromium.org/7941009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101781 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/message_unittest.cc')
-rw-r--r-- | dbus/message_unittest.cc | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/dbus/message_unittest.cc b/dbus/message_unittest.cc index 473a6ef..29fe888 100644 --- a/dbus/message_unittest.cc +++ b/dbus/message_unittest.cc @@ -166,9 +166,30 @@ TEST(MessageTest, ArrayOfBytes) { ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); ASSERT_FALSE(reader.HasMoreData()); ASSERT_EQ(3U, length); - ASSERT_EQ(1, output_bytes[0]); - ASSERT_EQ(2, output_bytes[1]); - ASSERT_EQ(3, output_bytes[2]); + EXPECT_EQ(1, output_bytes[0]); + EXPECT_EQ(2, output_bytes[1]); + EXPECT_EQ(3, output_bytes[2]); +} + +TEST(MessageTest, ArrayOfStrings) { + scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty()); + dbus::MessageWriter writer(message.get()); + std::vector<std::string> strings; + strings.push_back("fee"); + strings.push_back("fie"); + strings.push_back("foe"); + strings.push_back("fum"); + writer.AppendArrayOfStrings(strings); + + dbus::MessageReader reader(message.get()); + std::vector<std::string> output_strings; + ASSERT_TRUE(reader.PopArrayOfStrings(&output_strings)); + ASSERT_FALSE(reader.HasMoreData()); + ASSERT_EQ(4U, output_strings.size()); + EXPECT_EQ("fee", output_strings[0]); + EXPECT_EQ("fie", output_strings[1]); + EXPECT_EQ("foe", output_strings[2]); + EXPECT_EQ("fum", output_strings[3]); } TEST(MessageTest, ArrayOfObjectPaths) { @@ -185,9 +206,9 @@ TEST(MessageTest, ArrayOfObjectPaths) { ASSERT_TRUE(reader.PopArrayOfObjectPaths(&output_object_paths)); ASSERT_FALSE(reader.HasMoreData()); ASSERT_EQ(3U, output_object_paths.size()); - ASSERT_EQ("/object/path/1", output_object_paths[0]); - ASSERT_EQ("/object/path/2", output_object_paths[1]); - ASSERT_EQ("/object/path/3", output_object_paths[2]); + EXPECT_EQ("/object/path/1", output_object_paths[0]); + EXPECT_EQ("/object/path/2", output_object_paths[1]); + EXPECT_EQ("/object/path/3", output_object_paths[2]); } // Test that an array can be properly written and read. We only have this |