chromium/chrome/browser/dips/dips_bounce_detector_unittest.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/dips/dips_bounce_detector.h"

#include <string_view>
#include <tuple>

#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/strcat.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "base/types/pass_key.h"
#include "chrome/browser/dips/dips_service.h"
#include "chrome/browser/dips/dips_test_utils.h"
#include "chrome/browser/dips/dips_utils.h"
#include "components/content_settings/core/common/features.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/common/content_features.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

Bucket;
PassKey;
AllOf;
ElementsAre;
Eq;
Gt;
IsEmpty;
Pair;
SizeIs;

// Encodes data about a bounce (the url, time of bounce, and
// whether it's stateful) for use when testing that the bounce is
// recorded by the DIPSBounceDetector.
BounceTuple;
// Encodes data about an event recorded by DIPS event (the url, time of
// bounce, and type of event) for use when testing that the event is recorded
// by the DIPSBounceDetector.
EventTuple;

enum class UserGestureStatus {};
constexpr auto kNoUserGesture =;
constexpr auto kWithUserGesture =;

// Returns a simplified URL representation for ease of comparison in tests.
// Just host+path.
std::string FormatURL(const GURL& url) {}

void AppendRedirect(std::vector<std::string>* redirects,
                    const DIPSRedirectInfo& redirect,
                    const DIPSRedirectChainInfo& chain) {}

std::string URLForRedirectSourceId(ukm::TestUkmRecorder* ukm_recorder,
                                   ukm::SourceId source_id) {}

class FakeNavigation;

class TestBounceDetectorDelegate : public DIPSBounceDetectorDelegate {};

class FakeNavigation : public DIPSNavigationHandle {};

class DIPSBounceDetectorTest : public ::testing::Test {};

// Ensures that for every navigation, a client redirect occurring before
// `dips:kClientBounceDetectionTimeout` is considered a bounce whilst leaving
// Server redirects unaffected.
TEST_F(DIPSBounceDetectorTest,
       DetectStatefulRedirects_Before_ClientBounceDetectionTimeout) {}

// Ensures that for every navigation, a client redirect occurring after
// `dips:kClientBounceDetectionTimeout` is not considered a bounce whilst server
// redirects are unaffected.
TEST_F(DIPSBounceDetectorTest,
       DetectStatefulRedirects_After_ClientBounceDetectionTimeout) {}

TEST_F(DIPSBounceDetectorTest, DetectStatefulRedirect_Server) {}

TEST_F(DIPSBounceDetectorTest, DetectStatefulRedirect_Server_OnStartUp) {}

TEST_F(DIPSBounceDetectorTest, DetectStatefulRedirect_Server_LateNotification) {}

TEST_F(DIPSBounceDetectorTest, DetectStatefulRedirect_Client) {}

TEST_F(DIPSBounceDetectorTest, DetectStatefulRedirect_Client_OnStartUp) {}

TEST_F(DIPSBounceDetectorTest, DetectStatefulRedirect_Client_MergeCookies) {}

TEST_F(DIPSBounceDetectorTest, DetectStatefulRedirect_ServerClientServer) {}

TEST_F(DIPSBounceDetectorTest, DetectStatefulRedirect_Server_Uncommitted) {}

TEST_F(DIPSBounceDetectorTest, DetectStatefulRedirect_Client_Uncommitted) {}

TEST_F(DIPSBounceDetectorTest,
       ReportRedirectorsInChain_OnEachFinishedNavigation) {}

TEST_F(DIPSBounceDetectorTest,
       ReportRedirectorsInChain_IncludingUncommittedNavigations) {}

TEST_F(DIPSBounceDetectorTest,
       ReportRedirectorsInChain_OmitNonStatefulRedirects) {}

// This test verifies that sites in a redirect chain that are the same as the
// starting site (i.e., last site before the redirect chain started) are not
// reported.
TEST_F(DIPSBounceDetectorTest,
       ReportRedirectorsInChain_OmitSitesMatchingStartSite) {}

// This test verifies that sites in a (server) redirect chain that are the same
// as the ending site of a navigation are not reported.
TEST_F(DIPSBounceDetectorTest,
       ReportRedirectorsInChain_OmitSitesMatchingEndSite) {}

TEST_F(DIPSBounceDetectorTest,
       ReportRedirectorsInChain_OmitSitesMatchingEndSite_Uncommitted) {}

const std::vector<std::string>& GetAllRedirectMetrics() {}

TEST_F(DIPSBounceDetectorTest, Histograms_UMA) {}

TEST_F(DIPSBounceDetectorTest, Histograms_UKM) {}

TEST_F(DIPSBounceDetectorTest, SiteHadUserActivation) {}

TEST_F(DIPSBounceDetectorTest, ClientCookieAccessDuringNavigation) {}

ChainPair;

void AppendChainPair(std::vector<ChainPair>& vec,
                     std::vector<DIPSRedirectInfoPtr> redirects,
                     DIPSRedirectChainInfoPtr chain) {}

std::vector<DIPSRedirectInfoPtr> MakeServerRedirects(
    std::vector<std::string> urls,
    SiteDataAccessType access_type = SiteDataAccessType::kReadWrite) {}

DIPSRedirectInfoPtr MakeClientRedirect(
    std::string url,
    SiteDataAccessType access_type = SiteDataAccessType::kReadWrite,
    bool has_sticky_activation = false) {}

MATCHER_P(HasUrl, url, "") {}

MATCHER_P(HasRedirectType, redirect_type, "") {}

MATCHER_P(HasSiteDataAccessType, access_type, "") {}

MATCHER_P(HasInitialUrl, url, "") {}

MATCHER_P(HasFinalUrl, url, "") {}

MATCHER_P(HasLength, length, "") {}

TEST(DIPSRedirectContextTest, OneAppend) {}

TEST(DIPSRedirectContextTest, TwoAppends_NoClientRedirect) {}

TEST(DIPSRedirectContextTest, TwoAppends_WithClientRedirect) {}

TEST(DIPSRedirectContextTest, OnlyClientRedirects) {}

TEST(DIPSRedirectContextTest, OverflowMaxChain_TrimsFromFront) {}

TEST(DIPSRedirectContextTest, Uncommitted_NoClientRedirects) {}

TEST(DIPSRedirectContextTest, Uncommitted_IncludingClientRedirects) {}

TEST(DIPSRedirectContextTest, NoRedirects) {}

TEST(DIPSRedirectContextTest, AddLateCookieAccess) {}

TEST(DIPSRedirectContextTest, GetRedirectHeuristicURLs_NoRequirements) {}

TEST(DIPSRedirectContextTest, GetRedirectHeuristicURLs_RequireABAFlow) {}

TEST(DIPSRedirectContextTest,
     GetRedirectHeuristicURLs_RequireCurrentInteraction) {}