Commit 82c19507 authored by Mustafa Emre Acer's avatar Mustafa Emre Acer Committed by Commit Bot

Lookalike URLs: Separate incognito tests into a new test case

Testing four site both in the main profile and incognito is slow and causing test timeouts.
Separate the tests.

Bug: 923917
Change-Id: I2f93b0a200dd0c811fa66681afc4ef6da9f81aa5
Reviewed-on: https://chromium-review.googlesource.com/c/1427619Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Mustafa Emre Acer <meacer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626270}
parent 327a4fe1
...@@ -412,18 +412,10 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest, ...@@ -412,18 +412,10 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
"http://site1.com", "http://www.site2.com", "http://sité3.com", "http://site1.com", "http://www.site2.com", "http://sité3.com",
"http://www.sité4.com"}; "http://www.sité4.com"};
// Set high engagement scores in the main profile and low engagement scores
// in incognito. Main profile should record metrics, incognito shouldn't.
Browser* incognito = CreateIncognitoBrowser();
LookalikeUrlService::Get(incognito->profile())
->SetClockForTesting(test_clock());
for (const char* const kSite : kEngagedSites) { for (const char* const kSite : kEngagedSites) {
SetEngagementScore(browser(), GURL(kSite), kHighEngagement); SetEngagementScore(browser(), GURL(kSite), kHighEngagement);
SetEngagementScore(incognito, GURL(kSite), kLowEngagement);
} }
// Main profile should record metrics because there are engaged sites.
std::vector<GURL> ukm_urls; std::vector<GURL> ukm_urls;
for (const auto& test_case : kSiteEngagementTestCases) { for (const auto& test_case : kSiteEngagementTestCases) {
base::HistogramTester histograms; base::HistogramTester histograms;
...@@ -445,11 +437,43 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest, ...@@ -445,11 +437,43 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
CheckUkm(ukm_urls, CheckUkm(ukm_urls,
LookalikeUrlNavigationObserver::MatchType::kSiteEngagement); LookalikeUrlNavigationObserver::MatchType::kSiteEngagement);
} }
}
// Similar to Idn_SiteEngagement_Match, but tests a single domain. Also checks
// that the list of engaged sites in incognito and the main profile don't affect
// each other.
IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
Idn_SiteEngagement_Match_Incognito) {
const GURL kNavigatedUrl = GetURL("sité1.com");
const GURL kEngagedUrl = GetURL("site1.com");
// Set high engagement scores in the main profile and low engagement scores
// in incognito. Main profile should record metrics, incognito shouldn't.
Browser* incognito = CreateIncognitoBrowser();
LookalikeUrlService::Get(incognito->profile())
->SetClockForTesting(test_clock());
SetEngagementScore(browser(), kEngagedUrl, kHighEngagement);
SetEngagementScore(incognito, kEngagedUrl, kLowEngagement);
std::vector<GURL> ukm_urls;
// Main profile should record metrics because there are engaged sites.
{
base::HistogramTester histograms;
// Advance the clock to force LookalikeUrlService to fetch a new engaged
// site list.
test_clock()->Advance(base::TimeDelta::FromHours(1));
TestHistogramEventsRecordedAndInfobarVisibility(
browser(), &histograms, kNavigatedUrl, kEngagedUrl,
NavigationSuggestionEvent::kMatchSiteEngagement);
ukm_urls.push_back(kNavigatedUrl);
CheckUkm(ukm_urls,
LookalikeUrlNavigationObserver::MatchType::kSiteEngagement);
}
// Incognito shouldn't record metrics because there are no engaged sites. // Incognito shouldn't record metrics because there are no engaged sites.
for (const auto& test_case : kSiteEngagementTestCases) { {
base::HistogramTester histograms; base::HistogramTester histograms;
const GURL kNavigatedUrl = GetURL(test_case.navigated);
test_clock()->Advance(base::TimeDelta::FromHours(1)); test_clock()->Advance(base::TimeDelta::FromHours(1));
TestInfobarNotShown(incognito, kNavigatedUrl); TestInfobarNotShown(incognito, kNavigatedUrl);
histograms.ExpectTotalCount(LookalikeUrlNavigationObserver::kHistogramName, histograms.ExpectTotalCount(LookalikeUrlNavigationObserver::kHistogramName,
...@@ -458,35 +482,25 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest, ...@@ -458,35 +482,25 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
// Now reverse the scores: Set low engagement in the main profile and high // Now reverse the scores: Set low engagement in the main profile and high
// engagement in incognito. // engagement in incognito.
for (const char* const kSite : kEngagedSites) { SetEngagementScore(browser(), kEngagedUrl, kLowEngagement);
SetEngagementScore(browser(), GURL(kSite), kLowEngagement); SetEngagementScore(incognito, kEngagedUrl, kHighEngagement);
SetEngagementScore(incognito, GURL(kSite), kHighEngagement);
}
// Incognito should start recording metrics and main profile should stop. // Incognito should start recording metrics and main profile should stop.
for (const auto& test_case : kSiteEngagementTestCases) { {
base::HistogramTester histograms; base::HistogramTester histograms;
const GURL kNavigatedUrl = GetURL(test_case.navigated);
const GURL kExpectedSuggestedUrl = GetURL(test_case.suggested);
// Even if the navigated site has a low engagement score, it should be
// considered for lookalike suggestions.
SetEngagementScore(incognito, kNavigatedUrl, kLowEngagement);
// Advance the clock to force LookalikeUrlService to fetch a new engaged
// site list.
test_clock()->Advance(base::TimeDelta::FromHours(1)); test_clock()->Advance(base::TimeDelta::FromHours(1));
TestHistogramEventsRecordedAndInfobarVisibility( TestHistogramEventsRecordedAndInfobarVisibility(
incognito, &histograms, kNavigatedUrl, kExpectedSuggestedUrl, incognito, &histograms, kNavigatedUrl, kEngagedUrl,
NavigationSuggestionEvent::kMatchSiteEngagement); NavigationSuggestionEvent::kMatchSiteEngagement);
ukm_urls.push_back(kNavigatedUrl); ukm_urls.push_back(kNavigatedUrl);
CheckUkm(ukm_urls, CheckUkm(ukm_urls,
LookalikeUrlNavigationObserver::MatchType::kSiteEngagement); LookalikeUrlNavigationObserver::MatchType::kSiteEngagement);
} }
// Main profile shouldn't record metrics because there are no engaged sites. // Main profile shouldn't record metrics because there are no engaged sites.
for (const auto& test_case : kSiteEngagementTestCases) { {
base::HistogramTester histograms; base::HistogramTester histograms;
const GURL kNavigatedUrl = GetURL(test_case.navigated);
test_clock()->Advance(base::TimeDelta::FromHours(1)); test_clock()->Advance(base::TimeDelta::FromHours(1));
TestInfobarNotShown(browser(), kNavigatedUrl); TestInfobarNotShown(browser(), kNavigatedUrl);
histograms.ExpectTotalCount(LookalikeUrlNavigationObserver::kHistogramName, histograms.ExpectTotalCount(LookalikeUrlNavigationObserver::kHistogramName,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment