Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: chrome/browser/download/chrome_download_manager_delegate_unittest.cc

Issue 2029903002: Add token field to ClientSafeBrowsingReportReqeust (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_util.h"
15 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
16 #include "chrome/browser/download/chrome_download_manager_delegate.h" 17 #include "chrome/browser/download/chrome_download_manager_delegate.h"
17 #include "chrome/browser/download/download_item_model.h" 18 #include "chrome/browser/download/download_item_model.h"
18 #include "chrome/browser/download/download_prefs.h" 19 #include "chrome/browser/download/download_prefs.h"
19 #include "chrome/browser/download/download_target_info.h" 20 #include "chrome/browser/download/download_target_info.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 22 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
22 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
23 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
24 #include "components/syncable_prefs/testing_pref_service_syncable.h" 25 #include "components/syncable_prefs/testing_pref_service_syncable.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 safe_browsing::DownloadProtectionService::DownloadCheckResult verdict; 487 safe_browsing::DownloadProtectionService::DownloadCheckResult verdict;
487 488
488 content::DownloadDangerType expected_danger_type; 489 content::DownloadDangerType expected_danger_type;
489 }; 490 };
490 491
491 class TestDownloadProtectionService 492 class TestDownloadProtectionService
492 : public safe_browsing::DownloadProtectionService { 493 : public safe_browsing::DownloadProtectionService {
493 public: 494 public:
494 TestDownloadProtectionService() : DownloadProtectionService(nullptr) {} 495 TestDownloadProtectionService() : DownloadProtectionService(nullptr) {}
495 496
496 void CheckClientDownload(DownloadItem* download_item, 497 void CheckClientDownload(
497 const CheckDownloadCallback& callback) override { 498 DownloadItem* download_item,
498 callback.Run(MockCheckClientDownload()); 499 const CheckDownloadContentCallback& callback) override {
500 callback.Run(MockCheckClientDownload(), base::EmptyString());
499 } 501 }
500 MOCK_METHOD0(MockCheckClientDownload, 502 MOCK_METHOD0(MockCheckClientDownload,
501 safe_browsing::DownloadProtectionService::DownloadCheckResult()); 503 safe_browsing::DownloadProtectionService::DownloadCheckResult());
502 }; 504 };
503 505
504 class ChromeDownloadManagerDelegateTestWithSafeBrowsing 506 class ChromeDownloadManagerDelegateTestWithSafeBrowsing
505 : public ChromeDownloadManagerDelegateTest, 507 : public ChromeDownloadManagerDelegateTest,
506 public ::testing::WithParamInterface<SafeBrowsingTestParameters> { 508 public ::testing::WithParamInterface<SafeBrowsingTestParameters> {
507 public: 509 public:
508 void SetUp() override; 510 void SetUp() override;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 .WillRepeatedly(Return(kParameters.initial_danger_type)); 656 .WillRepeatedly(Return(kParameters.initial_danger_type));
655 657
656 if (kParameters.initial_danger_level != DownloadFileType::NOT_DANGEROUS) { 658 if (kParameters.initial_danger_level != DownloadFileType::NOT_DANGEROUS) {
657 DownloadItemModel(download_item.get()) 659 DownloadItemModel(download_item.get())
658 .SetDangerLevel(kParameters.initial_danger_level); 660 .SetDangerLevel(kParameters.initial_danger_level);
659 } 661 }
660 662
661 if (kParameters.expected_danger_type != 663 if (kParameters.expected_danger_type !=
662 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) { 664 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) {
663 EXPECT_CALL(*download_item, 665 EXPECT_CALL(*download_item,
664 OnContentCheckCompleted(kParameters.expected_danger_type)); 666 OnContentCheckCompleted(kParameters.expected_danger_type,
667 base::EmptyString()));
665 } else { 668 } else {
666 EXPECT_CALL(*download_item, OnContentCheckCompleted(_)).Times(0); 669 EXPECT_CALL(*download_item, OnContentCheckCompleted(_, _)).Times(0);
667 } 670 }
668 671
669 base::RunLoop run_loop; 672 base::RunLoop run_loop;
670 ASSERT_FALSE(delegate()->ShouldCompleteDownload(download_item.get(), 673 ASSERT_FALSE(delegate()->ShouldCompleteDownload(download_item.get(),
671 run_loop.QuitClosure())); 674 run_loop.QuitClosure()));
672 run_loop.Run(); 675 run_loop.Run();
673 } 676 }
674 677
675 #endif // FULL_SAFE_BROWSING 678 #endif // FULL_SAFE_BROWSING
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698