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

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

Issue 1430593005: EDK: Remove (direct) dependencies of //mojo/edk/system on //base/test. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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/BUILD.gn ('k') | mojo/edk/system/endpoint_relayer_unittest.cc » ('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> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "base/test/test_timeouts.h" 11 #include "base/time/time.h"
12 #include "mojo/edk/system/channel_test_base.h" 12 #include "mojo/edk/system/channel_test_base.h"
13 #include "mojo/edk/system/message_in_transit_queue.h" 13 #include "mojo/edk/system/message_in_transit_queue.h"
14 #include "mojo/edk/system/message_in_transit_test_utils.h" 14 #include "mojo/edk/system/message_in_transit_test_utils.h"
15 #include "mojo/edk/system/ref_ptr.h" 15 #include "mojo/edk/system/ref_ptr.h"
16 #include "mojo/edk/system/test/timeouts.h"
16 #include "mojo/edk/system/test_channel_endpoint_client.h" 17 #include "mojo/edk/system/test_channel_endpoint_client.h"
17 #include "mojo/public/cpp/system/macros.h" 18 #include "mojo/public/cpp/system/macros.h"
18 19
19 namespace mojo { 20 namespace mojo {
20 namespace system { 21 namespace system {
21 namespace { 22 namespace {
22 23
23 class ChannelEndpointTest : public test::ChannelTestBase { 24 class ChannelEndpointTest : public test::ChannelTestBase {
24 public: 25 public:
25 ChannelEndpointTest() {} 26 ChannelEndpointTest() {}
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // Check that our test utility works (at least in one direction). 70 // Check that our test utility works (at least in one direction).
70 test::VerifyTestMessage(send_message.get(), message_id); 71 test::VerifyTestMessage(send_message.get(), message_id);
71 72
72 // Event shouldn't be signalled yet. 73 // Event shouldn't be signalled yet.
73 EXPECT_FALSE(read_event.IsSignaled()); 74 EXPECT_FALSE(read_event.IsSignaled());
74 75
75 // Send it through channel/endpoint 1. 76 // Send it through channel/endpoint 1.
76 EXPECT_TRUE(endpoint1->EnqueueMessage(std::move(send_message))); 77 EXPECT_TRUE(endpoint1->EnqueueMessage(std::move(send_message)));
77 78
78 // Wait to receive it. 79 // Wait to receive it.
79 EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout())); 80 EXPECT_TRUE(read_event.TimedWait(base::TimeDelta::FromMicroseconds(
81 static_cast<int64_t>(test::TinyTimeout()))));
80 client0->SetReadEvent(nullptr); 82 client0->SetReadEvent(nullptr);
81 83
82 // Check the received message. 84 // Check the received message.
83 ASSERT_EQ(1u, client0->NumMessages()); 85 ASSERT_EQ(1u, client0->NumMessages());
84 std::unique_ptr<MessageInTransit> read_message = client0->PopMessage(); 86 std::unique_ptr<MessageInTransit> read_message = client0->PopMessage();
85 ASSERT_TRUE(read_message); 87 ASSERT_TRUE(read_message);
86 test::VerifyTestMessage(read_message.get(), message_id); 88 test::VerifyTestMessage(read_message.get(), message_id);
87 } 89 }
88 90
89 // Checks that prequeued messages and messages sent at various stages later on 91 // Checks that prequeued messages and messages sent at various stages later on
(...skipping 19 matching lines...) Expand all
109 111
110 channel(1)->SetBootstrapEndpoint(endpoint1.Clone()); 112 channel(1)->SetBootstrapEndpoint(endpoint1.Clone());
111 113
112 EXPECT_TRUE(endpoint1->EnqueueMessage(test::MakeTestMessage(5))); 114 EXPECT_TRUE(endpoint1->EnqueueMessage(test::MakeTestMessage(5)));
113 EXPECT_TRUE(endpoint1->EnqueueMessage(test::MakeTestMessage(6))); 115 EXPECT_TRUE(endpoint1->EnqueueMessage(test::MakeTestMessage(6)));
114 116
115 // Wait for the messages. 117 // Wait for the messages.
116 base::WaitableEvent read_event(true, false); 118 base::WaitableEvent read_event(true, false);
117 client0->SetReadEvent(&read_event); 119 client0->SetReadEvent(&read_event);
118 for (size_t i = 0; client0->NumMessages() < 6 && i < 6; i++) { 120 for (size_t i = 0; client0->NumMessages() < 6 && i < 6; i++) {
119 EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout())); 121 EXPECT_TRUE(read_event.TimedWait(base::TimeDelta::FromMicroseconds(
122 static_cast<int64_t>(test::TinyTimeout()))));
120 read_event.Reset(); 123 read_event.Reset();
121 } 124 }
122 client0->SetReadEvent(nullptr); 125 client0->SetReadEvent(nullptr);
123 126
124 // Check the received messages. 127 // Check the received messages.
125 ASSERT_EQ(6u, client0->NumMessages()); 128 ASSERT_EQ(6u, client0->NumMessages());
126 for (unsigned message_id = 1; message_id <= 6; message_id++) { 129 for (unsigned message_id = 1; message_id <= 6; message_id++) {
127 std::unique_ptr<MessageInTransit> read_message = client0->PopMessage(); 130 std::unique_ptr<MessageInTransit> read_message = client0->PopMessage();
128 ASSERT_TRUE(read_message); 131 ASSERT_TRUE(read_message);
129 test::VerifyTestMessage(read_message.get(), message_id); 132 test::VerifyTestMessage(read_message.get(), message_id);
130 } 133 }
131 } 134 }
132 135
133 } // namespace 136 } // namespace
134 } // namespace system 137 } // namespace system
135 } // namespace mojo 138 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/BUILD.gn ('k') | mojo/edk/system/endpoint_relayer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698