summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test/test_server.cc
diff options
context:
space:
mode:
authorkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 22:07:03 +0000
committerkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-12 22:07:03 +0000
commit6448b3abcfa035eaf65b7c0c15bb728513f228fe (patch)
tree3d8ee0bf2f528e93616a1d7721bc721ef6726189 /chrome_frame/test/test_server.cc
parentbb2eb35a70fcbc47be253bf50c8648c65271a19e (diff)
downloadchromium_src-6448b3abcfa035eaf65b7c0c15bb728513f228fe.zip
chromium_src-6448b3abcfa035eaf65b7c0c15bb728513f228fe.tar.gz
chromium_src-6448b3abcfa035eaf65b7c0c15bb728513f228fe.tar.bz2
[chrome_frame] Refactor/merge IE no interference tests with other mock event sink tests. Have the test mock contain, not inherit the IE event sink. Use the new test server to verify the right requests are being sent.
BUG=none TEST=none Review URL: http://codereview.chromium.org/2822016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52137 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test/test_server.cc')
-rw-r--r--chrome_frame/test/test_server.cc38
1 files changed, 33 insertions, 5 deletions
diff --git a/chrome_frame/test/test_server.cc b/chrome_frame/test/test_server.cc
index 88672b8..8f0910d 100644
--- a/chrome_frame/test/test_server.cc
+++ b/chrome_frame/test/test_server.cc
@@ -5,6 +5,7 @@
#include "base/logging.h"
#include "base/registry.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "chrome_frame/test/test_server.h"
@@ -217,9 +218,11 @@ void SimpleWebServer::DidClose(ListenSocket* sock) {
}
}
-HTTPTestServer::HTTPTestServer(int port, const char* address) {
+HTTPTestServer::HTTPTestServer(int port, const std::wstring& address,
+ FilePath root_dir)
+ : port_(port), address_(address), root_dir_(root_dir) {
net::EnsureWinsockInit();
- server_ = ListenSocket::Listen(address, port, this);
+ server_ = ListenSocket::Listen(WideToUTF8(address), port, this);
}
HTTPTestServer::~HTTPTestServer() {
@@ -258,10 +261,11 @@ void HTTPTestServer::DidRead(ListenSocket* socket,
std::string str(data, len);
connection->r_.OnDataReceived(str);
if (connection->r_.AllContentReceived()) {
+ std::wstring path = UTF8ToWide(connection->r_.path());
if (LowerCaseEqualsASCII(connection->r_.method(), "post"))
- this->Post(connection, connection->r_.path(), connection->r_);
+ this->Post(connection, path, connection->r_);
else
- this->Get(connection, connection->r_.path(), connection->r_);
+ this->Get(connection, path, connection->r_);
}
}
}
@@ -272,6 +276,29 @@ void HTTPTestServer::DidClose(ListenSocket* socket) {
connection_list_.erase(it);
}
+std::wstring HTTPTestServer::Resolve(const std::wstring& path) {
+ // Remove the first '/' if needed.
+ std::wstring stripped_path = path;
+ if (path.size() && path[0] == L'/')
+ stripped_path = path.substr(1);
+
+ if (port_ == 80) {
+ if (stripped_path.empty()) {
+ return StringPrintf(L"http://%ls", address_.c_str());
+ } else {
+ return StringPrintf(L"http://%ls/%ls", address_.c_str(),
+ stripped_path.c_str());
+ }
+ } else {
+ if (stripped_path.empty()) {
+ return StringPrintf(L"http://%ls:%d", address_.c_str(), port_);
+ } else {
+ return StringPrintf(L"http://%ls:%d/%ls", address_.c_str(), port_,
+ stripped_path.c_str());
+ }
+ }
+}
+
void ConfigurableConnection::SendChunk() {
int size = (int)data_.size();
const char* chunk_ptr = data_.c_str() + cur_pos_;
@@ -334,4 +361,5 @@ void ConfigurableConnection::SendWithOptions(const std::string& headers,
NewRunnableMethod(this, &ConfigurableConnection::SendChunk),
options.timeout_);
}
-} // namespace test_server
+
+} // namespace test_server \ No newline at end of file