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

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

Issue 1979153002: Use FileTypePolicies for is_archive and is_supported classifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_by_platform
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/download_protection_util_unittest.cc
diff --git a/chrome/common/safe_browsing/download_protection_util_unittest.cc b/chrome/common/safe_browsing/download_protection_util_unittest.cc
index f8511a4ab9787799f362f347a7502798d8fac0f2..3138975aeb5a02ffecd45fb92aee970ce2dee621 100644
--- a/chrome/common/safe_browsing/download_protection_util_unittest.cc
+++ b/chrome/common/safe_browsing/download_protection_util_unittest.cc
@@ -5,61 +5,21 @@
#include "chrome/common/safe_browsing/download_protection_util.h"
#include "base/files/file_path.h"
+#include "chrome/common/safe_browsing/file_type_policies.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace safe_browsing {
namespace download_protection_util {
-TEST(DownloadProtectionUtilTest, KnownValues) {
- EXPECT_EQ(0, GetSBClientDownloadExtensionValueForUMA(
- base::FilePath(FILE_PATH_LITERAL("foo.exe"))));
- EXPECT_EQ(0, GetSBClientDownloadExtensionValueForUMA(
- base::FilePath(FILE_PATH_LITERAL("foo.exe."))));
- EXPECT_EQ(0, GetSBClientDownloadExtensionValueForUMA(
- base::FilePath(FILE_PATH_LITERAL("foo.exe "))));
- EXPECT_EQ(0, GetSBClientDownloadExtensionValueForUMA(
- base::FilePath(FILE_PATH_LITERAL("foo.exe.. . . . "))));
- EXPECT_EQ(9, GetSBClientDownloadExtensionValueForUMA(
- base::FilePath(FILE_PATH_LITERAL("foo.dll"))));
- EXPECT_EQ(29, GetSBClientDownloadExtensionValueForUMA(
- base::FilePath(FILE_PATH_LITERAL("foo.jse"))));
- EXPECT_EQ(18, GetSBClientDownloadExtensionValueForUMA(
- base::FilePath(FILE_PATH_LITERAL("foo.111"))));
- EXPECT_EQ(18, GetSBClientDownloadExtensionValueForUMA(
- base::FilePath(FILE_PATH_LITERAL("foo.zzz"))));
- EXPECT_EQ(152, GetSBClientDownloadExtensionValueForUMA(
- base::FilePath(FILE_PATH_LITERAL("foo.tbz2"))));
- EXPECT_TRUE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.zip"))));
- EXPECT_TRUE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.zip."))));
- EXPECT_TRUE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.zip "))));
- EXPECT_TRUE(
- IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.zip ...."))));
- EXPECT_TRUE(
- IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.zip"))));
- EXPECT_TRUE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.rar"))));
- EXPECT_TRUE(
- IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.rar"))));
- EXPECT_FALSE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.ps1"))));
- EXPECT_FALSE(
- IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.unknownextension"))));
- EXPECT_FALSE(
- IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("no_extension"))));
- EXPECT_TRUE(IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL(".exe"))));
- EXPECT_TRUE(
- IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.msi"))));
- EXPECT_TRUE(
- IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.msi."))));
- EXPECT_TRUE(
- IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.msi "))));
- EXPECT_TRUE(IsSupportedBinaryFile(
- base::FilePath(FILE_PATH_LITERAL("foo.msi .. .."))));
- EXPECT_FALSE(
- IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.txt"))));
- EXPECT_FALSE(IsSupportedBinaryFile(
- base::FilePath(FILE_PATH_LITERAL("foo.unknownextension"))));
- EXPECT_FALSE(
- IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("no_extension"))));
+class DownloadProtectionUtilTest : public testing::Test {
+ public:
+ ~DownloadProtectionUtilTest() override {}
+ protected:
+ FileTypePoliciesManager file_type_policies_manager_;
+};
+
+TEST_F(DownloadProtectionUtilTest, KnownValues) {
EXPECT_EQ(ClientDownloadRequest::WIN_EXECUTABLE,
GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.exe"))));
EXPECT_EQ(ClientDownloadRequest::CHROME_EXTENSION,

Powered by Google App Engine
This is Rietveld 408576698