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

Side by Side Diff: dbus/message_unittest.cc

Issue 1839943003: dbus changes: add SetGlobalOutputChannelRemix support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: additional size_t cast modification Created 4 years, 8 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
« 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 size_t length = 0; 241 size_t length = 0;
242 ASSERT_EQ("ay", reader.GetDataSignature()); 242 ASSERT_EQ("ay", reader.GetDataSignature());
243 ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); 243 ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length));
244 ASSERT_FALSE(reader.HasMoreData()); 244 ASSERT_FALSE(reader.HasMoreData());
245 ASSERT_EQ(3U, length); 245 ASSERT_EQ(3U, length);
246 EXPECT_EQ(1, output_bytes[0]); 246 EXPECT_EQ(1, output_bytes[0]);
247 EXPECT_EQ(2, output_bytes[1]); 247 EXPECT_EQ(2, output_bytes[1]);
248 EXPECT_EQ(3, output_bytes[2]); 248 EXPECT_EQ(3, output_bytes[2]);
249 } 249 }
250 250
251 TEST(MessageTest, ArrayOfDoubles) {
252 scoped_ptr<Response> message(Response::CreateEmpty());
253 MessageWriter writer(message.get());
254 std::vector<double> doubles;
255 doubles.push_back(0.2);
256 doubles.push_back(0.5);
257 doubles.push_back(1);
258 writer.AppendArrayOfDoubles(doubles.data(), doubles.size());
259
260 MessageReader reader(message.get());
261 const double* output_doubles = NULL;
262 size_t length = 0;
263 ASSERT_EQ("ad", reader.GetDataSignature());
264 ASSERT_TRUE(reader.PopArrayOfDoubles(&output_doubles, &length));
265 ASSERT_FALSE(reader.HasMoreData());
266 ASSERT_EQ(3U, length);
267 EXPECT_EQ(0.2, output_doubles[0]);
268 EXPECT_EQ(0.5, output_doubles[1]);
269 EXPECT_EQ(1, output_doubles[2]);
270 }
271
251 TEST(MessageTest, ArrayOfBytes_Empty) { 272 TEST(MessageTest, ArrayOfBytes_Empty) {
252 scoped_ptr<Response> message(Response::CreateEmpty()); 273 scoped_ptr<Response> message(Response::CreateEmpty());
253 MessageWriter writer(message.get()); 274 MessageWriter writer(message.get());
254 std::vector<uint8_t> bytes; 275 std::vector<uint8_t> bytes;
255 writer.AppendArrayOfBytes(bytes.data(), bytes.size()); 276 writer.AppendArrayOfBytes(bytes.data(), bytes.size());
256 277
257 MessageReader reader(message.get()); 278 MessageReader reader(message.get());
258 const uint8_t* output_bytes = NULL; 279 const uint8_t* output_bytes = NULL;
259 size_t length = 0; 280 size_t length = 0;
260 ASSERT_EQ("ay", reader.GetDataSignature()); 281 ASSERT_EQ("ay", reader.GetDataSignature());
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 684
664 ASSERT_EQ("message_type: MESSAGE_METHOD_RETURN\n" 685 ASSERT_EQ("message_type: MESSAGE_METHOD_RETURN\n"
665 "signature: s\n\n" 686 "signature: s\n\n"
666 "string \"oooooooooooooooooooooooooooooooooooooooooooooooo" 687 "string \"oooooooooooooooooooooooooooooooooooooooooooooooo"
667 "oooooooooooooooooooooooooooooooooooooooooooooooooooo... " 688 "oooooooooooooooooooooooooooooooooooooooooooooooooooo... "
668 "(1000 bytes in total)\"\n", 689 "(1000 bytes in total)\"\n",
669 message->ToString()); 690 message->ToString());
670 } 691 }
671 692
672 } // namespace dbus 693 } // namespace dbus
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