Chromium Code Reviews| Index: net/tools/testserver/run_testserver.cc |
| diff --git a/net/tools/testserver/run_testserver.cc b/net/tools/testserver/run_testserver.cc |
| index f00f9f2d2b5730d59886b047c36f49a983ce55d5..74cc727bf7047497a1b89f164fe65862f5759364 100644 |
| --- a/net/tools/testserver/run_testserver.cc |
| +++ b/net/tools/testserver/run_testserver.cc |
| @@ -11,14 +11,18 @@ |
| #include "base/message_loop.h" |
| #include "base/process_util.h" |
| #include "base/test/test_timeouts.h" |
| +#include "base/string_number_conversions.h" |
| #include "base/utf_string_conversions.h" |
| #include "net/test/python_utils.h" |
| #include "net/test/test_server.h" |
| +#include "net/test/local_sync_test_server.h" |
| static void PrintUsage() { |
| printf("run_testserver --doc-root=relpath [--http|--https|--ftp|--sync]\n" |
| - " [--https-cert=ok|mismatched-name|expired]\n"); |
| - printf("(NOTE: relpath should be relative to the 'src' directory)\n"); |
| + " [--https-cert=ok|mismatched-name|expired]\n" |
| + " [--port=<port>] [--xmpp-port=<xmpp_port>]\n"); |
| + printf("(NOTE: relpath should be relative to the 'src' directory.\n"); |
| + printf(" --port and --xmpp-port only work with the --sync flag.)\n"); |
| } |
| // Launches the chromiumsync_test script, testing the --sync functionality. |
| @@ -87,6 +91,20 @@ int main(int argc, const char* argv[]) { |
| return RunSyncTest() ? 0 : -1; |
| } |
| + std::string port_str = "0"; |
|
akalin
2012/05/23 05:29:21
move port_str inside the if statement and don't in
Raghu Simha
2012/05/23 06:02:59
Done.
|
| + int port_int = 0; |
| + if (command_line->HasSwitch("port")) { |
| + port_str = command_line->GetSwitchValueASCII("port"); |
| + base::StringToInt(port_str, &port_int); |
| + } |
| + |
| + std::string xmpp_port_str = "0"; |
| + int xmpp_port_int = 0; |
| + if (command_line->HasSwitch("xmpp-port")) { |
| + xmpp_port_str = command_line->GetSwitchValueASCII("xmpp-port"); |
| + base::StringToInt(xmpp_port_str, &xmpp_port_int); |
| + } |
| + |
| net::TestServer::HTTPSOptions https_options; |
| if (command_line->HasSwitch("https-cert")) { |
| server_type = net::TestServer::TYPE_HTTPS; |
| @@ -114,12 +132,20 @@ int main(int argc, const char* argv[]) { |
| } |
| scoped_ptr<net::TestServer> test_server; |
| - if (server_type == net::TestServer::TYPE_HTTPS) |
| - test_server.reset(new net::TestServer(https_options, doc_root)); |
| - else |
| - test_server.reset(new net::TestServer(server_type, |
| - net::TestServer::kLocalhost, |
| - doc_root)); |
| + switch (server_type) { |
| + case net::TestServer::TYPE_HTTPS: |
| + test_server.reset(new net::TestServer(https_options, doc_root)); |
| + break; |
| + case net::TestServer::TYPE_SYNC: |
| + test_server.reset(new net::LocalSyncTestServer((uint16) port_int, |
|
akalin
2012/05/23 05:29:21
prefer static_cast<uint16>()
akalin
2012/05/23 05:29:21
in fact, you can probably stick the int parsing co
Raghu Simha
2012/05/23 06:02:59
Done.
Raghu Simha
2012/05/23 06:02:59
Done. Moved to a separate function. Added braces i
|
| + (uint16) xmpp_port_int)); |
| + break; |
| + default: |
| + test_server.reset(new net::TestServer(server_type, |
| + net::TestServer::kLocalhost, |
| + doc_root)); |
| + break; |
| + } |
| if (!test_server->Start()) { |
| printf("Error: failed to start test server. Exiting.\n"); |