Index: net/url_request/url_request_unittest.h |
=================================================================== |
--- net/url_request/url_request_unittest.h (revision 4466) |
+++ net/url_request/url_request_unittest.h (working copy) |
@@ -15,11 +15,13 @@ |
#include "base/process_util.h" |
#include "base/string_util.h" |
#include "base/thread.h" |
+#include "base/time.h" |
#include "base/waitable_event.h" |
#include "net/base/net_errors.h" |
#include "net/http/http_network_layer.h" |
#include "net/url_request/url_request.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#include "googleurl/src/url_util.h" |
const int kDefaultPort = 1337; |
const std::string kDefaultHostName("localhost"); |
@@ -202,7 +204,8 @@ |
// filter. |
if (!process_handle_) |
return false; |
- return pid == process_util::GetProcId(process_handle_); |
+ // TODO(port): rationalize return value of GetProcId |
+ return pid == (uint32)process_util::GetProcId(process_handle_); |
} |
GURL TestServerPage(const std::string& path) { |
@@ -210,7 +213,7 @@ |
} |
GURL TestServerPageW(const std::wstring& path) { |
- return GURL(UTF8ToWide(base_address_) + path); |
+ return GURL(base_address_ + WideToUTF8(path)); |
} |
// A subclass may wish to send the request in a different manner |
@@ -254,7 +257,7 @@ |
const std::wstring& cert_path) { |
std::stringstream ss; |
std::string port_str; |
- ss << port ? port : kDefaultPort; |
+ ss << (port ? port : kDefaultPort); |
ss >> port_str; |
base_address_ = scheme() + "://" + host_name + ":" + port_str + "/"; |
@@ -278,6 +281,7 @@ |
L'/', file_util::kPathSeparator); |
file_util::AppendToPath(&test_data_directory, normalized_document_root); |
+#if defined(OS_WIN) |
std::wstring command_line = |
L"\"" + python_runtime_ + L"\" " + L"\"" + testserver_path + |
L"\" --port=" + UTF8ToWide(port_str) + L" --data-dir=\"" + |
@@ -291,7 +295,23 @@ |
ASSERT_TRUE( |
process_util::LaunchApp(command_line, false, true, &process_handle_)) << |
"Failed to launch " << command_line; |
+#elif defined(OS_LINUX) |
+ bool tlslite_installed = !access("/usr/bin/tls.py", X_OK); |
+ ASSERT_TRUE(tlslite_installed) << "tlslite not installed? Please run 'python setup.py install' in third_party/tlslite."; |
+ std::vector<std::string> command_line; |
+ command_line.push_back("python"); |
+ command_line.push_back(WideToUTF8(testserver_path)); |
+ command_line.push_back("--port=" + port_str); |
+ command_line.push_back("--data-dir=" + WideToUTF8(test_data_directory)); |
+ if (!cert_path.empty()) |
+ command_line.push_back("--https=" + WideToUTF8(cert_path)); |
+ |
+ ASSERT_TRUE( |
+ process_util::LaunchApp(command_line, false, &process_handle_)) << |
+ "Failed to launch " << command_line[0] << " ..."; |
+#endif |
+ |
// Verify that the webserver is actually started. |
// Otherwise tests can fail if they run faster than Python can start. |
int retries = 10; |
@@ -300,7 +320,7 @@ |
retries--; |
PlatformThread::Sleep(500); |
} |
- ASSERT_TRUE(success) << "Webserver not starting properly."; |
+ ASSERT_TRUE(success) << "Webserver not starting properly. (On Linux, you need to install third_party/tlslite.)"; |
is_shutdown_ = false; |
} |
@@ -312,7 +332,7 @@ |
// here we append the time to avoid problems where the kill page |
// is being cached rather than being executed on the server |
std::ostringstream page_name; |
- page_name << "kill?" << GetTickCount(); |
+ page_name << "kill?" << (unsigned int)(base::Time::Now().ToInternalValue()); |
int retry_count = 5; |
while (retry_count > 0) { |
bool r = MakeGETRequest(page_name.str()); |
@@ -328,7 +348,9 @@ |
DCHECK(retry_count > 0); |
if (process_handle_) { |
+#if defined(OS_WIN) |
CloseHandle(process_handle_); |
+#endif |
process_handle_ = NULL; |
} |
@@ -369,7 +391,7 @@ |
std::string base_address_; |
std::wstring python_runtime_; |
- HANDLE process_handle_; |
+ ProcessHandle process_handle_; |
bool is_shutdown_; |
}; |