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

Side by Side 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: Fix comment, per asanka's review 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/safe_browsing/download_protection_util.h" 5 #include "chrome/common/safe_browsing/download_protection_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace safe_browsing { 10 namespace safe_browsing {
11 namespace download_protection_util { 11 namespace download_protection_util {
12 12
13 TEST(DownloadProtectionUtilTest, KnownValues) { 13 TEST(DownloadProtectionUtilTest, KnownValues) {
14 EXPECT_EQ(0, GetSBClientDownloadExtensionValueForUMA(
15 base::FilePath(FILE_PATH_LITERAL("foo.exe"))));
16 EXPECT_EQ(0, GetSBClientDownloadExtensionValueForUMA(
17 base::FilePath(FILE_PATH_LITERAL("foo.exe."))));
18 EXPECT_EQ(0, GetSBClientDownloadExtensionValueForUMA(
19 base::FilePath(FILE_PATH_LITERAL("foo.exe "))));
20 EXPECT_EQ(0, GetSBClientDownloadExtensionValueForUMA(
21 base::FilePath(FILE_PATH_LITERAL("foo.exe.. . . . "))));
22 EXPECT_EQ(9, GetSBClientDownloadExtensionValueForUMA(
23 base::FilePath(FILE_PATH_LITERAL("foo.dll"))));
24 EXPECT_EQ(29, GetSBClientDownloadExtensionValueForUMA(
25 base::FilePath(FILE_PATH_LITERAL("foo.jse"))));
26 EXPECT_EQ(18, GetSBClientDownloadExtensionValueForUMA(
27 base::FilePath(FILE_PATH_LITERAL("foo.111"))));
28 EXPECT_EQ(18, GetSBClientDownloadExtensionValueForUMA(
29 base::FilePath(FILE_PATH_LITERAL("foo.zzz"))));
30 EXPECT_EQ(152, GetSBClientDownloadExtensionValueForUMA(
31 base::FilePath(FILE_PATH_LITERAL("foo.tbz2"))));
32 EXPECT_TRUE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.zip"))));
33 EXPECT_TRUE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.zip."))));
34 EXPECT_TRUE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.zip "))));
35 EXPECT_TRUE(
36 IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.zip ...."))));
37 EXPECT_TRUE(
38 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.zip"))));
39 EXPECT_TRUE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.rar"))));
40 EXPECT_TRUE(
41 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.rar"))));
42 EXPECT_FALSE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.ps1"))));
43 EXPECT_FALSE(
44 IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.unknownextension"))));
45 EXPECT_FALSE(
46 IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("no_extension"))));
47 EXPECT_TRUE(IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL(".exe"))));
48 EXPECT_TRUE(
49 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.msi"))));
50 EXPECT_TRUE(
51 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.msi."))));
52 EXPECT_TRUE(
53 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.msi "))));
54 EXPECT_TRUE(IsSupportedBinaryFile(
55 base::FilePath(FILE_PATH_LITERAL("foo.msi .. .."))));
56 EXPECT_FALSE(
57 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.txt"))));
58 EXPECT_FALSE(IsSupportedBinaryFile(
59 base::FilePath(FILE_PATH_LITERAL("foo.unknownextension"))));
60 EXPECT_FALSE(
61 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("no_extension"))));
62
63 EXPECT_EQ(ClientDownloadRequest::WIN_EXECUTABLE, 14 EXPECT_EQ(ClientDownloadRequest::WIN_EXECUTABLE,
64 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.exe")))); 15 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.exe"))));
65 EXPECT_EQ(ClientDownloadRequest::CHROME_EXTENSION, 16 EXPECT_EQ(ClientDownloadRequest::CHROME_EXTENSION,
66 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.crx")))); 17 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.crx"))));
67 EXPECT_EQ(ClientDownloadRequest::ZIPPED_EXECUTABLE, 18 EXPECT_EQ(ClientDownloadRequest::ZIPPED_EXECUTABLE,
68 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.zip")))); 19 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.zip"))));
69 EXPECT_EQ(ClientDownloadRequest::ARCHIVE, 20 EXPECT_EQ(ClientDownloadRequest::ARCHIVE,
70 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.rar")))); 21 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.rar"))));
71 EXPECT_EQ(ClientDownloadRequest::MAC_EXECUTABLE, 22 EXPECT_EQ(ClientDownloadRequest::MAC_EXECUTABLE,
72 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.pkg")))); 23 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.pkg"))));
73 EXPECT_EQ(ClientDownloadRequest::ANDROID_APK, 24 EXPECT_EQ(ClientDownloadRequest::ANDROID_APK,
74 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.apk")))); 25 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.apk"))));
75 } 26 }
76 27
77 } // namespace download_protection_util 28 } // namespace download_protection_util
78 } // namespace safe_browsing 29 } // namespace safe_browsing
79 30
80 31
OLDNEW
« no previous file with comments | « chrome/common/safe_browsing/download_protection_util.cc ('k') | chrome/common/safe_browsing/file_type_policies.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698