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

Unified Diff: net/test/test_server.cc

Issue 4664009: All SSL UI tests work with ephemeral ports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows compile Created 10 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
Index: net/test/test_server.cc
diff --git a/net/test/test_server.cc b/net/test/test_server.cc
index 4b426eb4e9d28fc5a825f5d3f04b2a986190d8f3..85f1758632e34c610a2acf5a6e6d8518e61f99a4 100644
--- a/net/test/test_server.cc
+++ b/net/test/test_server.cc
@@ -14,6 +14,7 @@
#include "net/base/x509_certificate.h"
#endif
+#include "base/base64.h"
#include "base/command_line.h"
#include "base/debug/leak_annotations.h"
#include "base/file_util.h"
@@ -252,13 +253,13 @@ bool TestServer::GetAddressList(AddressList* address_list) const {
return true;
}
-GURL TestServer::GetURL(const std::string& path) {
+GURL TestServer::GetURL(const std::string& path) const {
return GURL(GetScheme() + "://" + host_port_pair_.ToString() +
"/" + path);
}
GURL TestServer::GetURLWithUser(const std::string& path,
- const std::string& user) {
+ const std::string& user) const {
return GURL(GetScheme() + "://" + user + "@" +
host_port_pair_.ToString() +
"/" + path);
@@ -266,12 +267,44 @@ GURL TestServer::GetURLWithUser(const std::string& path,
GURL TestServer::GetURLWithUserAndPassword(const std::string& path,
const std::string& user,
- const std::string& password) {
+ const std::string& password) const {
return GURL(GetScheme() + "://" + user + ":" + password +
"@" + host_port_pair_.ToString() +
"/" + path);
}
+// static
+bool TestServer::GetFilePathWithReplacements(
+ const std::string& original_file_path,
+ const std::vector<std::string>& text_to_replace,
+ std::string* replacement_path) {
+ DCHECK_EQ(0U, (text_to_replace.size() % 2));
akalin 2010/11/11 05:20:54 if you take a vector of pairs, this won't be neces
Paweł Hajdan Jr. 2010/11/11 10:40:45 Yeah, this should really take a vector of pairs.
cbentzel 2010/11/11 15:34:09 That made things cleaner, thanks for suggestion.
+ if (text_to_replace.empty()) {
akalin 2010/11/11 05:20:54 this check isn't necessary -- if you fall through
cbentzel 2010/11/11 15:34:09 Done.
+ *replacement_path = original_file_path;
+ return true;
+ }
+
+ std::string new_file_path = original_file_path;
+ for (size_t i = 0; i < text_to_replace.size(); i += 2) {
+ const std::string& old_text = text_to_replace[i];
+ const std::string& new_text = text_to_replace[i + 1];
+ std::string base64_old;
+ std::string base64_new;
+ if (!base::Base64Encode(old_text, &base64_old))
+ return false;
+ if (!base::Base64Encode(new_text, &base64_new))
+ return false;
+ new_file_path += (i == 0) ? "?" : "&";
Paweł Hajdan Jr. 2010/11/11 10:40:45 I'm not sure if I understand the logic that decide
cbentzel 2010/11/11 15:34:09 That's correct. The new implementation should make
+ new_file_path += "replace_text=";
+ new_file_path += base64_old;
+ new_file_path += ":";
+ new_file_path += base64_new;
+ }
+
+ *replacement_path = new_file_path;
+ return true;
+}
+
bool TestServer::SetPythonPath() {
FilePath third_party_dir;
if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) {

Powered by Google App Engine
This is Rietveld 408576698