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

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

Issue 1257233004: [SafeBrowsing] Consolidate extension lookup logic and extension lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@double-zip
Patch Set: Fix Windows unit test build. Created 5 years, 5 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
« no previous file with comments | « chrome/common/safe_browsing/download_protection_util.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..8bb47fbc34f3c63c838ce770cd2553b1b824205d
--- /dev/null
+++ b/chrome/common/safe_browsing/download_protection_util_unittest.cc
@@ -0,0 +1,44 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/safe_browsing/download_protection_util.h"
+
+#include "base/files/file_path.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(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_TRUE(IsArchiveFile(base::FilePath(FILE_PATH_LITERAL("foo.zip"))));
+ 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_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"))));
+}
+
+} // namespace download_protection_util
+} // namespace safe_browsing
+
+
« no previous file with comments | « chrome/common/safe_browsing/download_protection_util.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698