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

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

Issue 799113004: Update mojo sdk to rev 59145288bae55b0fce4276b017df6a1117bcf00f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add mojo's ply to checklicenses whitelist Created 6 years 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.cc ('k') | mojo/edk/system/incoming_endpoint.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.h" 5 #include "mojo/edk/system/channel.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/test/test_io_thread.h" 10 #include "base/test/test_io_thread.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 FROM_HERE, 192 FROM_HERE,
193 base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this))); 193 base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this)));
194 EXPECT_EQ(TRISTATE_TRUE, init_result()); 194 EXPECT_EQ(TRISTATE_TRUE, init_result());
195 195
196 scoped_refptr<ChannelEndpoint> channel_endpoint; 196 scoped_refptr<ChannelEndpoint> channel_endpoint;
197 scoped_refptr<MessagePipe> mp( 197 scoped_refptr<MessagePipe> mp(
198 MessagePipe::CreateLocalProxy(&channel_endpoint)); 198 MessagePipe::CreateLocalProxy(&channel_endpoint));
199 199
200 mp->Close(0); 200 mp->Close(0);
201 201
202 channel()->AttachAndRunEndpoint(channel_endpoint, true); 202 channel()->SetBootstrapEndpoint(channel_endpoint);
203 203
204 io_thread()->PostTaskAndWait( 204 io_thread()->PostTaskAndWait(
205 FROM_HERE, base::Bind(&ChannelTest::ShutdownChannelOnIOThread, 205 FROM_HERE, base::Bind(&ChannelTest::ShutdownChannelOnIOThread,
206 base::Unretained(this))); 206 base::Unretained(this)));
207 207
208 EXPECT_TRUE(channel()->HasOneRef()); 208 EXPECT_TRUE(channel()->HasOneRef());
209 } 209 }
210 210
211 // ChannelTest.ShutdownAfterAttachAndRun --------------------------------------- 211 // ChannelTest.ShutdownAfterAttachAndRun ---------------------------------------
212 212
213 TEST_F(ChannelTest, ShutdownAfterAttach) { 213 TEST_F(ChannelTest, ShutdownAfterAttach) {
214 io_thread()->PostTaskAndWait(FROM_HERE, 214 io_thread()->PostTaskAndWait(FROM_HERE,
215 base::Bind(&ChannelTest::CreateChannelOnIOThread, 215 base::Bind(&ChannelTest::CreateChannelOnIOThread,
216 base::Unretained(this))); 216 base::Unretained(this)));
217 ASSERT_TRUE(channel()); 217 ASSERT_TRUE(channel());
218 218
219 io_thread()->PostTaskAndWait( 219 io_thread()->PostTaskAndWait(
220 FROM_HERE, 220 FROM_HERE,
221 base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this))); 221 base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this)));
222 EXPECT_EQ(TRISTATE_TRUE, init_result()); 222 EXPECT_EQ(TRISTATE_TRUE, init_result());
223 223
224 scoped_refptr<ChannelEndpoint> channel_endpoint; 224 scoped_refptr<ChannelEndpoint> channel_endpoint;
225 scoped_refptr<MessagePipe> mp( 225 scoped_refptr<MessagePipe> mp(
226 MessagePipe::CreateLocalProxy(&channel_endpoint)); 226 MessagePipe::CreateLocalProxy(&channel_endpoint));
227 227
228 channel()->AttachAndRunEndpoint(channel_endpoint, true); 228 channel()->SetBootstrapEndpoint(channel_endpoint);
229 229
230 Waiter waiter; 230 Waiter waiter;
231 waiter.Init(); 231 waiter.Init();
232 ASSERT_EQ( 232 ASSERT_EQ(
233 MOJO_RESULT_OK, 233 MOJO_RESULT_OK,
234 mp->AddAwakable(0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, nullptr)); 234 mp->AddAwakable(0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, nullptr));
235 235
236 // Don't wait for the shutdown to run ... 236 // Don't wait for the shutdown to run ...
237 io_thread()->PostTask(FROM_HERE, 237 io_thread()->PostTask(FROM_HERE,
238 base::Bind(&ChannelTest::ShutdownChannelOnIOThread, 238 base::Bind(&ChannelTest::ShutdownChannelOnIOThread,
(...skipping 22 matching lines...) Expand all
261 261
262 io_thread()->PostTaskAndWait( 262 io_thread()->PostTaskAndWait(
263 FROM_HERE, 263 FROM_HERE,
264 base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this))); 264 base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this)));
265 EXPECT_EQ(TRISTATE_TRUE, init_result()); 265 EXPECT_EQ(TRISTATE_TRUE, init_result());
266 266
267 scoped_refptr<ChannelEndpoint> channel_endpoint; 267 scoped_refptr<ChannelEndpoint> channel_endpoint;
268 scoped_refptr<MessagePipe> mp( 268 scoped_refptr<MessagePipe> mp(
269 MessagePipe::CreateLocalProxy(&channel_endpoint)); 269 MessagePipe::CreateLocalProxy(&channel_endpoint));
270 270
271 channel()->AttachAndRunEndpoint(channel_endpoint, true); 271 channel()->SetBootstrapEndpoint(channel_endpoint);
272 272
273 io_thread()->PostTaskAndWait( 273 io_thread()->PostTaskAndWait(
274 FROM_HERE, base::Bind(&ChannelTest::ShutdownChannelOnIOThread, 274 FROM_HERE, base::Bind(&ChannelTest::ShutdownChannelOnIOThread,
275 base::Unretained(this))); 275 base::Unretained(this)));
276 276
277 Waiter waiter; 277 Waiter waiter;
278 waiter.Init(); 278 waiter.Init();
279 HandleSignalsState hss; 279 HandleSignalsState hss;
280 EXPECT_EQ( 280 EXPECT_EQ(
281 MOJO_RESULT_FAILED_PRECONDITION, 281 MOJO_RESULT_FAILED_PRECONDITION,
282 mp->AddAwakable(0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, &hss)); 282 mp->AddAwakable(0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, &hss));
283 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); 283 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals);
284 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); 284 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals);
285 285
286 mp->Close(0); 286 mp->Close(0);
287 287
288 EXPECT_TRUE(channel()->HasOneRef()); 288 EXPECT_TRUE(channel()->HasOneRef());
289 } 289 }
290 290
291 // TODO(vtl): More. ------------------------------------------------------------ 291 // TODO(vtl): More. ------------------------------------------------------------
292 292
293 } // namespace 293 } // namespace
294 } // namespace system 294 } // namespace system
295 } // namespace mojo 295 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/channel.cc ('k') | mojo/edk/system/incoming_endpoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698