#include "chrome/browser/ui/privacy_sandbox/privacy_sandbox_prompt_helper.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/privacy_sandbox/mock_privacy_sandbox_service.h"
#include "chrome/browser/privacy_sandbox/privacy_sandbox_service.h"
#include "chrome/browser/privacy_sandbox/privacy_sandbox_service_factory.h"
#include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service.h"
#include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/search/ntp_test_utils.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/privacy_sandbox/privacy_sandbox_features.h"
#include "components/search_engines/search_engines_switches.h"
#include "components/signin/public/base/signin_switches.h"
#include "components/sync/test/test_sync_service.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "url/url_constants.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/webui/help_app_ui/url_constants.h"
#endif
namespace {
const char kPrivacySandboxDialogDisplayHostHistogram[] = …;
constexpr char kPrivacySandboxPromptHelperEventHistogram[] = …;
std::unique_ptr<KeyedService> CreateTestSyncService(content::BrowserContext*) { … }
std::unique_ptr<KeyedService> CreateMockPrivacySandboxService(
content::BrowserContext*) { … }
}
class PrivacySandboxPromptHelperTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PrivacySandboxPromptHelperTest, NoPromptRequired) { … }
class PrivacySandboxPromptHelperTestWithParam
: public PrivacySandboxPromptHelperTest,
public testing::WithParamInterface<PrivacySandboxService::PromptType> { … };
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptHelperTestWithParam,
PromptOpensOnNtp) { … }
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptHelperTestWithParam,
PromptOpensAboutBlank) { … }
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptHelperTestWithParam,
PromptOpensOnSettings) { … }
# if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_PromptOpensOnHistory …
# else
#define MAYBE_PromptOpensOnHistory …
# endif
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptHelperTestWithParam,
MAYBE_PromptOpensOnHistory) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptHelperTestWithParam,
NoPromptNonDefaultNtp) { … }
#endif
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptHelperTestWithParam, NoPromptSync) { … }
#if BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS)
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptHelperTestWithParam,
NoPromptProfileSetup) { … }
#endif
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptHelperTestWithParam, UnsuitableUrl) { … }
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptHelperTestWithParam,
SinglePromptPerBrowser) { … }
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptHelperTestWithParam,
MultipleBrowserWindows) { … }
INSTANTIATE_TEST_SUITE_P(…);
class PrivacySandboxPromptNonNormalBrowserTest
: public PrivacySandboxPromptHelperTest,
public testing::WithParamInterface<PrivacySandboxService::PromptType> { … };
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptNonNormalBrowserTest,
NoPromptInLargeBrowser) { … }
IN_PROC_BROWSER_TEST_P(PrivacySandboxPromptNonNormalBrowserTest,
NoPromptInSmallBrowser) { … }
INSTANTIATE_TEST_SUITE_P(…);
class PrivacySandboxPromptHelperTestWithSearchEngineChoiceEnabled
: public PrivacySandboxPromptHelperTestWithParam { … };
IN_PROC_BROWSER_TEST_P(
PrivacySandboxPromptHelperTestWithSearchEngineChoiceEnabled,
NoPromptWhenSearchEngineChoiceDialogIsDisplayed) { … }
INSTANTIATE_TEST_SUITE_P(…);