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

Side by Side Diff: mojo/edk/system/channel_endpoint_unittest.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/channel_endpoint_client.h ('k') | mojo/edk/system/core.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/channel_endpoint.h" 5 #include "mojo/edk/system/channel_endpoint.h"
6 6
7 #include <memory>
8 #include <utility>
9
7 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
8 #include "base/test/test_timeouts.h" 11 #include "base/test/test_timeouts.h"
9 #include "mojo/edk/system/channel_test_base.h" 12 #include "mojo/edk/system/channel_test_base.h"
10 #include "mojo/edk/system/message_in_transit_queue.h" 13 #include "mojo/edk/system/message_in_transit_queue.h"
11 #include "mojo/edk/system/message_in_transit_test_utils.h" 14 #include "mojo/edk/system/message_in_transit_test_utils.h"
12 #include "mojo/edk/system/test_channel_endpoint_client.h" 15 #include "mojo/edk/system/test_channel_endpoint_client.h"
13 #include "mojo/public/cpp/system/macros.h" 16 #include "mojo/public/cpp/system/macros.h"
14 17
15 namespace mojo { 18 namespace mojo {
16 namespace system { 19 namespace system {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 new ChannelEndpoint(client1.get(), 1)); 60 new ChannelEndpoint(client1.get(), 1));
58 client1->Init(1, endpoint1.get()); 61 client1->Init(1, endpoint1.get());
59 channel(1)->SetBootstrapEndpoint(endpoint1); 62 channel(1)->SetBootstrapEndpoint(endpoint1);
60 63
61 // We'll receive a message on channel/client 0. 64 // We'll receive a message on channel/client 0.
62 base::WaitableEvent read_event(true, false); 65 base::WaitableEvent read_event(true, false);
63 client0->SetReadEvent(&read_event); 66 client0->SetReadEvent(&read_event);
64 67
65 // Make a test message. 68 // Make a test message.
66 unsigned message_id = 0x12345678; 69 unsigned message_id = 0x12345678;
67 scoped_ptr<MessageInTransit> send_message = test::MakeTestMessage(message_id); 70 std::unique_ptr<MessageInTransit> send_message =
71 test::MakeTestMessage(message_id);
68 // Check that our test utility works (at least in one direction). 72 // Check that our test utility works (at least in one direction).
69 test::VerifyTestMessage(send_message.get(), message_id); 73 test::VerifyTestMessage(send_message.get(), message_id);
70 74
71 // Event shouldn't be signalled yet. 75 // Event shouldn't be signalled yet.
72 EXPECT_FALSE(read_event.IsSignaled()); 76 EXPECT_FALSE(read_event.IsSignaled());
73 77
74 // Send it through channel/endpoint 1. 78 // Send it through channel/endpoint 1.
75 EXPECT_TRUE(endpoint1->EnqueueMessage(send_message.Pass())); 79 EXPECT_TRUE(endpoint1->EnqueueMessage(std::move(send_message)));
76 80
77 // Wait to receive it. 81 // Wait to receive it.
78 EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout())); 82 EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout()));
79 client0->SetReadEvent(nullptr); 83 client0->SetReadEvent(nullptr);
80 84
81 // Check the received message. 85 // Check the received message.
82 ASSERT_EQ(1u, client0->NumMessages()); 86 ASSERT_EQ(1u, client0->NumMessages());
83 scoped_ptr<MessageInTransit> read_message = client0->PopMessage(); 87 std::unique_ptr<MessageInTransit> read_message = client0->PopMessage();
84 ASSERT_TRUE(read_message); 88 ASSERT_TRUE(read_message);
85 test::VerifyTestMessage(read_message.get(), message_id); 89 test::VerifyTestMessage(read_message.get(), message_id);
86 } 90 }
87 91
88 // Checks that prequeued messages and messages sent at various stages later on 92 // Checks that prequeued messages and messages sent at various stages later on
89 // are all sent/received (and in the correct order). (Note: Due to the way 93 // are all sent/received (and in the correct order). (Note: Due to the way
90 // bootstrap endpoints work, the receiving side has to be set up first.) 94 // bootstrap endpoints work, the receiving side has to be set up first.)
91 TEST_F(ChannelEndpointTest, Prequeued) { 95 TEST_F(ChannelEndpointTest, Prequeued) {
92 scoped_refptr<test::TestChannelEndpointClient> client0( 96 scoped_refptr<test::TestChannelEndpointClient> client0(
93 new test::TestChannelEndpointClient()); 97 new test::TestChannelEndpointClient());
(...skipping 25 matching lines...) Expand all
119 client0->SetReadEvent(&read_event); 123 client0->SetReadEvent(&read_event);
120 for (size_t i = 0; client0->NumMessages() < 6 && i < 6; i++) { 124 for (size_t i = 0; client0->NumMessages() < 6 && i < 6; i++) {
121 EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout())); 125 EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout()));
122 read_event.Reset(); 126 read_event.Reset();
123 } 127 }
124 client0->SetReadEvent(nullptr); 128 client0->SetReadEvent(nullptr);
125 129
126 // Check the received messages. 130 // Check the received messages.
127 ASSERT_EQ(6u, client0->NumMessages()); 131 ASSERT_EQ(6u, client0->NumMessages());
128 for (unsigned message_id = 1; message_id <= 6; message_id++) { 132 for (unsigned message_id = 1; message_id <= 6; message_id++) {
129 scoped_ptr<MessageInTransit> read_message = client0->PopMessage(); 133 std::unique_ptr<MessageInTransit> read_message = client0->PopMessage();
130 ASSERT_TRUE(read_message); 134 ASSERT_TRUE(read_message);
131 test::VerifyTestMessage(read_message.get(), message_id); 135 test::VerifyTestMessage(read_message.get(), message_id);
132 } 136 }
133 } 137 }
134 138
135 } // namespace 139 } // namespace
136 } // namespace system 140 } // namespace system
137 } // namespace mojo 141 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/channel_endpoint_client.h ('k') | mojo/edk/system/core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698