| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Note: this test uses RenderViewFakeResourcesTest in order to set up a | 5 // Note: this test uses RenderViewFakeResourcesTest in order to set up a |
| 6 // real RenderThread to hold the phishing Scorer object. | 6 // real RenderThread to hold the phishing Scorer object. |
| 7 | 7 |
| 8 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 8 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
| 9 | 9 |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 private: | 54 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(MockScorer); | 55 DISALLOW_COPY_AND_ASSIGN(MockScorer); |
| 56 }; | 56 }; |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 class PhishingClassifierDelegateTest : public RenderViewFakeResourcesTest { | 59 class PhishingClassifierDelegateTest : public RenderViewFakeResourcesTest { |
| 60 protected: | 60 protected: |
| 61 bool OnMessageReceived(const IPC::Message& message) { | 61 bool OnMessageReceived(const IPC::Message& message) { |
| 62 bool handled = true; | 62 bool handled = true; |
| 63 IPC_BEGIN_MESSAGE_MAP(PhishingClassifierDelegateTest, message) | 63 IPC_BEGIN_MESSAGE_MAP(PhishingClassifierDelegateTest, message) |
| 64 IPC_MESSAGE_HANDLER(SafeBrowsingDetectionHostMsg_DetectedPhishingSite, | 64 IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_DetectedPhishingSite, |
| 65 OnDetectedPhishingSite) | 65 OnDetectedPhishingSite) |
| 66 IPC_MESSAGE_UNHANDLED( | 66 IPC_MESSAGE_UNHANDLED( |
| 67 handled = RenderViewFakeResourcesTest::OnMessageReceived(message)) | 67 handled = RenderViewFakeResourcesTest::OnMessageReceived(message)) |
| 68 IPC_END_MESSAGE_MAP() | 68 IPC_END_MESSAGE_MAP() |
| 69 return handled; | 69 return handled; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void OnDetectedPhishingSite(GURL phishing_url, double phishing_score) { | 72 void OnDetectedPhishingSite(GURL phishing_url, double phishing_score) { |
| 73 detected_phishing_site_ = true; | 73 detected_phishing_site_ = true; |
| 74 detected_url_ = phishing_url; | 74 detected_url_ = phishing_url; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 RunClassificationDone(delegate, true, 0.8); | 307 RunClassificationDone(delegate, true, 0.8); |
| 308 EXPECT_TRUE(detected_phishing_site_); | 308 EXPECT_TRUE(detected_phishing_site_); |
| 309 EXPECT_EQ(GURL("http://host.com/"), detected_url_); | 309 EXPECT_EQ(GURL("http://host.com/"), detected_url_); |
| 310 EXPECT_EQ(0.8, detected_score_); | 310 EXPECT_EQ(0.8, detected_score_); |
| 311 | 311 |
| 312 // The delegate will cancel pending classification on destruction. | 312 // The delegate will cancel pending classification on destruction. |
| 313 EXPECT_CALL(*classifier, CancelPendingClassification()); | 313 EXPECT_CALL(*classifier, CancelPendingClassification()); |
| 314 } | 314 } |
| 315 | 315 |
| 316 } // namespace safe_browsing | 316 } // namespace safe_browsing |
| OLD | NEW |