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

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

Issue 14625016: downloads: Make GetCrDownloadPath a static method on DownloadTargetDeterminer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/download/download_path_reservation_tracker_unittest.cc » ('j') | 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/common/cancelable_request.h" 23 #include "chrome/browser/common/cancelable_request.h"
24 #include "chrome/browser/download/chrome_download_manager_delegate.h" 24 #include "chrome/browser/download/chrome_download_manager_delegate.h"
25 #include "chrome/browser/download/download_crx_util.h" 25 #include "chrome/browser/download/download_crx_util.h"
26 #include "chrome/browser/download/download_history.h" 26 #include "chrome/browser/download/download_history.h"
27 #include "chrome/browser/download/download_item_model.h" 27 #include "chrome/browser/download/download_item_model.h"
28 #include "chrome/browser/download/download_prefs.h" 28 #include "chrome/browser/download/download_prefs.h"
29 #include "chrome/browser/download/download_request_limiter.h" 29 #include "chrome/browser/download/download_request_limiter.h"
30 #include "chrome/browser/download/download_service.h" 30 #include "chrome/browser/download/download_service.h"
31 #include "chrome/browser/download/download_service_factory.h" 31 #include "chrome/browser/download/download_service_factory.h"
32 #include "chrome/browser/download/download_shelf.h" 32 #include "chrome/browser/download/download_shelf.h"
33 #include "chrome/browser/download/download_target_determiner.h"
33 #include "chrome/browser/download/download_test_file_activity_observer.h" 34 #include "chrome/browser/download/download_test_file_activity_observer.h"
34 #include "chrome/browser/download/download_util.h"
35 #include "chrome/browser/extensions/extension_install_prompt.h" 35 #include "chrome/browser/extensions/extension_install_prompt.h"
36 #include "chrome/browser/extensions/extension_service.h" 36 #include "chrome/browser/extensions/extension_service.h"
37 #include "chrome/browser/extensions/extension_system.h" 37 #include "chrome/browser/extensions/extension_system.h"
38 #include "chrome/browser/history/download_row.h" 38 #include "chrome/browser/history/download_row.h"
39 #include "chrome/browser/history/history_service.h" 39 #include "chrome/browser/history/history_service.h"
40 #include "chrome/browser/history/history_service_factory.h" 40 #include "chrome/browser/history/history_service_factory.h"
41 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 41 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
42 #include "chrome/browser/infobars/infobar_service.h" 42 #include "chrome/browser/infobars/infobar_service.h"
43 #include "chrome/browser/net/url_request_mock_util.h" 43 #include "chrome/browser/net/url_request_mock_util.h"
44 #include "chrome/browser/profiles/profile.h" 44 #include "chrome/browser/profiles/profile.h"
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 // Get the details on what was stored into the history. 1678 // Get the details on what was stored into the history.
1679 scoped_ptr<std::vector<history::DownloadRow> > downloads_in_database; 1679 scoped_ptr<std::vector<history::DownloadRow> > downloads_in_database;
1680 ASSERT_TRUE(DownloadsHistoryDataCollector( 1680 ASSERT_TRUE(DownloadsHistoryDataCollector(
1681 browser()->profile()).WaitForDownloadInfo(&downloads_in_database)); 1681 browser()->profile()).WaitForDownloadInfo(&downloads_in_database));
1682 ASSERT_EQ(1u, downloads_in_database->size()); 1682 ASSERT_EQ(1u, downloads_in_database->size());
1683 1683
1684 // Confirm history storage is what you expect for a partially completed 1684 // Confirm history storage is what you expect for a partially completed
1685 // slow download job. 1685 // slow download job.
1686 history::DownloadRow& row(downloads_in_database->at(0)); 1686 history::DownloadRow& row(downloads_in_database->at(0));
1687 EXPECT_EQ(DestinationFile(browser(), file), row.target_path); 1687 EXPECT_EQ(DestinationFile(browser(), file), row.target_path);
1688 EXPECT_EQ(download_util::GetCrDownloadPath(DestinationFile(browser(), file)), 1688 EXPECT_EQ(DownloadTargetDeterminer::GetCrDownloadPath(
1689 DestinationFile(browser(), file)),
1689 row.current_path); 1690 row.current_path);
1690 ASSERT_EQ(2u, row.url_chain.size()); 1691 ASSERT_EQ(2u, row.url_chain.size());
1691 EXPECT_EQ(redirect_url.spec(), row.url_chain[0].spec()); 1692 EXPECT_EQ(redirect_url.spec(), row.url_chain[0].spec());
1692 EXPECT_EQ(download_url.spec(), row.url_chain[1].spec()); 1693 EXPECT_EQ(download_url.spec(), row.url_chain[1].spec());
1693 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, row.danger_type); 1694 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, row.danger_type);
1694 EXPECT_LE(start, row.start_time); 1695 EXPECT_LE(start, row.start_time);
1695 EXPECT_EQ(URLRequestSlowDownloadJob::kFirstDownloadSize, row.received_bytes); 1696 EXPECT_EQ(URLRequestSlowDownloadJob::kFirstDownloadSize, row.received_bytes);
1696 EXPECT_EQ(URLRequestSlowDownloadJob::kFirstDownloadSize 1697 EXPECT_EQ(URLRequestSlowDownloadJob::kFirstDownloadSize
1697 + URLRequestSlowDownloadJob::kSecondDownloadSize, row.total_bytes); 1698 + URLRequestSlowDownloadJob::kSecondDownloadSize, row.total_bytes);
1698 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, row.state); 1699 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, row.state);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 // Get the details on what was stored into the history. 1763 // Get the details on what was stored into the history.
1763 scoped_ptr<std::vector<history::DownloadRow> > downloads_in_database; 1764 scoped_ptr<std::vector<history::DownloadRow> > downloads_in_database;
1764 ASSERT_TRUE(DownloadsHistoryDataCollector( 1765 ASSERT_TRUE(DownloadsHistoryDataCollector(
1765 browser()->profile()).WaitForDownloadInfo(&downloads_in_database)); 1766 browser()->profile()).WaitForDownloadInfo(&downloads_in_database));
1766 ASSERT_EQ(1u, downloads_in_database->size()); 1767 ASSERT_EQ(1u, downloads_in_database->size());
1767 1768
1768 // Confirm history storage is what you expect for an unvalidated 1769 // Confirm history storage is what you expect for an unvalidated
1769 // dangerous file. 1770 // dangerous file.
1770 history::DownloadRow& row(downloads_in_database->at(0)); 1771 history::DownloadRow& row(downloads_in_database->at(0));
1771 EXPECT_EQ(DestinationFile(browser(), file), row.target_path); 1772 EXPECT_EQ(DestinationFile(browser(), file), row.target_path);
1772 EXPECT_NE(download_util::GetCrDownloadPath(DestinationFile(browser(), file)), 1773 EXPECT_NE(DownloadTargetDeterminer::GetCrDownloadPath(
1774 DestinationFile(browser(), file)),
1773 row.current_path); 1775 row.current_path);
1774 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE, row.danger_type); 1776 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE, row.danger_type);
1775 EXPECT_LE(start, row.start_time); 1777 EXPECT_LE(start, row.start_time);
1776 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, row.state); 1778 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, row.state);
1777 EXPECT_FALSE(row.opened); 1779 EXPECT_FALSE(row.opened);
1778 1780
1779 // Validate the download and wait for it to finish. 1781 // Validate the download and wait for it to finish.
1780 std::vector<DownloadItem*> downloads; 1782 std::vector<DownloadItem*> downloads;
1781 DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads); 1783 DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads);
1782 ASSERT_EQ(1u, downloads.size()); 1784 ASSERT_EQ(1u, downloads.size());
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2934 scoped_ptr<content::DownloadTestObserver> observer( 2936 scoped_ptr<content::DownloadTestObserver> observer(
2935 DangerousDownloadWaiter( 2937 DangerousDownloadWaiter(
2936 browser(), 1, 2938 browser(), 1,
2937 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); 2939 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY));
2938 ui_test_utils::NavigateToURL(browser(), url); 2940 ui_test_utils::NavigateToURL(browser(), url);
2939 observer->WaitForFinished(); 2941 observer->WaitForFinished();
2940 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED)); 2942 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::CANCELLED));
2941 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); 2943 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen());
2942 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 2944 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
2943 } 2945 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_path_reservation_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698