| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 EXPECT_EQ(0U, features.features().size()); | 186 EXPECT_EQ(0U, features.features().size()); |
| 187 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); | 187 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); |
| 188 | 188 |
| 189 // Extraction should fail for this case because the URL is a POST request. | 189 // Extraction should fail for this case because the URL is a POST request. |
| 190 LoadURLWithPost("http://host.net/"); | 190 LoadURLWithPost("http://host.net/"); |
| 191 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); | 191 EXPECT_FALSE(RunPhishingClassifier(&page_text, &phishy_score, &features)); |
| 192 EXPECT_EQ(0U, features.features().size()); | 192 EXPECT_EQ(0U, features.features().size()); |
| 193 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); | 193 EXPECT_EQ(PhishingClassifier::kInvalidScore, phishy_score); |
| 194 } | 194 } |
| 195 | 195 |
| 196 TEST_F(PhishingClassifierTest, DisableDetection) { |
| 197 // No scorer yet, so the classifier is not ready. |
| 198 EXPECT_FALSE(classifier_->is_ready()); |
| 199 |
| 200 // Now set the scorer. |
| 201 classifier_->set_phishing_scorer(scorer_.get()); |
| 202 EXPECT_TRUE(classifier_->is_ready()); |
| 203 |
| 204 // Set a NULL scorer, which turns detection back off. |
| 205 classifier_->set_phishing_scorer(NULL); |
| 206 EXPECT_FALSE(classifier_->is_ready()); |
| 207 } |
| 208 |
| 196 } // namespace safe_browsing | 209 } // namespace safe_browsing |
| OLD | NEW |