| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "third_party/mojo/src/mojo/edk/system/message_in_transit_test_utils.h" | 5 #include "mojo/edk/system/message_in_transit_test_utils.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace mojo { | 9 namespace mojo { |
| 10 namespace system { | 10 namespace edk { |
| 11 namespace test { | 11 namespace test { |
| 12 | 12 |
| 13 scoped_ptr<MessageInTransit> MakeTestMessage(unsigned id) { | 13 scoped_ptr<MessageInTransit> MakeTestMessage(unsigned id) { |
| 14 return make_scoped_ptr( | 14 return make_scoped_ptr( |
| 15 new MessageInTransit(MessageInTransit::Type::ENDPOINT_CLIENT, | 15 new MessageInTransit(MessageInTransit::Type::MESSAGE, |
| 16 MessageInTransit::Subtype::ENDPOINT_CLIENT_DATA, | |
| 17 static_cast<uint32_t>(sizeof(id)), &id)); | 16 static_cast<uint32_t>(sizeof(id)), &id)); |
| 18 } | 17 } |
| 19 | 18 |
| 20 void VerifyTestMessage(const MessageInTransit* message, unsigned id) { | 19 void VerifyTestMessage(const MessageInTransit* message, unsigned id) { |
| 21 ASSERT_TRUE(message); | 20 ASSERT_TRUE(message); |
| 22 EXPECT_EQ(MessageInTransit::Type::ENDPOINT_CLIENT, message->type()); | 21 EXPECT_EQ(MessageInTransit::Type::MESSAGE, message->type()); |
| 23 EXPECT_EQ(MessageInTransit::Subtype::ENDPOINT_CLIENT_DATA, | |
| 24 message->subtype()); | |
| 25 EXPECT_EQ(sizeof(id), message->num_bytes()); | 22 EXPECT_EQ(sizeof(id), message->num_bytes()); |
| 26 EXPECT_EQ(id, *static_cast<const unsigned*>(message->bytes())); | 23 EXPECT_EQ(id, *static_cast<const unsigned*>(message->bytes())); |
| 27 } | 24 } |
| 28 | 25 |
| 29 bool IsTestMessage(MessageInTransit* message, unsigned* id) { | 26 bool IsTestMessage(MessageInTransit* message, unsigned* id) { |
| 30 if (message->type() != MessageInTransit::Type::ENDPOINT_CLIENT || | 27 if (message->type() != MessageInTransit::Type::MESSAGE || |
| 31 message->subtype() != MessageInTransit::Subtype::ENDPOINT_CLIENT_DATA || | |
| 32 message->num_bytes() != sizeof(*id)) | 28 message->num_bytes() != sizeof(*id)) |
| 33 return false; | 29 return false; |
| 34 | 30 |
| 35 *id = *static_cast<const unsigned*>(message->bytes()); | 31 *id = *static_cast<const unsigned*>(message->bytes()); |
| 36 return true; | 32 return true; |
| 37 } | 33 } |
| 38 | 34 |
| 39 } // namespace test | 35 } // namespace test |
| 40 } // namespace system | 36 } // namespace edk |
| 41 } // namespace mojo | 37 } // namespace mojo |
| OLD | NEW |