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

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

Issue 348083004: [Android] Disable download protection and client side detection services. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert change in database_manager.h Created 6 years, 5 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 | Annotate | Revision Log
« chrome/chrome_tests_unit.gypi ('K') | « chrome/chrome_tests_unit.gypi ('k') | no next file » | 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) 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // Test with empty page text. 250 // Test with empty page text.
251 page_text = base::string16(); 251 page_text = base::string16();
252 expected_features.Clear(); 252 expected_features.Clear();
253 expected_shingle_hashes.clear(); 253 expected_shingle_hashes.clear();
254 features.Clear(); 254 features.Clear();
255 shingle_hashes.clear(); 255 shingle_hashes.clear();
256 ASSERT_TRUE(ExtractFeatures(&page_text, &features, &shingle_hashes)); 256 ASSERT_TRUE(ExtractFeatures(&page_text, &features, &shingle_hashes));
257 ExpectFeatureMapsAreEqual(features, expected_features); 257 ExpectFeatureMapsAreEqual(features, expected_features);
258 EXPECT_THAT(expected_shingle_hashes, testing::ContainerEq(shingle_hashes)); 258 EXPECT_THAT(expected_shingle_hashes, testing::ContainerEq(shingle_hashes));
259 259
260 #if !defined(OS_ANDROID)
261 // The test code is disabled due to http://crbug.com/392234
262 // The client-side detection feature is not enabled on Android yet.
263 // If we decided to enable the feature, we need to fix the bug first.
264
260 // Chinese translation of the phrase "hello goodbye hello goodbye". This tests 265 // Chinese translation of the phrase "hello goodbye hello goodbye". This tests
261 // that we can correctly separate terms in languages that don't use spaces. 266 // that we can correctly separate terms in languages that don't use spaces.
262 page_text = 267 page_text =
263 base::UTF8ToUTF16("\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x86\x8d\xe8\xa7\x81" 268 base::UTF8ToUTF16("\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x86\x8d\xe8\xa7\x81"
264 "\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x86\x8d\xe8\xa7\x81"); 269 "\xe4\xbd\xa0\xe5\xa5\xbd\xe5\x86\x8d\xe8\xa7\x81");
265 expected_features.Clear(); 270 expected_features.Clear();
266 expected_features.AddBooleanFeature( 271 expected_features.AddBooleanFeature(
267 features::kPageTerm + std::string("\xe4\xbd\xa0\xe5\xa5\xbd")); 272 features::kPageTerm + std::string("\xe4\xbd\xa0\xe5\xa5\xbd"));
268 expected_features.AddBooleanFeature( 273 expected_features.AddBooleanFeature(
269 features::kPageTerm + std::string("\xe5\x86\x8d\xe8\xa7\x81")); 274 features::kPageTerm + std::string("\xe5\x86\x8d\xe8\xa7\x81"));
270 expected_shingle_hashes.clear(); 275 expected_shingle_hashes.clear();
271 expected_shingle_hashes.insert(MurmurHash3String( 276 expected_shingle_hashes.insert(MurmurHash3String(
272 "\xe4\xbd\xa0\xe5\xa5\xbd \xe5\x86\x8d\xe8\xa7\x81 " 277 "\xe4\xbd\xa0\xe5\xa5\xbd \xe5\x86\x8d\xe8\xa7\x81 "
273 "\xe4\xbd\xa0\xe5\xa5\xbd \xe5\x86\x8d\xe8\xa7\x81 ", kMurmurHash3Seed)); 278 "\xe4\xbd\xa0\xe5\xa5\xbd \xe5\x86\x8d\xe8\xa7\x81 ", kMurmurHash3Seed));
274 279
275 features.Clear(); 280 features.Clear();
276 shingle_hashes.clear(); 281 shingle_hashes.clear();
277 ASSERT_TRUE(ExtractFeatures(&page_text, &features, &shingle_hashes)); 282 ASSERT_TRUE(ExtractFeatures(&page_text, &features, &shingle_hashes));
278 ExpectFeatureMapsAreEqual(features, expected_features); 283 ExpectFeatureMapsAreEqual(features, expected_features);
279 EXPECT_THAT(expected_shingle_hashes, testing::ContainerEq(shingle_hashes)); 284 EXPECT_THAT(expected_shingle_hashes, testing::ContainerEq(shingle_hashes));
285 #endif
280 } 286 }
281 287
282 TEST_F(PhishingTermFeatureExtractorTest, Continuation) { 288 TEST_F(PhishingTermFeatureExtractorTest, Continuation) {
283 // For this test, we'll cause the feature extraction to run multiple 289 // For this test, we'll cause the feature extraction to run multiple
284 // iterations by incrementing the clock. 290 // iterations by incrementing the clock.
285 ResetExtractor(200 /* max shingles per page */); 291 ResetExtractor(200 /* max shingles per page */);
286 292
287 // This page has a total of 30 words. For the features to be computed 293 // This page has a total of 30 words. For the features to be computed
288 // correctly, the extractor has to process the entire string of text. 294 // correctly, the extractor has to process the entire string of text.
289 base::string16 page_text(ASCIIToUTF16("one ")); 295 base::string16 page_text(ASCIIToUTF16("one "));
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // Now extract normally and make sure nothing breaks. 455 // Now extract normally and make sure nothing breaks.
450 EXPECT_TRUE(ExtractFeatures(page_text.get(), &features, &shingle_hashes)); 456 EXPECT_TRUE(ExtractFeatures(page_text.get(), &features, &shingle_hashes));
451 457
452 FeatureMap expected_features; 458 FeatureMap expected_features;
453 expected_features.AddBooleanFeature(features::kPageTerm + 459 expected_features.AddBooleanFeature(features::kPageTerm +
454 std::string("multi word test")); 460 std::string("multi word test"));
455 ExpectFeatureMapsAreEqual(features, expected_features); 461 ExpectFeatureMapsAreEqual(features, expected_features);
456 } 462 }
457 463
458 } // namespace safe_browsing 464 } // namespace safe_browsing
OLDNEW
« chrome/chrome_tests_unit.gypi ('K') | « chrome/chrome_tests_unit.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698