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

Unified Diff: chrome/browser/net/file_downloader_unittest.cc

Issue 1851803002: [NTP Popular Sites] Store country/version in prefs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/net/file_downloader.cc ('k') | chrome/browser/resources/popular_sites_internals.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/file_downloader_unittest.cc
diff --git a/chrome/browser/net/file_downloader_unittest.cc b/chrome/browser/net/file_downloader_unittest.cc
index 0eb5474fc23ea96cec7c1cbc13a64e3fad269763..4d0da7877f9b91b4ba8365956b8ae28a9a2b7b6e 100644
--- a/chrome/browser/net/file_downloader_unittest.cc
+++ b/chrome/browser/net/file_downloader_unittest.cc
@@ -34,7 +34,7 @@ class FileDownloaderTest : public testing::Test {
ASSERT_FALSE(base::PathExists(path_));
}
- MOCK_METHOD1(OnDownloadFinished, void(bool success));
+ MOCK_METHOD1(OnDownloadFinished, void(FileDownloader::Result));
protected:
const base::FilePath& path() const { return path_; }
@@ -57,12 +57,12 @@ class FileDownloaderTest : public testing::Test {
net::URLRequestStatus::SUCCESS);
}
- void Download(bool overwrite, bool expect_success) {
+ void Download(bool overwrite, FileDownloader::Result expected_result) {
FileDownloader downloader(
GURL(kURL), path_, overwrite, request_context_.get(),
base::Bind(&FileDownloaderTest::OnDownloadFinished,
base::Unretained(this)));
- EXPECT_CALL(*this, OnDownloadFinished(expect_success));
+ EXPECT_CALL(*this, OnDownloadFinished(expected_result));
// Wait for the FileExists check to happen if necessary.
if (!overwrite)
content::BrowserThread::GetBlockingPool()->FlushForTesting();
@@ -84,7 +84,7 @@ class FileDownloaderTest : public testing::Test {
TEST_F(FileDownloaderTest, Success) {
SetValidResponse();
- Download(true, true);
+ Download(true, FileDownloader::DOWNLOADED);
EXPECT_TRUE(base::PathExists(path()));
std::string contents;
ASSERT_TRUE(base::ReadFileToString(path(), &contents));
@@ -93,20 +93,20 @@ TEST_F(FileDownloaderTest, Success) {
TEST_F(FileDownloaderTest, Failure) {
SetFailedResponse();
- Download(true, false);
+ Download(true, FileDownloader::FAILED);
EXPECT_FALSE(base::PathExists(path()));
}
TEST_F(FileDownloaderTest, Overwrite) {
SetValidResponse();
- Download(true, true);
+ Download(true, FileDownloader::DOWNLOADED);
ASSERT_TRUE(base::PathExists(path()));
std::string contents;
ASSERT_TRUE(base::ReadFileToString(path(), &contents));
ASSERT_EQ(std::string(kFileContents1), contents);
SetValidResponse2();
- Download(true, true);
+ Download(true, FileDownloader::DOWNLOADED);
// The file should have been overwritten with the new contents.
EXPECT_TRUE(base::PathExists(path()));
ASSERT_TRUE(base::ReadFileToString(path(), &contents));
@@ -115,14 +115,14 @@ TEST_F(FileDownloaderTest, Overwrite) {
TEST_F(FileDownloaderTest, DontOverwrite) {
SetValidResponse();
- Download(true, true);
+ Download(true, FileDownloader::DOWNLOADED);
ASSERT_TRUE(base::PathExists(path()));
std::string contents;
ASSERT_TRUE(base::ReadFileToString(path(), &contents));
EXPECT_EQ(std::string(kFileContents1), contents);
SetValidResponse2();
- Download(false, true);
+ Download(false, FileDownloader::EXISTS);
// The file should still have the old contents.
EXPECT_TRUE(base::PathExists(path()));
ASSERT_TRUE(base::ReadFileToString(path(), &contents));
« no previous file with comments | « chrome/browser/net/file_downloader.cc ('k') | chrome/browser/resources/popular_sites_internals.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698