#include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.h"
#include "chrome/browser/search_engine_choice/search_engine_choice_service_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/dialog_test_browser_window.h"
#include "chrome/test/base/testing_browser_process.h"
#include "components/country_codes/country_codes.h"
#include "components/search_engines/prepopulated_engines.h"
#include "components/search_engines/search_engine_choice/search_engine_choice_utils.h"
#include "components/search_engines/search_engine_utils.h"
#include "components/search_engines/search_engines_pref_names.h"
#include "components/search_engines/search_engines_switches.h"
#include "components/search_engines/template_url_prepopulate_data.h"
#include "components/search_engines/template_url_service.h"
#include "components/signin/public/base/signin_switches.h"
#include "components/web_modal/test_web_contents_modal_dialog_host.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
#if !BUILDFLAG(CHROME_FOR_TESTING)
void SetUserSelectedDefaultSearchProvider(
TemplateURLService* template_url_service,
bool created_by_policy) { … }
struct TestParam { … };
std::string ParamToTestSuffix(const ::testing::TestParamInfo<TestParam>& info) { … }
const TestParam kTestParams[] = …;
#endif
class ResizableDialogTestBrowserWindow : public DialogTestBrowserWindow { … };
}
class SearchEngineChoiceDialogServiceTest : public BrowserWithTestWindowTest { … };
#if !BUILDFLAG(CHROME_FOR_TESTING)
class SearchEngineListCountryOverrideParametrizedTest
: public SearchEngineChoiceDialogServiceTest,
public testing::WithParamInterface<TestParam> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(SearchEngineChoiceDialogServiceTest, NotifyLearnMoreLinkClicked) { … }
TEST_F(SearchEngineChoiceDialogServiceTest, NotifyMoreButtonClicked) { … }
TEST_F(SearchEngineChoiceDialogServiceTest,
ComputeDialogConditions_SmallBrowser) { … }
TEST_F(SearchEngineChoiceDialogServiceTest, RegisterDialog) { … }
TEST_F(SearchEngineChoiceDialogServiceTest, NotifyChoiceMade_Dialog) { … }
TEST_F(SearchEngineChoiceDialogServiceTest, NotifyChoiceMade_Fre) { … }
TEST_F(SearchEngineChoiceDialogServiceTest, NotifyChoiceMade_ProfileCreation) { … }
TEST_F(SearchEngineChoiceDialogServiceTest,
DoNotDisplayDialogIfPolicyIsSetDynamically) { … }
TEST_F(SearchEngineChoiceDialogServiceTest, DoNotCreateServiceIfPolicyIsSet) { … }
TEST_F(SearchEngineChoiceDialogServiceTest,
SearchEngineChoicePropagatesFromParentProfileToIncognito) { … }
TEST_F(SearchEngineChoiceDialogServiceTest,
SearchEngineChoicePropagatesFromIncognitoToParentProfile) { … }
TEST_F(SearchEngineChoiceDialogServiceTest, IsUrlSuitableForDialog) { … }
TEST_F(SearchEngineChoiceDialogServiceTest,
CanSuppressPrivacySandboxPromo_Dialog) { … }
TEST_F(SearchEngineChoiceDialogServiceTest,
CanSuppressPrivacySandboxPromo_FRE) { … }
TEST_F(SearchEngineChoiceDialogServiceTest,
CanSuppressPrivacySandboxPromo_ProfileCreation) { … }
TEST_P(SearchEngineListCountryOverrideParametrizedTest,
CheckNumberOfSearchEngines) { … }
#else
TEST_F(SearchEngineChoiceDialogServiceTest,
ServiceNotInitializedInChromeForTesting) {
SearchEngineChoiceDialogService* search_engine_choice_dialog_service =
GetSearchEngineChoiceDialogService();
ASSERT_EQ(search_engine_choice_dialog_service, nullptr);
}
#endif