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)); |
} |
} |