chromium/chrome/browser/media/media_engagement_service_unittest.cc

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

#include "chrome/browser/media/media_engagement_service.h"

#include <memory>
#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/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/media/media_engagement_score.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.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.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 "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/web_contents_tester.h"
#include "media/base/media_switches.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

base::FilePath g_temp_history_dir;

// History is automatically expired after 90 days.
base::TimeDelta kHistoryExpirationThreshold =;

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

base::Time GetReferenceTime() {}

std::unique_ptr<KeyedService> BuildTestHistoryService(
    scoped_refptr<base::SequencedTaskRunner> backend_runner,
    content::BrowserContext* context) {}

// Blocks until the HistoryBackend is completely destroyed, to ensure the
// destruction tasks do not interfere with a newer instance of
// HistoryService/HistoryBackend.
void BlockUntilHistoryBackendDestroyed(Profile* profile) {}

}  // namespace

class MediaEngagementServiceTest : public ChromeRenderViewHostTestHarness,
                                   public testing::WithParamInterface<bool> {};

TEST_P(MediaEngagementServiceTest, MojoSerialization) {}

TEST_P(MediaEngagementServiceTest, RestrictedToHTTPAndHTTPS) {}

TEST_P(MediaEngagementServiceTest,
       HandleRecordVisitAndPlaybackAndAdvanceClockion) {}

TEST_P(MediaEngagementServiceTest, IncognitoEngagementService) {}

TEST_P(MediaEngagementServiceTest, IncognitoOverrideRegularProfile) {}

TEST_P(MediaEngagementServiceTest, CleanupOriginsOnHistoryDeletion) {}

// The test is flaky: crbug.com/1042417.
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
#define MAYBE_CleanUpDatabaseWhenHistoryIsExpired
#else
#define MAYBE_CleanUpDatabaseWhenHistoryIsExpired
#endif
TEST_P(MediaEngagementServiceTest, MAYBE_CleanUpDatabaseWhenHistoryIsExpired) {}

TEST_P(MediaEngagementServiceTest, CleanUpDatabaseWhenHistoryIsDeleted) {}

TEST_P(MediaEngagementServiceTest, HistoryExpirationIsNoOp) {}

TEST_P(MediaEngagementServiceTest,
       CleanupDataOnSiteDataCleanup_OutsideBoundary) {}

TEST_P(MediaEngagementServiceTest,
       CleanupDataOnSiteDataCleanup_WithinBoundary) {}

TEST_P(MediaEngagementServiceTest, CleanupDataOnSiteDataCleanup_NoTimeSet) {}

TEST_P(MediaEngagementServiceTest, CleanupDataOnSiteDataCleanup_All) {}

TEST_P(MediaEngagementServiceTest, HasHighEngagement) {}

TEST_P(MediaEngagementServiceTest, SchemaVersion_Changed) {}

TEST_P(MediaEngagementServiceTest, SchemaVersion_Same) {}

INSTANTIATE_TEST_SUITE_P();

class MediaEngagementServiceEnabledTest
    : public ChromeRenderViewHostTestHarness {};

TEST_F(MediaEngagementServiceEnabledTest, IsEnabled) {}