summaryrefslogtreecommitdiffstats
path: root/chrome/test/chromedriver/server/http_handler_unittest.cc
diff options
context:
space:
mode:
authorkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-22 20:08:18 +0000
committerkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-22 20:08:18 +0000
commit72f2592365d94cc3cb7294e24d682fcd81151abc (patch)
tree63e906431dbaeb5466946d80d8658c637ea0af3c /chrome/test/chromedriver/server/http_handler_unittest.cc
parentc9904b429860b83606492d4fe8f1b232c04753b5 (diff)
downloadchromium_src-72f2592365d94cc3cb7294e24d682fcd81151abc.zip
chromium_src-72f2592365d94cc3cb7294e24d682fcd81151abc.tar.gz
chromium_src-72f2592365d94cc3cb7294e24d682fcd81151abc.tar.bz2
[chromedriver] Switch from using HttpRequest to net::HttpServerRequestInfo.
This is in preparation for switching to net::HttpServer and removing mongoose. BUG=none Review URL: https://chromiumcodereview.appspot.com/19672012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/chromedriver/server/http_handler_unittest.cc')
-rw-r--r--chrome/test/chromedriver/server/http_handler_unittest.cc41
1 files changed, 28 insertions, 13 deletions
diff --git a/chrome/test/chromedriver/server/http_handler_unittest.cc b/chrome/test/chromedriver/server/http_handler_unittest.cc
index 816cb3e..76c4f6e 100644
--- a/chrome/test/chromedriver/server/http_handler_unittest.cc
+++ b/chrome/test/chromedriver/server/http_handler_unittest.cc
@@ -12,6 +12,7 @@
#include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/server/http_handler.h"
#include "chrome/test/chromedriver/server/http_response.h"
+#include "net/server/http_server_request_info.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -32,7 +33,10 @@ Status DummyCommand(
TEST(HttpHandlerTest, HandleOutsideOfBaseUrl) {
Logger log;
HttpHandler handler(&log, "base/url/");
- HttpRequest request(kGet, "base/path", "body");
+ net::HttpServerRequestInfo request;
+ request.method = "get";
+ request.path = "base/path";
+ request.data = "body";
HttpResponse response;
handler.Handle(request, &response);
ASSERT_EQ(HttpResponse::kBadRequest, response.status());
@@ -41,7 +45,9 @@ TEST(HttpHandlerTest, HandleOutsideOfBaseUrl) {
TEST(HttpHandlerTest, HandleUnknownCommand) {
Logger log;
HttpHandler handler(&log, "/");
- HttpRequest request(kGet, "/path", std::string());
+ net::HttpServerRequestInfo request;
+ request.method = "get";
+ request.path = "/path";
HttpResponse response;
handler.Handle(request, &response);
ASSERT_EQ(HttpResponse::kNotFound, response.status());
@@ -54,7 +60,9 @@ TEST(HttpHandlerTest, HandleNewSession) {
handler.command_map_->push_back(
CommandMapping(kPost, internal::kNewSessionPathPattern,
base::Bind(&DummyCommand, Status(kOk))));
- HttpRequest request(kPost, "/base/session", std::string());
+ net::HttpServerRequestInfo request;
+ request.method = "post";
+ request.path = "/base/session";
HttpResponse response;
handler.Handle(request, &response);
ASSERT_EQ(HttpResponse::kSeeOther, response.status());
@@ -69,7 +77,10 @@ TEST(HttpHandlerTest, HandleInvalidPost) {
HttpHandler handler(&log, "/");
handler.command_map_->push_back(
CommandMapping(kPost, "path", base::Bind(&DummyCommand, Status(kOk))));
- HttpRequest request(kPost, "/path", "should be a dictionary");
+ net::HttpServerRequestInfo request;
+ request.method = "post";
+ request.path = "/path";
+ request.data = "should be a dictionary";
HttpResponse response;
handler.Handle(request, &response);
ASSERT_EQ(HttpResponse::kBadRequest, response.status());
@@ -81,7 +92,9 @@ TEST(HttpHandlerTest, HandleUnimplementedCommand) {
handler.command_map_->push_back(
CommandMapping(kPost, "path",
base::Bind(&DummyCommand, Status(kUnknownCommand))));
- HttpRequest request(kPost, "/path", std::string());
+ net::HttpServerRequestInfo request;
+ request.method = "post";
+ request.path = "/path";
HttpResponse response;
handler.Handle(request, &response);
ASSERT_EQ(HttpResponse::kNotImplemented, response.status());
@@ -92,7 +105,9 @@ TEST(HttpHandlerTest, HandleCommand) {
HttpHandler handler(&log, "/");
handler.command_map_->push_back(
CommandMapping(kPost, "path", base::Bind(&DummyCommand, Status(kOk))));
- HttpRequest request(kPost, "/path", std::string());
+ net::HttpServerRequestInfo request;
+ request.method = "post";
+ request.path = "/path";
HttpResponse response;
handler.Handle(request, &response);
ASSERT_EQ(HttpResponse::kOk, response.status());
@@ -112,7 +127,7 @@ TEST(MatchesCommandTest, DiffMethod) {
std::string session_id;
base::DictionaryValue params;
ASSERT_FALSE(internal::MatchesCommand(
- kGet, "path", command, &session_id, &params));
+ "get", "path", command, &session_id, &params));
ASSERT_STREQ("", session_id.c_str());
ASSERT_EQ(0u, params.size());
}
@@ -123,13 +138,13 @@ TEST(MatchesCommandTest, DiffPathLength) {
std::string session_id;
base::DictionaryValue params;
ASSERT_FALSE(internal::MatchesCommand(
- kPost, "path", command, &session_id, &params));
+ "post", "path", command, &session_id, &params));
ASSERT_FALSE(internal::MatchesCommand(
- kPost, std::string(), command, &session_id, &params));
+ "post", std::string(), command, &session_id, &params));
ASSERT_FALSE(
- internal::MatchesCommand(kPost, "/", command, &session_id, &params));
+ internal::MatchesCommand("post", "/", command, &session_id, &params));
ASSERT_FALSE(internal::MatchesCommand(
- kPost, "path/path/path", command, &session_id, &params));
+ "post", "path/path/path", command, &session_id, &params));
}
TEST(MatchesCommandTest, DiffPaths) {
@@ -138,7 +153,7 @@ TEST(MatchesCommandTest, DiffPaths) {
std::string session_id;
base::DictionaryValue params;
ASSERT_FALSE(internal::MatchesCommand(
- kPost, "path/bpath", command, &session_id, &params));
+ "post", "path/bpath", command, &session_id, &params));
}
TEST(MatchesCommandTest, Substitution) {
@@ -147,7 +162,7 @@ TEST(MatchesCommandTest, Substitution) {
std::string session_id;
base::DictionaryValue params;
ASSERT_TRUE(internal::MatchesCommand(
- kPost, "path/1/space/2/3", command, &session_id, &params));
+ "post", "path/1/space/2/3", command, &session_id, &params));
ASSERT_EQ("1", session_id);
ASSERT_EQ(2u, params.size());
std::string param;