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

Unified Diff: net/server/http_server_unittest.cc

Issue 245563002: Fixes flaky HttpServer.SendRaw failures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review fixes Created 6 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/server/http_server_unittest.cc
diff --git a/net/server/http_server_unittest.cc b/net/server/http_server_unittest.cc
index 87c35b198e7b3d42d385681aedc576a3766e09d0..de8690f138e05608447ffe718c878a186fd0d4cd 100644
--- a/net/server/http_server_unittest.cc
+++ b/net/server/http_server_unittest.cc
@@ -91,12 +91,22 @@ class TestHttpClient {
}
bool Read(std::string* message) {
- net::TestCompletionCallback callback;
- ReadInternal(callback.callback());
- int bytes_received = callback.WaitForResult();
- if (bytes_received <= 0)
- return false;
- *message = std::string(read_buffer_->data(), bytes_received);
+ return Read(message, 1);
+ }
+
+ bool Read(std::string* message, int expected_bytes) {
+ int total_bytes_received = 0;
+ message->clear();
+ while (total_bytes_received < expected_bytes) {
+ net::TestCompletionCallback callback;
+ ReadInternal(callback.callback());
+ int bytes_received = callback.WaitForResult();
+ if (bytes_received <= 0)
+ return false;
+
+ total_bytes_received += bytes_received;
+ message->append(read_buffer_->data(), bytes_received);
+ }
return true;
}
@@ -308,8 +318,7 @@ TEST_F(HttpServerTest, Send200) {
ASSERT_TRUE(EndsWith(response, "Response!", true));
}
-// Flaky on at least OS X and Vista. http://crbug.com/365067.
-TEST_F(HttpServerTest, DISABLED_SendRaw) {
+TEST_F(HttpServerTest, SendRaw) {
TestHttpClient client;
ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
client.Send("GET /test HTTP/1.1\r\n\r\n");
@@ -318,9 +327,10 @@ TEST_F(HttpServerTest, DISABLED_SendRaw) {
server_->SendRaw(GetConnectionId(0), "More Data");
server_->SendRaw(GetConnectionId(0), "Third Piece of Data");
+ const std::string expected_response("Raw Data More DataThird Piece of Data");
std::string response;
- ASSERT_TRUE(client.Read(&response));
- ASSERT_EQ("Raw Data More DataThird Piece of Data", response);
+ ASSERT_TRUE(client.Read(&response, expected_response.length()));
+ ASSERT_EQ(expected_response, response);
}
namespace {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698