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

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

Issue 2593183002: [downloads] Remove DownloadManager::RemoveAllDownloads. (Closed)
Patch Set: Fix SavePageBrowsertest Created 4 years 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 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 647
648 base::FilePath full_file_name, dir; 648 base::FilePath full_file_name, dir;
649 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_ONLY_HTML, "a", 1, &dir, 649 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_ONLY_HTML, "a", 1, &dir,
650 &full_file_name); 650 &full_file_name);
651 ASSERT_FALSE(HasFailure()); 651 ASSERT_FALSE(HasFailure());
652 652
653 DownloadManager* manager(GetDownloadManager()); 653 DownloadManager* manager(GetDownloadManager());
654 std::vector<DownloadItem*> downloads; 654 std::vector<DownloadItem*> downloads;
655 manager->GetAllDownloads(&downloads); 655 manager->GetAllDownloads(&downloads);
656 ASSERT_EQ(1UL, downloads.size()); 656 ASSERT_EQ(1UL, downloads.size());
657
657 DownloadRemovedObserver removed(browser()->profile(), downloads[0]->GetId()); 658 DownloadRemovedObserver removed(browser()->profile(), downloads[0]->GetId());
658 659 downloads[0]->Remove();
659 EXPECT_EQ(manager->RemoveAllDownloads(), 1);
660
661 removed.WaitForRemoved(); 660 removed.WaitForRemoved();
662 661
663 EXPECT_TRUE(base::PathExists(full_file_name)); 662 EXPECT_TRUE(base::PathExists(full_file_name));
664 EXPECT_FALSE(base::PathExists(dir)); 663 EXPECT_FALSE(base::PathExists(dir));
665 EXPECT_TRUE(base::ContentsEqual(GetTestDirFile("a.htm"), full_file_name)); 664 EXPECT_TRUE(base::ContentsEqual(GetTestDirFile("a.htm"), full_file_name));
666 } 665 }
667 666
668 // This tests that a webpage with the title "test.exe" is saved as 667 // This tests that a webpage with the title "test.exe" is saved as
669 // "test.exe.htm". 668 // "test.exe.htm".
670 // We probably don't care to handle this on Linux or Mac. 669 // We probably don't care to handle this on Linux or Mac.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 GURL download_url("http://mock.http/downloads/thisdayinhistory.xls"); 792 GURL download_url("http://mock.http/downloads/thisdayinhistory.xls");
794 DownloadPersistedObserver persisted( 793 DownloadPersistedObserver persisted(
795 browser()->profile(), 794 browser()->profile(),
796 base::Bind(&DownloadStoredProperly, download_url, base::FilePath(), -1, 795 base::Bind(&DownloadStoredProperly, download_url, base::FilePath(), -1,
797 history::DownloadState::COMPLETE)); 796 history::DownloadState::COMPLETE));
798 797
799 ui_test_utils::NavigateToURL(browser(), url); 798 ui_test_utils::NavigateToURL(browser(), url);
800 799
801 ASSERT_TRUE(VerifySavePackageExpectations(browser(), download_url)); 800 ASSERT_TRUE(VerifySavePackageExpectations(browser(), download_url));
802 persisted.WaitForPersisted(); 801 persisted.WaitForPersisted();
803 GetDownloadManager()->RemoveAllDownloads(); 802 std::vector<content::DownloadItem*> downloads;
803 GetDownloadManager()->GetAllDownloads(&downloads);
804 for (auto download : downloads)
805 download->Remove();
804 } 806 }
805 807
806 base::FilePath full_file_name, dir; 808 base::FilePath full_file_name, dir;
807 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, 809 SaveCurrentTab(url, content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML,
808 "iframe-src-is-a-download", 3, &dir, &full_file_name); 810 "iframe-src-is-a-download", 3, &dir, &full_file_name);
809 ASSERT_FALSE(HasFailure()); 811 ASSERT_FALSE(HasFailure());
810 812
811 EXPECT_TRUE(base::PathExists(full_file_name)); 813 EXPECT_TRUE(base::PathExists(full_file_name));
812 EXPECT_TRUE(base::PathExists(dir.AppendASCII("thisdayinhistory.html"))); 814 EXPECT_TRUE(base::PathExists(dir.AppendASCII("thisdayinhistory.html")));
813 EXPECT_TRUE(base::PathExists(dir.AppendASCII("no-such-file.html"))); 815 EXPECT_TRUE(base::PathExists(dir.AppendASCII("no-such-file.html")));
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 TestOriginalVsSavedPage(save_page_type, url, 1, expected_substrings); 1320 TestOriginalVsSavedPage(save_page_type, url, 1, expected_substrings);
1319 } 1321 }
1320 1322
1321 INSTANTIATE_TEST_CASE_P( 1323 INSTANTIATE_TEST_CASE_P(
1322 SaveType, 1324 SaveType,
1323 SavePageOriginalVsSavedComparisonTest, 1325 SavePageOriginalVsSavedComparisonTest,
1324 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, 1326 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML,
1325 content::SAVE_PAGE_TYPE_AS_MHTML)); 1327 content::SAVE_PAGE_TYPE_AS_MHTML));
1326 1328
1327 } // namespace 1329 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698