diff options
author | jabdelmalek@google.com <jabdelmalek@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-16 16:44:11 +0000 |
---|---|---|
committer | jabdelmalek@google.com <jabdelmalek@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-16 16:44:11 +0000 |
commit | bedf8749411d079d41d62263ed434d86dab708bd (patch) | |
tree | 586ef192471003427019b65b46a69d0bf4f06653 /chrome/test/base/ui_test_utils.cc | |
parent | 7b5635c1046e7d6f41521e8ff77b7ff1152cf48b (diff) | |
download | chromium_src-bedf8749411d079d41d62263ed434d86dab708bd.zip chromium_src-bedf8749411d079d41d62263ed434d86dab708bd.tar.gz chromium_src-bedf8749411d079d41d62263ed434d86dab708bd.tar.bz2 |
Use a random port for WebSocket tests. In browser_tests the websocket server might run simultaneously when the sharding supervisor is used. In practice I haven't seen a try run that fails from this because the sharding_supervisor reruns failed tests serially, but probably good to fix this.
BUG=118460
Review URL: https://chromiumcodereview.appspot.com/9693066
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127180 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/base/ui_test_utils.cc')
-rw-r--r-- | chrome/test/base/ui_test_utils.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc index 520b0ce..ec9e941 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -20,6 +20,7 @@ #include "base/message_loop.h" #include "base/path_service.h" #include "base/process_util.h" +#include "base/rand_util.h" #include "base/string_number_conversions.h" #include "base/test/test_timeouts.h" #include "base/utf_string_conversions.h" @@ -790,12 +791,17 @@ void AppendToPythonPath(const FilePath& dir) { } // anonymous namespace TestWebSocketServer::TestWebSocketServer() - : started_(false) { + : started_(false), port_(kDefaultWsPort) { #if defined(OS_POSIX) process_group_id_ = base::kNullProcessHandle; #endif } +int TestWebSocketServer::UseRandomPort() { + port_ = base::RandInt(1024, 65535); + return port_; +} + bool TestWebSocketServer::Start(const FilePath& root_directory) { if (started_) return true; @@ -806,7 +812,7 @@ bool TestWebSocketServer::Start(const FilePath& root_directory) { cmd_line->AppendArg("--register_cygwin"); cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") + root_directory.value()); - cmd_line->AppendArg("--port=" + base::IntToString(kDefaultWsPort)); + cmd_line->AppendArg("--port=" + base::IntToString(port_)); if (!temp_dir_.CreateUniqueTempDir()) { LOG(ERROR) << "Unable to create a temporary directory."; return false; |