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 <[email protected]>
Reviewed-by: Wez <[email protected]>
Cr-Commit-Position: refs/heads/master@{#557140}
diff --git a/net/socket/tcp_socket_unittest.cc b/net/socket/tcp_socket_unittest.cc
index 5b97c310..83c2b96 100644
--- a/net/socket/tcp_socket_unittest.cc
+++ b/net/socket/tcp_socket_unittest.cc
@@ -575,12 +575,16 @@
const int msg_size = strlen(kMsg);
ASSERT_EQ(msg_size, write_result);
- // Try reading again. ReadIfReady() should still succeed.
TestCompletionCallback read_callback2;
int read_result = connecting_socket->ReadIfReady(
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));
}