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

Unified Diff: chrome/browser/safe_browsing/client_side_detection_host_unittest.cc

Issue 7189074: Send the referral URL with the client-side phishing detection request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unnecessary header Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
diff --git a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
index a1c26049c02dd53e9ae4019260c7839ec22b49c1..c8da47d5028c519c4c54d9a0d73504fc7af91160 100644
--- a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
@@ -45,8 +45,10 @@ const bool kTrue = true;
namespace safe_browsing {
namespace {
-MATCHER_P(EqualsProto, other, "") {
- return other.SerializeAsString() == arg.SerializeAsString();
+MATCHER_P(PartiallyEqualVerdict, other, "") {
mattm 2011/06/20 22:33:06 maybe add a comment about why we only match some p
noelutz 2011/06/20 22:58:12 Done.
+ return (other.url() == arg.url() &&
+ other.client_score() == arg.client_score() &&
+ other.is_phishing() == arg.is_phishing());
}
ACTION(QuitUIMessageLoop) {
@@ -107,7 +109,8 @@ class MockBrowserFeatureExtractor : public BrowserFeatureExtractor {
: BrowserFeatureExtractor(tab) {}
virtual ~MockBrowserFeatureExtractor() {}
- MOCK_METHOD2(ExtractFeatures, void(ClientPhishingRequest*,
+ MOCK_METHOD3(ExtractFeatures, void(const BrowseInfo& info,
+ ClientPhishingRequest*,
BrowserFeatureExtractor::DoneCallback*));
};
@@ -151,6 +154,9 @@ class ClientSideDetectionHostTest : public TabContentsWrapperTestHarness {
}
void OnDetectedPhishingSite(const std::string& verdict_str) {
+ // Make sure we have a valid BrowseInfo object set before we call this
+ // method.
+ csd_host_->browse_info_.reset(new BrowseInfo);
csd_host_->OnDetectedPhishingSite(verdict_str);
}
@@ -228,7 +234,7 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteInvalidVerdict) {
MockBrowserFeatureExtractor* mock_extractor = new MockBrowserFeatureExtractor(
contents());
SetFeatureExtractor(mock_extractor); // The host class takes ownership.
- EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _)).Times(0);
+ EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)).Times(0);
OnDetectedPhishingSite("Invalid Protocol Buffer");
EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor));
}
@@ -243,7 +249,8 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteNotPhishing) {
verdict.set_is_phishing(true);
EXPECT_CALL(*csd_service_,
- SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _))
+ SendClientReportPhishingRequest(
+ Pointee(PartiallyEqualVerdict(verdict)), _))
.WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop()));
OnDetectedPhishingSite(verdict.SerializeAsString());
MessageLoop::current()->Run();
@@ -268,7 +275,8 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteDisabled) {
verdict.set_is_phishing(true);
EXPECT_CALL(*csd_service_,
- SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _))
+ SendClientReportPhishingRequest(
+ Pointee(PartiallyEqualVerdict(verdict)), _))
.WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop()));
OnDetectedPhishingSite(verdict.SerializeAsString());
MessageLoop::current()->Run();
@@ -294,7 +302,8 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteShowInterstitial) {
verdict.set_is_phishing(true);
EXPECT_CALL(*csd_service_,
- SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _))
+ SendClientReportPhishingRequest(
+ Pointee(PartiallyEqualVerdict(verdict)), _))
.WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop()));
OnDetectedPhishingSite(verdict.SerializeAsString());
MessageLoop::current()->Run();
@@ -347,7 +356,8 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteMultiplePings) {
verdict.set_is_phishing(true);
EXPECT_CALL(*csd_service_,
- SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _))
+ SendClientReportPhishingRequest(
+ Pointee(PartiallyEqualVerdict(verdict)), _))
.WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop()));
OnDetectedPhishingSite(verdict.SerializeAsString());
MessageLoop::current()->Run();
@@ -365,7 +375,8 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteMultiplePings) {
verdict.set_url(other_phishing_url.spec());
verdict.set_client_score(0.8f);
EXPECT_CALL(*csd_service_,
- SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _))
+ SendClientReportPhishingRequest(
+ Pointee(PartiallyEqualVerdict(verdict)), _))
.WillOnce(DoAll(DeleteArg<0>(),
SaveArg<1>(&cb_other),
QuitUIMessageLoop()));

Powered by Google App Engine
This is Rietveld 408576698