Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: chrome/browser/safe_browsing/client_side_detection_host_unittest.cc

Issue 2083363002: Remove calls to deprecated MessageLoop methods in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser/safe_browsing/client_side_detection_host.h" 5 #include "chrome/browser/safe_browsing/client_side_detection_host.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 EXPECT_CALL(*csd_service_, 622 EXPECT_CALL(*csd_service_,
623 SendClientReportPhishingRequest( 623 SendClientReportPhishingRequest(
624 Pointee(PartiallyEqualVerdict(verdict)), _, _)) 624 Pointee(PartiallyEqualVerdict(verdict)), _, _))
625 .WillOnce(DoAll(DeleteArg<0>(), 625 .WillOnce(DoAll(DeleteArg<0>(),
626 SaveArg<2>(&cb_other), 626 SaveArg<2>(&cb_other),
627 QuitUIMessageLoop())); 627 QuitUIMessageLoop()));
628 std::vector<GURL> redirect_chain; 628 std::vector<GURL> redirect_chain;
629 redirect_chain.push_back(other_phishing_url); 629 redirect_chain.push_back(other_phishing_url);
630 SetRedirectChain(redirect_chain); 630 SetRedirectChain(redirect_chain);
631 OnPhishingDetectionDone(verdict.SerializeAsString()); 631 OnPhishingDetectionDone(verdict.SerializeAsString());
632 base::MessageLoop::current()->Run(); 632 base::RunLoop().Run();
633 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get())); 633 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
634 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); 634 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get()));
635 ASSERT_FALSE(cb_other.is_null()); 635 ASSERT_FALSE(cb_other.is_null());
636 636
637 // We expect that the interstitial is shown for the second phishing URL and 637 // We expect that the interstitial is shown for the second phishing URL and
638 // not for the first phishing URL. 638 // not for the first phishing URL.
639 UnsafeResource resource; 639 UnsafeResource resource;
640 EXPECT_CALL(*ui_manager_.get(), DisplayBlockingPage(_)) 640 EXPECT_CALL(*ui_manager_.get(), DisplayBlockingPage(_))
641 .WillOnce(SaveArg<0>(&resource)); 641 .WillOnce(SaveArg<0>(&resource));
642 642
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 SetUnsafeSubResourceForCurrent(true /* expect_unsafe_resource */); 699 SetUnsafeSubResourceForCurrent(true /* expect_unsafe_resource */);
700 700
701 EXPECT_CALL(*csd_service_, 701 EXPECT_CALL(*csd_service_,
702 SendClientReportPhishingRequest( 702 SendClientReportPhishingRequest(
703 Pointee(PartiallyEqualVerdict(verdict)), _, CallbackIsNull())) 703 Pointee(PartiallyEqualVerdict(verdict)), _, CallbackIsNull()))
704 .WillOnce(DoAll(DeleteArg<0>(), QuitUIMessageLoop())); 704 .WillOnce(DoAll(DeleteArg<0>(), QuitUIMessageLoop()));
705 std::vector<GURL> redirect_chain; 705 std::vector<GURL> redirect_chain;
706 redirect_chain.push_back(url); 706 redirect_chain.push_back(url);
707 SetRedirectChain(redirect_chain); 707 SetRedirectChain(redirect_chain);
708 OnPhishingDetectionDone(verdict.SerializeAsString()); 708 OnPhishingDetectionDone(verdict.SerializeAsString());
709 base::MessageLoop::current()->Run(); 709 base::RunLoop().Run();
710 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get())); 710 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
711 } 711 }
712 712
713 TEST_F(ClientSideDetectionHostTest, 713 TEST_F(ClientSideDetectionHostTest,
714 OnPhishingDetectionDoneVerdictNotPhishingButSBMatchOnNewRVH) { 714 OnPhishingDetectionDoneVerdictNotPhishingButSBMatchOnNewRVH) {
715 // When navigating to a different host (thus creating a pending RVH) which 715 // When navigating to a different host (thus creating a pending RVH) which
716 // matches regular malware list, and after navigation the renderer sends a 716 // matches regular malware list, and after navigation the renderer sends a
717 // verdict string that isn't phishing, we should still send the report. 717 // verdict string that isn't phishing, we should still send the report.
718 718
719 // Do an initial navigation to a safe host. 719 // Do an initial navigation to a safe host.
(...skipping 18 matching lines...) Expand all
738 WaitAndCheckPreClassificationChecks(); 738 WaitAndCheckPreClassificationChecks();
739 739
740 EXPECT_CALL(*csd_service_, 740 EXPECT_CALL(*csd_service_,
741 SendClientReportPhishingRequest( 741 SendClientReportPhishingRequest(
742 Pointee(PartiallyEqualVerdict(verdict)), _, CallbackIsNull())) 742 Pointee(PartiallyEqualVerdict(verdict)), _, CallbackIsNull()))
743 .WillOnce(DoAll(DeleteArg<0>(), QuitUIMessageLoop())); 743 .WillOnce(DoAll(DeleteArg<0>(), QuitUIMessageLoop()));
744 std::vector<GURL> redirect_chain; 744 std::vector<GURL> redirect_chain;
745 redirect_chain.push_back(url); 745 redirect_chain.push_back(url);
746 SetRedirectChain(redirect_chain); 746 SetRedirectChain(redirect_chain);
747 OnPhishingDetectionDone(verdict.SerializeAsString()); 747 OnPhishingDetectionDone(verdict.SerializeAsString());
748 base::MessageLoop::current()->Run(); 748 base::RunLoop().Run();
749 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get())); 749 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
750 750
751 ExpectPreClassificationChecks(start_url, &kFalse, &kFalse, &kFalse, &kFalse, 751 ExpectPreClassificationChecks(start_url, &kFalse, &kFalse, &kFalse, &kFalse,
752 &kFalse, &kFalse, &kFalse, &kFalse); 752 &kFalse, &kFalse, &kFalse, &kFalse);
753 NavigateWithoutSBHitAndCommit(start_url); 753 NavigateWithoutSBHitAndCommit(start_url);
754 WaitAndCheckPreClassificationChecks(); 754 WaitAndCheckPreClassificationChecks();
755 } 755 }
756 756
757 TEST_F( 757 TEST_F(
758 ClientSideDetectionHostTest, 758 ClientSideDetectionHostTest,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 // should apply to the committed navigation, so we should get a report even 792 // should apply to the committed navigation, so we should get a report even
793 // though the verdict has is_phishing = false. 793 // though the verdict has is_phishing = false.
794 EXPECT_CALL(*csd_service_, 794 EXPECT_CALL(*csd_service_,
795 SendClientReportPhishingRequest( 795 SendClientReportPhishingRequest(
796 Pointee(PartiallyEqualVerdict(verdict)), _, CallbackIsNull())) 796 Pointee(PartiallyEqualVerdict(verdict)), _, CallbackIsNull()))
797 .WillOnce(DoAll(DeleteArg<0>(), QuitUIMessageLoop())); 797 .WillOnce(DoAll(DeleteArg<0>(), QuitUIMessageLoop()));
798 std::vector<GURL> redirect_chain; 798 std::vector<GURL> redirect_chain;
799 redirect_chain.push_back(url); 799 redirect_chain.push_back(url);
800 SetRedirectChain(redirect_chain); 800 SetRedirectChain(redirect_chain);
801 OnPhishingDetectionDone(verdict.SerializeAsString()); 801 OnPhishingDetectionDone(verdict.SerializeAsString());
802 base::MessageLoop::current()->Run(); 802 base::RunLoop().Run();
803 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get())); 803 EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
804 } 804 }
805 805
806 TEST_F(ClientSideDetectionHostTest, SafeBrowsingHitOnFreshTab) { 806 TEST_F(ClientSideDetectionHostTest, SafeBrowsingHitOnFreshTab) {
807 // A fresh WebContents should not have any NavigationEntries yet. (See 807 // A fresh WebContents should not have any NavigationEntries yet. (See
808 // https://crbug.com/524208.) 808 // https://crbug.com/524208.)
809 EXPECT_EQ(nullptr, controller().GetLastCommittedEntry()); 809 EXPECT_EQ(nullptr, controller().GetLastCommittedEntry());
810 EXPECT_EQ(nullptr, controller().GetPendingEntry()); 810 EXPECT_EQ(nullptr, controller().GetPendingEntry());
811 811
812 // Simulate a subresource malware hit (this could happen if the WebContents 812 // Simulate a subresource malware hit (this could happen if the WebContents
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 EXPECT_EQ(url, resource.url); 1199 EXPECT_EQ(url, resource.url);
1200 EXPECT_EQ(url, resource.original_url); 1200 EXPECT_EQ(url, resource.original_url);
1201 1201
1202 ExpectStartPhishingDetection(NULL); 1202 ExpectStartPhishingDetection(NULL);
1203 1203
1204 // Showing a phishing warning will invalidate all the weak pointers which 1204 // Showing a phishing warning will invalidate all the weak pointers which
1205 // means we will not extract malware features. 1205 // means we will not extract malware features.
1206 ExpectShouldClassifyForMalwareResult(false); 1206 ExpectShouldClassifyForMalwareResult(false);
1207 } 1207 }
1208 } // namespace safe_browsing 1208 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698