chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc
TEST_F(SafeBrowsingBlockingPageTest, MalwareReportsTransitionEnabled) {
  // The old pref is enabled.
  Profile* profile = Profile::FromBrowserContext(
      web_contents()->GetBrowserContext());
  profile->GetPrefs()->SetBoolean(prefs::kSafeBrowsingReportingEnabled, true);

  // 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();

  // At this point, nothing should have changed yet.
  EXPECT_FALSE(profile->GetPrefs()->GetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled));

  ProceedThroughInterstitial(sb_interstitial);

  // Since the user has proceeded without changing the checkbox, the new pref
  // has been updated.
  EXPECT_TRUE(profile->GetPrefs()->GetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled));
}
// Test that the transition from old to new preference works.
Test that the transition from old to new preference works.
Test that the transition from old to new preference works .
TEST_F(SafeBrowsingBlockingPageTest, MalwareReportsTransitionEnabled) {
  Profile* profile = Profile::FromBrowserContext(
      web_contents()->GetBrowserContext());
  profile->GetPrefs()->SetBoolean(prefs::kSafeBrowsingReportingEnabled, true);
  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));
  ProceedThroughInterstitial(sb_interstitial);
  EXPECT_TRUE(profile->GetPrefs()->GetBoolean(
      prefs::kSafeBrowsingExtendedReportingEnabled));
}
TEST_F ( SafeBrowsingBlockingPageTest , MalwareReportsTransitionEnabled ) { Profile * profile = Profile :: FromBrowserContext ( web_contents ( ) -> GetBrowserContext ( ) ) ; profile -> GetPrefs ( ) -> SetBoolean ( prefs :: kSafeBrowsingReportingEnabled , true ) ; 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 ) ) ; ProceedThroughInterstitial ( sb_interstitial ) ; EXPECT_TRUE ( profile -> GetPrefs ( ) -> GetBoolean ( prefs :: kSafeBrowsingExtendedReportingEnabled ) ) ; }
Test that the transition from old to new preference works.
Test that the transition from old to new preference works .
// The old pref is enabled. // Start a load. // Simulate the load causing a safe browsing interstitial to be shown. // At this point, nothing should have changed yet. // Since the user has proceeded without changing the checkbox, the new pref // has been updated.