#include "components/privacy_sandbox/privacy_sandbox_settings_impl.h"
#include <string>
#include <tuple>
#include <vector>
#include "base/json/values_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/gtest_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_command_line.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/with_feature_override.h"
#include "base/values.h"
#include "components/browsing_topics/test_util.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/features.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/content_settings/core/test/content_settings_mock_provider.h"
#include "components/content_settings/core/test/content_settings_test_utils.h"
#include "components/privacy_sandbox/canonical_topic.h"
#include "components/privacy_sandbox/privacy_sandbox_attestations/privacy_sandbox_attestations.h"
#include "components/privacy_sandbox/privacy_sandbox_attestations/scoped_privacy_sandbox_attestations.h"
#include "components/privacy_sandbox/privacy_sandbox_features.h"
#include "components/privacy_sandbox/privacy_sandbox_prefs.h"
#include "components/privacy_sandbox/privacy_sandbox_settings.h"
#include "components/privacy_sandbox/privacy_sandbox_test_util.h"
#include "components/privacy_sandbox/tpcd_experiment_eligibility.h"
#include "components/privacy_sandbox/tracking_protection_prefs.h"
#include "components/privacy_sandbox/tracking_protection_settings.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "url/origin.h"
namespace privacy_sandbox {
Topic;
namespace {
using enum privacy_sandbox_test_util::StateKey;
using enum privacy_sandbox_test_util::InputKey;
using enum privacy_sandbox_test_util::OutputKey;
constexpr auto CONTENT_SETTING_ALLOW = …;
constexpr auto CONTENT_SETTING_BLOCK = …;
constexpr auto kBlockThirdParty = …;
constexpr int kTestTaxonomyVersion = …;
MultipleInputKeys;
MultipleOutputKeys;
MultipleStateKeys;
SiteDataExceptions;
TestCase;
TestInput;
TestOutput;
TestState;
}
class PrivacySandboxSettingsTest : public testing::Test { … };
TEST_F(PrivacySandboxSettingsTest, TopicsDataAccessibleSince) { … }
TEST_F(PrivacySandboxSettingsTest, FledgeJoiningAllowed) { … }
TEST_F(PrivacySandboxSettingsTest, NonEtldPlusOneBlocked) { … }
TEST_F(PrivacySandboxSettingsTest, FledgeJoinSettingTimeRangeDeletion) { … }
TEST_F(PrivacySandboxSettingsTest, OnRelatedWebsiteSetsEnabledChanged) { … }
TEST_F(PrivacySandboxSettingsTest, OnFirstPartySetsEnabledChanged3pcd) { … }
TEST_F(PrivacySandboxSettingsTest, IsTopicAllowed) { … }
TEST_F(PrivacySandboxSettingsTest, IsTopicAllowed_ByFinchSettings) { … }
TEST_F(PrivacySandboxSettingsTest, ClearingTopicSettings) { … }
TEST_F(PrivacySandboxSettingsTest,
GetCookieDeprecationExperimentCurrentEligibility) { … }
TEST_F(PrivacySandboxSettingsTest, IsCookieDeprecationLabelAllowed) { … }
class PrivacySandboxSettingsAttributionReportingTransitionalDebugModeTest
: public PrivacySandboxSettingsTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(
PrivacySandboxSettingsAttributionReportingTransitionalDebugModeTest,
IsAttributionReportingTransitionalDebuggingAllowed_CanBypassInCookieDeprecationExperiment) { … }
struct PrivateAggregationDebugModeTestCase { … };
class PrivacySandboxSettingsPrivateAggregationDebugModeTest
: public PrivacySandboxSettingsTest,
public testing::WithParamInterface<PrivateAggregationDebugModeTestCase> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(PrivacySandboxSettingsPrivateAggregationDebugModeTest,
IsPrivateAggregationDebugModeAllowed) { … }
class PrivacySandboxSettingsTestCookiesClearOnExitTurnedOff
: public PrivacySandboxSettingsTest { … };
TEST_F(PrivacySandboxSettingsTestCookiesClearOnExitTurnedOff,
UseLastTopicsDataAccessibleSince) { … }
class PrivacySandboxSettingsTestCookiesClearOnExitTurnedOn
: public PrivacySandboxSettingsTest { … };
TEST_F(PrivacySandboxSettingsTestCookiesClearOnExitTurnedOn,
UpdateTopicsDataAccessibleSince) { … }
class PrivacySandboxSettingsMockDelegateTest
: public PrivacySandboxSettingsTest { … };
TEST_F(PrivacySandboxSettingsMockDelegateTest, IsSubjectToM1NoticeRestricted) { … }
class PrivacySandboxSettingsM1Test : public PrivacySandboxSettingsTest { … };
TEST_F(PrivacySandboxSettingsM1Test, ApiPreferenceEnabled) { … }
TEST_F(PrivacySandboxSettingsM1Test, ApiPreferenceDisabled) { … }
TEST_F(PrivacySandboxSettingsM1Test, CookieControlsModeHasNoEffect) { … }
TEST_F(PrivacySandboxSettingsM1Test, SiteDataDefaultBlockExceptionApplies) { … }
TEST_F(PrivacySandboxSettingsM1Test, SiteDataBlockExceptionApplies) { … }
TEST_F(PrivacySandboxSettingsM1Test, SiteDataAllowDoesntOverridePref) { … }
TEST_F(PrivacySandboxSettingsM1Test, SiteDataAllowExceptions) { … }
TEST_F(PrivacySandboxSettingsM1Test, UnrelatedSiteDataBlock) { … }
TEST_F(PrivacySandboxSettingsM1Test, UnrelatedSiteDataAllow) { … }
TEST_F(PrivacySandboxSettingsM1Test, ApisAreOffInIncognito) { … }
TEST_F(PrivacySandboxSettingsM1Test, ApisAreOffForRestrictedAccounts) { … }
TEST_F(PrivacySandboxSettingsM1Test,
CheckFledgeDependentApi_FledgeOn_OtherApiOn) { … }
TEST_F(PrivacySandboxSettingsM1Test,
CheckFledgeDependentApi_FledgeOff_OtherApiOff) { … }
TEST_F(PrivacySandboxSettingsM1Test,
CheckAdMeasurementDependentApi_AdMeasurementOn_OtherApiOn) { … }
TEST_F(PrivacySandboxSettingsM1Test,
CheckAdMeasurementDependentApi_AdMeasurementOff_OtherApiOff) { … }
TEST_F(PrivacySandboxSettingsM1Test, NoAppropriateTopicsConsent) { … }
TEST_F(PrivacySandboxSettingsM1Test, TopicsConsentStatus) { … }
class PrivacySandboxSettingsM1RestrictedNotice
: public PrivacySandboxSettingsM1Test { … };
TEST_F(PrivacySandboxSettingsM1RestrictedNotice,
AllApisAreOffExceptMeasurementForRestrictedAccounts) { … }
class PrivacySandboxAttestationsTest : public base::test::WithFeatureOverride,
public PrivacySandboxSettingsM1Test { … };
TEST_P(PrivacySandboxAttestationsTest, AttestationsFileNotYetChecked) { … }
TEST_P(PrivacySandboxAttestationsTest, NoEnrollments) { … }
TEST_P(PrivacySandboxAttestationsTest, EnrollmentWithoutAttestations) { … }
TEST_P(PrivacySandboxAttestationsTest, TopicsAttestation) { … }
TEST_P(PrivacySandboxAttestationsTest, PrivateAggregationAttestation) { … }
TEST_P(PrivacySandboxAttestationsTest, SharedStorageAttestation) { … }
TEST_P(PrivacySandboxAttestationsTest, FledgeAttestation) { … }
TEST_P(PrivacySandboxAttestationsTest, FledgeAttestationBlockJoiningEtldplus1) { … }
TEST_P(PrivacySandboxAttestationsTest, AttributionReportingAttestation) { … }
TEST_P(PrivacySandboxAttestationsTest, SetOverrideFromDevtools) { … }
TEST_P(PrivacySandboxAttestationsTest, SetOverrideFromFlags) { … }
INSTANTIATE_FEATURE_OVERRIDE_TEST_SUITE(…);
struct PrivacySandbox3pcdTestCase { … };
const PrivacySandbox3pcdTestCase kTestCases[] = …;
class PrivacySandbox3pcdExperimentTest
: public PrivacySandboxSettingsM1Test,
public testing::WithParamInterface<PrivacySandbox3pcdTestCase> { … };
TEST_P(PrivacySandbox3pcdExperimentTest, ExperimentDisablesAdsAPIs) { … }
INSTANTIATE_TEST_SUITE_P(…);
namespace {
const char* attestation_failed_template = …;
const char* site_settings_template = …;
const char* sandbox_restricted_template = …;
const char* select_url_template = …;
class PrivacySandboxSettingsSharedStorageDebugTest
: public PrivacySandboxSettingsM1Test { … };
}
TEST_F(PrivacySandboxSettingsSharedStorageDebugTest, ApiPreferenceEnabled) { … }
TEST_F(PrivacySandboxSettingsSharedStorageDebugTest, ApiPreferenceDisabled) { … }
TEST_F(PrivacySandboxSettingsSharedStorageDebugTest,
ApisAreOffForRestrictedAccounts) { … }
TEST_F(PrivacySandboxSettingsSharedStorageDebugTest,
SiteDataDefaultBlockExceptionApplies) { … }
TEST_F(PrivacySandboxSettingsSharedStorageDebugTest, NoEnrollments) { … }
}