| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/chromedriver/server/http_handler.h" | 5 #include "chrome/test/chromedriver/server/http_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/test/chromedriver/chrome/log.h" | 13 #include "chrome/test/chromedriver/chrome/log.h" |
| 14 #include "chrome/test/chromedriver/chrome/status.h" | 14 #include "chrome/test/chromedriver/chrome/status.h" |
| 15 #include "chrome/test/chromedriver/command.h" | 15 #include "chrome/test/chromedriver/command.h" |
| 16 #include "net/http/http_status_code.h" | 16 #include "net/http/http_status_code.h" |
| 17 #include "net/server/http_server_request_info.h" | 17 #include "net/server/http_server_request_info.h" |
| 18 #include "net/server/http_server_response_info.h" | 18 #include "net/server/http_server_response_info.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 void DummyCommand( | 23 void DummyCommand( |
| 24 const Status& status, | 24 const Status& status, |
| 25 const base::DictionaryValue& params, | 25 const base::DictionaryValue& params, |
| 26 const std::string& session_id, | 26 const std::string& session_id, |
| 27 const CommandCallback& callback) { | 27 const CommandCallback& callback) { |
| 28 callback.Run(status, | 28 callback.Run(status, std::unique_ptr<base::Value>(new base::Value(1)), |
| 29 std::unique_ptr<base::Value>(new base::FundamentalValue(1)), | 29 "session_id", false); |
| 30 "session_id", | |
| 31 false); | |
| 32 } | 30 } |
| 33 | 31 |
| 34 void OnResponse(net::HttpServerResponseInfo* response_to_set, | 32 void OnResponse(net::HttpServerResponseInfo* response_to_set, |
| 35 std::unique_ptr<net::HttpServerResponseInfo> response) { | 33 std::unique_ptr<net::HttpServerResponseInfo> response) { |
| 36 *response_to_set = *response; | 34 *response_to_set = *response; |
| 37 } | 35 } |
| 38 | 36 |
| 39 } // namespace | 37 } // namespace |
| 40 | 38 |
| 41 TEST(HttpHandlerTest, HandleOutsideOfBaseUrl) { | 39 TEST(HttpHandlerTest, HandleOutsideOfBaseUrl) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 CommandMapping command(kPost, "path/:xyz", | 190 CommandMapping command(kPost, "path/:xyz", |
| 193 base::Bind(&DummyCommand, Status(kOk))); | 191 base::Bind(&DummyCommand, Status(kOk))); |
| 194 std::string session_id; | 192 std::string session_id; |
| 195 base::DictionaryValue params; | 193 base::DictionaryValue params; |
| 196 ASSERT_TRUE(internal::MatchesCommand( | 194 ASSERT_TRUE(internal::MatchesCommand( |
| 197 "post", "path/%40a%%b%%c%%%%", command, &session_id, ¶ms)); | 195 "post", "path/%40a%%b%%c%%%%", command, &session_id, ¶ms)); |
| 198 std::string param; | 196 std::string param; |
| 199 ASSERT_TRUE(params.GetString("xyz", ¶m)); | 197 ASSERT_TRUE(params.GetString("xyz", ¶m)); |
| 200 ASSERT_EQ("@a%b%c%%", param); | 198 ASSERT_EQ("@a%b%c%%", param); |
| 201 } | 199 } |
| OLD | NEW |