OLD | NEW |
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 "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 "base/posix/eintr_wrapper.h" | 10 #include "base/posix/eintr_wrapper.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 TEST(MessageTest, ArrayOfBytes) { | 201 TEST(MessageTest, ArrayOfBytes) { |
202 scoped_ptr<Response> message(Response::CreateEmpty()); | 202 scoped_ptr<Response> message(Response::CreateEmpty()); |
203 MessageWriter writer(message.get()); | 203 MessageWriter writer(message.get()); |
204 std::vector<uint8> bytes; | 204 std::vector<uint8> bytes; |
205 bytes.push_back(1); | 205 bytes.push_back(1); |
206 bytes.push_back(2); | 206 bytes.push_back(2); |
207 bytes.push_back(3); | 207 bytes.push_back(3); |
208 writer.AppendArrayOfBytes(bytes.data(), bytes.size()); | 208 writer.AppendArrayOfBytes(bytes.data(), bytes.size()); |
209 | 209 |
210 MessageReader reader(message.get()); | 210 MessageReader reader(message.get()); |
211 uint8* output_bytes = NULL; | 211 const uint8* output_bytes = NULL; |
212 size_t length = 0; | 212 size_t length = 0; |
213 ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); | 213 ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); |
214 ASSERT_FALSE(reader.HasMoreData()); | 214 ASSERT_FALSE(reader.HasMoreData()); |
215 ASSERT_EQ(3U, length); | 215 ASSERT_EQ(3U, length); |
216 EXPECT_EQ(1, output_bytes[0]); | 216 EXPECT_EQ(1, output_bytes[0]); |
217 EXPECT_EQ(2, output_bytes[1]); | 217 EXPECT_EQ(2, output_bytes[1]); |
218 EXPECT_EQ(3, output_bytes[2]); | 218 EXPECT_EQ(3, output_bytes[2]); |
219 } | 219 } |
220 | 220 |
221 TEST(MessageTest, ArrayOfBytes_Empty) { | 221 TEST(MessageTest, ArrayOfBytes_Empty) { |
222 scoped_ptr<Response> message(Response::CreateEmpty()); | 222 scoped_ptr<Response> message(Response::CreateEmpty()); |
223 MessageWriter writer(message.get()); | 223 MessageWriter writer(message.get()); |
224 std::vector<uint8> bytes; | 224 std::vector<uint8> bytes; |
225 writer.AppendArrayOfBytes(bytes.data(), bytes.size()); | 225 writer.AppendArrayOfBytes(bytes.data(), bytes.size()); |
226 | 226 |
227 MessageReader reader(message.get()); | 227 MessageReader reader(message.get()); |
228 uint8* output_bytes = NULL; | 228 const uint8* output_bytes = NULL; |
229 size_t length = 0; | 229 size_t length = 0; |
230 ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); | 230 ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); |
231 ASSERT_FALSE(reader.HasMoreData()); | 231 ASSERT_FALSE(reader.HasMoreData()); |
232 ASSERT_EQ(0U, length); | 232 ASSERT_EQ(0U, length); |
233 EXPECT_EQ(NULL, output_bytes); | 233 EXPECT_EQ(NULL, output_bytes); |
234 } | 234 } |
235 | 235 |
236 TEST(MessageTest, ArrayOfStrings) { | 236 TEST(MessageTest, ArrayOfStrings) { |
237 scoped_ptr<Response> message(Response::CreateEmpty()); | 237 scoped_ptr<Response> message(Response::CreateEmpty()); |
238 MessageWriter writer(message.get()); | 238 MessageWriter writer(message.get()); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 | 623 |
624 ASSERT_EQ("message_type: MESSAGE_METHOD_RETURN\n" | 624 ASSERT_EQ("message_type: MESSAGE_METHOD_RETURN\n" |
625 "signature: s\n\n" | 625 "signature: s\n\n" |
626 "string \"oooooooooooooooooooooooooooooooooooooooooooooooo" | 626 "string \"oooooooooooooooooooooooooooooooooooooooooooooooo" |
627 "oooooooooooooooooooooooooooooooooooooooooooooooooooo... " | 627 "oooooooooooooooooooooooooooooooooooooooooooooooooooo... " |
628 "(1000 bytes in total)\"\n", | 628 "(1000 bytes in total)\"\n", |
629 message->ToString()); | 629 message->ToString()); |
630 } | 630 } |
631 | 631 |
632 } // namespace dbus | 632 } // namespace dbus |
OLD | NEW |