#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;
BounceTuple;
EventTuple;
enum class UserGestureStatus { … };
constexpr auto kNoUserGesture = …;
constexpr auto kWithUserGesture = …;
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 { … };
TEST_F(DIPSBounceDetectorTest,
DetectStatefulRedirects_Before_ClientBounceDetectionTimeout) { … }
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) { … }
TEST_F(DIPSBounceDetectorTest,
ReportRedirectorsInChain_OmitSitesMatchingStartSite) { … }
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) { … }