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

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

Issue 2743563006: Componentize safe_browsing [+1]: move protos to component
Patch Set: fix remaining proto references Created 3 years, 9 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
« no previous file with comments | « chrome/renderer/safe_browsing/scorer.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/safe_browsing/scorer.h" 5 #include "chrome/renderer/safe_browsing/scorer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/format_macros.h" 14 #include "base/format_macros.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "chrome/common/safe_browsing/client_model.pb.h"
18 #include "chrome/renderer/safe_browsing/features.h" 17 #include "chrome/renderer/safe_browsing/features.h"
18 #include "components/safe_browsing/common/client_model.pb.h"
19 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 namespace safe_browsing { 22 namespace safe_browsing {
23 23
24 class PhishingScorerTest : public ::testing::Test { 24 class PhishingScorerTest : public ::testing::Test {
25 protected: 25 protected:
26 void SetUp() override { 26 void SetUp() override {
27 // Setup a simple model. Note that the scorer does not care about 27 // Setup a simple model. Note that the scorer does not care about
28 // how features are encoded so we use readable strings here to make 28 // how features are encoded so we use readable strings here to make
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 EXPECT_DOUBLE_EQ(0.6899744811276125, scorer->ComputeScore(features)); 140 EXPECT_DOUBLE_EQ(0.6899744811276125, scorer->ComputeScore(features));
141 141
142 // Now, both feature 1 and feature 2 match. Expected logodds: 142 // Now, both feature 1 and feature 2 match. Expected logodds:
143 // 0.5 (empty rule) + 2.0 (rule weight) * 0.15 (feature weight) + 143 // 0.5 (empty rule) + 2.0 (rule weight) * 0.15 (feature weight) +
144 // 3.0 (rule weight) * 0.15 (feature1 weight) * 1.0 (feature2) weight = 9.8 144 // 3.0 (rule weight) * 0.15 (feature1 weight) * 1.0 (feature2) weight = 9.8
145 // => p = 0.99999627336071584 145 // => p = 0.99999627336071584
146 EXPECT_TRUE(features.AddBooleanFeature("feature2")); 146 EXPECT_TRUE(features.AddBooleanFeature("feature2"));
147 EXPECT_DOUBLE_EQ(0.77729986117469119, scorer->ComputeScore(features)); 147 EXPECT_DOUBLE_EQ(0.77729986117469119, scorer->ComputeScore(features));
148 } 148 }
149 } // namespace safe_browsing 149 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/renderer/safe_browsing/scorer.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698