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

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

Issue 1420053005: Move code in components/safe_browsing_db and chrome/browser/s_b/ under the safe_browsing namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_components_move
Patch Set: Other minor fixes incl. using "using safe_browsing::ClassName" instead of safe_browsing::ClassName everywhere. Created 5 years, 1 month 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 // This test creates a fake safebrowsing service, where we can inject known- 5 // This test creates a fake safebrowsing service, where we can inject known-
6 // threat urls. It then uses a real browser to go to these urls, and sends 6 // threat urls. It then uses a real browser to go to these urls, and sends
7 // "goback" or "proceed" commands and verifies they work. 7 // "goback" or "proceed" commands and verifies they work.
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/public/test/test_browser_thread.h" 45 #include "content/public/test/test_browser_thread.h"
46 #include "content/public/test/test_utils.h" 46 #include "content/public/test/test_utils.h"
47 #include "net/test/url_request/url_request_mock_http_job.h" 47 #include "net/test/url_request/url_request_mock_http_job.h"
48 48
49 using chrome_browser_interstitials::SecurityInterstitialIDNTest; 49 using chrome_browser_interstitials::SecurityInterstitialIDNTest;
50 using content::BrowserThread; 50 using content::BrowserThread;
51 using content::InterstitialPage; 51 using content::InterstitialPage;
52 using content::NavigationController; 52 using content::NavigationController;
53 using content::WebContents; 53 using content::WebContents;
54 54
55 namespace { 55 namespace safe_browsing {
56 56
57 const char kEmptyPage[] = "empty.html"; 57 const char kEmptyPage[] = "empty.html";
58 const char kMalwarePage[] = "safe_browsing/malware.html"; 58 const char kMalwarePage[] = "safe_browsing/malware.html";
59 const char kMalwareIframe[] = "safe_browsing/malware_iframe.html"; 59 const char kMalwareIframe[] = "safe_browsing/malware_iframe.html";
60 const char kUnrelatedUrl[] = "https://www.google.com"; 60 const char kUnrelatedUrl[] = "https://www.google.com";
61 61
62 // A SafeBrowsingDatabaseManager class that allows us to inject the malicious 62 // A SafeBrowsingDatabaseManager class that allows us to inject the malicious
63 // URLs. 63 // URLs.
64 class FakeSafeBrowsingDatabaseManager : public TestSafeBrowsingDatabaseManager { 64 class FakeSafeBrowsingDatabaseManager : public TestSafeBrowsingDatabaseManager {
65 public: 65 public:
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 SafeBrowsingBlockingPage* CreateSafeBrowsingPage( 347 SafeBrowsingBlockingPage* CreateSafeBrowsingPage(
348 SafeBrowsingUIManager* delegate, 348 SafeBrowsingUIManager* delegate,
349 WebContents* web_contents, 349 WebContents* web_contents,
350 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) 350 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources)
351 override { 351 override {
352 return new TestSafeBrowsingBlockingPage(delegate, web_contents, 352 return new TestSafeBrowsingBlockingPage(delegate, web_contents,
353 unsafe_resources); 353 unsafe_resources);
354 } 354 }
355 }; 355 };
356 356
357 } // namespace
mattm 2015/11/11 01:10:16 Keep the anon namespace inside the new namespace.
vakh (old account. dont use) 2015/11/11 18:59:53 Done.
358
359 // Tests the safe browsing blocking page in a browser. 357 // Tests the safe browsing blocking page in a browser.
360 class SafeBrowsingBlockingPageBrowserTest 358 class SafeBrowsingBlockingPageBrowserTest
361 : public InProcessBrowserTest, 359 : public InProcessBrowserTest,
362 public testing::WithParamInterface<SBThreatType> { 360 public testing::WithParamInterface<SBThreatType> {
363 public: 361 public:
364 enum Visibility { 362 enum Visibility {
365 VISIBILITY_ERROR = -1, 363 VISIBILITY_ERROR = -1,
366 HIDDEN = 0, 364 HIDDEN = 0,
367 VISIBLE = 1 365 VISIBLE = 1
368 }; 366 };
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 AssertNoInterstitial(true); // Assert the interstitial is gone 735 AssertNoInterstitial(true); // Assert the interstitial is gone
738 736
739 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( 737 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
740 prefs::kSafeBrowsingExtendedReportingEnabled)); 738 prefs::kSafeBrowsingExtendedReportingEnabled));
741 EXPECT_EQ(url, 739 EXPECT_EQ(url,
742 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 740 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
743 741
744 if (expect_malware_details) { 742 if (expect_malware_details) {
745 malware_report_sent_runner->Run(); 743 malware_report_sent_runner->Run();
746 std::string serialized = GetReportSent(); 744 std::string serialized = GetReportSent();
747 safe_browsing::ClientMalwareReportRequest report; 745 ClientMalwareReportRequest report;
748 ASSERT_TRUE(report.ParseFromString(serialized)); 746 ASSERT_TRUE(report.ParseFromString(serialized));
749 // Verify the report is complete. 747 // Verify the report is complete.
750 EXPECT_TRUE(report.complete()); 748 EXPECT_TRUE(report.complete());
751 } 749 }
752 } 750 }
753 751
754 // Verifies that the "proceed anyway" link isn't available when it is disabled 752 // Verifies that the "proceed anyway" link isn't available when it is disabled
755 // by the corresponding policy. Also verifies that sending the "proceed" 753 // by the corresponding policy. Also verifies that sending the "proceed"
756 // command anyway doesn't advance to the unsafe site. 754 // command anyway doesn't advance to the unsafe site.
757 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, ProceedDisabled) { 755 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, ProceedDisabled) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest, 1014 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest,
1017 SafeBrowsingBlockingPageDecodesIDN) { 1015 SafeBrowsingBlockingPageDecodesIDN) {
1018 EXPECT_TRUE(VerifyIDNDecoded()); 1016 EXPECT_TRUE(VerifyIDNDecoded());
1019 } 1017 }
1020 1018
1021 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageIDNTestWithThreatType, 1019 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageIDNTestWithThreatType,
1022 SafeBrowsingBlockingPageIDNTest, 1020 SafeBrowsingBlockingPageIDNTest,
1023 testing::Values(SB_THREAT_TYPE_URL_MALWARE, 1021 testing::Values(SB_THREAT_TYPE_URL_MALWARE,
1024 SB_THREAT_TYPE_URL_PHISHING, 1022 SB_THREAT_TYPE_URL_PHISHING,
1025 SB_THREAT_TYPE_URL_UNWANTED)); 1023 SB_THREAT_TYPE_URL_UNWANTED));
1024
1025 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698