summaryrefslogtreecommitdiffstats
path: root/net/test
diff options
context:
space:
mode:
authorrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-24 20:40:21 +0000
committerrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-24 20:40:21 +0000
commite0c9e24599c1bffa614af97b60ba77a8e9826d99 (patch)
tree374a0061c7fbaf6238c18ace46783e07009a3933 /net/test
parentb5db5eefdea45fb50601433e13fc6e2c7ac6f4a0 (diff)
downloadchromium_src-e0c9e24599c1bffa614af97b60ba77a8e9826d99.zip
chromium_src-e0c9e24599c1bffa614af97b60ba77a8e9826d99.tar.gz
chromium_src-e0c9e24599c1bffa614af97b60ba77a8e9826d99.tar.bz2
[sync] Add --port and --xmpp-port parameters to run_testserver.cc
run_testserver is a useful test utility that launches a python testserver after setting the required python path. When it is used to start a sync testserver, the only parameter it supports is --sync, indicating that we want a sync server. It doesn't support the --port and --xmpp-port flags, that are used to specify the ports on which we want the sync server and sync xmpp server to run. This patch adds the parameters to run_testserver.cc and plumbs them down to the TestServer objects created by run_testserver.cc. It also separates out sync specific testserver code into a new class called LocalSyncTestServer. Separating the sync server in python code is out of the scope of this CL because it requires significant refactoring, since it is in use on multiple platforms, and will be dealt with separately. BUG= 117559 TEST=Build and run run_testserver with the paramters --sync, --port and --xmpp-port Review URL: https://chromiumcodereview.appspot.com/10388206 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test')
-rw-r--r--net/test/OWNERS4
-rw-r--r--net/test/local_sync_test_server.cc40
-rw-r--r--net/test/local_sync_test_server.h43
-rw-r--r--net/test/local_test_server.h8
4 files changed, 91 insertions, 4 deletions
diff --git a/net/test/OWNERS b/net/test/OWNERS
index 92ecc88..5b08e34 100644
--- a/net/test/OWNERS
+++ b/net/test/OWNERS
@@ -1 +1,5 @@
+# General reviewer, except sync-specific bits.
phajdan.jr@chromium.org
+
+# For changes to local_sync_test_server.{h|cc}.
+akalin@chromium.org
diff --git a/net/test/local_sync_test_server.cc b/net/test/local_sync_test_server.cc
new file mode 100644
index 0000000..8d757f8
--- /dev/null
+++ b/net/test/local_sync_test_server.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/test/local_sync_test_server.h"
+
+#include "base/command_line.h"
+#include "base/string_number_conversions.h"
+#include "base/values.h"
+#include "net/test/test_server.h"
+
+namespace net {
+
+LocalSyncTestServer::LocalSyncTestServer()
+ : LocalTestServer(net::TestServer::TYPE_SYNC,
+ net::TestServer::kLocalhost,
+ FilePath()),
+ xmpp_port_(0) {}
+
+LocalSyncTestServer::LocalSyncTestServer(uint16 port, uint16 xmpp_port)
+ : LocalTestServer(net::TestServer::TYPE_SYNC,
+ net::TestServer::kLocalhost,
+ FilePath()),
+ xmpp_port_(xmpp_port) {
+ SetPort(port);
+}
+
+LocalSyncTestServer::~LocalSyncTestServer() {}
+
+bool LocalSyncTestServer::AddCommandLineArguments(
+ CommandLine* command_line) const {
+ LocalTestServer::AddCommandLineArguments(command_line);
+ if (xmpp_port_ != 0) {
+ std::string xmpp_port_str = base::IntToString(xmpp_port_);
+ command_line->AppendArg("--xmpp-port=" + xmpp_port_str);
+ }
+ return true;
+}
+
+} // namespace net
diff --git a/net/test/local_sync_test_server.h b/net/test/local_sync_test_server.h
new file mode 100644
index 0000000..839fd1e
--- /dev/null
+++ b/net/test/local_sync_test_server.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_TEST_LOCAL_SYNC_TEST_SERVER_H_
+#define NET_TEST_LOCAL_SYNC_TEST_SERVER_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "net/test/local_test_server.h"
+
+namespace net {
+
+// Runs a Python-based sync test server on the same machine in which the
+// LocalSyncTestServer runs.
+class LocalSyncTestServer : public LocalTestServer {
+ public:
+ // Initialize a sync server that listens on localhost using ephemeral ports
+ // for sync and p2p notifications.
+ LocalSyncTestServer();
+
+ // Initialize a sync server that listens on |port| for sync updates and
+ // |xmpp_port| for p2p notifications.
+ LocalSyncTestServer(uint16 port, uint16 xmpp_port);
+
+ virtual ~LocalSyncTestServer();
+
+ // Calls LocalTestServer::AddCommandLineArguments and then appends the
+ // --xmpp-port flag to |command_line| if required. Returns true on success.
+ virtual bool AddCommandLineArguments(
+ CommandLine* command_line) const OVERRIDE;
+
+ private:
+ // Port on which the Sync XMPP server listens.
+ uint16 xmpp_port_;
+
+ DISALLOW_COPY_AND_ASSIGN(LocalSyncTestServer);
+};
+
+} // namespace net
+
+#endif // NET_TEST_LOCAL_SYNC_TEST_SERVER_H_
diff --git a/net/test/local_test_server.h b/net/test/local_test_server.h
index 63ea00e..6aa1990 100644
--- a/net/test/local_test_server.h
+++ b/net/test/local_test_server.h
@@ -49,6 +49,10 @@ class LocalTestServer : public BaseTestServer {
// testserver python script in |*directory|.
static bool GetTestServerDirectory(FilePath* directory) 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;
+
private:
bool Init(const FilePath& document_root);
@@ -58,10 +62,6 @@ class LocalTestServer : public BaseTestServer {
// Waits for the server to start. Returns true on success.
bool WaitToStart() WARN_UNUSED_RESULT;
- // Add the command line arguments for the Python test server to
- // |command_line|. Return true on success.
- bool AddCommandLineArguments(CommandLine* command_line) const;
-
// Handle of the Python process running the test server.
base::ProcessHandle process_handle_;