chromium/components/metrics/file_metrics_provider_unittest.cc

// Copyright 2016 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/metrics/file_metrics_provider.h"

#include <memory>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/memory_mapped_file.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_flattener.h"
#include "base/metrics/histogram_snapshot_manager.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/metrics/persistent_memory_allocator.h"
#include "base/metrics/sparse_histogram.h"
#include "base/metrics/statistics_recorder.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "components/metrics/metrics_log.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/metrics/persistent_system_profile.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/metrics_proto/chrome_user_metrics_extension.pb.h"
#include "third_party/metrics_proto/system_profile.pb.h"

namespace {
const char kMetricsName[] =;
const char kMergedCountHistogramName[] =;
const char kMetricsFilename[] =;

void WriteSystemProfileToAllocator(
    base::PersistentHistogramAllocator* allocator) {}
}  // namespace

namespace metrics {

class HistogramFlattenerDeltaRecorder : public base::HistogramFlattener {};

// Exactly the same as FileMetricsProvider, but provides a way to "hook" into
// RecordSourcesChecked() and run a callback each time it is called so that it
// is easier to individually verify the sources being merged.
class TestFileMetricsProvider : public FileMetricsProvider {};

class FileMetricsProviderTest : public testing::TestWithParam<bool> {};

// Run all test cases with both small and large files.
INSTANTIATE_TEST_SUITE_P();

TEST_P(FileMetricsProviderTest, AccessMetrics) {}

TEST_P(FileMetricsProviderTest, AccessTimeLimitedFile) {}

TEST_P(FileMetricsProviderTest, FilterDelaysFile) {}

TEST_P(FileMetricsProviderTest, FilterSkipsFile) {}

TEST_P(FileMetricsProviderTest, AccessDirectory) {}

TEST_P(FileMetricsProviderTest, AccessDirectoryWithInvalidFiles) {}

TEST_P(FileMetricsProviderTest, AccessTimeLimitedDirectory) {}

TEST_P(FileMetricsProviderTest, AccessCountLimitedDirectory) {}

TEST_P(FileMetricsProviderTest, AccessSizeLimitedDirectory) {}

TEST_P(FileMetricsProviderTest, AccessFilteredDirectory) {}

TEST_P(FileMetricsProviderTest, AccessReadWriteMetrics) {}

TEST_P(FileMetricsProviderTest, AccessInitialMetrics) {}

TEST_P(FileMetricsProviderTest, AccessEmbeddedProfileMetricsWithoutProfile) {}

TEST_P(FileMetricsProviderTest, AccessEmbeddedProfileMetricsWithProfile) {}

TEST_P(FileMetricsProviderTest, AccessEmbeddedFallbackMetricsWithoutProfile) {}

TEST_P(FileMetricsProviderTest, AccessEmbeddedFallbackMetricsWithProfile) {}

TEST_P(FileMetricsProviderTest, AccessEmbeddedProfileMetricsFromDir) {}

TEST_P(FileMetricsProviderTest,
       RecordInitialHistogramSnapshotsStabilityHistograms) {}

TEST_P(FileMetricsProviderTest, IndependentLogContainsUmaHistograms) {}

// Verifies that if the embedded system profile in the file does not contain
// a client UUID, the generated independent log's client ID is not overwritten.
TEST_P(FileMetricsProviderTest, EmbeddedProfileWithoutClientUuid) {}

// Verifies that if the embedded system profile in the file contains a client
// UUID, it is used as the generated independent log's client ID.
TEST_P(FileMetricsProviderTest, EmbeddedProfileWithClientUuid) {}

TEST_P(FileMetricsProviderTest, MetricsDisabledRegisterAtomicFile) {}

TEST_P(FileMetricsProviderTest, MetricsDisabledRegisterAtomicDir) {}

TEST_P(FileMetricsProviderTest, MetricsDisabledRegisterActiveFile) {}

}  // namespace metrics