OLD | NEW |
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 "base/containers/hash_tables.h" |
7 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
8 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
9 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
10 #include "base/hash_tables.h" | |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "chrome/common/safe_browsing/client_model.pb.h" | 14 #include "chrome/common/safe_browsing/client_model.pb.h" |
15 #include "chrome/renderer/safe_browsing/features.h" | 15 #include "chrome/renderer/safe_browsing/features.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace safe_browsing { | 19 namespace safe_browsing { |
20 | 20 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 EXPECT_DOUBLE_EQ(0.6899744811276125, scorer->ComputeScore(features)); | 118 EXPECT_DOUBLE_EQ(0.6899744811276125, scorer->ComputeScore(features)); |
119 | 119 |
120 // Now, both feature 1 and feature 2 match. Expected logodds: | 120 // Now, both feature 1 and feature 2 match. Expected logodds: |
121 // 0.5 (empty rule) + 2.0 (rule weight) * 0.15 (feature weight) + | 121 // 0.5 (empty rule) + 2.0 (rule weight) * 0.15 (feature weight) + |
122 // 3.0 (rule weight) * 0.15 (feature1 weight) * 1.0 (feature2) weight = 9.8 | 122 // 3.0 (rule weight) * 0.15 (feature1 weight) * 1.0 (feature2) weight = 9.8 |
123 // => p = 0.99999627336071584 | 123 // => p = 0.99999627336071584 |
124 EXPECT_TRUE(features.AddBooleanFeature("feature2")); | 124 EXPECT_TRUE(features.AddBooleanFeature("feature2")); |
125 EXPECT_DOUBLE_EQ(0.77729986117469119, scorer->ComputeScore(features)); | 125 EXPECT_DOUBLE_EQ(0.77729986117469119, scorer->ComputeScore(features)); |
126 } | 126 } |
127 } // namespace safe_browsing | 127 } // namespace safe_browsing |
OLD | NEW |