| 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 that although this is not a "browser" test, it runs as part of | 5 // Note that although this is not a "browser" test, it runs as part of |
| 6 // browser_tests. This is because WebKit does not work properly if it is | 6 // browser_tests. This is because WebKit does not work properly if it is |
| 7 // shutdown and re-initialized. Since browser_tests runs each test in a | 7 // shutdown and re-initialized. Since browser_tests runs each test in a |
| 8 // new process, this avoids the problem. | 8 // new process, this avoids the problem. |
| 9 | 9 |
| 10 #include "chrome/renderer/safe_browsing/phishing_classifier.h" | 10 #include "chrome/renderer/safe_browsing/phishing_classifier.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // Features that are in the model. | 125 // Features that are in the model. |
| 126 const std::string url_tld_token_net_; | 126 const std::string url_tld_token_net_; |
| 127 const std::string page_link_domain_phishing_; | 127 const std::string page_link_domain_phishing_; |
| 128 const std::string page_term_login_; | 128 const std::string page_term_login_; |
| 129 | 129 |
| 130 // This member holds the status from the most recent call to the | 130 // This member holds the status from the most recent call to the |
| 131 // ClassificationFinished callback. | 131 // ClassificationFinished callback. |
| 132 ClientPhishingRequest verdict_; | 132 ClientPhishingRequest verdict_; |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 TEST_F(PhishingClassifierTest, TestClassification) { | 135 TEST_F(PhishingClassifierTest, DISABLED_TestClassification) { |
| 136 // No scorer yet, so the classifier is not ready. | 136 // No scorer yet, so the classifier is not ready. |
| 137 EXPECT_FALSE(classifier_->is_ready()); | 137 EXPECT_FALSE(classifier_->is_ready()); |
| 138 | 138 |
| 139 // Now set the scorer. | 139 // Now set the scorer. |
| 140 classifier_->set_phishing_scorer(scorer_.get()); | 140 classifier_->set_phishing_scorer(scorer_.get()); |
| 141 EXPECT_TRUE(classifier_->is_ready()); | 141 EXPECT_TRUE(classifier_->is_ready()); |
| 142 | 142 |
| 143 // This test doesn't exercise the extraction timing. | 143 // This test doesn't exercise the extraction timing. |
| 144 EXPECT_CALL(*clock_, Now()) | 144 EXPECT_CALL(*clock_, Now()) |
| 145 .WillRepeatedly(::testing::Return(base::TimeTicks::Now())); | 145 .WillRepeatedly(::testing::Return(base::TimeTicks::Now())); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 EXPECT_EQ(0U, features.features().size()); | 188 EXPECT_EQ(0U, features.features().size()); |
| 189 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); | 189 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); |
| 190 | 190 |
| 191 // Extraction should fail for this case because the URL is a POST request. | 191 // Extraction should fail for this case because the URL is a POST request. |
| 192 LoadURLWithPost("http://host.net/"); | 192 LoadURLWithPost("http://host.net/"); |
| 193 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); | 193 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); |
| 194 EXPECT_EQ(0U, features.features().size()); | 194 EXPECT_EQ(0U, features.features().size()); |
| 195 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); | 195 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); |
| 196 } | 196 } |
| 197 | 197 |
| 198 TEST_F(PhishingClassifierTest, DisableDetection) { | 198 TEST_F(PhishingClassifierTest, DISABLED_DisableDetection) { |
| 199 // No scorer yet, so the classifier is not ready. | 199 // No scorer yet, so the classifier is not ready. |
| 200 EXPECT_FALSE(classifier_->is_ready()); | 200 EXPECT_FALSE(classifier_->is_ready()); |
| 201 | 201 |
| 202 // Now set the scorer. | 202 // Now set the scorer. |
| 203 classifier_->set_phishing_scorer(scorer_.get()); | 203 classifier_->set_phishing_scorer(scorer_.get()); |
| 204 EXPECT_TRUE(classifier_->is_ready()); | 204 EXPECT_TRUE(classifier_->is_ready()); |
| 205 | 205 |
| 206 // Set a NULL scorer, which turns detection back off. | 206 // Set a NULL scorer, which turns detection back off. |
| 207 classifier_->set_phishing_scorer(NULL); | 207 classifier_->set_phishing_scorer(NULL); |
| 208 EXPECT_FALSE(classifier_->is_ready()); | 208 EXPECT_FALSE(classifier_->is_ready()); |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace safe_browsing | 211 } // namespace safe_browsing |
| OLD | NEW |