OLD | NEW |
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 uint8* output_bytes = NULL; | 164 uint8* output_bytes = NULL; |
165 size_t length = 0; | 165 size_t length = 0; |
166 ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); | 166 ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); |
167 ASSERT_FALSE(reader.HasMoreData()); | 167 ASSERT_FALSE(reader.HasMoreData()); |
168 ASSERT_EQ(3U, length); | 168 ASSERT_EQ(3U, length); |
169 EXPECT_EQ(1, output_bytes[0]); | 169 EXPECT_EQ(1, output_bytes[0]); |
170 EXPECT_EQ(2, output_bytes[1]); | 170 EXPECT_EQ(2, output_bytes[1]); |
171 EXPECT_EQ(3, output_bytes[2]); | 171 EXPECT_EQ(3, output_bytes[2]); |
172 } | 172 } |
173 | 173 |
| 174 TEST(MessageTest, ArrayOfBytes_Empty) { |
| 175 scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty()); |
| 176 dbus::MessageWriter writer(message.get()); |
| 177 std::vector<uint8> bytes; |
| 178 writer.AppendArrayOfBytes(bytes.data(), bytes.size()); |
| 179 |
| 180 dbus::MessageReader reader(message.get()); |
| 181 uint8* output_bytes = NULL; |
| 182 size_t length = 0; |
| 183 ASSERT_TRUE(reader.PopArrayOfBytes(&output_bytes, &length)); |
| 184 ASSERT_FALSE(reader.HasMoreData()); |
| 185 ASSERT_EQ(0U, length); |
| 186 EXPECT_EQ(NULL, output_bytes); |
| 187 } |
| 188 |
174 TEST(MessageTest, ArrayOfStrings) { | 189 TEST(MessageTest, ArrayOfStrings) { |
175 scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty()); | 190 scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty()); |
176 dbus::MessageWriter writer(message.get()); | 191 dbus::MessageWriter writer(message.get()); |
177 std::vector<std::string> strings; | 192 std::vector<std::string> strings; |
178 strings.push_back("fee"); | 193 strings.push_back("fee"); |
179 strings.push_back("fie"); | 194 strings.push_back("fie"); |
180 strings.push_back("foe"); | 195 strings.push_back("foe"); |
181 strings.push_back("fum"); | 196 strings.push_back("fum"); |
182 writer.AppendArrayOfStrings(strings); | 197 writer.AppendArrayOfStrings(strings); |
183 | 198 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 | 515 |
501 EXPECT_EQ("org.chromium.destination", message->GetDestination()); | 516 EXPECT_EQ("org.chromium.destination", message->GetDestination()); |
502 EXPECT_EQ("/org/chromium/path", message->GetPath()); | 517 EXPECT_EQ("/org/chromium/path", message->GetPath()); |
503 EXPECT_EQ("org.chromium.interface", message->GetInterface()); | 518 EXPECT_EQ("org.chromium.interface", message->GetInterface()); |
504 EXPECT_EQ("member", message->GetMember()); | 519 EXPECT_EQ("member", message->GetMember()); |
505 EXPECT_EQ("org.chromium.error", message->GetErrorName()); | 520 EXPECT_EQ("org.chromium.error", message->GetErrorName()); |
506 EXPECT_EQ(":1.2", message->GetSender()); | 521 EXPECT_EQ(":1.2", message->GetSender()); |
507 EXPECT_EQ(123U, message->GetSerial()); | 522 EXPECT_EQ(123U, message->GetSerial()); |
508 EXPECT_EQ(456U, message->GetReplySerial()); | 523 EXPECT_EQ(456U, message->GetReplySerial()); |
509 } | 524 } |
OLD | NEW |