summaryrefslogtreecommitdiffstats
path: root/net/test
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-07 04:36:07 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-07 04:36:07 +0000
commit4c120c6de158f2e246f2fee6511c1bcbdf3eab5f (patch)
tree359621394248a5e2d706ea2d81c121141abe4b80 /net/test
parent48f0cb0b8b0b76be6ccee823bb8aba7ceb2b1014 (diff)
downloadchromium_src-4c120c6de158f2e246f2fee6511c1bcbdf3eab5f.zip
chromium_src-4c120c6de158f2e246f2fee6511c1bcbdf3eab5f.tar.gz
chromium_src-4c120c6de158f2e246f2fee6511c1bcbdf3eab5f.tar.bz2
Try #2: Run safebrowsing_service_test through the net testserver code.
Allows us to use ephemeral ports. Original review: https://chromiumcodereview.appspot.com/10073033 BUG=96459,119403 Review URL: https://chromiumcodereview.appspot.com/10918251 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166344 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test')
-rw-r--r--net/test/base_test_server.cc6
-rw-r--r--net/test/base_test_server.h8
-rw-r--r--net/test/local_sync_test_server.cc3
-rw-r--r--net/test/local_test_server.cc18
-rw-r--r--net/test/local_test_server.h15
5 files changed, 42 insertions, 8 deletions
diff --git a/net/test/base_test_server.cc b/net/test/base_test_server.cc
index d13d57c..9307acf 100644
--- a/net/test/base_test_server.cc
+++ b/net/test/base_test_server.cc
@@ -390,6 +390,12 @@ bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const {
base::Value::CreateIntegerValue(ssl_options_.tls_intolerant));
}
}
+
+ return GenerateAdditionalArguments(arguments);
+}
+
+bool BaseTestServer::GenerateAdditionalArguments(
+ base::DictionaryValue* arguments) const {
return true;
}
diff --git a/net/test/base_test_server.h b/net/test/base_test_server.h
index 9f1290e..d343f18 100644
--- a/net/test/base_test_server.h
+++ b/net/test/base_test_server.h
@@ -214,7 +214,13 @@ class BaseTestServer {
// Generates a DictionaryValue with the arguments for launching the external
// Python test server.
- bool GenerateArguments(base::DictionaryValue* arguments) const;
+ bool GenerateArguments(base::DictionaryValue* arguments) const
+ WARN_UNUSED_RESULT;
+
+ // Subclasses can override this to add arguments that are specific to their
+ // own test servers.
+ virtual bool GenerateAdditionalArguments(
+ base::DictionaryValue* arguments) const WARN_UNUSED_RESULT;
private:
void Init(const std::string& host);
diff --git a/net/test/local_sync_test_server.cc b/net/test/local_sync_test_server.cc
index 8d757f8..432fde1 100644
--- a/net/test/local_sync_test_server.cc
+++ b/net/test/local_sync_test_server.cc
@@ -29,7 +29,8 @@ LocalSyncTestServer::~LocalSyncTestServer() {}
bool LocalSyncTestServer::AddCommandLineArguments(
CommandLine* command_line) const {
- LocalTestServer::AddCommandLineArguments(command_line);
+ if (!LocalTestServer::AddCommandLineArguments(command_line))
+ return false;
if (xmpp_port_ != 0) {
std::string xmpp_port_str = base::IntToString(xmpp_port_);
command_line->AppendArg("--xmpp-port=" + xmpp_port_str);
diff --git a/net/test/local_test_server.cc b/net/test/local_test_server.cc
index 17137a69..53879df 100644
--- a/net/test/local_test_server.cc
+++ b/net/test/local_test_server.cc
@@ -94,13 +94,19 @@ bool LocalTestServer::GetTestServerDirectory(FilePath* directory) {
return true;
}
+bool LocalTestServer::GetTestServerPath(FilePath* testserver_path) const {
+ if (!GetTestServerDirectory(testserver_path))
+ return false;
+ *testserver_path = testserver_path->Append(FILE_PATH_LITERAL(
+ "testserver.py"));
+ return true;
+}
+
bool LocalTestServer::Start() {
// Get path to Python server script.
FilePath testserver_path;
- if (!GetTestServerDirectory(&testserver_path))
+ if (!GetTestServerPath(&testserver_path))
return false;
- testserver_path =
- testserver_path.Append(FILE_PATH_LITERAL("testserver.py"));
if (!SetPythonPath())
return false;
@@ -159,8 +165,12 @@ bool LocalTestServer::Init(const FilePath& document_root) {
return true;
}
+bool LocalTestServer::SetPythonPath() const {
+ return SetPythonPathStatic();
+}
+
// static
-bool LocalTestServer::SetPythonPath() {
+bool LocalTestServer::SetPythonPathStatic() {
FilePath third_party_dir;
if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) {
LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT";
diff --git a/net/test/local_test_server.h b/net/test/local_test_server.h
index d8d070e..3c6bdde 100644
--- a/net/test/local_test_server.h
+++ b/net/test/local_test_server.h
@@ -43,15 +43,26 @@ class LocalTestServer : public BaseTestServer {
bool Stop();
// Modify PYTHONPATH to contain libraries we need.
- static bool SetPythonPath() WARN_UNUSED_RESULT;
+ virtual bool SetPythonPath() const WARN_UNUSED_RESULT;
+
+ // This is a static version so that RunSyncTest in run_testserver.cc can use
+ // it.
+ // TODO(mattm): We should refactor so this isn't necessary (crbug.com/159731).
+ static bool SetPythonPathStatic() WARN_UNUSED_RESULT;
// Returns true if successfully stored the FilePath for the directory of the
// testserver python script in |*directory|.
static bool GetTestServerDirectory(FilePath* directory) WARN_UNUSED_RESULT;
+ // Returns true if successfully stored the FilePath for the testserver python
+ // script in |*testserver_path|.
+ virtual bool GetTestServerPath(FilePath* testserver_path) const
+ WARN_UNUSED_RESULT;
+
// Adds the command line arguments for the Python test server to
// |command_line|. Returns true on success.
- virtual bool AddCommandLineArguments(CommandLine* command_line) const;
+ virtual bool AddCommandLineArguments(CommandLine* command_line) const
+ WARN_UNUSED_RESULT;
// Returns the actual path of document root for test cases. This function
// should be called by test cases to retrieve the actual document root path.