| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mojo/edk/system/message_in_transit_test_utils.h" | |
| 6 | |
| 7 #include <stdint.h> | |
| 8 | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 namespace mojo { | |
| 12 namespace edk { | |
| 13 namespace test { | |
| 14 | |
| 15 scoped_ptr<MessageInTransit> MakeTestMessage(unsigned id) { | |
| 16 return make_scoped_ptr( | |
| 17 new MessageInTransit(MessageInTransit::Type::MESSAGE, | |
| 18 static_cast<uint32_t>(sizeof(id)), &id)); | |
| 19 } | |
| 20 | |
| 21 void VerifyTestMessage(const MessageInTransit* message, unsigned id) { | |
| 22 ASSERT_TRUE(message); | |
| 23 EXPECT_EQ(MessageInTransit::Type::MESSAGE, message->type()); | |
| 24 EXPECT_EQ(sizeof(id), message->num_bytes()); | |
| 25 EXPECT_EQ(id, *static_cast<const unsigned*>(message->bytes())); | |
| 26 } | |
| 27 | |
| 28 bool IsTestMessage(MessageInTransit* message, unsigned* id) { | |
| 29 if (message->type() != MessageInTransit::Type::MESSAGE || | |
| 30 message->num_bytes() != sizeof(*id)) | |
| 31 return false; | |
| 32 | |
| 33 *id = *static_cast<const unsigned*>(message->bytes()); | |
| 34 return true; | |
| 35 } | |
| 36 | |
| 37 } // namespace test | |
| 38 } // namespace edk | |
| 39 } // namespace mojo | |
| OLD | NEW |