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

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: whitespace 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..2dab596ef67b22ea6a270a17b2b9b902e751afdb 100644
--- a/net/server/http_server_unittest.cc
+++ b/net/server/http_server_unittest.cc
@@ -91,12 +91,21 @@ 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;
mef 2014/04/23 21:46:03 do you need to clear a |message| here?
gunsch 2014/04/24 20:02:47 Done.
+ 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 +317,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");
@@ -319,7 +327,7 @@ TEST_F(HttpServerTest, DISABLED_SendRaw) {
server_->SendRaw(GetConnectionId(0), "Third Piece of Data");
std::string response;
- ASSERT_TRUE(client.Read(&response));
+ ASSERT_TRUE(client.Read(&response, 37));
mef 2014/04/23 21:46:03 How was this magical number calculated?
gunsch 2014/04/24 20:02:47 Done.
ASSERT_EQ("Raw Data More DataThird Piece of Data", response);
}
« 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