diff options
Diffstat (limited to 'net/socket')
-rw-r--r-- | net/socket/ssl_test_util.cc | 23 | ||||
-rw-r--r-- | net/socket/ssl_test_util.h | 8 |
2 files changed, 29 insertions, 2 deletions
diff --git a/net/socket/ssl_test_util.cc b/net/socket/ssl_test_util.cc index 1acc0b5..649b27d 100644 --- a/net/socket/ssl_test_util.cc +++ b/net/socket/ssl_test_util.cc @@ -94,11 +94,29 @@ const int TestServerLauncher::kBadHTTPSPort = 9666; // The issuer name of the cert that should be trusted for the test to work. const wchar_t TestServerLauncher::kCertIssuerName[] = L"Test CA"; -TestServerLauncher::TestServerLauncher() : process_handle_(NULL) +TestServerLauncher::TestServerLauncher() : process_handle_(NULL), + connection_attempts_(10), + connection_timeout_(1000) #if defined(OS_LINUX) , cert_(NULL) #endif { + InitCertPath(); +} + +TestServerLauncher::TestServerLauncher(int connection_attempts, + int connection_timeout) + : process_handle_(NULL), + connection_attempts_(connection_attempts), + connection_timeout_(connection_timeout) +#if defined(OS_LINUX) +, cert_(NULL) +#endif +{ + InitCertPath(); +} + +void TestServerLauncher::InitCertPath() { PathService::Get(base::DIR_SOURCE_ROOT, &cert_dir_); cert_dir_ = cert_dir_.Append(FILE_PATH_LITERAL("net")) .Append(FILE_PATH_LITERAL("data")) @@ -253,7 +271,8 @@ bool TestServerLauncher::WaitToStart(const std::string& host_name, int port) { return false; net::TCPPinger pinger(addr); - rv = pinger.Ping(); + rv = pinger.Ping(base::TimeDelta::FromMilliseconds(connection_timeout_), + connection_attempts_); return rv == net::OK; } diff --git a/net/socket/ssl_test_util.h b/net/socket/ssl_test_util.h index acda685..ad9bbab 100644 --- a/net/socket/ssl_test_util.h +++ b/net/socket/ssl_test_util.h @@ -26,6 +26,7 @@ namespace net { class TestServerLauncher { public: TestServerLauncher(); + TestServerLauncher(int connection_attempts, int connection_timeout); virtual ~TestServerLauncher(); @@ -94,6 +95,9 @@ class TestServerLauncher { // Returns false if our test root certificate is not trusted. bool CheckCATrusted(); + // Initilize the certificate path. + void InitCertPath(); + FilePath document_root_dir_; FilePath cert_dir_; @@ -102,6 +106,10 @@ class TestServerLauncher { base::ProcessHandle process_handle_; + // Number of tries and timeout for each try used for WaitToStart. + int connection_attempts_; + int connection_timeout_; + #if defined(OS_LINUX) struct PrivateCERTCertificate; PrivateCERTCertificate *cert_; |