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

Side by Side Diff: chrome/renderer/safe_browsing/features_unittest.cc

Issue 2667343006: Componentize safe_browsing [X+1] : move the renderer part to component.
Patch Set: Created 3 years, 10 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
(Empty)
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.
4
5 #include "chrome/renderer/safe_browsing/features.h"
6
7 #include <stddef.h>
8
9 #include "base/format_macros.h"
10 #include "base/strings/stringprintf.h"
11 #include "chrome/renderer/safe_browsing/test_utils.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace safe_browsing {
15
16 TEST(PhishingFeaturesTest, TooManyFeatures) {
17 FeatureMap features;
18 for (size_t i = 0; i < FeatureMap::kMaxFeatureMapSize; ++i) {
19 EXPECT_TRUE(features.AddBooleanFeature(
20 base::StringPrintf("Feature%" PRIuS, i)));
21 }
22 EXPECT_EQ(FeatureMap::kMaxFeatureMapSize, features.features().size());
23
24 // Attempting to add more features should fail.
25 for (size_t i = 0; i < 3; ++i) {
26 EXPECT_FALSE(features.AddBooleanFeature(
27 base::StringPrintf("Extra%" PRIuS, i)));
28 }
29 EXPECT_EQ(FeatureMap::kMaxFeatureMapSize, features.features().size());
30 }
31
32 TEST(PhishingFeaturesTest, IllegalFeatureValue) {
33 FeatureMap features;
34 EXPECT_FALSE(features.AddRealFeature("toosmall", -0.1));
35 EXPECT_TRUE(features.AddRealFeature("zero", 0.0));
36 EXPECT_TRUE(features.AddRealFeature("pointfive", 0.5));
37 EXPECT_TRUE(features.AddRealFeature("one", 1.0));
38 EXPECT_FALSE(features.AddRealFeature("toolarge", 1.1));
39
40 FeatureMap expected_features;
41 expected_features.AddRealFeature("zero", 0.0);
42 expected_features.AddRealFeature("pointfive", 0.5);
43 expected_features.AddRealFeature("one", 1.0);
44 ExpectFeatureMapsAreEqual(features, expected_features);
45 }
46
47 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/renderer/safe_browsing/features.cc ('k') | chrome/renderer/safe_browsing/mock_feature_extractor_clock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698