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

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

Issue 2556433003: Support optional performance measuring in SubresourceFilter. (Closed)
Patch Set: Link TODO to a bug. Created 4 years 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
« no previous file with comments | « no previous file | components/subresource_filter/content/browser/content_subresource_filter_driver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This test creates a safebrowsing service using test safebrowsing database 5 // This test creates a safebrowsing service using test safebrowsing database
6 // and a test protocol manager. It is used to test logics in safebrowsing 6 // and a test protocol manager. It is used to test logics in safebrowsing
7 // service. 7 // service.
8 8
9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
10 10
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 class MockSubresourceFilterDriver 106 class MockSubresourceFilterDriver
107 : public subresource_filter::ContentSubresourceFilterDriver { 107 : public subresource_filter::ContentSubresourceFilterDriver {
108 public: 108 public:
109 explicit MockSubresourceFilterDriver( 109 explicit MockSubresourceFilterDriver(
110 content::RenderFrameHost* render_frame_host) 110 content::RenderFrameHost* render_frame_host)
111 : subresource_filter::ContentSubresourceFilterDriver(render_frame_host) {} 111 : subresource_filter::ContentSubresourceFilterDriver(render_frame_host) {}
112 112
113 ~MockSubresourceFilterDriver() override = default; 113 ~MockSubresourceFilterDriver() override = default;
114 114
115 MOCK_METHOD2(ActivateForProvisionalLoad, 115 MOCK_METHOD3(ActivateForProvisionalLoad,
116 void(subresource_filter::ActivationState, const GURL&)); 116 void(subresource_filter::ActivationState, const GURL&, bool));
117 117
118 private: 118 private:
119 DISALLOW_COPY_AND_ASSIGN(MockSubresourceFilterDriver); 119 DISALLOW_COPY_AND_ASSIGN(MockSubresourceFilterDriver);
120 }; 120 };
121 121
122 class NeverCompletingHttpResponse : public net::test_server::HttpResponse { 122 class NeverCompletingHttpResponse : public net::test_server::HttpResponse {
123 public: 123 public:
124 ~NeverCompletingHttpResponse() override {} 124 ~NeverCompletingHttpResponse() override {}
125 125
126 void SendResponse( 126 void SendResponse(
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 PHISH, 951 PHISH,
952 ThreatPatternType::SOCIAL_ENGINEERING_ADS, 952 ThreatPatternType::SOCIAL_ENGINEERING_ADS,
953 &malware_full_hash); 953 &malware_full_hash);
954 SetupResponseForUrl(bad_url, malware_full_hash); 954 SetupResponseForUrl(bad_url, malware_full_hash);
955 955
956 WebContents* main_contents = 956 WebContents* main_contents =
957 browser()->tab_strip_model()->GetActiveWebContents(); 957 browser()->tab_strip_model()->GetActiveWebContents();
958 958
959 EXPECT_CALL(observer_, OnSafeBrowsingHit(IsUnsafeResourceFor(bad_url))) 959 EXPECT_CALL(observer_, OnSafeBrowsingHit(IsUnsafeResourceFor(bad_url)))
960 .Times(1); 960 .Times(1);
961 EXPECT_CALL(*driver(), ActivateForProvisionalLoad(::testing::_, ::testing::_)) 961 EXPECT_CALL(*driver(), ActivateForProvisionalLoad(::testing::_, ::testing::_,
962 ::testing::_))
962 .Times(0); 963 .Times(0);
963 ui_test_utils::NavigateToURL(browser(), bad_url); 964 ui_test_utils::NavigateToURL(browser(), bad_url);
964 Mock::VerifyAndClearExpectations(&observer_); 965 Mock::VerifyAndClearExpectations(&observer_);
965 ASSERT_TRUE(got_hit_report()); 966 ASSERT_TRUE(got_hit_report());
966 967
967 content::WaitForInterstitialAttach(main_contents); 968 content::WaitForInterstitialAttach(main_contents);
968 EXPECT_TRUE(ShowingInterstitialPage()); 969 EXPECT_TRUE(ShowingInterstitialPage());
969 testing::Mock::VerifyAndClearExpectations(driver()); 970 testing::Mock::VerifyAndClearExpectations(driver());
970 EXPECT_CALL(*driver(), ActivateForProvisionalLoad(::testing::_, ::testing::_)) 971 EXPECT_CALL(*driver(), ActivateForProvisionalLoad(::testing::_, ::testing::_,
972 ::testing::_))
971 .Times(1); 973 .Times(1);
972 InterstitialPage* interstitial_page = main_contents->GetInterstitialPage(); 974 InterstitialPage* interstitial_page = main_contents->GetInterstitialPage();
973 ASSERT_TRUE(interstitial_page); 975 ASSERT_TRUE(interstitial_page);
974 interstitial_page->Proceed(); 976 interstitial_page->Proceed();
975 content::WaitForInterstitialDetach(main_contents); 977 content::WaitForInterstitialDetach(main_contents);
976 EXPECT_FALSE(ShowingInterstitialPage()); 978 EXPECT_FALSE(ShowingInterstitialPage());
977 testing::Mock::VerifyAndClearExpectations(driver()); 979 testing::Mock::VerifyAndClearExpectations(driver());
978 } 980 }
979 981
980 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, SocEngReportingBlacklistEmpty) { 982 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, SocEngReportingBlacklistEmpty) {
(...skipping 10 matching lines...) Expand all
991 993
992 SBFullHashResult malware_full_hash; 994 SBFullHashResult malware_full_hash;
993 GenUrlFullHashResult(bad_url, MALWARE, &malware_full_hash); 995 GenUrlFullHashResult(bad_url, MALWARE, &malware_full_hash);
994 SetupResponseForUrl(bad_url, malware_full_hash); 996 SetupResponseForUrl(bad_url, malware_full_hash);
995 997
996 WebContents* main_contents = 998 WebContents* main_contents =
997 browser()->tab_strip_model()->GetActiveWebContents(); 999 browser()->tab_strip_model()->GetActiveWebContents();
998 1000
999 EXPECT_CALL(observer_, OnSafeBrowsingHit(IsUnsafeResourceFor(bad_url))) 1001 EXPECT_CALL(observer_, OnSafeBrowsingHit(IsUnsafeResourceFor(bad_url)))
1000 .Times(1); 1002 .Times(1);
1001 EXPECT_CALL(*driver(), ActivateForProvisionalLoad(::testing::_, ::testing::_)) 1003 EXPECT_CALL(*driver(), ActivateForProvisionalLoad(::testing::_, ::testing::_,
1004 ::testing::_))
1002 .Times(0); 1005 .Times(0);
1003 ui_test_utils::NavigateToURL(browser(), bad_url); 1006 ui_test_utils::NavigateToURL(browser(), bad_url);
1004 testing::Mock::VerifyAndClearExpectations(driver()); 1007 testing::Mock::VerifyAndClearExpectations(driver());
1005 ASSERT_TRUE(got_hit_report()); 1008 ASSERT_TRUE(got_hit_report());
1006 1009
1007 content::WaitForInterstitialAttach(main_contents); 1010 content::WaitForInterstitialAttach(main_contents);
1008 EXPECT_TRUE(ShowingInterstitialPage()); 1011 EXPECT_TRUE(ShowingInterstitialPage());
1009 testing::Mock::VerifyAndClearExpectations(driver()); 1012 testing::Mock::VerifyAndClearExpectations(driver());
1010 EXPECT_CALL(*driver(), ActivateForProvisionalLoad(::testing::_, ::testing::_)) 1013 EXPECT_CALL(*driver(), ActivateForProvisionalLoad(::testing::_, ::testing::_,
1014 ::testing::_))
1011 .Times(0); 1015 .Times(0);
1012 InterstitialPage* interstitial_page = main_contents->GetInterstitialPage(); 1016 InterstitialPage* interstitial_page = main_contents->GetInterstitialPage();
1013 ASSERT_TRUE(interstitial_page); 1017 ASSERT_TRUE(interstitial_page);
1014 interstitial_page->Proceed(); 1018 interstitial_page->Proceed();
1015 content::WaitForInterstitialDetach(main_contents); 1019 content::WaitForInterstitialDetach(main_contents);
1016 EXPECT_FALSE(ShowingInterstitialPage()); 1020 EXPECT_FALSE(ShowingInterstitialPage());
1017 testing::Mock::VerifyAndClearExpectations(driver()); 1021 testing::Mock::VerifyAndClearExpectations(driver());
1018 } 1022 }
1019 1023
1020 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, 1024 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest,
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 content::Source<SafeBrowsingDatabaseManager>( 1828 content::Source<SafeBrowsingDatabaseManager>(
1825 sb_factory_->test_safe_browsing_service()->database_manager().get())); 1829 sb_factory_->test_safe_browsing_service()->database_manager().get()));
1826 BrowserThread::PostTask( 1830 BrowserThread::PostTask(
1827 BrowserThread::IO, FROM_HERE, 1831 BrowserThread::IO, FROM_HERE,
1828 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, 1832 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate,
1829 base::Unretained(this))); 1833 base::Unretained(this)));
1830 observer.Wait(); 1834 observer.Wait();
1831 } 1835 }
1832 1836
1833 } // namespace safe_browsing 1837 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | components/subresource_filter/content/browser/content_subresource_filter_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698