Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / common / safe_browsing / download_protection_util_unittest.cc
blob64e141f5d4a322f87196f98e6b6ca149f34e19e5
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
3 // found in the LICENSE file.
5 #include "chrome/common/safe_browsing/download_protection_util.h"
7 #include "base/files/file_path.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace safe_browsing {
11 namespace download_protection_util {
13 TEST(DownloadProtectionUtilTest, KnownValues) {
14 EXPECT_EQ(0, GetSBClientDownloadExtensionValueForUMA(
15 base::FilePath(FILE_PATH_LITERAL("foo.exe"))));
16 EXPECT_EQ(9, GetSBClientDownloadExtensionValueForUMA(
17 base::FilePath(FILE_PATH_LITERAL("foo.dll"))));
18 EXPECT_EQ(29, GetSBClientDownloadExtensionValueForUMA(
19 base::FilePath(FILE_PATH_LITERAL("foo.jse"))));
20 EXPECT_EQ(18, GetSBClientDownloadExtensionValueForUMA(
21 base::FilePath(FILE_PATH_LITERAL("foo.111"))));
22 EXPECT_EQ(18, GetSBClientDownloadExtensionValueForUMA(
23 base::FilePath(FILE_PATH_LITERAL("foo.zzz"))));
24 EXPECT_EQ(152, GetSBClientDownloadExtensionValueForUMA(
25 base::FilePath(FILE_PATH_LITERAL("foo.tbz2"))));
26 EXPECT_TRUE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.zip"))));
27 EXPECT_TRUE(
28 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.zip"))));
29 EXPECT_TRUE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.rar"))));
30 EXPECT_TRUE(
31 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.rar"))));
32 EXPECT_FALSE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.ps1"))));
33 EXPECT_FALSE(
34 IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.unknownextension"))));
35 EXPECT_FALSE(
36 IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("no_extension"))));
37 EXPECT_TRUE(IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL(".exe"))));
38 EXPECT_TRUE(
39 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.msi"))));
40 EXPECT_FALSE(
41 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("foo.txt"))));
42 EXPECT_FALSE(IsSupportedBinaryFile(
43 base::FilePath(FILE_PATH_LITERAL("foo.unknownextension"))));
44 EXPECT_FALSE(
45 IsSupportedBinaryFile(base::FilePath(FILE_PATH_LITERAL("no_extension"))));
47 EXPECT_EQ(ClientDownloadRequest::WIN_EXECUTABLE,
48 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.exe"))));
49 EXPECT_EQ(ClientDownloadRequest::CHROME_EXTENSION,
50 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.crx"))));
51 EXPECT_EQ(ClientDownloadRequest::ZIPPED_EXECUTABLE,
52 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.zip"))));
53 EXPECT_EQ(ClientDownloadRequest::ARCHIVE,
54 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.rar"))));
55 EXPECT_EQ(ClientDownloadRequest::MAC_EXECUTABLE,
56 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.pkg"))));
57 EXPECT_EQ(ClientDownloadRequest::ANDROID_APK,
58 GetDownloadType(base::FilePath(FILE_PATH_LITERAL("foo.apk"))));
61 } // namespace download_protection_util
62 } // namespace safe_browsing