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_service.h" | 5 #include "chrome/browser/safe_browsing/download_feedback_service.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/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 ASSERT_TRUE(feedback(0)); | 222 ASSERT_TRUE(feedback(0)); |
223 EXPECT_TRUE(feedback(0)->start_called()); | 223 EXPECT_TRUE(feedback(0)->start_called()); |
224 EXPECT_EQ(ping_request, feedback(0)->GetPingRequestForTesting()); | 224 EXPECT_EQ(ping_request, feedback(0)->GetPingRequestForTesting()); |
225 EXPECT_EQ(ping_response, feedback(0)->GetPingResponseForTesting()); | 225 EXPECT_EQ(ping_response, feedback(0)->GetPingResponseForTesting()); |
226 | 226 |
227 feedback(0)->finish_callback().Run(); | 227 feedback(0)->finish_callback().Run(); |
228 EXPECT_FALSE(feedback(0)); | 228 EXPECT_FALSE(feedback(0)); |
229 | 229 |
230 // File should still exist since our FakeDownloadFeedback does not delete it. | 230 // File should still exist since our FakeDownloadFeedback does not delete it. |
231 base::RunLoop().RunUntilIdle(); | 231 base::RunLoop().RunUntilIdle(); |
232 EXPECT_TRUE(file_util::PathExists(file_path)); | 232 EXPECT_TRUE(base::PathExists(file_path)); |
233 } | 233 } |
234 | 234 |
235 TEST_F(DownloadFeedbackServiceTest, MultiplePendingFeedbackComplete) { | 235 TEST_F(DownloadFeedbackServiceTest, MultiplePendingFeedbackComplete) { |
236 const std::string ping_request = "ping"; | 236 const std::string ping_request = "ping"; |
237 const std::string ping_response = "resp"; | 237 const std::string ping_response = "resp"; |
238 const size_t num_downloads = 3; | 238 const size_t num_downloads = 3; |
239 | 239 |
240 content::DownloadItem::AcquireFileCallback | 240 content::DownloadItem::AcquireFileCallback |
241 download_discarded_callback[num_downloads]; | 241 download_discarded_callback[num_downloads]; |
242 | 242 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 feedback(2)->finish_callback().Run(); | 289 feedback(2)->finish_callback().Run(); |
290 | 290 |
291 EXPECT_FALSE(feedback(0)); | 291 EXPECT_FALSE(feedback(0)); |
292 EXPECT_FALSE(feedback(1)); | 292 EXPECT_FALSE(feedback(1)); |
293 EXPECT_FALSE(feedback(2)); | 293 EXPECT_FALSE(feedback(2)); |
294 } | 294 } |
295 | 295 |
296 base::RunLoop().RunUntilIdle(); | 296 base::RunLoop().RunUntilIdle(); |
297 // These files should still exist since the FakeDownloadFeedback does not | 297 // These files should still exist since the FakeDownloadFeedback does not |
298 // delete them. | 298 // delete them. |
299 EXPECT_TRUE(file_util::PathExists(file_path[0])); | 299 EXPECT_TRUE(base::PathExists(file_path[0])); |
300 EXPECT_TRUE(file_util::PathExists(file_path[1])); | 300 EXPECT_TRUE(base::PathExists(file_path[1])); |
301 EXPECT_TRUE(file_util::PathExists(file_path[2])); | 301 EXPECT_TRUE(base::PathExists(file_path[2])); |
302 } | 302 } |
303 | 303 |
304 TEST_F(DownloadFeedbackServiceTest, MultiFeedbackWithIncomplete) { | 304 TEST_F(DownloadFeedbackServiceTest, MultiFeedbackWithIncomplete) { |
305 const std::string ping_request = "ping"; | 305 const std::string ping_request = "ping"; |
306 const std::string ping_response = "resp"; | 306 const std::string ping_response = "resp"; |
307 const size_t num_downloads = 3; | 307 const size_t num_downloads = 3; |
308 | 308 |
309 content::DownloadItem::AcquireFileCallback | 309 content::DownloadItem::AcquireFileCallback |
310 download_discarded_callback[num_downloads]; | 310 download_discarded_callback[num_downloads]; |
311 | 311 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 SCOPED_TRACE(i); | 354 SCOPED_TRACE(i); |
355 EXPECT_FALSE(feedback(i)); | 355 EXPECT_FALSE(feedback(i)); |
356 } | 356 } |
357 | 357 |
358 // Running a download acquired callback after the DownloadFeedbackService is | 358 // Running a download acquired callback after the DownloadFeedbackService is |
359 // destroyed should delete the file. | 359 // destroyed should delete the file. |
360 download_discarded_callback[2].Run(file_path[2]); | 360 download_discarded_callback[2].Run(file_path[2]); |
361 EXPECT_EQ(2U, num_feedbacks()); | 361 EXPECT_EQ(2U, num_feedbacks()); |
362 | 362 |
363 // File should still exist since the FileUtilProxy task hasn't run yet. | 363 // File should still exist since the FileUtilProxy task hasn't run yet. |
364 EXPECT_TRUE(file_util::PathExists(file_path[2])); | 364 EXPECT_TRUE(base::PathExists(file_path[2])); |
365 | 365 |
366 base::RunLoop().RunUntilIdle(); | 366 base::RunLoop().RunUntilIdle(); |
367 // File should be deleted since the AcquireFileCallback ran after the service | 367 // File should be deleted since the AcquireFileCallback ran after the service |
368 // was deleted. | 368 // was deleted. |
369 EXPECT_FALSE(file_util::PathExists(file_path[2])); | 369 EXPECT_FALSE(base::PathExists(file_path[2])); |
370 | 370 |
371 // These files should still exist since the FakeDownloadFeedback does not | 371 // These files should still exist since the FakeDownloadFeedback does not |
372 // delete them. | 372 // delete them. |
373 EXPECT_TRUE(file_util::PathExists(file_path[0])); | 373 EXPECT_TRUE(base::PathExists(file_path[0])); |
374 EXPECT_TRUE(file_util::PathExists(file_path[1])); | 374 EXPECT_TRUE(base::PathExists(file_path[1])); |
375 } | 375 } |
376 | 376 |
377 } // namespace safe_browsing | 377 } // namespace safe_browsing |
OLD | NEW |