Commit 1c67dcbe authored by Wez's avatar Wez Committed by Commit Bot

Fix ReadIfReady() calls in new CancelPendingReadIfReady test.

ReadIfReady() either completes synchronously, or notifies the caller
when it should be called again, rather than completing asynchronously.

Bug: 841180
TBR: xunjieli
Change-Id: I70258381380feea49279cb81a7f285f2b1d11f01
Reviewed-on: https://chromium-review.googlesource.com/1051447
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557140}
parent 23eeef21
...@@ -575,12 +575,16 @@ TEST_F(TCPSocketTest, CancelPendingReadIfReady) { ...@@ -575,12 +575,16 @@ TEST_F(TCPSocketTest, CancelPendingReadIfReady) {
const int msg_size = strlen(kMsg); const int msg_size = strlen(kMsg);
ASSERT_EQ(msg_size, write_result); ASSERT_EQ(msg_size, write_result);
// Try reading again. ReadIfReady() should still succeed.
TestCompletionCallback read_callback2; TestCompletionCallback read_callback2;
int read_result = connecting_socket->ReadIfReady( int read_result = connecting_socket->ReadIfReady(
read_buffer.get(), read_buffer->size(), read_callback2.callback()); read_buffer.get(), read_buffer->size(), read_callback2.callback());
if (read_result == ERR_IO_PENDING) {
ASSERT_EQ(OK, read_callback2.GetResult(read_result));
read_result = connecting_socket->ReadIfReady(
read_buffer.get(), read_buffer->size(), read_callback2.callback());
}
ASSERT_EQ(msg_size, read_callback2.GetResult(read_result)); ASSERT_EQ(msg_size, read_result);
ASSERT_EQ(0, memcmp(&kMsg, read_buffer->data(), msg_size)); ASSERT_EQ(0, memcmp(&kMsg, read_buffer->data(), msg_size));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment