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

Unified Diff: chrome/common/safe_browsing/file_type_policies_unittest.cc

Issue 1929693003: Populate download_file_types proto and filter it for each platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@file_type_polices2
Patch Set: rebase Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/safe_browsing/file_type_policies_unittest.cc
diff --git a/chrome/common/safe_browsing/file_type_policies_unittest.cc b/chrome/common/safe_browsing/file_type_policies_unittest.cc
index e77f5993edfa8859435950fc05efe439b7562fa0..385ba57b260082b5b65fd9aaa98a6421d1396dd0 100644
--- a/chrome/common/safe_browsing/file_type_policies_unittest.cc
+++ b/chrome/common/safe_browsing/file_type_policies_unittest.cc
@@ -48,16 +48,33 @@ TEST_F(FileTypePoliciesTest, UnpackResourceBundle) {
EXPECT_EQ("exe", file_type.extension());
EXPECT_EQ(0l, file_type.uma_value());
EXPECT_EQ(false, file_type.is_archive());
+ EXPECT_EQ(DownloadFileType::FULL_PING, file_type.ping_setting());
+
+ // The current settings for EXE are different for Windows than
+ // for other platforms. If that changes, update this test.
+#if OS_WIN
EXPECT_EQ(DownloadFileType::ALLOW_ON_USER_GESTURE,
file_type.platform_settings(0).danger_level());
+#else
+ EXPECT_EQ(DownloadFileType::NOT_DANGEROUS,
+ file_type.platform_settings(0).danger_level());
+#endif
EXPECT_EQ(DownloadFileType::DISALLOW_AUTO_OPEN,
file_type.platform_settings(0).auto_open_hint());
- EXPECT_EQ(DownloadFileType::FULL_PING,
- file_type.platform_settings(0).ping_setting());
+
+ // Look up a well know archive type
+ base::FilePath zip_file(FILE_PATH_LITERAL("b/bar.txt.zip"));
+ file_type = policies_.PolicyForFile(zip_file);
+ EXPECT_EQ("zip", file_type.extension());
+ EXPECT_EQ(7l, file_type.uma_value());
+ EXPECT_EQ(true, file_type.is_archive());
+ EXPECT_EQ(DownloadFileType::FULL_PING, file_type.ping_setting());
+ EXPECT_EQ(DownloadFileType::NOT_DANGEROUS,
+ file_type.platform_settings(0).danger_level());
// Check other accessors
- EXPECT_EQ(0l, policies_.UmaValueForFile(exe_file));
- EXPECT_EQ(false, policies_.IsFileAnArchive(exe_file));
+ EXPECT_EQ(7l, policies_.UmaValueForFile(zip_file));
+ EXPECT_EQ(true, policies_.IsFileAnArchive(zip_file));
// Verify settings on default type.
file_type = policies_.PolicyForFile(
@@ -65,12 +82,11 @@ TEST_F(FileTypePoliciesTest, UnpackResourceBundle) {
EXPECT_EQ("", file_type.extension());
EXPECT_EQ(18l, file_type.uma_value());
EXPECT_EQ(false, file_type.is_archive());
- EXPECT_EQ(DownloadFileType::ALLOW_ON_USER_GESTURE,
+ EXPECT_EQ(DownloadFileType::SAMPLED_PING, file_type.ping_setting());
+ EXPECT_EQ(DownloadFileType::NOT_DANGEROUS,
file_type.platform_settings(0).danger_level());
EXPECT_EQ(DownloadFileType::DISALLOW_AUTO_OPEN,
file_type.platform_settings(0).auto_open_hint());
- EXPECT_EQ(DownloadFileType::SAMPLED_PING,
- file_type.platform_settings(0).ping_setting());
}
TEST_F(FileTypePoliciesTest, BadProto) {

Powered by Google App Engine
This is Rietveld 408576698