OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/phishing_term_feature_extractor.h" | 5 #include "chrome/renderer/safe_browsing/phishing_term_feature_extractor.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 181 |
182 // Test with empty page text. | 182 // Test with empty page text. |
183 page_text = base::string16(); | 183 page_text = base::string16(); |
184 expected_features.Clear(); | 184 expected_features.Clear(); |
185 features.Clear(); | 185 features.Clear(); |
186 ASSERT_TRUE(ExtractFeatures(&page_text, &features)); | 186 ASSERT_TRUE(ExtractFeatures(&page_text, &features)); |
187 ExpectFeatureMapsAreEqual(features, expected_features); | 187 ExpectFeatureMapsAreEqual(features, expected_features); |
188 | 188 |
189 // Chinese translation of the phrase "hello goodbye". This tests that | 189 // Chinese translation of the phrase "hello goodbye". This tests that |
190 // we can correctly separate terms in languages that don't use spaces. | 190 // we can correctly separate terms in languages that don't use spaces. |
191 page_text = UTF8ToUTF16("\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x86\x8d\xe8\xa7\x81"); | 191 page_text = |
| 192 base::UTF8ToUTF16("\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x86\x8d\xe8\xa7\x81"); |
192 expected_features.Clear(); | 193 expected_features.Clear(); |
193 expected_features.AddBooleanFeature( | 194 expected_features.AddBooleanFeature( |
194 features::kPageTerm + std::string("\xe4\xbd\xa0\xe5\xa5\xbd")); | 195 features::kPageTerm + std::string("\xe4\xbd\xa0\xe5\xa5\xbd")); |
195 expected_features.AddBooleanFeature( | 196 expected_features.AddBooleanFeature( |
196 features::kPageTerm + std::string("\xe5\x86\x8d\xe8\xa7\x81")); | 197 features::kPageTerm + std::string("\xe5\x86\x8d\xe8\xa7\x81")); |
197 | 198 |
198 features.Clear(); | 199 features.Clear(); |
199 ASSERT_TRUE(ExtractFeatures(&page_text, &features)); | 200 ASSERT_TRUE(ExtractFeatures(&page_text, &features)); |
200 ExpectFeatureMapsAreEqual(features, expected_features); | 201 ExpectFeatureMapsAreEqual(features, expected_features); |
201 } | 202 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // Now extract normally and make sure nothing breaks. | 310 // Now extract normally and make sure nothing breaks. |
310 EXPECT_TRUE(ExtractFeatures(page_text.get(), &features)); | 311 EXPECT_TRUE(ExtractFeatures(page_text.get(), &features)); |
311 | 312 |
312 FeatureMap expected_features; | 313 FeatureMap expected_features; |
313 expected_features.AddBooleanFeature(features::kPageTerm + | 314 expected_features.AddBooleanFeature(features::kPageTerm + |
314 std::string("multi word test")); | 315 std::string("multi word test")); |
315 ExpectFeatureMapsAreEqual(features, expected_features); | 316 ExpectFeatureMapsAreEqual(features, expected_features); |
316 } | 317 } |
317 | 318 |
318 } // namespace safe_browsing | 319 } // namespace safe_browsing |
OLD | NEW |