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

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

Issue 2778853002: Fix flaky DownloadTest.FeedbackServiceKeepDownload (Closed)
Patch Set: Use DownloadTestObserverTerminal instead Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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,
3457 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_QUIT)); 3451 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_QUIT));
3452 std::unique_ptr<content::DownloadTestObserver> completion_observer(
3453 new content::DownloadTestObserverTerminal(
3454 DownloadManagerForBrowser(browser()), 1,
3455 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE));
3458 ui_test_utils::NavigateToURLWithDisposition( 3456 ui_test_utils::NavigateToURLWithDisposition(
3459 browser(), GURL(download_url), WindowOpenDisposition::NEW_BACKGROUND_TAB, 3457 browser(), GURL(download_url), WindowOpenDisposition::NEW_BACKGROUND_TAB,
3460 ui_test_utils::BROWSER_TEST_NONE); 3458 ui_test_utils::BROWSER_TEST_NONE);
3461 interruption_observer->WaitForFinished(); 3459 interruption_observer->WaitForFinished();
3462 3460
3463 // Get the download from the DownloadManager. 3461 // Get the download from the DownloadManager.
3464 std::vector<DownloadItem*> downloads; 3462 std::vector<DownloadItem*> downloads;
3465 DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads); 3463 DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads);
3466 ASSERT_EQ(1u, downloads.size()); 3464 ASSERT_EQ(1u, downloads.size());
3467 EXPECT_TRUE(downloads[0]->IsDangerous()); 3465 EXPECT_TRUE(downloads[0]->IsDangerous());
(...skipping 15 matching lines...) Expand all
3483 sb_service->download_protection_service(); 3481 sb_service->download_protection_service();
3484 download_protection_service->feedback_service()->MaybeStorePingsForDownload( 3482 download_protection_service->feedback_service()->MaybeStorePingsForDownload(
3485 safe_browsing::DownloadProtectionService::UNCOMMON, 3483 safe_browsing::DownloadProtectionService::UNCOMMON,
3486 true /* upload_requested */, downloads[0], ping_request, ping_response); 3484 true /* upload_requested */, downloads[0], ping_request, ping_response);
3487 ASSERT_TRUE(safe_browsing::DownloadFeedbackService::IsEnabledForDownload( 3485 ASSERT_TRUE(safe_browsing::DownloadFeedbackService::IsEnabledForDownload(
3488 *(downloads[0]))); 3486 *(downloads[0])));
3489 3487
3490 // Begin feedback and check that file is still there. 3488 // Begin feedback and check that file is still there.
3491 download_protection_service->feedback_service()->BeginFeedbackForDownload( 3489 download_protection_service->feedback_service()->BeginFeedbackForDownload(
3492 downloads[0], DownloadCommands::KEEP); 3490 downloads[0], DownloadCommands::KEEP);
3491 completion_observer->WaitForFinished();
3493 3492
3494 std::vector<DownloadItem*> updated_downloads; 3493 std::vector<DownloadItem*> updated_downloads;
3495 GetDownloads(browser(), &updated_downloads); 3494 GetDownloads(browser(), &updated_downloads);
3496 ASSERT_EQ(std::size_t(1), updated_downloads.size()); 3495 ASSERT_EQ(std::size_t(1), updated_downloads.size());
3497 ASSERT_FALSE(updated_downloads[0]->IsDangerous()); 3496 ASSERT_FALSE(updated_downloads[0]->IsDangerous());
3498 ASSERT_TRUE(PathExists(updated_downloads[0]->GetFullPath())); 3497 ASSERT_TRUE(PathExists(updated_downloads[0]->GetTargetFilePath()));
3499 updated_downloads[0]->Cancel(true); 3498 updated_downloads[0]->Cancel(true);
3500 } 3499 }
3501 3500
3502 IN_PROC_BROWSER_TEST_F(DownloadTestWithFakeSafeBrowsing, 3501 IN_PROC_BROWSER_TEST_F(DownloadTestWithFakeSafeBrowsing,
3503 SendUncommonDownloadReportIfUserProceed) { 3502 SendUncommonDownloadReportIfUserProceed) {
3504 browser()->profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, 3503 browser()->profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled,
3505 true); 3504 true);
3506 // Make a dangerous file. 3505 // Make a dangerous file.
3507 GURL download_url( 3506 GURL download_url(
3508 net::URLRequestMockHTTPJob::GetMockUrl(kDangerousMockFilePath)); 3507 net::URLRequestMockHTTPJob::GetMockUrl(kDangerousMockFilePath));
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
3804 browser(), 1, 3803 browser(), 1,
3805 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); 3804 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY));
3806 ui_test_utils::NavigateToURL(browser(), extension_url); 3805 ui_test_utils::NavigateToURL(browser(), extension_url);
3807 3806
3808 observer->WaitForFinished(); 3807 observer->WaitForFinished();
3809 3808
3810 // Download shelf should close. 3809 // Download shelf should close.
3811 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 3810 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
3812 } 3811 }
3813 #endif // defined(OS_CHROMEOS) 3812 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698