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

Unified Diff: util/net/http_transport_test.cc

Issue 1451793002: Add RandomString() and its test, and use it everywhere it makes sense (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Fix tpyo Created 5 years, 1 month 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 | « util/misc/random_string_test.cc ('k') | util/net/http_transport_test_server.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/net/http_transport_test.cc
diff --git a/util/net/http_transport_test.cc b/util/net/http_transport_test.cc
index fe4099980b8d8d0dff85e0ed362fb6f9d1077b4b..16b1cd0ac661f2b4e953a086f9548f644048f502 100644
--- a/util/net/http_transport_test.cc
+++ b/util/net/http_transport_test.cc
@@ -24,7 +24,6 @@
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
@@ -32,6 +31,7 @@
#include "test/multiprocess_exec.h"
#include "test/paths.h"
#include "util/file/file_io.h"
+#include "util/misc/random_string.h"
#include "util/net/http_body.h"
#include "util/net/http_headers.h"
#include "util/net/http_multipart_builder.h"
@@ -89,14 +89,11 @@ class HTTPTransportTestFixture : public MultiprocessExec {
// The parent will also tell the web server what response body to send back.
// The web server will only send the response body if the response code is
// 200.
- std::string expect_response_body;
- for (size_t index = 0; index < 8; ++index) {
- expect_response_body += static_cast<char>(base::RandInt(' ', '~'));
- }
+ const std::string random_string = RandomString();
ASSERT_TRUE(LoggingWriteFile(WritePipeHandle(),
- expect_response_body.c_str(),
- expect_response_body.size()));
+ random_string.c_str(),
+ random_string.size()));
// Now execute the HTTP request.
scoped_ptr<HTTPTransport> transport(HTTPTransport::Create());
@@ -111,7 +108,7 @@ class HTTPTransportTestFixture : public MultiprocessExec {
bool success = transport->ExecuteSynchronously(&response_body);
if (response_code_ == 200) {
EXPECT_TRUE(success);
- expect_response_body += "\r\n";
+ std::string expect_response_body = random_string + "\r\n";
EXPECT_EQ(expect_response_body, response_body);
} else {
EXPECT_FALSE(success);
« no previous file with comments | « util/misc/random_string_test.cc ('k') | util/net/http_transport_test_server.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698