#include "services/network/first_party_sets/first_party_sets_access_delegate.h"
#include <optional>
#include <set>
#include <string>
#include "base/containers/flat_set.h"
#include "base/functional/callback_helpers.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/version.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/features.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_cache_filter.h"
#include "net/first_party_sets/first_party_sets_context_config.h"
#include "net/first_party_sets/global_first_party_sets.h"
#include "services/network/public/mojom/first_party_sets_access_delegate.mojom.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;
Not;
Optional;
Pair;
UnorderedElementsAre;
OverrideSets;
namespace network {
namespace {
const net::SchemefulSite kSet1Primary(GURL("https://set1primary.test"));
const net::SchemefulSite kSet1AssociatedSite1(
GURL("https://set1associatedSite1.test"));
const net::SchemefulSite kSet1AssociatedSite2(
GURL("https://set1associatedSite2.test"));
const net::SchemefulSite kSet2Primary(GURL("https://set2primary.test"));
const net::SchemefulSite kSet2AssociatedSite1(
GURL("https://set2associatedSite1.test"));
const net::SchemefulSite kSet3Primary(GURL("https://set3primary.test"));
const net::SchemefulSite kSet3AssociatedSite1(
GURL("https://set3associatedSite1.test"));
const int64_t kClearAtRunId(2);
const int64_t kBrowserRunId(3);
const char kDelayedQueriesCountHistogram[] = …;
const char kMostDelayedQuerDeltaHistogram[] = …;
mojom::FirstPartySetsAccessDelegateParamsPtr
CreateFirstPartySetsAccessDelegateParams(bool enabled) { … }
mojom::FirstPartySetsReadyEventPtr CreateFirstPartySetsReadyEvent(
std::optional<net::FirstPartySetsContextConfig> config,
std::optional<net::FirstPartySetsCacheFilter> cache_filter) { … }
}
class WaitingFeatureInitializer { … };
class NoopFirstPartySetsAccessDelegateTest : public ::testing::Test,
public WaitingFeatureInitializer { … };
TEST_F(NoopFirstPartySetsAccessDelegateTest, ComputeMetadata) { … }
TEST_F(NoopFirstPartySetsAccessDelegateTest, FindEntries) { … }
class FirstPartySetsAccessDelegateTest : public ::testing::Test,
public WaitingFeatureInitializer { … };
class FirstPartySetsAccessDelegateDisabledTest
: public FirstPartySetsAccessDelegateTest { … };
TEST_F(FirstPartySetsAccessDelegateDisabledTest, ComputeMetadata) { … }
TEST_F(FirstPartySetsAccessDelegateDisabledTest, FindEntries) { … }
class AsyncFirstPartySetsAccessDelegateTest
: public FirstPartySetsAccessDelegateTest { … };
TEST_F(AsyncFirstPartySetsAccessDelegateTest,
QueryBeforeReady_ComputeMetadata) { … }
TEST_F(AsyncFirstPartySetsAccessDelegateTest, QueryBeforeReady_FindEntries) { … }
TEST_F(AsyncFirstPartySetsAccessDelegateTest, OverrideSets_ComputeMetadata) { … }
TEST_F(AsyncFirstPartySetsAccessDelegateTest, OverrideSets_FindEntries) { … }
class SyncFirstPartySetsAccessDelegateTest
: public AsyncFirstPartySetsAccessDelegateTest { … };
TEST_F(SyncFirstPartySetsAccessDelegateTest, ComputeMetadata) { … }
TEST_F(SyncFirstPartySetsAccessDelegateTest, FindEntries) { … }
class FirstPartySetsAccessDelegateSetToDisabledTest
: public FirstPartySetsAccessDelegateTest { … };
TEST_F(FirstPartySetsAccessDelegateSetToDisabledTest,
DisabledThenReady_ComputeMetadata) { … }
TEST_F(FirstPartySetsAccessDelegateSetToDisabledTest,
DisabledThenReady_FindEntries) { … }
TEST_F(FirstPartySetsAccessDelegateSetToDisabledTest,
ReadyThenDisabled_ComputeMetadata) { … }
TEST_F(FirstPartySetsAccessDelegateSetToDisabledTest,
ReadyThenDisabled_FindEntries) { … }
class FirstPartySetsAccessDelegateSetToEnabledTest
: public FirstPartySetsAccessDelegateTest { … };
TEST_F(FirstPartySetsAccessDelegateSetToEnabledTest,
EnabledThenReady_ComputeMetadata) { … }
TEST_F(FirstPartySetsAccessDelegateSetToEnabledTest,
EnabledThenReady_FindEntries) { … }
TEST_F(FirstPartySetsAccessDelegateSetToEnabledTest,
ReadyThenEnabled_ComputeMetadata) { … }
TEST_F(FirstPartySetsAccessDelegateSetToEnabledTest,
ReadyThenEnabled_FindEntries) { … }
class AsyncNonwaitingFirstPartySetsAccessDelegateTest
: public FirstPartySetsAccessDelegateTest { … };
TEST_F(AsyncNonwaitingFirstPartySetsAccessDelegateTest,
QueryBeforeReady_ComputeMetadata) { … }
TEST_F(AsyncNonwaitingFirstPartySetsAccessDelegateTest,
QueryBeforeReady_FindEntries) { … }
TEST_F(AsyncNonwaitingFirstPartySetsAccessDelegateTest,
OverrideSets_ComputeMetadata) { … }
TEST_F(AsyncNonwaitingFirstPartySetsAccessDelegateTest,
OverrideSets_FindEntries) { … }
}