chromium/components/browsing_topics/browsing_topics_calculator_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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/browsing_topics/browsing_topics_calculator.h"

#include <memory>

#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "base/strings/strcat.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 "components/browsing_topics/test_util.h"
#include "components/browsing_topics/util.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/history/core/browser/history_database_params.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/test/test_history_database.h"
#include "components/optimization_guide/core/test_model_info_builder.h"
#include "components/privacy_sandbox/privacy_sandbox_prefs.h"
#include "components/privacy_sandbox/privacy_sandbox_settings_impl.h"
#include "components/privacy_sandbox/privacy_sandbox_test_util.h"
#include "components/privacy_sandbox/tracking_protection_settings.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/browsing_topics_test_util.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "third_party/blink/public/common/features.h"

namespace browsing_topics {

namespace {

constexpr int kTaxonomyVersion =;

constexpr char kHost1[] =;
constexpr char kHost2[] =;
constexpr char kHost3[] =;
constexpr char kHost4[] =;
constexpr char kHost5[] =;
constexpr char kHost6[] =;

Topic ExpectedRandomTopic(size_t index) {}

class TestHistoryService : public history::HistoryService {};

}  // namespace

class BrowsingTopicsCalculatorTest : public testing::Test {};

TEST_F(BrowsingTopicsCalculatorTest, PermissionDenied) {}

TEST_F(BrowsingTopicsCalculatorTest, ApiUsageContextQueryError) {}

TEST_F(BrowsingTopicsCalculatorTest, AnnotationExecutionError) {}

class BrowsingTopicsCalculatorUnsupporedTaxonomyVersionTest
    : public BrowsingTopicsCalculatorTest {};

TEST_F(BrowsingTopicsCalculatorUnsupporedTaxonomyVersionTest,
       TaxonomyVersionNotSupportedInBinary) {}

TEST_F(BrowsingTopicsCalculatorTest, HangingAfterApiUsageRequested) {}

TEST_F(BrowsingTopicsCalculatorTest, HangingAfterHistoryRequested) {}

TEST_F(BrowsingTopicsCalculatorTest, HangingAfterModelRequested) {}

TEST_F(BrowsingTopicsCalculatorTest, HangingAfterAnnotationRequested) {}

TEST_F(BrowsingTopicsCalculatorTest,
       SlowHistoryQueryAndHangingAfterModelRequested) {}

TEST_F(BrowsingTopicsCalculatorTest, TimeoutRetrySuccessMetrics) {}

TEST_F(BrowsingTopicsCalculatorTest, TimeoutRetryHangingMetrics) {}

TEST_F(BrowsingTopicsCalculatorTest, TerminatedBeforeComplete) {}

TEST_F(BrowsingTopicsCalculatorTest, TopicsMetadata) {}

// Regression test for crbug/1495959.
TEST_F(BrowsingTopicsCalculatorTest, ModelAvailableAfterDelay) {}

TEST_F(BrowsingTopicsCalculatorTest, TopTopicsRankedByFrequency) {}

TEST_F(BrowsingTopicsCalculatorTest, ModelHasNoTopicsForHost) {}

TEST_F(BrowsingTopicsCalculatorTest,
       TopTopicsRankedByFrequency_AlsoAffectedByHostsCount) {}

TEST_F(BrowsingTopicsCalculatorTest, AllTopTopicsRandomlyPadded) {}

TEST_F(BrowsingTopicsCalculatorTest, TopTopicsPartiallyPadded) {}

TEST_F(BrowsingTopicsCalculatorTest, CalculationResultUkm_FailedCalculation) {}

TEST_F(BrowsingTopicsCalculatorTest, CalculationResultUkm) {}

TEST_F(BrowsingTopicsCalculatorTest, TopTopicsAndObservingDomains) {}

TEST_F(
    BrowsingTopicsCalculatorTest,
    HistoryHostsBefore21DaysAgo_IgnoredForTopTopicsDecision_IgnoredForObservingDomainsDecision) {}

TEST_F(
    BrowsingTopicsCalculatorTest,
    HistoryHostsBetween7And21Days_IgnoredForTopTopicsDecision_ConsideredForObservingDomainsDecision) {}

TEST_F(BrowsingTopicsCalculatorTest,
       DataQueryBoundedByTopicsDataAccessibleSince) {}

TEST_F(BrowsingTopicsCalculatorTest,
       HistoryDataBoundedByLastEpochCalculationTime) {}

TEST_F(BrowsingTopicsCalculatorTest,
       HistoryDataAndApiUsageContextDataBoundedByPriorEpochsCalculationTime) {}

TEST_F(BrowsingTopicsCalculatorTest,
       TopTopicsAndObservingDomains_DomainsSizeExceedsLimit) {}

TEST_F(BrowsingTopicsCalculatorTest, TopicBlocked) {}

TEST_F(BrowsingTopicsCalculatorTest, TopicBlockedByFinch) {}

TEST_F(BrowsingTopicsCalculatorTest, TopicsPrioritizedByFinch) {}

TEST_F(BrowsingTopicsCalculatorTest, PaddedTopicsDoNotDuplicate) {}

TEST_F(BrowsingTopicsCalculatorTest, Metrics_LessThan5HistoryTopics) {}

TEST_F(BrowsingTopicsCalculatorTest, Metrics_MoreThan5HistoryTopics) {}

TEST_F(BrowsingTopicsCalculatorTest, NoDescendantTopics) {}

TEST_F(BrowsingTopicsCalculatorTest, DescendantTopicIsBlocked) {}

TEST_F(BrowsingTopicsCalculatorTest, TopicHasDistantDescendant) {}

TEST_F(BrowsingTopicsCalculatorTest, MultipleTopTopicsHaveDescendants) {}

}  // namespace browsing_topics