chromium/services/preferences/tracked/pref_hash_filter_unittest.cc

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

#include "services/preferences/tracked/pref_hash_filter.h"

#include <stddef.h>

#include <map>
#include <memory>
#include <set>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/statistics_recorder.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "components/prefs/testing_pref_store.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/preferences/public/cpp/tracked/configuration.h"
#include "services/preferences/public/cpp/tracked/mock_validation_delegate.h"
#include "services/preferences/public/cpp/tracked/pref_names.h"
#include "services/preferences/tracked/hash_store_contents.h"
#include "services/preferences/tracked/pref_hash_store.h"
#include "services/preferences/tracked/pref_hash_store_transaction.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

EnforcementLevel;
PrefTrackingStrategy;
ValueType;
ValueState;

const char kAtomicPref[] =;
const char kAtomicPref2[] =;
const char kAtomicPref3[] =;
const char kAtomicPref4[] =;
const char kDeprecatedTrackedDictionaryEntry[] =;
const char kDeprecatedUntrackedDictionary[] =;
const char kReportOnlyPref[] =;
const char kReportOnlySplitPref[] =;
const char kSplitPref[] =;

const prefs::TrackedPreferenceMetadata kTestTrackedPrefs[] =;

}  // namespace

// A PrefHashStore that allows simulation of CheckValue results and captures
// checked and stored values.
class MockPrefHashStore : public PrefHashStore {};

void MockPrefHashStore::SetCheckResult(const std::string& path,
                                       ValueState result) {}

void MockPrefHashStore::SetInvalidKeysResult(
    const std::string& path,
    const std::vector<std::string>& invalid_keys_result) {}

std::unique_ptr<PrefHashStoreTransaction> MockPrefHashStore::BeginTransaction(
    HashStoreContents* storage) {}

std::string MockPrefHashStore::ComputeMac(const std::string& path,
                                          const base::Value* new_value) {}

base::Value::Dict MockPrefHashStore::ComputeSplitMacs(
    const std::string& path,
    const base::Value::Dict* split_values) {}

ValueState MockPrefHashStore::RecordCheckValue(const std::string& path,
                                               const void* value,
                                               PrefTrackingStrategy strategy) {}

void MockPrefHashStore::RecordStoreHash(const std::string& path,
                                        const void* new_value,
                                        PrefTrackingStrategy strategy) {}

void MockPrefHashStore::ClearStoreHash(const std::string& path) {}

std::string_view
MockPrefHashStore::MockPrefHashStoreTransaction ::GetStoreUMASuffix() const {}

ValueState MockPrefHashStore::MockPrefHashStoreTransaction::CheckValue(
    const std::string& path,
    const base::Value* value) const {}

void MockPrefHashStore::MockPrefHashStoreTransaction::StoreHash(
    const std::string& path,
    const base::Value* new_value) {}

ValueState MockPrefHashStore::MockPrefHashStoreTransaction::CheckSplitValue(
    const std::string& path,
    const base::Value::Dict* initial_split_value,
    std::vector<std::string>* invalid_keys) const {}

void MockPrefHashStore::MockPrefHashStoreTransaction::StoreSplitHash(
    const std::string& path,
    const base::Value::Dict* new_value) {}

bool MockPrefHashStore::MockPrefHashStoreTransaction::HasHash(
    const std::string& path) const {}

void MockPrefHashStore::MockPrefHashStoreTransaction::ImportHash(
    const std::string& path,
    const base::Value* hash) {}

void MockPrefHashStore::MockPrefHashStoreTransaction::ClearHash(
    const std::string& path) {}

bool MockPrefHashStore::MockPrefHashStoreTransaction::IsSuperMACValid() const {}

bool MockPrefHashStore::MockPrefHashStoreTransaction::StampSuperMac() {}

std::vector<prefs::mojom::TrackedPreferenceMetadataPtr> GetConfiguration(
    EnforcementLevel max_enforcement_level) {}

class MockHashStoreContents : public HashStoreContents {};

std::string MockHashStoreContents::GetStoredMac(const std::string& path) const {}

std::string MockHashStoreContents::GetStoredSplitMac(
    const std::string& path,
    const std::string& split_path) const {}

MockHashStoreContents::MockHashStoreContents(MockHashStoreContents* origin_mock)
    :{}

bool MockHashStoreContents::IsCopyable() const {}

std::unique_ptr<HashStoreContents> MockHashStoreContents::MakeCopy() const {}

std::string_view MockHashStoreContents::GetUMASuffix() const {}

void MockHashStoreContents::Reset() {}

bool MockHashStoreContents::GetMac(const std::string& path,
                                   std::string* out_value) {}

bool MockHashStoreContents::GetSplitMacs(
    const std::string& path,
    std::map<std::string, std::string>* split_macs) {}

void MockHashStoreContents::SetMac(const std::string& path,
                                   const std::string& value) {}

void MockHashStoreContents::SetSplitMac(const std::string& path,
                                        const std::string& split_path,
                                        const std::string& value) {}

void MockHashStoreContents::ImportEntry(const std::string& path,
                                        const base::Value* in_value) {}

bool MockHashStoreContents::RemoveEntry(const std::string& path) {}

const base::Value::Dict* MockHashStoreContents::GetContents() const {}

std::string MockHashStoreContents::GetSuperMac() const {}

void MockHashStoreContents::SetSuperMac(const std::string& super_mac) {}

class PrefHashFilterTest : public testing::TestWithParam<EnforcementLevel>,
                           public prefs::mojom::ResetOnLoadObserver {};

TEST_P(PrefHashFilterTest, EmptyAndUnchanged) {}

TEST_P(PrefHashFilterTest, StampSuperMACAltersStore) {}

TEST_P(PrefHashFilterTest, FilterTrackedPrefUpdate) {}

TEST_P(PrefHashFilterTest, FilterTrackedPrefClearing) {}

TEST_P(PrefHashFilterTest, FilterSplitPrefUpdate) {}

TEST_P(PrefHashFilterTest, FilterTrackedSplitPrefClearing) {}

TEST_P(PrefHashFilterTest, FilterUntrackedPrefUpdate) {}

TEST_P(PrefHashFilterTest, MultiplePrefsFilterSerializeData) {}

TEST_P(PrefHashFilterTest, UnknownNullValue) {}

TEST_P(PrefHashFilterTest, InitialValueUnknown) {}

TEST_P(PrefHashFilterTest, InitialValueTrustedUnknown) {}

TEST_P(PrefHashFilterTest, InitialValueChanged) {}

TEST_P(PrefHashFilterTest, EmptyCleared) {}

TEST_P(PrefHashFilterTest, InitialValueUnchangedLegacyId) {}

TEST_P(PrefHashFilterTest, DontResetReportOnly) {}

TEST_P(PrefHashFilterTest, CallFilterSerializeDataCallbacks) {}

TEST_P(PrefHashFilterTest, CallFilterSerializeDataCallbacksWithFailure) {}

TEST_P(PrefHashFilterTest, ExternalValidationValueChanged) {}

TEST_P(PrefHashFilterTest, CleanupDeprecatedTrackedDictionary) {}

INSTANTIATE_TEST_SUITE_P();