Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SearchEngineTracker: Wait for service load when testing. #10393

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions browser/search_engines/search_engine_tracker_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ class SearchEngineProviderP3ATest : public InProcessBrowserTest {
};

IN_PROC_BROWSER_TEST_F(SearchEngineProviderP3ATest, DefaultSearchEngineP3A) {
// Check that the metric is reported on startup.
histogram_tester_->ExpectUniqueSample(kDefaultSearchEngineMetric,
SearchEngineP3A::kGoogle, 1);

// Load service for switching the default search engine.
// NB: This adds delay which helps reliability of the first measurement.
auto* service =
TemplateURLServiceFactory::GetForProfile(browser()->profile());
search_test_utils::WaitForTemplateURLServiceToLoad(service);

// Check that the metric is reported on startup.
histogram_tester_->ExpectUniqueSample(kDefaultSearchEngineMetric,
SearchEngineP3A::kGoogle, 1);

// Check that changing the default engine triggers emitting of a new value.
auto ddg_data = TemplateURLPrepopulateData::GetPrepopulatedEngine(
browser()->profile()->GetPrefs(),
Expand Down