| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "headless/public/util/generic_url_request_job.h" | 5 #include "headless/public/util/generic_url_request_job.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 namespace headless { | 40 namespace headless { |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 class MockFetcher : public URLFetcher { | 44 class MockFetcher : public URLFetcher { |
| 45 public: | 45 public: |
| 46 MockFetcher(base::DictionaryValue* fetch_request, | 46 MockFetcher(base::DictionaryValue* fetch_request, |
| 47 const std::string& json_reply) | 47 const std::string& json_reply) |
| 48 : fetch_reply_(base::JSONReader::Read(json_reply, base::JSON_PARSE_RFC)), | 48 : fetch_reply_(base::JSONReader::Read(json_reply, base::JSON_PARSE_RFC)), |
| 49 fetch_request_(fetch_request) { | 49 fetch_request_(fetch_request) { |
| 50 CHECK(fetch_reply_) << "Invalid json: " << json_reply; | 50 // Invalid json. |
| 51 CHECK(fetch_reply_); |
| 51 } | 52 } |
| 52 | 53 |
| 53 ~MockFetcher() override {} | 54 ~MockFetcher() override {} |
| 54 | 55 |
| 55 void StartFetch(const GURL& url, | 56 void StartFetch(const GURL& url, |
| 56 const std::string& method, | 57 const std::string& method, |
| 57 const net::HttpRequestHeaders& request_headers, | 58 const net::HttpRequestHeaders& request_headers, |
| 58 ResultListener* result_listener) override { | 59 ResultListener* result_listener) override { |
| 59 // Record the request. | 60 // Record the request. |
| 60 fetch_request_->SetString("url", url.spec()); | 61 fetch_request_->SetString("url", url.spec()); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 job_delegate_.SetShouldBlock(true); | 363 job_delegate_.SetShouldBlock(true); |
| 363 | 364 |
| 364 std::unique_ptr<net::URLRequest> request( | 365 std::unique_ptr<net::URLRequest> request( |
| 365 CreateAndCompleteJob(GURL("https://example.com"), reply)); | 366 CreateAndCompleteJob(GURL("https://example.com"), reply)); |
| 366 | 367 |
| 367 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status()); | 368 EXPECT_EQ(net::URLRequestStatus::FAILED, request->status().status()); |
| 368 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request->status().error()); | 369 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request->status().error()); |
| 369 } | 370 } |
| 370 | 371 |
| 371 } // namespace headless | 372 } // namespace headless |
| OLD | NEW |