summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-18 04:35:41 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-18 04:35:41 +0000
commit0fefd0206fc58c2908f299261a2e3f665266629e (patch)
treeb05ac051184c14260de6eae1c168ccb74bfd4a68 /net
parent966aa081ab4757e0386727ce9873d12dcf87b2b2 (diff)
downloadchromium_src-0fefd0206fc58c2908f299261a2e3f665266629e.zip
chromium_src-0fefd0206fc58c2908f299261a2e3f665266629e.tar.gz
chromium_src-0fefd0206fc58c2908f299261a2e3f665266629e.tar.bz2
net: Make a few test server connection values constants. Also do a little FilePath cleanup while we're at it.
BUG=none TEST=Net unittests do not time out on the fyi wine/valgrind test bot. Review URL: http://codereview.chromium.org/501100 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34933 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/net_test_constants.h18
-rw-r--r--net/net.gyp1
-rw-r--r--net/socket/ssl_test_util.cc25
-rw-r--r--net/url_request/url_request_unittest.h11
4 files changed, 39 insertions, 16 deletions
diff --git a/net/base/net_test_constants.h b/net/base/net_test_constants.h
new file mode 100644
index 0000000..83eb43f
--- /dev/null
+++ b/net/base/net_test_constants.h
@@ -0,0 +1,18 @@
+// Copyright (c) 2009 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_BASE_NET_TEST_CONSTANTS_H_
+#define NET_BASE_NET_TEST_CONSTANTS_H_
+
+namespace net {
+
+// Number of connection attempts for tests.
+const int kDefaultTestConnectionAttempts = 10;
+
+// Connection timeout in milliseconds for tests.
+const int kDefaultTestConnectionTimeout = 1000;
+
+} // namespace net
+
+#endif // NET_BASE_NET_TEST_CONSTANTS_H_
diff --git a/net/net.gyp b/net/net.gyp
index d95ffd7..2528073 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -593,6 +593,7 @@
'base/listen_socket_unittest.h',
'base/mime_sniffer_unittest.cc',
'base/mime_util_unittest.cc',
+ 'base/net_test_constants.h',
'base/net_util_unittest.cc',
'base/registry_controlled_domain_unittest.cc',
'base/run_all_unittests.cc',
diff --git a/net/socket/ssl_test_util.cc b/net/socket/ssl_test_util.cc
index d00b89d..becb322 100644
--- a/net/socket/ssl_test_util.cc
+++ b/net/socket/ssl_test_util.cc
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <string>
#include <algorithm>
+#include <string>
+#include <vector>
#include "net/socket/ssl_test_util.h"
@@ -31,6 +32,7 @@
#include "base/path_service.h"
#include "base/string_util.h"
#include "net/base/host_resolver.h"
+#include "net/base/net_test_constants.h"
#include "net/base/test_completion_callback.h"
#include "net/socket/tcp_client_socket.h"
#include "net/socket/tcp_pinger.h"
@@ -47,8 +49,8 @@ static CERTCertificate* LoadTemporaryCert(const FilePath& filename) {
base::EnsureNSSInit();
std::string rawcert;
- if (!file_util::ReadFileToString(filename.ToWStringHack(), &rawcert)) {
- LOG(ERROR) << "Can't load certificate " << filename.ToWStringHack();
+ if (!file_util::ReadFileToString(filename, &rawcert)) {
+ LOG(ERROR) << "Can't load certificate " << filename.value();
return NULL;
}
@@ -56,7 +58,7 @@ static CERTCertificate* LoadTemporaryCert(const FilePath& filename) {
cert = CERT_DecodeCertFromPackage(const_cast<char *>(rawcert.c_str()),
rawcert.length());
if (!cert) {
- LOG(ERROR) << "Can't convert certificate " << filename.ToWStringHack();
+ LOG(ERROR) << "Can't convert certificate " << filename.value();
return NULL;
}
@@ -71,8 +73,7 @@ static CERTCertificate* LoadTemporaryCert(const FilePath& filename) {
rv = CERT_ChangeCertTrust(CERT_GetDefaultCertDB(), cert, &trust);
if (rv != SECSuccess) {
- LOG(ERROR) << "Can't change trust for certificate "
- << filename.ToWStringHack();
+ LOG(ERROR) << "Can't change trust for certificate " << filename.value();
CERT_DestroyCertificate(cert);
return NULL;
}
@@ -84,8 +85,8 @@ static CERTCertificate* LoadTemporaryCert(const FilePath& filename) {
#if defined(OS_MACOSX)
static net::X509Certificate* LoadTemporaryCert(const FilePath& filename) {
std::string rawcert;
- if (!file_util::ReadFileToString(filename.ToWStringHack(), &rawcert)) {
- LOG(ERROR) << "Can't load certificate " << filename.ToWStringHack();
+ if (!file_util::ReadFileToString(filename, &rawcert)) {
+ LOG(ERROR) << "Can't load certificate " << filename.value();
return NULL;
}
@@ -133,10 +134,10 @@ const int TestServerLauncher::kBadHTTPSPort = 9666;
const wchar_t TestServerLauncher::kCertIssuerName[] = L"Test CA";
TestServerLauncher::TestServerLauncher() : process_handle_(
- base::kNullProcessHandle),
- forking_(false),
- connection_attempts_(10),
- connection_timeout_(1000)
+ base::kNullProcessHandle),
+ forking_(false),
+ connection_attempts_(kDefaultTestConnectionAttempts),
+ connection_timeout_(kDefaultTestConnectionTimeout)
#if defined(OS_LINUX)
, cert_(NULL)
#endif
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index 649aa37..88aa3ae 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -24,6 +24,7 @@
#include "net/base/host_resolver.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
+#include "net/base/net_test_constants.h"
#include "net/base/ssl_config_service_defaults.h"
#include "net/http/http_network_layer.h"
#include "net/socket/ssl_test_util.h"
@@ -383,14 +384,16 @@ class HTTPTestServer : public BaseTestServer {
const std::wstring& document_root,
const std::wstring& file_root_url,
MessageLoop* loop) {
- return CreateServerWithFileRootURL(document_root, file_root_url,
- loop, 10, 1000);
+ return CreateServerWithFileRootURL(document_root, file_root_url, loop,
+ net::kDefaultTestConnectionAttempts,
+ net::kDefaultTestConnectionTimeout);
}
static scoped_refptr<HTTPTestServer> CreateForkingServer(
const std::wstring& document_root) {
scoped_refptr<HTTPTestServer> test_server =
- new HTTPTestServer(10, 1000);
+ new HTTPTestServer(net::kDefaultTestConnectionAttempts,
+ net::kDefaultTestConnectionTimeout);
test_server->set_forking(true);
FilePath no_cert;
FilePath docroot = FilePath::FromWStringHack(document_root);
@@ -484,7 +487,7 @@ class HTTPTestServer : public BaseTestServer {
retry_count--;
}
// Make sure we were successful in stopping the testserver.
- DCHECK(retry_count > 0);
+ DCHECK_GT(retry_count, 0);
}
virtual std::string scheme() { return "http"; }