Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10157)

Unified Diff: chrome/test/chromedriver/server/http_handler_unittest.cc

Issue 19616008: [chromedriver] Allow commands to be async. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/chromedriver/server/http_handler.cc ('k') | chrome/test/chromedriver/session.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/server/http_handler_unittest.cc
diff --git a/chrome/test/chromedriver/server/http_handler_unittest.cc b/chrome/test/chromedriver/server/http_handler_unittest.cc
index 76c4f6e5f70e95394a51e6275aaa8a0029276e76..3fc6cd8900054d9bf68df548eab9b2180516c796 100644
--- a/chrome/test/chromedriver/server/http_handler_unittest.cc
+++ b/chrome/test/chromedriver/server/http_handler_unittest.cc
@@ -10,6 +10,7 @@
#include "base/values.h"
#include "chrome/test/chromedriver/chrome/log.h"
#include "chrome/test/chromedriver/chrome/status.h"
+#include "chrome/test/chromedriver/command.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"
@@ -17,15 +18,19 @@
namespace {
-Status DummyCommand(
- Status status,
+void DummyCommand(
+ const Status& status,
const base::DictionaryValue& params,
const std::string& session_id,
- scoped_ptr<base::Value>* value,
- std::string* out_session_id) {
- value->reset(new base::FundamentalValue(1));
- *out_session_id = "session_id";
- return status;
+ const CommandCallback& callback) {
+ callback.Run(status,
+ scoped_ptr<base::Value>(new base::FundamentalValue(1)),
+ "session_id");
+}
+
+void OnResponse(HttpResponse* response_to_set,
+ scoped_ptr<HttpResponse> response) {
+ *response_to_set = *response;
}
} // namespace
@@ -38,7 +43,7 @@ TEST(HttpHandlerTest, HandleOutsideOfBaseUrl) {
request.path = "base/path";
request.data = "body";
HttpResponse response;
- handler.Handle(request, &response);
+ handler.Handle(request, base::Bind(&OnResponse, &response));
ASSERT_EQ(HttpResponse::kBadRequest, response.status());
}
@@ -49,7 +54,7 @@ TEST(HttpHandlerTest, HandleUnknownCommand) {
request.method = "get";
request.path = "/path";
HttpResponse response;
- handler.Handle(request, &response);
+ handler.Handle(request, base::Bind(&OnResponse, &response));
ASSERT_EQ(HttpResponse::kNotFound, response.status());
}
@@ -64,7 +69,7 @@ TEST(HttpHandlerTest, HandleNewSession) {
request.method = "post";
request.path = "/base/session";
HttpResponse response;
- handler.Handle(request, &response);
+ handler.Handle(request, base::Bind(&OnResponse, &response));
ASSERT_EQ(HttpResponse::kSeeOther, response.status());
std::string location;
ASSERT_TRUE(response.GetHeader("Location", &location));
@@ -82,7 +87,7 @@ TEST(HttpHandlerTest, HandleInvalidPost) {
request.path = "/path";
request.data = "should be a dictionary";
HttpResponse response;
- handler.Handle(request, &response);
+ handler.Handle(request, base::Bind(&OnResponse, &response));
ASSERT_EQ(HttpResponse::kBadRequest, response.status());
}
@@ -96,7 +101,7 @@ TEST(HttpHandlerTest, HandleUnimplementedCommand) {
request.method = "post";
request.path = "/path";
HttpResponse response;
- handler.Handle(request, &response);
+ handler.Handle(request, base::Bind(&OnResponse, &response));
ASSERT_EQ(HttpResponse::kNotImplemented, response.status());
}
@@ -109,7 +114,7 @@ TEST(HttpHandlerTest, HandleCommand) {
request.method = "post";
request.path = "/path";
HttpResponse response;
- handler.Handle(request, &response);
+ handler.Handle(request, base::Bind(&OnResponse, &response));
ASSERT_EQ(HttpResponse::kOk, response.status());
std::string mime;
ASSERT_TRUE(response.GetHeader("Content-Type", &mime));
« no previous file with comments | « chrome/test/chromedriver/server/http_handler.cc ('k') | chrome/test/chromedriver/session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698