-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[waffle]Record when the user clicks on the learn more link
Record a histogram when the user clicks on the "learn more" link. We record different instances for when the click happens in the Profile Picker or in the Search Engine Choice dialog. Bug: b:307714156 Change-Id: I3ea89290e757e9ca92534b9b01334ae1da51849c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4988248 Commit-Queue: Matthew Denton <mpdenton@chromium.org> Auto-Submit: Jack Yammine <jyammine@google.com> Reviewed-by: Nicolas Dossou-Gbété <dgn@chromium.org> Reviewed-by: Matthew Denton <mpdenton@chromium.org> Cr-Commit-Position: refs/heads/main@{#1217126}
- Loading branch information
Jack Yammine
authored and
Chromium LUCI CQ
committed
Oct 30, 2023
1 parent
1d5d20c
commit e9e4e31
Showing
13 changed files
with
156 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
chrome/browser/search_engine_choice/search_engine_choice_service_unittest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/search_engine_choice/search_engine_choice_service.h" | ||
#include "base/functional/bind.h" | ||
#include "base/memory/raw_ptr.h" | ||
#include "base/test/metrics/histogram_tester.h" | ||
#include "base/test/scoped_feature_list.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/search_engines/template_url_service_factory.h" | ||
#include "chrome/browser/ui/webui/settings/search_engines_handler.h" | ||
#include "chrome/test/base/testing_browser_process.h" | ||
#include "chrome/test/base/testing_profile_manager.h" | ||
#include "components/country_codes/country_codes.h" | ||
#include "components/search_engines/search_engine_choice_utils.h" | ||
#include "components/search_engines/template_url_service.h" | ||
#include "components/signin/public/base/signin_switches.h" | ||
#include "content/public/test/browser_task_environment.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
class SearchEngineChoiceServiceTest : public testing::Test { | ||
public: | ||
SearchEngineChoiceServiceTest() | ||
: profile_manager_(TestingBrowserProcess::GetGlobal()) {} | ||
|
||
void SetUp() override { | ||
testing::Test::SetUp(); | ||
ASSERT_TRUE(profile_manager_.SetUp()); | ||
profile_ = profile_manager_.CreateTestingProfile("Profile 1"); | ||
|
||
TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | ||
profile(), | ||
base::BindRepeating(&TemplateURLServiceFactory::BuildInstanceFor)); | ||
|
||
PrefService* pref_service = profile()->GetPrefs(); | ||
// The search engine choice feature is only enabled for countries in the EEA | ||
// region. | ||
const int kBelgiumCountryId = | ||
country_codes::CountryCharsToCountryID('B', 'E'); | ||
pref_service->SetInteger(country_codes::kCountryIDAtInstall, | ||
kBelgiumCountryId); | ||
|
||
TemplateURLService* template_url_service = | ||
TemplateURLServiceFactory::GetForProfile(profile()); | ||
search_engine_choice_service_ = std::make_unique<SearchEngineChoiceService>( | ||
*profile_, *template_url_service); | ||
} | ||
|
||
Profile* profile() const { return profile_; } | ||
|
||
SearchEngineChoiceService* search_engine_choice_service() { | ||
return search_engine_choice_service_.get(); | ||
} | ||
|
||
const base::HistogramTester& histogram_tester() const { | ||
return histogram_tester_; | ||
} | ||
|
||
private: | ||
base::test::ScopedFeatureList feature_list_{switches::kSearchEngineChoice}; | ||
content::BrowserTaskEnvironment task_environment_; | ||
TestingProfileManager profile_manager_; | ||
raw_ptr<Profile> profile_ = nullptr; | ||
std::unique_ptr<SearchEngineChoiceService> search_engine_choice_service_; | ||
base::HistogramTester histogram_tester_; | ||
}; | ||
|
||
TEST_F(SearchEngineChoiceServiceTest, HandleLearnMoreLinkClicked) { | ||
search_engine_choice_service()->NotifyLearnMoreLinkClicked( | ||
SearchEngineChoiceService::EntryPoint::kDialog); | ||
histogram_tester().ExpectBucketCount( | ||
search_engines::kSearchEngineChoiceScreenEventsHistogram, | ||
search_engines::SearchEngineChoiceScreenEvents::kLearnMoreWasDisplayed, | ||
1); | ||
|
||
search_engine_choice_service()->NotifyLearnMoreLinkClicked( | ||
SearchEngineChoiceService::EntryPoint::kProfilePicker); | ||
histogram_tester().ExpectBucketCount( | ||
search_engines::kSearchEngineChoiceScreenEventsHistogram, | ||
search_engines::SearchEngineChoiceScreenEvents::kFreLearnMoreWasDisplayed, | ||
1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters