OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/browser/safe_browsing/download_feedback.h" | 5 #include "chrome/browser/safe_browsing/download_feedback.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 EXPECT_TRUE(uploader()->start_called_); | 185 EXPECT_TRUE(uploader()->start_called_); |
186 | 186 |
187 EXPECT_EQ(url_request_context_getter_, | 187 EXPECT_EQ(url_request_context_getter_, |
188 uploader()->url_request_context_getter_); | 188 uploader()->url_request_context_getter_); |
189 EXPECT_EQ(file_task_runner_, uploader()->file_task_runner_); | 189 EXPECT_EQ(file_task_runner_, uploader()->file_task_runner_); |
190 EXPECT_EQ(upload_file_path_, uploader()->file_path_); | 190 EXPECT_EQ(upload_file_path_, uploader()->file_path_); |
191 EXPECT_EQ(expected_report_metadata.SerializeAsString(), | 191 EXPECT_EQ(expected_report_metadata.SerializeAsString(), |
192 uploader()->metadata_); | 192 uploader()->metadata_); |
193 EXPECT_EQ(kTestFeedbackURL, uploader()->base_url_.spec()); | 193 EXPECT_EQ(kTestFeedbackURL, uploader()->base_url_.spec()); |
194 | 194 |
195 EXPECT_TRUE(file_util::PathExists(upload_file_path_)); | 195 EXPECT_TRUE(base::PathExists(upload_file_path_)); |
196 | 196 |
197 EXPECT_FALSE(feedback_finish_called_); | 197 EXPECT_FALSE(feedback_finish_called_); |
198 uploader()->finish_callback_.Run( | 198 uploader()->finish_callback_.Run( |
199 TwoPhaseUploader::STATE_SUCCESS, net::OK, 0, ""); | 199 TwoPhaseUploader::STATE_SUCCESS, net::OK, 0, ""); |
200 EXPECT_TRUE(feedback_finish_called_); | 200 EXPECT_TRUE(feedback_finish_called_); |
201 base::RunLoop().RunUntilIdle(); | 201 base::RunLoop().RunUntilIdle(); |
202 EXPECT_FALSE(file_util::PathExists(upload_file_path_)); | 202 EXPECT_FALSE(base::PathExists(upload_file_path_)); |
203 } | 203 } |
204 | 204 |
205 TEST_F(DownloadFeedbackTest, CancelUpload) { | 205 TEST_F(DownloadFeedbackTest, CancelUpload) { |
206 ClientDownloadReport expected_report_metadata; | 206 ClientDownloadReport expected_report_metadata; |
207 expected_report_metadata.mutable_download_request()->set_url("http://test"); | 207 expected_report_metadata.mutable_download_request()->set_url("http://test"); |
208 expected_report_metadata.mutable_download_request()->set_length( | 208 expected_report_metadata.mutable_download_request()->set_length( |
209 upload_file_data_.size()); | 209 upload_file_data_.size()); |
210 expected_report_metadata.mutable_download_request()->mutable_digests( | 210 expected_report_metadata.mutable_download_request()->mutable_digests( |
211 )->set_sha1("hi"); | 211 )->set_sha1("hi"); |
212 expected_report_metadata.mutable_download_response()->set_verdict( | 212 expected_report_metadata.mutable_download_response()->set_verdict( |
(...skipping 10 matching lines...) Expand all Loading... |
223 ping_request, | 223 ping_request, |
224 ping_response); | 224 ping_response); |
225 EXPECT_FALSE(uploader()); | 225 EXPECT_FALSE(uploader()); |
226 | 226 |
227 feedback->Start(base::Bind(&DownloadFeedbackTest::FinishCallback, | 227 feedback->Start(base::Bind(&DownloadFeedbackTest::FinishCallback, |
228 base::Unretained(this), | 228 base::Unretained(this), |
229 feedback)); | 229 feedback)); |
230 ASSERT_TRUE(uploader()); | 230 ASSERT_TRUE(uploader()); |
231 EXPECT_FALSE(feedback_finish_called_); | 231 EXPECT_FALSE(feedback_finish_called_); |
232 EXPECT_TRUE(uploader()->start_called_); | 232 EXPECT_TRUE(uploader()->start_called_); |
233 EXPECT_TRUE(file_util::PathExists(upload_file_path_)); | 233 EXPECT_TRUE(base::PathExists(upload_file_path_)); |
234 | 234 |
235 delete feedback; | 235 delete feedback; |
236 EXPECT_FALSE(feedback_finish_called_); | 236 EXPECT_FALSE(feedback_finish_called_); |
237 | 237 |
238 base::RunLoop().RunUntilIdle(); | 238 base::RunLoop().RunUntilIdle(); |
239 EXPECT_FALSE(file_util::PathExists(upload_file_path_)); | 239 EXPECT_FALSE(base::PathExists(upload_file_path_)); |
240 } | 240 } |
241 | 241 |
242 } // namespace safe_browsing | 242 } // namespace safe_browsing |
OLD | NEW |