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

Unified Diff: chrome/renderer/safe_browsing/features_unittest.cc

Issue 2878046: Add an extractor for DOM features to be used for client side phishing detection. (Closed)
Patch Set: address marria's comments Created 10 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
Index: chrome/renderer/safe_browsing/features_unittest.cc
diff --git a/chrome/renderer/safe_browsing/features_unittest.cc b/chrome/renderer/safe_browsing/features_unittest.cc
index ad07ba29c2713920bba0716058294b9276648fdb..ac5cb555e16028b2a01f4f5b90dd718b8951cf23 100644
--- a/chrome/renderer/safe_browsing/features_unittest.cc
+++ b/chrome/renderer/safe_browsing/features_unittest.cc
@@ -6,6 +6,7 @@
#include "base/format_macros.h"
#include "base/string_util.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace safe_browsing {
@@ -24,4 +25,20 @@ TEST(PhishingFeaturesTest, TooManyFeatures) {
EXPECT_EQ(FeatureMap::kMaxFeatureMapSize, features.features().size());
}
+TEST(PhishingFeaturesTest, IllegalFeatureValue) {
+ FeatureMap features;
+ EXPECT_FALSE(features.AddRealFeature("toosmall", -0.1));
+ EXPECT_TRUE(features.AddRealFeature("zero", 0.0));
+ EXPECT_TRUE(features.AddRealFeature("pointfive", 0.5));
+ EXPECT_TRUE(features.AddRealFeature("one", 1.0));
+ EXPECT_FALSE(features.AddRealFeature("toolarge", 1.1));
+
+ FeatureMap expected_features;
+ expected_features.AddRealFeature("zero", 0.0);
+ expected_features.AddRealFeature("pointfive", 0.5);
+ expected_features.AddRealFeature("one", 1.0);
+ EXPECT_THAT(features.features(),
+ ::testing::ContainerEq(expected_features.features()));
+}
+
} // namespace safe_browsing
« no previous file with comments | « chrome/renderer/safe_browsing/features.cc ('k') | chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698