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 // 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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 MOCK_CONST_METHOD1(ComputeScore, double(const FeatureMap&)); | 54 MOCK_CONST_METHOD1(ComputeScore, double(const FeatureMap&)); |
55 | 55 |
56 private: | 56 private: |
57 DISALLOW_COPY_AND_ASSIGN(MockScorer); | 57 DISALLOW_COPY_AND_ASSIGN(MockScorer); |
58 }; | 58 }; |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 class PhishingClassifierDelegateTest | 61 class PhishingClassifierDelegateTest |
62 : public content::RenderViewFakeResourcesTest { | 62 : public content::RenderViewFakeResourcesTest { |
63 protected: | 63 protected: |
64 bool OnMessageReceived(const IPC::Message& message) { | 64 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
65 bool handled = true; | 65 bool handled = true; |
66 IPC_BEGIN_MESSAGE_MAP(PhishingClassifierDelegateTest, message) | 66 IPC_BEGIN_MESSAGE_MAP(PhishingClassifierDelegateTest, message) |
67 IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_PhishingDetectionDone, | 67 IPC_MESSAGE_HANDLER(SafeBrowsingHostMsg_PhishingDetectionDone, |
68 OnPhishingDetectionDone) | 68 OnPhishingDetectionDone) |
69 IPC_MESSAGE_UNHANDLED(handled = | 69 IPC_MESSAGE_UNHANDLED(handled = |
70 content::RenderViewFakeResourcesTest::OnMessageReceived(message)) | 70 content::RenderViewFakeResourcesTest::OnMessageReceived(message)) |
71 IPC_END_MESSAGE_MAP() | 71 IPC_END_MESSAGE_MAP() |
72 return handled; | 72 return handled; |
73 } | 73 } |
74 | 74 |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 verdict.set_is_phishing(false); // Send IPC even if site is not phishing. | 464 verdict.set_is_phishing(false); // Send IPC even if site is not phishing. |
465 RunClassificationDone(delegate, verdict); | 465 RunClassificationDone(delegate, verdict); |
466 ASSERT_TRUE(verdict_.get()); | 466 ASSERT_TRUE(verdict_.get()); |
467 EXPECT_EQ(verdict.SerializeAsString(), verdict_->SerializeAsString()); | 467 EXPECT_EQ(verdict.SerializeAsString(), verdict_->SerializeAsString()); |
468 | 468 |
469 // The delegate will cancel pending classification on destruction. | 469 // The delegate will cancel pending classification on destruction. |
470 EXPECT_CALL(*classifier, CancelPendingClassification()); | 470 EXPECT_CALL(*classifier, CancelPendingClassification()); |
471 } | 471 } |
472 | 472 |
473 } // namespace safe_browsing | 473 } // namespace safe_browsing |
OLD | NEW |