Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/download/download_browsertest.h" | 5 #include "chrome/browser/download/download_browsertest.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 3419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3430 *(downloads[0]))); | 3430 *(downloads[0]))); |
| 3431 | 3431 |
| 3432 // Begin feedback and check that the file is "stolen". | 3432 // Begin feedback and check that the file is "stolen". |
| 3433 download_protection_service->feedback_service()->BeginFeedbackForDownload( | 3433 download_protection_service->feedback_service()->BeginFeedbackForDownload( |
| 3434 downloads[0], DownloadCommands::DISCARD); | 3434 downloads[0], DownloadCommands::DISCARD); |
| 3435 std::vector<DownloadItem*> updated_downloads; | 3435 std::vector<DownloadItem*> updated_downloads; |
| 3436 GetDownloads(browser(), &updated_downloads); | 3436 GetDownloads(browser(), &updated_downloads); |
| 3437 ASSERT_TRUE(updated_downloads.empty()); | 3437 ASSERT_TRUE(updated_downloads.empty()); |
| 3438 } | 3438 } |
| 3439 | 3439 |
| 3440 // Test is flaky Linux. crbug.com/705224 | 3440 IN_PROC_BROWSER_TEST_F(DownloadTest, FeedbackServiceKeepDownload) { |
| 3441 #if defined(OS_LINUX) | |
| 3442 #define MAYBE_FeedbackServiceKeepDownload DISABLED_FeedbackServiceKeepDownload | |
| 3443 #else | |
| 3444 #define MAYBE_FeedbackServiceKeepDownload FeedbackServiceKeepDownload | |
| 3445 #endif | |
| 3446 IN_PROC_BROWSER_TEST_F(DownloadTest, MAYBE_FeedbackServiceKeepDownload) { | |
| 3447 PrefService* prefs = browser()->profile()->GetPrefs(); | 3441 PrefService* prefs = browser()->profile()->GetPrefs(); |
| 3448 prefs->SetBoolean(prefs::kSafeBrowsingEnabled, true); | 3442 prefs->SetBoolean(prefs::kSafeBrowsingEnabled, true); |
| 3449 safe_browsing::SetExtendedReportingPref(prefs, true); | 3443 safe_browsing::SetExtendedReportingPref(prefs, true); |
| 3450 | 3444 |
| 3451 // Make a dangerous file. | 3445 // Make a dangerous file. |
| 3452 GURL download_url(net::URLRequestMockHTTPJob::GetMockUrl( | 3446 GURL download_url(net::URLRequestMockHTTPJob::GetMockUrl( |
| 3453 "downloads/dangerous/dangerous.swf")); | 3447 "downloads/dangerous/dangerous.swf")); |
| 3454 std::unique_ptr<content::DownloadTestObserverInterrupted> | 3448 std::unique_ptr<content::DownloadTestObserverInterrupted> |
| 3455 interruption_observer(new content::DownloadTestObserverInterrupted( | 3449 interruption_observer(new content::DownloadTestObserverInterrupted( |
| 3456 DownloadManagerForBrowser(browser()), 1, | 3450 DownloadManagerForBrowser(browser()), 1, |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 3483 sb_service->download_protection_service(); | 3477 sb_service->download_protection_service(); |
| 3484 download_protection_service->feedback_service()->MaybeStorePingsForDownload( | 3478 download_protection_service->feedback_service()->MaybeStorePingsForDownload( |
| 3485 safe_browsing::DownloadProtectionService::UNCOMMON, | 3479 safe_browsing::DownloadProtectionService::UNCOMMON, |
| 3486 true /* upload_requested */, downloads[0], ping_request, ping_response); | 3480 true /* upload_requested */, downloads[0], ping_request, ping_response); |
| 3487 ASSERT_TRUE(safe_browsing::DownloadFeedbackService::IsEnabledForDownload( | 3481 ASSERT_TRUE(safe_browsing::DownloadFeedbackService::IsEnabledForDownload( |
| 3488 *(downloads[0]))); | 3482 *(downloads[0]))); |
| 3489 | 3483 |
| 3490 // Begin feedback and check that file is still there. | 3484 // Begin feedback and check that file is still there. |
| 3491 download_protection_service->feedback_service()->BeginFeedbackForDownload( | 3485 download_protection_service->feedback_service()->BeginFeedbackForDownload( |
| 3492 downloads[0], DownloadCommands::KEEP); | 3486 downloads[0], DownloadCommands::KEEP); |
| 3487 std::unique_ptr<DownloadTestObserverNotInProgress> completion_observer( | |
|
asanka
2017/03/31 14:37:24
Instead, could you use a DownloadTestObserverTermi
Jialiu Lin
2017/03/31 21:34:33
Done.
Jialiu Lin
2017/03/31 21:34:33
Done.
| |
| 3488 new DownloadTestObserverNotInProgress( | |
| 3489 DownloadManagerForBrowser(browser()), 1)); | |
| 3490 | |
| 3491 // Make sure download is finished before starting evaluation. | |
| 3492 if (!completion_observer->IsFinished()) { | |
| 3493 completion_observer->StartObserving(); | |
| 3494 completion_observer->WaitForFinished(); | |
| 3495 } | |
| 3493 | 3496 |
| 3494 std::vector<DownloadItem*> updated_downloads; | 3497 std::vector<DownloadItem*> updated_downloads; |
| 3495 GetDownloads(browser(), &updated_downloads); | 3498 GetDownloads(browser(), &updated_downloads); |
| 3496 ASSERT_EQ(std::size_t(1), updated_downloads.size()); | 3499 ASSERT_EQ(std::size_t(1), updated_downloads.size()); |
| 3497 ASSERT_FALSE(updated_downloads[0]->IsDangerous()); | 3500 ASSERT_FALSE(updated_downloads[0]->IsDangerous()); |
| 3498 ASSERT_TRUE(PathExists(updated_downloads[0]->GetFullPath())); | 3501 ASSERT_TRUE(PathExists(updated_downloads[0]->GetTargetFilePath())); |
| 3499 updated_downloads[0]->Cancel(true); | 3502 updated_downloads[0]->Cancel(true); |
| 3500 } | 3503 } |
| 3501 | 3504 |
| 3502 IN_PROC_BROWSER_TEST_F(DownloadTestWithFakeSafeBrowsing, | 3505 IN_PROC_BROWSER_TEST_F(DownloadTestWithFakeSafeBrowsing, |
| 3503 SendUncommonDownloadReportIfUserProceed) { | 3506 SendUncommonDownloadReportIfUserProceed) { |
| 3504 browser()->profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, | 3507 browser()->profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, |
| 3505 true); | 3508 true); |
| 3506 // Make a dangerous file. | 3509 // Make a dangerous file. |
| 3507 GURL download_url( | 3510 GURL download_url( |
| 3508 net::URLRequestMockHTTPJob::GetMockUrl(kDangerousMockFilePath)); | 3511 net::URLRequestMockHTTPJob::GetMockUrl(kDangerousMockFilePath)); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3804 browser(), 1, | 3807 browser(), 1, |
| 3805 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 3808 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
| 3806 ui_test_utils::NavigateToURL(browser(), extension_url); | 3809 ui_test_utils::NavigateToURL(browser(), extension_url); |
| 3807 | 3810 |
| 3808 observer->WaitForFinished(); | 3811 observer->WaitForFinished(); |
| 3809 | 3812 |
| 3810 // Download shelf should close. | 3813 // Download shelf should close. |
| 3811 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 3814 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 3812 } | 3815 } |
| 3813 #endif // defined(OS_CHROMEOS) | 3816 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |