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

Side by Side Diff: chrome/browser/safe_browsing/client_side_detection_service_unittest.cc

Issue 7866011: Switch to the new client-side phishing model that uses Murmurhash for word hashes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile problems and add another test Created 9 years, 3 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
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 <map> 5 #include <map>
6 #include <queue> 6 #include <queue>
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.255.255")); 558 EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.255.255"));
559 EXPECT_FALSE(csd_service_->IsBadIpAddress("192.2.0.0")); 559 EXPECT_FALSE(csd_service_->IsBadIpAddress("192.2.0.0"));
560 } 560 }
561 561
562 TEST_F(ClientSideDetectionServiceTest, ModelHasValidHashIds) { 562 TEST_F(ClientSideDetectionServiceTest, ModelHasValidHashIds) {
563 ClientSideModel model; 563 ClientSideModel model;
564 EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model)); 564 EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model));
565 model.add_hashes("bla"); 565 model.add_hashes("bla");
566 EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model)); 566 EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model));
567 model.add_page_term(0); 567 model.add_page_term(0);
568 model.add_page_word(0);
569 EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model)); 568 EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model));
570 569
571 model.add_page_term(-1); 570 model.add_page_term(-1);
572 EXPECT_FALSE(ClientSideDetectionService::ModelHasValidHashIds(model)); 571 EXPECT_FALSE(ClientSideDetectionService::ModelHasValidHashIds(model));
573 model.set_page_term(1, 1); 572 model.set_page_term(1, 1);
574 EXPECT_FALSE(ClientSideDetectionService::ModelHasValidHashIds(model)); 573 EXPECT_FALSE(ClientSideDetectionService::ModelHasValidHashIds(model));
575 model.set_page_term(1, 0); 574 model.set_page_term(1, 0);
576 EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model)); 575 EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model));
577 576
578 model.add_page_word(-2);
579 EXPECT_FALSE(ClientSideDetectionService::ModelHasValidHashIds(model));
580 model.set_page_word(1, 2);
581 EXPECT_FALSE(ClientSideDetectionService::ModelHasValidHashIds(model));
582 model.set_page_word(1, 0);
583 EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model));
584
585 // Test bad rules. 577 // Test bad rules.
586 model.add_hashes("blu"); 578 model.add_hashes("blu");
587 ClientSideModel::Rule* rule = model.add_rule(); 579 ClientSideModel::Rule* rule = model.add_rule();
588 rule->add_feature(0); 580 rule->add_feature(0);
589 rule->add_feature(1); 581 rule->add_feature(1);
590 rule->set_weight(0.1f); 582 rule->set_weight(0.1f);
591 EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model)); 583 EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model));
592 584
593 rule = model.add_rule(); 585 rule = model.add_rule();
594 rule->add_feature(0); 586 rule->add_feature(0);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 EXPECT_TRUE(ClientSideDetectionService::IsFalsePositiveResponse( 775 EXPECT_TRUE(ClientSideDetectionService::IsFalsePositiveResponse(
784 url, response)); 776 url, response));
785 777
786 // If an entry in the whitelist matches the URL it should return true. 778 // If an entry in the whitelist matches the URL it should return true.
787 response.clear_whitelist_expression(); 779 response.clear_whitelist_expression();
788 response.add_whitelist_expression("www.google.com/a/b.html"); 780 response.add_whitelist_expression("www.google.com/a/b.html");
789 EXPECT_TRUE(ClientSideDetectionService::IsFalsePositiveResponse( 781 EXPECT_TRUE(ClientSideDetectionService::IsFalsePositiveResponse(
790 url, response)); 782 url, response));
791 } 783 }
792 } // namespace safe_browsing 784 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/client_side_detection_service.cc ('k') | chrome/chrome_renderer.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698