chromium/chrome/browser/engagement/site_engagement_service_unittest.cc

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

#include "components/site_engagement/content/site_engagement_service.h"

#include <algorithm>
#include <map>
#include <string>
#include <utility>

#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/simple_test_clock.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/engagement/history_aware_site_engagement_service.h"
#include "chrome/browser/engagement/site_engagement_service_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
#include "components/content_settings/core/browser/content_settings_observer.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_types.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/prefs/pref_service.h"
#include "components/site_engagement/content/engagement_type.h"
#include "components/site_engagement/content/site_engagement_helper.h"
#include "components/site_engagement/content/site_engagement_metrics.h"
#include "components/site_engagement/content/site_engagement_observer.h"
#include "components/site_engagement/content/site_engagement_score.h"
#include "components/site_engagement/core/pref_names.h"
#include "components/webapps/common/web_app_id.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"

NavigationSimulator;

namespace site_engagement {

namespace {

base::FilePath g_temp_history_dir;

const double kMaxRoundingDeviation =;

// Waits until a change is observed in site engagement content settings.
class SiteEngagementChangeWaiter : public content_settings::Observer {};

base::Time GetReferenceTime() {}

std::unique_ptr<KeyedService> BuildTestHistoryService(
    content::BrowserContext* context) {}

std::unique_ptr<KeyedService> BuildTestSiteEngagementService(
    content::BrowserContext* context) {}

}  // namespace

class ObserverTester : public SiteEngagementObserver {};

class SiteEngagementServiceTest : public ChromeRenderViewHostTestHarness {};

TEST_F(SiteEngagementServiceTest, GetMedianEngagement) {}

// Tests that the Site Engagement service is hooked up properly to navigations
// by performing two navigations and checking the engagement score increases
// both times.
TEST_F(SiteEngagementServiceTest, ScoreIncrementsOnPageRequest) {}

// Expect that site engagement scores for several sites are correctly
// aggregated during navigation events.
TEST_F(SiteEngagementServiceTest, GetTotalNavigationPoints) {}

TEST_F(SiteEngagementServiceTest, GetTotalUserInputPoints) {}

TEST_F(SiteEngagementServiceTest, GetTotalNotificationPoints) {}

// TODO(crbug.com/40899584): Fix and enable this test.
TEST_F(SiteEngagementServiceTest, DISABLED_RestrictedToHTTPAndHTTPS) {}

TEST_F(SiteEngagementServiceTest, LastShortcutLaunch) {}

// TODO(crbug.com/40724963): Flaky test.
TEST_F(SiteEngagementServiceTest, DISABLED_CheckHistograms) {}

// Expect that sites that have reached zero engagement are cleaned up. Expect
// engagement times to be reset if too much time has passed since the last
// engagement.
TEST_F(SiteEngagementServiceTest, CleanupEngagementScores) {}

TEST_F(SiteEngagementServiceTest, CleanupEngagementScoresProportional) {}

// Tests behavior of CleanupEngagementScores() with a very short
// DECAY_PERIOD_IN_HOURS.
TEST_F(SiteEngagementServiceTest, CleanupEngagementScoresShortDecayPeriod) {}

TEST_F(SiteEngagementServiceTest, NavigationAccumulation) {}

TEST_F(SiteEngagementServiceTest, IsBootstrapped) {}

TEST_F(SiteEngagementServiceTest, CleanupOriginsOnHistoryDeletion) {}

TEST_F(SiteEngagementServiceTest, EngagementLevel) {}

TEST_F(SiteEngagementServiceTest, Observers) {}

TEST_F(SiteEngagementServiceTest, LastEngagementTime) {}

TEST_F(SiteEngagementServiceTest, CleanupMovesScoreBackToNow) {}

TEST_F(SiteEngagementServiceTest, CleanupMovesScoreBackToRebase) {}

TEST_F(SiteEngagementServiceTest, IncognitoEngagementService) {}

TEST_F(SiteEngagementServiceTest, GetScoreFromSettings) {}

TEST_F(SiteEngagementServiceTest, GetAllDetailsIncludesBonusOnlyScores) {}

TEST_F(SiteEngagementServiceTest, GetAllDetailsFilterByURLSets) {}

}  // namespace site_engagement