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

Side by Side Diff: mojo/edk/system/message_in_transit_test_utils.cc

Issue 1353683005: EDK: Convert remaining scoped_ptr -> std::unique_ptr in //mojo/edk/system. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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 | « mojo/edk/system/message_in_transit_test_utils.h ('k') | mojo/edk/system/message_pipe.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "mojo/edk/system/message_in_transit_test_utils.h" 5 #include "mojo/edk/system/message_in_transit_test_utils.h"
6 6
7 #include "mojo/edk/util/make_unique.h"
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 9
9 namespace mojo { 10 namespace mojo {
10 namespace system { 11 namespace system {
11 namespace test { 12 namespace test {
12 13
13 scoped_ptr<MessageInTransit> MakeTestMessage(unsigned id) { 14 std::unique_ptr<MessageInTransit> MakeTestMessage(unsigned id) {
14 return make_scoped_ptr( 15 return util::MakeUnique<MessageInTransit>(
15 new MessageInTransit(MessageInTransit::Type::ENDPOINT_CLIENT, 16 MessageInTransit::Type::ENDPOINT_CLIENT,
16 MessageInTransit::Subtype::ENDPOINT_CLIENT_DATA, 17 MessageInTransit::Subtype::ENDPOINT_CLIENT_DATA,
17 static_cast<uint32_t>(sizeof(id)), &id)); 18 static_cast<uint32_t>(sizeof(id)), &id);
18 } 19 }
19 20
20 void VerifyTestMessage(const MessageInTransit* message, unsigned id) { 21 void VerifyTestMessage(const MessageInTransit* message, unsigned id) {
21 ASSERT_TRUE(message); 22 ASSERT_TRUE(message);
22 EXPECT_EQ(MessageInTransit::Type::ENDPOINT_CLIENT, message->type()); 23 EXPECT_EQ(MessageInTransit::Type::ENDPOINT_CLIENT, message->type());
23 EXPECT_EQ(MessageInTransit::Subtype::ENDPOINT_CLIENT_DATA, 24 EXPECT_EQ(MessageInTransit::Subtype::ENDPOINT_CLIENT_DATA,
24 message->subtype()); 25 message->subtype());
25 EXPECT_EQ(sizeof(id), message->num_bytes()); 26 EXPECT_EQ(sizeof(id), message->num_bytes());
26 EXPECT_EQ(id, *static_cast<const unsigned*>(message->bytes())); 27 EXPECT_EQ(id, *static_cast<const unsigned*>(message->bytes()));
27 } 28 }
28 29
29 bool IsTestMessage(MessageInTransit* message, unsigned* id) { 30 bool IsTestMessage(MessageInTransit* message, unsigned* id) {
30 if (message->type() != MessageInTransit::Type::ENDPOINT_CLIENT || 31 if (message->type() != MessageInTransit::Type::ENDPOINT_CLIENT ||
31 message->subtype() != MessageInTransit::Subtype::ENDPOINT_CLIENT_DATA || 32 message->subtype() != MessageInTransit::Subtype::ENDPOINT_CLIENT_DATA ||
32 message->num_bytes() != sizeof(*id)) 33 message->num_bytes() != sizeof(*id))
33 return false; 34 return false;
34 35
35 *id = *static_cast<const unsigned*>(message->bytes()); 36 *id = *static_cast<const unsigned*>(message->bytes());
36 return true; 37 return true;
37 } 38 }
38 39
39 } // namespace test 40 } // namespace test
40 } // namespace system 41 } // namespace system
41 } // namespace mojo 42 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/message_in_transit_test_utils.h ('k') | mojo/edk/system/message_pipe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698