OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/domain_reliability/uploader.h" | 5 #include "components/domain_reliability/uploader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 net::HttpUtil::AssembleRawHeaders(headers, strlen(headers)))); | 84 net::HttpUtil::AssembleRawHeaders(headers, strlen(headers)))); |
85 fetcher->SetResponseString(""); | 85 fetcher->SetResponseString(""); |
86 fetcher->delegate()->OnURLFetchComplete(fetcher); | 86 fetcher->delegate()->OnURLFetchComplete(fetcher); |
87 } | 87 } |
88 | 88 |
89 void SimulateUploadError(int error) { | 89 void SimulateUploadError(int error) { |
90 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); | 90 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); |
91 EXPECT_TRUE(fetcher); | 91 EXPECT_TRUE(fetcher); |
92 | 92 |
93 net::URLRequestStatus status; | 93 net::URLRequestStatus status; |
94 status.set_status(net::URLRequestStatus::FAILED); | 94 fetcher->set_status(net::URLRequestStatus::FromError(error)); |
95 status.set_error(error); | |
96 fetcher->set_status(status); | |
97 fetcher->set_response_code(-1); | 95 fetcher->set_response_code(-1); |
98 fetcher->delegate()->OnURLFetchComplete(fetcher); | 96 fetcher->delegate()->OnURLFetchComplete(fetcher); |
99 } | 97 } |
100 | 98 |
101 scoped_refptr<base::TestSimpleTaskRunner> network_task_runner_; | 99 scoped_refptr<base::TestSimpleTaskRunner> network_task_runner_; |
102 net::TestURLFetcherFactory url_fetcher_factory_; | 100 net::TestURLFetcherFactory url_fetcher_factory_; |
103 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; | 101 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; |
104 MockTime time_; | 102 MockTime time_; |
105 scoped_ptr<DomainReliabilityUploader> uploader_; | 103 scoped_ptr<DomainReliabilityUploader> uploader_; |
106 | 104 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 150 } |
153 | 151 |
154 TEST_F(DomainReliabilityUploaderTest, DiscardedUpload) { | 152 TEST_F(DomainReliabilityUploaderTest, DiscardedUpload) { |
155 uploader_->set_discard_uploads(true); | 153 uploader_->set_discard_uploads(true); |
156 SimulateUpload(); | 154 SimulateUpload(); |
157 SimulateNoUploadRequest(); | 155 SimulateNoUploadRequest(); |
158 } | 156 } |
159 | 157 |
160 } // namespace | 158 } // namespace |
161 } // namespace domain_reliability | 159 } // namespace domain_reliability |
OLD | NEW |