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

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

Issue 728553002: Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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/channel_manager.cc ('k') | mojo/edk/system/configuration.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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 base::Bind(&ChannelTest::CreateChannelOnIOThread, 97 base::Bind(&ChannelTest::CreateChannelOnIOThread,
98 base::Unretained(this))); 98 base::Unretained(this)));
99 ASSERT_TRUE(channel()); 99 ASSERT_TRUE(channel());
100 100
101 io_thread()->PostTaskAndWait( 101 io_thread()->PostTaskAndWait(
102 FROM_HERE, 102 FROM_HERE,
103 base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this))); 103 base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this)));
104 EXPECT_EQ(TRISTATE_TRUE, init_result()); 104 EXPECT_EQ(TRISTATE_TRUE, init_result());
105 105
106 io_thread()->PostTaskAndWait( 106 io_thread()->PostTaskAndWait(
107 FROM_HERE, 107 FROM_HERE, base::Bind(&ChannelTest::ShutdownChannelOnIOThread,
108 base::Bind(&ChannelTest::ShutdownChannelOnIOThread, 108 base::Unretained(this)));
109 base::Unretained(this)));
110 109
111 // Okay to destroy |Channel| on not-the-I/O-thread. 110 // Okay to destroy |Channel| on not-the-I/O-thread.
112 EXPECT_TRUE(channel()->HasOneRef()); 111 EXPECT_TRUE(channel()->HasOneRef());
113 *mutable_channel() = nullptr; 112 *mutable_channel() = nullptr;
114 } 113 }
115 114
116 // ChannelTest.InitFails ------------------------------------------------------- 115 // ChannelTest.InitFails -------------------------------------------------------
117 116
118 class MockRawChannelOnInitFails : public RawChannel { 117 class MockRawChannelOnInitFails : public RawChannel {
119 public: 118 public:
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 195
197 scoped_refptr<ChannelEndpoint> channel_endpoint; 196 scoped_refptr<ChannelEndpoint> channel_endpoint;
198 scoped_refptr<MessagePipe> mp( 197 scoped_refptr<MessagePipe> mp(
199 MessagePipe::CreateLocalProxy(&channel_endpoint)); 198 MessagePipe::CreateLocalProxy(&channel_endpoint));
200 199
201 mp->Close(0); 200 mp->Close(0);
202 201
203 channel()->AttachAndRunEndpoint(channel_endpoint, true); 202 channel()->AttachAndRunEndpoint(channel_endpoint, true);
204 203
205 io_thread()->PostTaskAndWait( 204 io_thread()->PostTaskAndWait(
206 FROM_HERE, 205 FROM_HERE, base::Bind(&ChannelTest::ShutdownChannelOnIOThread,
207 base::Bind(&ChannelTest::ShutdownChannelOnIOThread, 206 base::Unretained(this)));
208 base::Unretained(this)));
209 207
210 EXPECT_TRUE(channel()->HasOneRef()); 208 EXPECT_TRUE(channel()->HasOneRef());
211 } 209 }
212 210
213 // ChannelTest.ShutdownAfterAttachAndRun --------------------------------------- 211 // ChannelTest.ShutdownAfterAttachAndRun ---------------------------------------
214 212
215 TEST_F(ChannelTest, ShutdownAfterAttach) { 213 TEST_F(ChannelTest, ShutdownAfterAttach) {
216 io_thread()->PostTaskAndWait(FROM_HERE, 214 io_thread()->PostTaskAndWait(FROM_HERE,
217 base::Bind(&ChannelTest::CreateChannelOnIOThread, 215 base::Bind(&ChannelTest::CreateChannelOnIOThread,
218 base::Unretained(this))); 216 base::Unretained(this)));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this))); 264 base::Bind(&ChannelTest::InitChannelOnIOThread, base::Unretained(this)));
267 EXPECT_EQ(TRISTATE_TRUE, init_result()); 265 EXPECT_EQ(TRISTATE_TRUE, init_result());
268 266
269 scoped_refptr<ChannelEndpoint> channel_endpoint; 267 scoped_refptr<ChannelEndpoint> channel_endpoint;
270 scoped_refptr<MessagePipe> mp( 268 scoped_refptr<MessagePipe> mp(
271 MessagePipe::CreateLocalProxy(&channel_endpoint)); 269 MessagePipe::CreateLocalProxy(&channel_endpoint));
272 270
273 channel()->AttachAndRunEndpoint(channel_endpoint, true); 271 channel()->AttachAndRunEndpoint(channel_endpoint, true);
274 272
275 io_thread()->PostTaskAndWait( 273 io_thread()->PostTaskAndWait(
276 FROM_HERE, 274 FROM_HERE, base::Bind(&ChannelTest::ShutdownChannelOnIOThread,
277 base::Bind(&ChannelTest::ShutdownChannelOnIOThread, 275 base::Unretained(this)));
278 base::Unretained(this)));
279 276
280 Waiter waiter; 277 Waiter waiter;
281 waiter.Init(); 278 waiter.Init();
282 HandleSignalsState hss; 279 HandleSignalsState hss;
283 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, 280 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
284 mp->AddWaiter(0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, &hss)); 281 mp->AddWaiter(0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, &hss));
285 EXPECT_EQ(0u, hss.satisfied_signals); 282 EXPECT_EQ(0u, hss.satisfied_signals);
286 EXPECT_EQ(0u, hss.satisfiable_signals); 283 EXPECT_EQ(0u, hss.satisfiable_signals);
287 284
288 mp->Close(0); 285 mp->Close(0);
289 286
290 EXPECT_TRUE(channel()->HasOneRef()); 287 EXPECT_TRUE(channel()->HasOneRef());
291 } 288 }
292 289
293 // TODO(vtl): More. ------------------------------------------------------------ 290 // TODO(vtl): More. ------------------------------------------------------------
294 291
295 } // namespace 292 } // namespace
296 } // namespace system 293 } // namespace system
297 } // namespace mojo 294 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/channel_manager.cc ('k') | mojo/edk/system/configuration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698