| Index: mojo/edk/system/raw_channel_unittest.cc
|
| diff --git a/mojo/edk/system/raw_channel_unittest.cc b/mojo/edk/system/raw_channel_unittest.cc
|
| index af75543bb2f6f1ce5d9c5f741068ae51ad4f7b52..a6694bdc83a5194d1d00233eefbff253990dc8d8 100644
|
| --- a/mojo/edk/system/raw_channel_unittest.cc
|
| +++ b/mojo/edk/system/raw_channel_unittest.cc
|
| @@ -478,14 +478,9 @@ TEST_F(RawChannelTest, OnError) {
|
|
|
| EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1)));
|
|
|
| - // We should get a write error.
|
| - delegate.WaitForWriteError();
|
| -
|
| - // We should also get a read error.
|
| + // We should get a shutdown error.
|
| delegate.WaitForReadError();
|
|
|
| - EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(2)));
|
| -
|
| // Sleep a bit, to make sure we don't get another |OnError()|
|
| // notification. (If we actually get another one, |OnError()| crashes.)
|
| test::Sleep(test::DeadlineFromMilliseconds(20));
|
| @@ -500,27 +495,28 @@ TEST_F(RawChannelTest, ReadUnaffectedByWriteError) {
|
| const size_t kMessageCount = 5;
|
|
|
| // Write a few messages into the other end.
|
| + RawChannel* other = RawChannel::Create(handles[1].Pass());
|
| + WriteOnlyRawChannelDelegate write_delegate;
|
| + test_io_thread()->PostTaskAndWait(
|
| + FROM_HERE,
|
| + base::Bind(&InitOnIOThread, other, base::Unretained(&write_delegate)));
|
| uint32_t message_size = 1;
|
| for (size_t i = 0; i < kMessageCount;
|
| i++, message_size += message_size / 2 + 1)
|
| - EXPECT_TRUE(WriteTestMessageToHandle(handles[1].get(), message_size));
|
| + EXPECT_TRUE(other->WriteMessage(MakeTestMessage(message_size)));
|
|
|
| // Close the other end, which should make writing fail.
|
| - handles[1].reset();
|
| + test_io_thread()->PostTaskAndWait(
|
| + FROM_HERE, base::Bind(&RawChannel::Shutdown, base::Unretained(other)));
|
|
|
| - // Only start up reading here. The system buffer should still contain the
|
| - // messages that were written.
|
| + // Only start up reading here. The RawChannel ensures that it won't close the
|
| + // pipe until the other end read everything.
|
| ErrorRecordingRawChannelDelegate delegate(kMessageCount, true, true);
|
| RawChannel* rc = RawChannel::Create(handles[0].Pass());
|
| test_io_thread()->PostTaskAndWait(
|
| FROM_HERE,
|
| base::Bind(&InitOnIOThread, rc, base::Unretained(&delegate)));
|
|
|
| - EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1)));
|
| -
|
| - // We should definitely get a write error.
|
| - delegate.WaitForWriteError();
|
| -
|
| // Wait for reading to finish. A writing failure shouldn't affect reading.
|
| delegate.Wait();
|
|
|
|
|