Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / chrome / renderer / safe_browsing / features_unittest.cc
blobefba01304d1356cc4343dd0daa98eba5c4ab0ff6
1 // Copyright (c) 2012 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/renderer/safe_browsing/features.h"
7 #include "base/format_macros.h"
8 #include "base/strings/stringprintf.h"
9 #include "chrome/renderer/safe_browsing/test_utils.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace safe_browsing {
14 TEST(PhishingFeaturesTest, TooManyFeatures) {
15 FeatureMap features;
16 for (size_t i = 0; i < FeatureMap::kMaxFeatureMapSize; ++i) {
17 EXPECT_TRUE(features.AddBooleanFeature(
18 base::StringPrintf("Feature%" PRIuS, i)));
20 EXPECT_EQ(FeatureMap::kMaxFeatureMapSize, features.features().size());
22 // Attempting to add more features should fail.
23 for (size_t i = 0; i < 3; ++i) {
24 EXPECT_FALSE(features.AddBooleanFeature(
25 base::StringPrintf("Extra%" PRIuS, i)));
27 EXPECT_EQ(FeatureMap::kMaxFeatureMapSize, features.features().size());
30 TEST(PhishingFeaturesTest, IllegalFeatureValue) {
31 FeatureMap features;
32 EXPECT_FALSE(features.AddRealFeature("toosmall", -0.1));
33 EXPECT_TRUE(features.AddRealFeature("zero", 0.0));
34 EXPECT_TRUE(features.AddRealFeature("pointfive", 0.5));
35 EXPECT_TRUE(features.AddRealFeature("one", 1.0));
36 EXPECT_FALSE(features.AddRealFeature("toolarge", 1.1));
38 FeatureMap expected_features;
39 expected_features.AddRealFeature("zero", 0.0);
40 expected_features.AddRealFeature("pointfive", 0.5);
41 expected_features.AddRealFeature("one", 1.0);
42 ExpectFeatureMapsAreEqual(features, expected_features);
45 } // namespace safe_browsing