Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: dbus/message_unittest.cc

Issue 7686013: Add AppendArrayOfObjectPaths, which was missing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dbus/message.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "dbus/message.h" 5 #include "dbus/message.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 uint8* output_bytes = NULL; 168 uint8* output_bytes = NULL;
169 size_t length = 0; 169 size_t length = 0;
170 ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); 170 ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length));
171 ASSERT_FALSE(reader.HasMoreData()); 171 ASSERT_FALSE(reader.HasMoreData());
172 ASSERT_EQ(3U, length); 172 ASSERT_EQ(3U, length);
173 ASSERT_EQ(1, output_bytes[0]); 173 ASSERT_EQ(1, output_bytes[0]);
174 ASSERT_EQ(2, output_bytes[1]); 174 ASSERT_EQ(2, output_bytes[1]);
175 ASSERT_EQ(3, output_bytes[2]); 175 ASSERT_EQ(3, output_bytes[2]);
176 } 176 }
177 177
178 TEST(MessageTest, ArrayOfObjectPaths) {
179 dbus::Message message;
180 message.reset_raw_message(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL));
181 dbus::MessageWriter writer(&message);
182 std::vector<std::string> object_paths;
183 object_paths.push_back("/object/path/1");
184 object_paths.push_back("/object/path/2");
185 object_paths.push_back("/object/path/3");
186 writer.AppendArrayOfObjectPaths(object_paths);
187
188 dbus::MessageReader reader(&message);
189 std::vector<std::string> output_object_paths;
190 ASSERT_TRUE(reader.PopArrayOfObjectPaths(&output_object_paths));
191 ASSERT_FALSE(reader.HasMoreData());
192 ASSERT_EQ(3U, output_object_paths.size());
193 ASSERT_EQ("/object/path/1", output_object_paths[0]);
194 ASSERT_EQ("/object/path/2", output_object_paths[1]);
195 ASSERT_EQ("/object/path/3", output_object_paths[2]);
196 }
197
178 // Test that an array can be properly written and read. We only have this 198 // Test that an array can be properly written and read. We only have this
179 // test for array, as repeating this for other container types is too 199 // test for array, as repeating this for other container types is too
180 // redundant. 200 // redundant.
181 TEST(MessageTest, OpenArrayAndPopArray) { 201 TEST(MessageTest, OpenArrayAndPopArray) {
182 dbus::Message message; 202 dbus::Message message;
183 message.reset_raw_message(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL)); 203 message.reset_raw_message(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL));
184 dbus::MessageWriter writer(&message); 204 dbus::MessageWriter writer(&message);
185 dbus::MessageWriter array_writer(&message); 205 dbus::MessageWriter array_writer(&message);
186 writer.OpenArray("s", &array_writer); // Open an array of strings. 206 writer.OpenArray("s", &array_writer); // Open an array of strings.
187 array_writer.AppendString("foo"); 207 array_writer.AppendString("foo");
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 471
452 EXPECT_EQ("org.chromium.destination", message.GetDestination()); 472 EXPECT_EQ("org.chromium.destination", message.GetDestination());
453 EXPECT_EQ("/org/chromium/path", message.GetPath()); 473 EXPECT_EQ("/org/chromium/path", message.GetPath());
454 EXPECT_EQ("org.chromium.interface", message.GetInterface()); 474 EXPECT_EQ("org.chromium.interface", message.GetInterface());
455 EXPECT_EQ("member", message.GetMember()); 475 EXPECT_EQ("member", message.GetMember());
456 EXPECT_EQ("org.chromium.error", message.GetErrorName()); 476 EXPECT_EQ("org.chromium.error", message.GetErrorName());
457 EXPECT_EQ(":1.2", message.GetSender()); 477 EXPECT_EQ(":1.2", message.GetSender());
458 EXPECT_EQ(123U, message.GetSerial()); 478 EXPECT_EQ(123U, message.GetSerial());
459 EXPECT_EQ(456U, message.GetReplySerial()); 479 EXPECT_EQ(456U, message.GetReplySerial());
460 } 480 }
OLDNEW
« no previous file with comments | « dbus/message.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698