#include "components/history_clusters/core/history_clusters_service.h"
#include <memory>
#include <string>
#include <vector>
#include "base/files/scoped_temp_dir.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/history/core/browser/history_context.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/history_types.h"
#include "components/history/core/browser/url_row.h"
#include "components/history/core/test/history_service_test_util.h"
#include "components/history/core/test/visit_annotations_test_utils.h"
#include "components/history_clusters/core/clustering_backend.h"
#include "components/history_clusters/core/config.h"
#include "components/history_clusters/core/features.h"
#include "components/history_clusters/core/history_clusters_db_tasks.h"
#include "components/history_clusters/core/history_clusters_prefs.h"
#include "components/history_clusters/core/history_clusters_service_task_get_most_recent_clusters.h"
#include "components/history_clusters/core/history_clusters_service_task_update_clusters.h"
#include "components/history_clusters/core/history_clusters_service_test_api.h"
#include "components/history_clusters/core/history_clusters_types.h"
#include "components/history_clusters/core/history_clusters_util.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace history_clusters {
base::Time DaysAgo(int days) { … }
class TestClusteringBackend : public ClusteringBackend { … };
class HistoryClustersServiceTest : public testing::Test { … };
TEST_F(HistoryClustersServiceTest, EligibleAndEnabledHistogramRecorded) { … }
TEST_F(HistoryClustersServiceTest, HardCapOnVisitsFetchedFromHistory) { … }
TEST_F(HistoryClustersServiceTest, QueryClusters_IncompleteAndPersistedVisits) { … }
TEST_F(HistoryClustersServiceTest,
QueryClusters_PersistedClusters_NoMixedDays) { … }
TEST_F(HistoryClustersServiceTest,
QueryClusters_PersistedClusters_UseNavigationContextClusters) { … }
TEST_F(HistoryClustersServiceTest, QueryClusters_PersistedClusters_Today) { … }
TEST_F(HistoryClustersServiceTest, QueryClusters_PersistedClusters_MixedDay) { … }
TEST_F(HistoryClustersServiceTest, QueryVisits_OldestFirst) { … }
TEST_F(HistoryClustersServiceTest, QueryClusteredVisits) { … }
TEST_F(HistoryClustersServiceTest, EndToEndWithBackend) { … }
TEST_F(HistoryClustersServiceTest, CompleteVisitContextAnnotationsIfReady) { … }
TEST_F(HistoryClustersServiceTest,
CompleteVisitContextAnnotationsIfReadyWhenFeatureEnabled) { … }
class HistoryClustersServiceKeywordTest : public HistoryClustersServiceTest { … };
TEST_F(HistoryClustersServiceKeywordTest, DoesQueryMatchAnyCluster) { … }
TEST_F(HistoryClustersServiceKeywordTest,
DoesQueryMatchAnyClusterSecondaryCacheNavigationContextClusters) { … }
TEST_F(HistoryClustersServiceKeywordTest, LoadCachesFromPrefs) { … }
TEST_F(HistoryClustersServiceKeywordTest, LoadSecondaryCachesFromPrefs) { … }
TEST_F(HistoryClustersServiceKeywordTest,
DoesQueryMatchAnyClusterMaxKeywordPhrases) { … }
class HistoryClustersServiceJourneysDisabledTest
: public HistoryClustersServiceTest { … };
TEST_F(HistoryClustersServiceJourneysDisabledTest,
CompleteVisitContextAnnotationsIfReadyWhenFeatureDisabled) { … }
TEST_F(HistoryClustersServiceJourneysDisabledTest, QueryClusters) { … }
TEST_F(HistoryClustersServiceTest, UpdateClusters_Sparse) { … }
TEST_F(HistoryClustersServiceTest, UpdateClusters_Reclustering) { … }
TEST_F(HistoryClustersServiceTest, UpdateClusters_ReclusterMultipleClusters) { … }
TEST_F(HistoryClustersServiceTest, UpdateClusters_PopularDay) { … }
}