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

Unified Diff: chrome/browser/download/download_manager_unittest.cc

Issue 8468020: Propagate the SafeBrowsing download protection verdict to the DownloadItem. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Address Ben's comment. Created 9 years, 1 month 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
Index: chrome/browser/download/download_manager_unittest.cc
diff --git a/chrome/browser/download/download_manager_unittest.cc b/chrome/browser/download/download_manager_unittest.cc
index a85fb3efebcc5a9b6295b7ca1953985fb39b3d10..040dd45527d9bf4461c8d5a8d4fe9bda914f269b 100644
--- a/chrome/browser/download/download_manager_unittest.cc
+++ b/chrome/browser/download/download_manager_unittest.cc
@@ -145,17 +145,6 @@ class DownloadManagerTest : public testing::Test {
return file_manager_;
}
- // Make sure download item |id| was set with correct safety state for
- // given |is_dangerous_file| and |is_dangerous_url|.
- bool VerifySafetyState(bool is_dangerous_file,
- bool is_dangerous_url,
- int id) {
- DownloadItem::SafetyState safety_state =
- download_manager_->GetDownloadItem(id)->safety_state();
- return (is_dangerous_file || is_dangerous_url) ?
- safety_state != DownloadItem::SAFE : safety_state == DownloadItem::SAFE;
- }
-
DISALLOW_COPY_AND_ASSIGN(DownloadManagerTest);
};
@@ -255,29 +244,23 @@ const struct {
const struct {
FilePath::StringType suggested_path;
- bool is_dangerous_file;
- bool is_dangerous_url;
+ bool needs_quarantine_file;
bool finish_before_rename;
int expected_rename_count;
} kDownloadRenameCases[] = {
// Safe download, download finishes BEFORE file name determined.
// Renamed twice (linear path through UI). Crdownload file does not need
// to be deleted.
- { FILE_PATH_LITERAL("foo.zip"), false, false, true, 2, },
- // Dangerous download (file is dangerous or download URL is not safe or both),
- // download finishes BEFORE file name determined. Needs to be renamed only
- // once.
- { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), true, false, true, 1, },
- { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), false, true, true, 1, },
- { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), true, true, true, 1, },
+ { FILE_PATH_LITERAL("foo.zip"), false, true, 2, },
+ // Potentially dangerous download (e.g., file is dangerous), download finishes
+ // BEFORE file name determined. Needs to be renamed only once.
+ { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), true, true, 1, },
// Safe download, download finishes AFTER file name determined.
// Needs to be renamed twice.
- { FILE_PATH_LITERAL("foo.zip"), false, false, false, 2, },
- // Dangerous download, download finishes AFTER file name determined.
- // Needs to be renamed only once.
- { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), true, false, false, 1, },
- { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), false, true, false, 1, },
- { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), true, true, false, 1, },
+ { FILE_PATH_LITERAL("foo.zip"), false, false, 2, },
+ // Potentially dangerous download, download finishes AFTER file name
+ // determined. Needs to be renamed only once.
+ { FILE_PATH_LITERAL("Unconfirmed xxx.crdownload"), true, false, 1, },
};
class MockDownloadFile : public DownloadFile {
@@ -454,10 +437,11 @@ TEST_F(DownloadManagerTest, DownloadRenameTest) {
download_manager_->CreateDownloadItem(info.get(), DownloadRequestHandle());
DownloadItem* download = GetActiveDownloadItem(i);
ASSERT_TRUE(download != NULL);
- if (kDownloadRenameCases[i].is_dangerous_file)
- download->MarkFileDangerous();
- if (kDownloadRenameCases[i].is_dangerous_url)
- download->MarkUrlDangerous();
+ if (kDownloadRenameCases[i].needs_quarantine_file) {
+ DownloadStateInfo info = download->state_info();
+ info.needs_quarantine_file = true;
+ download->SetFileCheckResults(info);
+ }
int32* id_ptr = new int32;
*id_ptr = i; // Deleted in FileSelected().
@@ -470,11 +454,7 @@ TEST_F(DownloadManagerTest, DownloadRenameTest) {
message_loop_.RunAllPending();
OnResponseCompleted(i, 1024, std::string("fake_hash"));
}
-
message_loop_.RunAllPending();
- EXPECT_TRUE(VerifySafetyState(kDownloadRenameCases[i].is_dangerous_file,
- kDownloadRenameCases[i].is_dangerous_url,
- i));
}
}

Powered by Google App Engine
This is Rietveld 408576698