| OLD | NEW |
| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, |
| 239 base::Unretained(this))); | 239 base::Unretained(this))); |
| 240 | 240 |
| 241 // ... since this |Wait()| should fail once the channel is shut down. | 241 // ... since this |Wait()| should fail once the channel is shut down. |
| 242 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, | 242 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
| 243 waiter.Wait(MOJO_DEADLINE_INDEFINITE, nullptr)); | 243 waiter.Wait(MOJO_DEADLINE_INDEFINITE, nullptr)); |
| 244 HandleSignalsState hss; | 244 HandleSignalsState hss; |
| 245 mp->RemoveWaiter(0, &waiter, &hss); | 245 mp->RemoveWaiter(0, &waiter, &hss); |
| 246 EXPECT_EQ(0u, hss.satisfied_signals); | 246 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); |
| 247 EXPECT_EQ(0u, hss.satisfiable_signals); | 247 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); |
| 248 | 248 |
| 249 mp->Close(0); | 249 mp->Close(0); |
| 250 | 250 |
| 251 EXPECT_TRUE(channel()->HasOneRef()); | 251 EXPECT_TRUE(channel()->HasOneRef()); |
| 252 } | 252 } |
| 253 | 253 |
| 254 // ChannelTest.WaitAfterAttachRunAndShutdown ----------------------------------- | 254 // ChannelTest.WaitAfterAttachRunAndShutdown ----------------------------------- |
| 255 | 255 |
| 256 TEST_F(ChannelTest, WaitAfterAttachRunAndShutdown) { | 256 TEST_F(ChannelTest, WaitAfterAttachRunAndShutdown) { |
| 257 io_thread()->PostTaskAndWait(FROM_HERE, | 257 io_thread()->PostTaskAndWait(FROM_HERE, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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(MOJO_RESULT_FAILED_PRECONDITION, | 280 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
| 281 mp->AddWaiter(0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, &hss)); | 281 mp->AddWaiter(0, &waiter, MOJO_HANDLE_SIGNAL_READABLE, 123, &hss)); |
| 282 EXPECT_EQ(0u, hss.satisfied_signals); | 282 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfied_signals); |
| 283 EXPECT_EQ(0u, hss.satisfiable_signals); | 283 EXPECT_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, hss.satisfiable_signals); |
| 284 | 284 |
| 285 mp->Close(0); | 285 mp->Close(0); |
| 286 | 286 |
| 287 EXPECT_TRUE(channel()->HasOneRef()); | 287 EXPECT_TRUE(channel()->HasOneRef()); |
| 288 } | 288 } |
| 289 | 289 |
| 290 // TODO(vtl): More. ------------------------------------------------------------ | 290 // TODO(vtl): More. ------------------------------------------------------------ |
| 291 | 291 |
| 292 } // namespace | 292 } // namespace |
| 293 } // namespace system | 293 } // namespace system |
| 294 } // namespace mojo | 294 } // namespace mojo |
| OLD | NEW |