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

Unified Diff: net/url_request/url_request_unittest.h

Issue 182031: Speed up net_unittests by re-using one FTP test server instance. (Closed)
Patch Set: add google.patch Created 11 years, 4 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 | net/url_request/url_request_unittest.cc » ('j') | net/url_request/url_request_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_unittest.h
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index e0589575aa85f7d3886f3c636ad2523c7db168f4..2eea1005682f2bd7e6ebbb2ac26e97fc714a0a71 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -263,11 +263,23 @@ class BaseTestServer : public base::RefCounted<BaseTestServer> {
}
GURL TestServerPage(const std::string& path) {
- return GURL(base_address_ + path);
+ return GURL(scheme_ + "://" + host_name_ + ":" + port_str_ + "/" + path);
wtc 2009/08/31 20:38:44 Is there a GURL method that combines these compone
}
+ GURL TestServerPage(const std::string& path,
+ const std::string& user, const std::string& password) {
wtc 2009/08/31 20:38:44 This is the second form in the Style Guide: http:/
+ if (password.empty())
+ return GURL(scheme_ + "://" + user + "@" +
+ host_name_ + ":" + port_str_ + "/" + path);
+ else
wtc 2009/08/31 20:38:44 Nit: don't use else after a return statement.
+ return GURL(scheme_ + "://" + user + ":" + password +
+ "@" + host_name_ + ":" + port_str_ + "/" + path);
+ }
+
+ // Deprecated in favor of TestServerPage.
+ // TODO(phajdan.jr): Remove TestServerPageW.
GURL TestServerPageW(const std::wstring& path) {
- return GURL(base_address_ + WideToUTF8(path));
+ return TestServerPage(WideToUTF8(path));
}
virtual bool MakeGETRequest(const std::string& page_name) = 0;
@@ -282,41 +294,19 @@ class BaseTestServer : public base::RefCounted<BaseTestServer> {
const FilePath& document_root,
const FilePath& cert_path,
const std::wstring& file_root_url) {
- std::string blank;
- return Start(protocol, host_name, port, document_root, cert_path,
- file_root_url, blank, blank);
- }
-
- bool Start(net::TestServerLauncher::Protocol protocol,
- const std::string& host_name, int port,
- const FilePath& document_root,
- const FilePath& cert_path,
- const std::wstring& file_root_url,
- const std::string& url_user,
- const std::string& url_password) {
if (!launcher_.Start(protocol,
host_name, port, document_root, cert_path, file_root_url))
return false;
- std::string scheme;
if (protocol == net::TestServerLauncher::ProtoFTP)
- scheme = "ftp";
+ scheme_ = "ftp";
else
- scheme = "http";
+ scheme_ = "http";
if (!cert_path.empty())
- scheme.push_back('s');
+ scheme_.push_back('s');
- std::string port_str = IntToString(port);
- if (url_user.empty()) {
- base_address_ = scheme + "://" + host_name + ":" + port_str + "/";
- } else {
- if (url_password.empty())
- base_address_ = scheme + "://" + url_user + "@" +
- host_name + ":" + port_str + "/";
- else
- base_address_ = scheme + "://" + url_user + ":" + url_password +
- "@" + host_name + ":" + port_str + "/";
- }
+ host_name_ = host_name;
+ port_str_ = IntToString(port);
return true;
}
@@ -344,7 +334,9 @@ class BaseTestServer : public base::RefCounted<BaseTestServer> {
};
net::TestServerLauncher launcher_;
- std::string base_address_;
+ std::string scheme_;
+ std::string host_name_;
+ std::string port_str_;
};
@@ -419,7 +411,7 @@ class HTTPTestServer : public BaseTestServer {
const std::wstring& file_root_url) {
return server->Start(net::TestServerLauncher::ProtoHTTP, kDefaultHostName,
kHTTPDefaultPort, document_root, cert_path,
- file_root_url, "", "");
+ file_root_url);
}
// A subclass may wish to send the request in a different manner
@@ -577,27 +569,18 @@ class FTPTestServer : public BaseTestServer {
static scoped_refptr<FTPTestServer> CreateServer(
const std::wstring& document_root) {
- std::string blank;
- return CreateServer(document_root, blank, blank);
- }
-
- static scoped_refptr<FTPTestServer> CreateServer(
- const std::wstring& document_root,
- const std::string& url_user,
- const std::string& url_password) {
scoped_refptr<FTPTestServer> test_server = new FTPTestServer();
FilePath docroot = FilePath::FromWStringHack(document_root);
FilePath no_cert;
if (!test_server->Start(net::TestServerLauncher::ProtoFTP,
- kDefaultHostName, kFTPDefaultPort, docroot, no_cert, std::wstring(),
- url_user, url_password)) {
+ kDefaultHostName, kFTPDefaultPort, docroot, no_cert, std::wstring())) {
return NULL;
}
return test_server;
}
virtual bool MakeGETRequest(const std::string& page_name) {
- const GURL& url = TestServerPage(base_address_, page_name);
+ const GURL& url = TestServerPage(page_name);
TestDelegate d;
URLRequest request(url, &d);
request.set_context(new TestURLRequestContext());
« no previous file with comments | « no previous file | net/url_request/url_request_unittest.cc » ('j') | net/url_request/url_request_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698