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 <stdint.h> | 7 #include <stdint.h> |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 scoped_refptr<content::MessageLoopRunner> runner_; | 273 scoped_refptr<content::MessageLoopRunner> runner_; |
274 }; | 274 }; |
275 | 275 |
276 IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, Navigation) { | 276 IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, Navigation) { |
277 MockScorer scorer; | 277 MockScorer scorer; |
278 delegate_->SetPhishingScorer(&scorer); | 278 delegate_->SetPhishingScorer(&scorer); |
279 ASSERT_TRUE(classifier_->is_ready()); | 279 ASSERT_TRUE(classifier_->is_ready()); |
280 | 280 |
281 // Test an initial load. We expect classification to happen normally. | 281 // Test an initial load. We expect classification to happen normally. |
282 EXPECT_CALL(*classifier_, CancelPendingClassification()).Times(2); | 282 EXPECT_CALL(*classifier_, CancelPendingClassification()).Times(2); |
283 std::string port = base::IntToString(embedded_test_server_->port()); | 283 std::string port = base::UintToString(embedded_test_server_->port()); |
284 std::string html = "<html><body><iframe src=\"http://sub1.com:"; | 284 std::string html = "<html><body><iframe src=\"http://sub1.com:"; |
285 html += port; | 285 html += port; |
286 html += "/\"></iframe></body></html>"; | 286 html += "/\"></iframe></body></html>"; |
287 GURL url = LoadHtml("host.com", html); | 287 GURL url = LoadHtml("host.com", html); |
288 Mock::VerifyAndClearExpectations(classifier_); | 288 Mock::VerifyAndClearExpectations(classifier_); |
289 OnStartPhishingDetection(url); | 289 OnStartPhishingDetection(url); |
290 base::string16 page_text = ASCIIToUTF16("dummy"); | 290 base::string16 page_text = ASCIIToUTF16("dummy"); |
291 { | 291 { |
292 InSequence s; | 292 InSequence s; |
293 EXPECT_CALL(*classifier_, CancelPendingClassification()); | 293 EXPECT_CALL(*classifier_, CancelPendingClassification()); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 PageCaptured(&page_text, false); | 538 PageCaptured(&page_text, false); |
539 Mock::VerifyAndClearExpectations(classifier_); | 539 Mock::VerifyAndClearExpectations(classifier_); |
540 EXPECT_CALL(*classifier_, CancelPendingClassification()); | 540 EXPECT_CALL(*classifier_, CancelPendingClassification()); |
541 | 541 |
542 ui_test_utils::NavigateToURL( | 542 ui_test_utils::NavigateToURL( |
543 browser(), GURL("javascript:location.replace(\'redir\');")); | 543 browser(), GURL("javascript:location.replace(\'redir\');")); |
544 | 544 |
545 Mock::VerifyAndClearExpectations(classifier_); | 545 Mock::VerifyAndClearExpectations(classifier_); |
546 | 546 |
547 std::string url_str = "http://host4.com:"; | 547 std::string url_str = "http://host4.com:"; |
548 url_str += base::IntToString(embedded_test_server_->port()); | 548 url_str += base::UintToString(embedded_test_server_->port()); |
549 url_str += "/redir"; | 549 url_str += "/redir"; |
550 OnStartPhishingDetection(GURL(url_str)); | 550 OnStartPhishingDetection(GURL(url_str)); |
551 page_text = ASCIIToUTF16("123"); | 551 page_text = ASCIIToUTF16("123"); |
552 { | 552 { |
553 InSequence s; | 553 InSequence s; |
554 EXPECT_CALL(*classifier_, CancelPendingClassification()); | 554 EXPECT_CALL(*classifier_, CancelPendingClassification()); |
555 EXPECT_CALL(*classifier_, BeginClassification(Pointee(page_text), _)); | 555 EXPECT_CALL(*classifier_, BeginClassification(Pointee(page_text), _)); |
556 PageCaptured(&page_text, false); | 556 PageCaptured(&page_text, false); |
557 Mock::VerifyAndClearExpectations(classifier_); | 557 Mock::VerifyAndClearExpectations(classifier_); |
558 } | 558 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 RunClassificationDone(verdict); | 666 RunClassificationDone(verdict); |
667 ASSERT_TRUE(intercepting_filter_->verdict()); | 667 ASSERT_TRUE(intercepting_filter_->verdict()); |
668 EXPECT_EQ(verdict.SerializeAsString(), | 668 EXPECT_EQ(verdict.SerializeAsString(), |
669 intercepting_filter_->verdict()->SerializeAsString()); | 669 intercepting_filter_->verdict()->SerializeAsString()); |
670 | 670 |
671 // The delegate will cancel pending classification on destruction. | 671 // The delegate will cancel pending classification on destruction. |
672 EXPECT_CALL(*classifier_, CancelPendingClassification()); | 672 EXPECT_CALL(*classifier_, CancelPendingClassification()); |
673 } | 673 } |
674 | 674 |
675 } // namespace safe_browsing | 675 } // namespace safe_browsing |
OLD | NEW |