#include "components/history/core/browser/history_service.h"
#include <stdint.h>
#include <algorithm>
#include <array>
#include <memory>
#include <string>
#include <utility>
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.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 "components/history/core/browser/features.h"
#include "components/history/core/browser/history_backend.h"
#include "components/history/core/browser/history_client.h"
#include "components/history/core/browser/history_database_params.h"
#include "components/history/core/browser/history_db_task.h"
#include "components/history/core/browser/history_types.h"
#include "components/history/core/browser/visit_delegate.h"
#include "components/history/core/test/database_test_utils.h"
#include "components/history/core/test/test_history_database.h"
#include "components/visitedlink/core/visited_link.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace history {
class TestVisitDelegate : public VisitDelegate { … };
void TestVisitDelegate::AddVisitedLink(const VisitedLink& link) { … }
class HistoryServiceTest : public testing::Test { … };
TEST_F(HistoryServiceTest, RemoveNotification) { … }
TEST_F(HistoryServiceTest, AddPage) { … }
TEST_F(HistoryServiceTest, AddRedirect) { … }
TEST_F(HistoryServiceTest, MakeIntranetURLsTyped) { … }
TEST_F(HistoryServiceTest, Typed) { … }
TEST_F(HistoryServiceTest, SetTitle) { … }
TEST_F(HistoryServiceTest, MostVisitedURLs) { … }
TEST_F(HistoryServiceTest, QueryMostRepeatedQueriesForKeyword) { … }
namespace {
class HistoryDBTaskImpl : public HistoryDBTask { … };
const int HistoryDBTaskImpl::kWantInvokeCount = …;
}
TEST_F(HistoryServiceTest, HistoryDBTask) { … }
TEST_F(HistoryServiceTest, HistoryDBTaskCanceled) { … }
void AddPageAtTime(HistoryService* history,
const std::string& url_spec,
base::Time time_in_the_past) { … }
void AddPageInThePast(HistoryService* history,
const std::string& url_spec,
int days_back) { … }
void AddSyncedPageInThePast(HistoryService* history,
const std::string& url_spec,
int days_back) { … }
base::Time GetTimeInThePast(base::Time base_time,
int days_back,
int hours_since_midnight,
int minutes = 0,
int seconds = 0) { … }
int GetMonthlyHostCountHelper(HistoryService* history,
base::CancelableTaskTracker* tracker) { … }
std::pair<DomainDiversityResults, DomainDiversityResults>
GetDomainDiversityHelper(HistoryService* history,
base::Time begin_time,
base::Time end_time,
DomainMetricBitmaskType metric_type_bitmask,
base::CancelableTaskTracker* tracker) { … }
void TestDomainMetric(const std::optional<DomainMetricCountType>& metric,
int expected) { … }
void TestDomainMetricSet(const DomainMetricSet& metric_set,
int expected_one_day_metric,
int expected_seven_day_metric,
int expected_twenty_eight_day_metric) { … }
TEST_F(HistoryServiceTest, CountMonthlyVisitedHosts) { … }
TEST_F(HistoryServiceTest, GetDomainDiversityShortBasetimeRange) { … }
TEST_F(HistoryServiceTest, GetDomainDiversityLongBasetimeRange) { … }
TEST_F(HistoryServiceTest, GetDomainDiversityBitmaskTest) { … }
TEST_F(HistoryServiceTest, GetUniqueDomainsVisited) { … }
namespace {
class AddSyncedVisitTask : public HistoryDBTask { … };
}
TEST_F(HistoryServiceTest, GetDomainDiversityLocalVsSynced) { … }
TEST_F(HistoryServiceTest, GetMostRecentVisitsForGurl) { … }
class OrderingHistoryServiceTest : public HistoryServiceTest { … };
TEST_F(OrderingHistoryServiceTest, EnsureCorrectOrder) { … }
}