| 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 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 5 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/common/safe_browsing/csd.pb.h" | 10 #include "chrome/common/safe_browsing/csd.pb.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 // Return true anyway, since we don't want to block other IPC. | 75 // Return true anyway, since we don't want to block other IPC. |
| 76 return true; | 76 return true; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void VerifyMessageContent(const std::string& verdict_str) { | 79 void VerifyMessageContent(const std::string& verdict_str) { |
| 80 ClientPhishingRequest verdict; | 80 ClientPhishingRequest verdict; |
| 81 if (verdict.ParseFromString(verdict_str)) { | 81 if (verdict.ParseFromString(verdict_str)) { |
| 82 EXPECT_EQ("http://host.com/", verdict.url()); | 82 EXPECT_EQ("http://host.com/", verdict.url()); |
| 83 EXPECT_EQ(0.8f, verdict.client_score()); | 83 EXPECT_EQ(0.8f, verdict.client_score()); |
| 84 EXPECT_EQ(false, verdict.is_phishing()); | 84 EXPECT_FALSE(verdict.is_phishing()); |
| 85 } else { | 85 } else { |
| 86 NOTREACHED() << "Cannot parse IPC content. Test failed."; | 86 NOTREACHED() << "Cannot parse IPC content. Test failed."; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 class PhishingClassifierDelegateTest : public ChromeRenderViewTest { | 91 class PhishingClassifierDelegateTest : public ChromeRenderViewTest { |
| 92 protected: | 92 protected: |
| 93 void SetUp() override { | 93 void SetUp() override { |
| 94 ChromeUnitTestSuite::InitializeProviders(); | 94 ChromeUnitTestSuite::InitializeProviders(); |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 verdict.set_url(url.spec()); | 496 verdict.set_url(url.spec()); |
| 497 verdict.set_client_score(0.8f); | 497 verdict.set_client_score(0.8f); |
| 498 verdict.set_is_phishing(false); // Send IPC even if site is not phishing. | 498 verdict.set_is_phishing(false); // Send IPC even if site is not phishing. |
| 499 RunAndVerifyClassificationDone(verdict); | 499 RunAndVerifyClassificationDone(verdict); |
| 500 | 500 |
| 501 // The delegate will cancel pending classification on destruction. | 501 // The delegate will cancel pending classification on destruction. |
| 502 EXPECT_CALL(*classifier_, CancelPendingClassification()); | 502 EXPECT_CALL(*classifier_, CancelPendingClassification()); |
| 503 } | 503 } |
| 504 | 504 |
| 505 } // namespace safe_browsing | 505 } // namespace safe_browsing |
| OLD | NEW |