OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
14 #include "base/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "chrome/renderer/safe_browsing/client_model.pb.h" | 15 #include "chrome/renderer/safe_browsing/client_model.pb.h" |
16 #include "chrome/renderer/safe_browsing/features.h" | 16 #include "chrome/renderer/safe_browsing/features.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 namespace safe_browsing { | 20 namespace safe_browsing { |
21 | 21 |
22 class PhishingScorerTest : public ::testing::Test { | 22 class PhishingScorerTest : public ::testing::Test { |
23 protected: | 23 protected: |
24 virtual void SetUp() { | 24 virtual void SetUp() { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 EXPECT_DOUBLE_EQ(0.6899744811276125, scorer->ComputeScore(features)); | 209 EXPECT_DOUBLE_EQ(0.6899744811276125, scorer->ComputeScore(features)); |
210 | 210 |
211 // Now, both feature 1 and feature 2 match. Expected logodds: | 211 // Now, both feature 1 and feature 2 match. Expected logodds: |
212 // 0.5 (empty rule) + 2.0 (rule weight) * 0.15 (feature weight) + | 212 // 0.5 (empty rule) + 2.0 (rule weight) * 0.15 (feature weight) + |
213 // 3.0 (rule weight) * 0.15 (feature1 weight) * 1.0 (feature2) weight = 9.8 | 213 // 3.0 (rule weight) * 0.15 (feature1 weight) * 1.0 (feature2) weight = 9.8 |
214 // => p = 0.99999627336071584 | 214 // => p = 0.99999627336071584 |
215 EXPECT_TRUE(features.AddBooleanFeature("feature2")); | 215 EXPECT_TRUE(features.AddBooleanFeature("feature2")); |
216 EXPECT_DOUBLE_EQ(0.77729986117469119, scorer->ComputeScore(features)); | 216 EXPECT_DOUBLE_EQ(0.77729986117469119, scorer->ComputeScore(features)); |
217 } | 217 } |
218 } // namespace safe_browsing | 218 } // namespace safe_browsing |
OLD | NEW |