chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
TEST_F(SafeBrowsingBlockingPageTest, MalwareReportsToggling) {
  // Disable malware reports.
  Profile* profile = Profile::FromBrowserContext(
      web_contents()->GetBrowserContext());
  profile->GetPrefs()->SetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled, false);

  // Start a load.
  controller().LoadURL(GURL(kBadURL), content::Referrer(),
                       content::PAGE_TRANSITION_TYPED, std::string());

  // Simulate the load causing a safe browsing interstitial to be shown.
  ShowInterstitial(false, kBadURL);
  SafeBrowsingBlockingPage* sb_interstitial =
      GetSafeBrowsingBlockingPage();
  ASSERT_TRUE(sb_interstitial);

  base::RunLoop().RunUntilIdle();

  EXPECT_FALSE(profile->GetPrefs()->GetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled));

  // Simulate the user check the report agreement checkbox.
  sb_interstitial->SetReportingPreference(true);

  EXPECT_TRUE(profile->GetPrefs()->GetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled));

  // Simulate the user uncheck the report agreement checkbox.
  sb_interstitial->SetReportingPreference(false);

  EXPECT_FALSE(profile->GetPrefs()->GetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled));
}
// Test that toggling the checkbox has the anticipated effects.
Test that toggling the checkbox has the anticipated effects.
Test that toggling the checkbox has the anticipated effects .
TEST_F(SafeBrowsingBlockingPageTest, MalwareReportsToggling) {
  Profile* profile = Profile::FromBrowserContext(
      web_contents()->GetBrowserContext());
  profile->GetPrefs()->SetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled, false);
  controller().LoadURL(GURL(kBadURL), content::Referrer(),
                       content::PAGE_TRANSITION_TYPED, std::string());
  ShowInterstitial(false, kBadURL);
  SafeBrowsingBlockingPage* sb_interstitial =
      GetSafeBrowsingBlockingPage();
  ASSERT_TRUE(sb_interstitial);
  base::RunLoop().RunUntilIdle();
  EXPECT_FALSE(profile->GetPrefs()->GetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled));
  sb_interstitial->SetReportingPreference(true);
  EXPECT_TRUE(profile->GetPrefs()->GetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled));
  sb_interstitial->SetReportingPreference(false);
  EXPECT_FALSE(profile->GetPrefs()->GetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled));
}
TEST_F ( SafeBrowsingBlockingPageTest , MalwareReportsToggling ) { Profile * profile = Profile :: FromBrowserContext ( web_contents ( ) -> GetBrowserContext ( ) ) ; profile -> GetPrefs ( ) -> SetBoolean ( prefs :: kSafeBrowsingExtendedReportingEnabled , false ) ; controller ( ) . LoadURL ( GURL ( kBadURL ) , content :: Referrer ( ) , content :: PAGE_TRANSITION_TYPED , std :: string ( ) ) ; ShowInterstitial ( false , kBadURL ) ; SafeBrowsingBlockingPage * sb_interstitial = GetSafeBrowsingBlockingPage ( ) ; ASSERT_TRUE ( sb_interstitial ) ; base :: RunLoop ( ) . RunUntilIdle ( ) ; EXPECT_FALSE ( profile -> GetPrefs ( ) -> GetBoolean ( prefs :: kSafeBrowsingExtendedReportingEnabled ) ) ; sb_interstitial -> SetReportingPreference ( true ) ; EXPECT_TRUE ( profile -> GetPrefs ( ) -> GetBoolean ( prefs :: kSafeBrowsingExtendedReportingEnabled ) ) ; sb_interstitial -> SetReportingPreference ( false ) ; EXPECT_FALSE ( profile -> GetPrefs ( ) -> GetBoolean ( prefs :: kSafeBrowsingExtendedReportingEnabled ) ) ; }
Test that toggling the checkbox has the anticipated effects.
Test that toggling the checkbox has the anticipated effects .
// Disable malware reports. // Start a load. // Simulate the load causing a safe browsing interstitial to be shown. // Simulate the user check the report agreement checkbox. // Simulate the user uncheck the report agreement checkbox.