#include "net/first_party_sets/global_first_party_sets.h"
#include <optional>
#include "base/containers/flat_map.h"
#include "base/version.h"
#include "net/base/schemeful_site.h"
#include "net/first_party_sets/first_party_set_entry.h"
#include "net/first_party_sets/first_party_set_entry_override.h"
#include "net/first_party_sets/first_party_set_metadata.h"
#include "net/first_party_sets/first_party_sets_context_config.h"
#include "net/first_party_sets/local_set_declaration.h"
#include "net/first_party_sets/sets_mutation.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
IsEmpty;
Optional;
Pair;
UnorderedElementsAre;
namespace net {
namespace {
const base::Version kVersion("1.2.3");
const SchemefulSite kPrimary(GURL("https://primary.test"));
const SchemefulSite kPrimaryCctld(GURL("https://primary.ccltd"));
const SchemefulSite kPrimary2(GURL("https://primary2.test"));
const SchemefulSite kPrimary3(GURL("https://primary3.test"));
const SchemefulSite kAssociated1(GURL("https://associated1.test"));
const SchemefulSite kAssociated1Cctld(GURL("https://associated1.cctld"));
const SchemefulSite kAssociated1Cctld2(GURL("https://associated1.cctld2"));
const SchemefulSite kAssociated2(GURL("https://associated2.test"));
const SchemefulSite kAssociated3(GURL("https://associated3.test"));
const SchemefulSite kAssociated4(GURL("https://associated4.test"));
const SchemefulSite kAssociated5(GURL("https://associated5.test"));
const SchemefulSite kService(GURL("https://service.test"));
base::flat_map<SchemefulSite, FirstPartySetEntry> CollectEffectiveSetEntries(
const GlobalFirstPartySets& sets,
const FirstPartySetsContextConfig& config) { … }
}
class GlobalFirstPartySetsTest : public ::testing::Test { … };
TEST_F(GlobalFirstPartySetsTest, CtorSkipsInvalidVersion) { … }
TEST_F(GlobalFirstPartySetsTest, Clone) { … }
TEST_F(GlobalFirstPartySetsTest, Ctor_PrimaryWithAlias_Valid) { … }
TEST_F(GlobalFirstPartySetsTest, FindEntry_Nonexistent) { … }
TEST_F(GlobalFirstPartySetsTest, FindEntry_Exists) { … }
TEST_F(GlobalFirstPartySetsTest, FindEntry_NoNormalization) { … }
TEST_F(GlobalFirstPartySetsTest, FindEntry_ExistsViaOverride) { … }
TEST_F(GlobalFirstPartySetsTest, FindEntry_RemovedViaOverride) { … }
TEST_F(GlobalFirstPartySetsTest, FindEntry_ExistsViaAlias) { … }
TEST_F(GlobalFirstPartySetsTest, FindEntry_ExistsViaOverrideWithDecoyAlias) { … }
TEST_F(GlobalFirstPartySetsTest, FindEntry_RemovedViaOverrideWithDecoyAlias) { … }
TEST_F(GlobalFirstPartySetsTest, FindEntry_AliasesIgnoredForConfig) { … }
TEST_F(GlobalFirstPartySetsTest, Empty_Empty) { … }
TEST_F(GlobalFirstPartySetsTest, Empty_NonemptyEntries) { … }
TEST_F(GlobalFirstPartySetsTest, Empty_NonemptyManualSet) { … }
TEST_F(GlobalFirstPartySetsTest, InvalidPublicSetsVersion_NonemptyManualSet) { … }
TEST_F(GlobalFirstPartySetsTest,
ForEachEffectiveSetEntry_ManualSetAndConfig_FullIteration) { … }
class PopulatedGlobalFirstPartySetsTest : public GlobalFirstPartySetsTest { … };
TEST_F(PopulatedGlobalFirstPartySetsTest,
ApplyManuallySpecifiedSet_DeduplicatesPrimaryPrimary) { … }
TEST_F(PopulatedGlobalFirstPartySetsTest,
ApplyManuallySpecifiedSet_DeduplicatesPrimaryNonprimary) { … }
TEST_F(PopulatedGlobalFirstPartySetsTest,
ApplyManuallySpecifiedSet_DeduplicatesNonprimaryPrimary) { … }
TEST_F(PopulatedGlobalFirstPartySetsTest,
ApplyManuallySpecifiedSet_DeduplicatesNonprimaryNonprimary) { … }
TEST_F(PopulatedGlobalFirstPartySetsTest,
ApplyManuallySpecifiedSet_PrunesInducedSingletons) { … }
TEST_F(PopulatedGlobalFirstPartySetsTest,
ApplyManuallySpecifiedSet_RespectsManualAlias) { … }
TEST_F(PopulatedGlobalFirstPartySetsTest, ForEachPublicSetEntry_FullIteration) { … }
TEST_F(PopulatedGlobalFirstPartySetsTest, ForEachPublicSetEntry_EarlyReturn) { … }
TEST_F(PopulatedGlobalFirstPartySetsTest,
ForEachEffectiveSetEntry_PublicSetsOnly_FullIteration) { … }
TEST_F(PopulatedGlobalFirstPartySetsTest,
ForEachEffectiveSetEntry_PublicSetsWithManualSet_FullIteration) { … }
TEST_F(PopulatedGlobalFirstPartySetsTest,
ForEachEffectiveSetEntry_PublicSetsWithConfig_FullIteration) { … }
TEST_F(
PopulatedGlobalFirstPartySetsTest,
ForEachEffectiveSetEntry_PublicSetsWithManualSetAndConfig_FullIteration) { … }
TEST_F(
PopulatedGlobalFirstPartySetsTest,
ForEachEffectiveSetEntry_PublicSetsWithManualSetAndConfig_ManualAliasOverlap) { … }
TEST_F(PopulatedGlobalFirstPartySetsTest, ComputeMetadata) { … }
TEST_F(GlobalFirstPartySetsTest, ComputeConfig_Empty) { … }
TEST_F(GlobalFirstPartySetsTest,
ComputeConfig_Replacements_NoIntersection_NoRemoval) { … }
TEST_F(
GlobalFirstPartySetsTest,
ComputeConfig_Replacements_ReplacesExistingAssociatedSite_RemovedFromFormerSet) { … }
TEST_F(
GlobalFirstPartySetsTest,
ComputeConfig_Replacements_ReplacesExistingPrimary_RemovesFormerAssociatedSites) { … }
TEST_F(
GlobalFirstPartySetsTest,
ComputeConfig_Replacements_ReplacesExistingAssociatedSite_RemovesSingletons) { … }
TEST_F(GlobalFirstPartySetsTest,
ComputeConfig_Additions_NoIntersection_AddsWithoutUpdating) { … }
TEST_F(
GlobalFirstPartySetsTest,
ComputeConfig_Additions_PolicyPrimaryIsExistingAssociatedSite_PolicySetAbsorbsExistingSet) { … }
TEST_F(
GlobalFirstPartySetsTest,
ComputeConfig_Additions_PolicyPrimaryIsExistingPrimary_PolicySetAbsorbsExistingAssociatedSites) { … }
TEST_F(
GlobalFirstPartySetsTest,
ComputeConfig_ReplacementsAndAdditions_SetListsOverlapWithSameExistingSet) { … }
TEST_F(GlobalFirstPartySetsTest, TransitiveOverlap_TwoCommonPrimaries) { … }
TEST_F(GlobalFirstPartySetsTest, TransitiveOverlap_TwoCommonAssociatedSites) { … }
TEST_F(GlobalFirstPartySetsTest, InvalidPublicSetsVersion_ComputeConfig) { … }
class GlobalFirstPartySetsWithConfigTest
: public PopulatedGlobalFirstPartySetsTest { … };
TEST_F(GlobalFirstPartySetsWithConfigTest, ComputeMetadata) { … }
}