chromium/base/metrics/histogram_unittest.cc

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

#include "base/metrics/histogram.h"

#include <limits.h>
#include <stddef.h>
#include <stdint.h>

#include <climits>
#include <memory>
#include <string>
#include <vector>

#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/bucket_ranges.h"
#include "base/metrics/dummy_histogram.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/metrics_hashes.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/metrics/persistent_memory_allocator.h"
#include "base/metrics/record_histogram_checker.h"
#include "base/metrics/sample_vector.h"
#include "base/metrics/statistics_recorder.h"
#include "base/pickle.h"
#include "base/strings/stringprintf.h"
#include "base/test/gtest_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {
namespace {

const char kExpiredHistogramName[] =;

// Test implementation of RecordHistogramChecker interface.
class TestRecordHistogramChecker : public RecordHistogramChecker {};

}  // namespace

// Test parameter indicates if a persistent memory allocator should be used
// for histogram allocation. False will allocate histograms from the process
// heap.
class HistogramTest : public testing::TestWithParam<bool> {};

// Run all HistogramTest cases with both heap and persistent memory.
INSTANTIATE_TEST_SUITE_P();

// Check for basic syntax and use.
TEST_P(HistogramTest, BasicTest) {}

// Check that the macro correctly matches histograms by name and records their
// data together.
TEST_P(HistogramTest, NameMatchTest) {}

// Check that delta calculations work correctly.
TEST_P(HistogramTest, DeltaTest) {}

// Check that delta calculations work correctly with SnapshotUnloggedSamples()
// and MarkSamplesAsLogged().
TEST_P(HistogramTest, UnloggedSamplesTest) {}

// Check that final-delta calculations work correctly.
TEST_P(HistogramTest, FinalDeltaTest) {}

// Check that IsDefinitelyEmpty() works with the results of SnapshotDelta().
TEST_P(HistogramTest, IsDefinitelyEmpty_SnapshotDelta) {}

TEST_P(HistogramTest, ExponentialRangesTest) {}

TEST_P(HistogramTest, LinearRangesTest) {}

TEST_P(HistogramTest, SingleValueEnumerationHistogram) {}

TEST_P(HistogramTest, ArrayToCustomEnumRangesTest) {}

TEST_P(HistogramTest, CustomHistogramTest) {}

TEST_P(HistogramTest, CustomHistogramWithOnly2Buckets) {}

TEST_P(HistogramTest, AddCountTest) {}

TEST_P(HistogramTest, AddCount_LargeValuesDontOverflow) {}

// Some metrics are designed so that they are guaranteed not to overflow between
// snapshots, but could overflow over a long-running session.
// Make sure that counts returned by Histogram::SnapshotDelta do not overflow
// even when a total count (returned by Histogram::SnapshotSample) does.
TEST_P(HistogramTest, AddCount_LargeCountsDontOverflow) {}

// Make sure histogram handles out-of-bounds data gracefully.
TEST_P(HistogramTest, BoundsTest) {}

// Check to be sure samples land as expected is "correct" buckets.
TEST_P(HistogramTest, BucketPlacementTest) {}

TEST_P(HistogramTest, CorruptSampleCounts) {}

TEST_P(HistogramTest, CorruptBucketBounds) {}

TEST_P(HistogramTest, HistogramSerializeInfo) {}

TEST_P(HistogramTest, CustomHistogramSerializeInfo) {}

TEST_P(HistogramTest, BadConstruction) {}

TEST_P(HistogramTest, FactoryTime) {}

TEST_P(HistogramTest, ScaledLinearHistogram) {}

// For Histogram, LinearHistogram and CustomHistogram, the minimum for a
// declared range is 1, while the maximum is (HistogramBase::kSampleType_MAX -
// 1). But we accept ranges exceeding those limits, and silently clamped to
// those limits. This is for backwards compatibility.
TEST(HistogramDeathTest, BadRangesTest) {}

TEST_P(HistogramTest, ExpiredHistogramTest) {}

TEST_P(HistogramTest, CheckGetCountAndBucketData) {}

TEST_P(HistogramTest, WriteAscii) {}

TEST_P(HistogramTest, ToGraphDict) {}

// Tests ToGraphDict() returns deterministic length size and normalizes to
// scale.
TEST_P(HistogramTest, ToGraphDictNormalize) {}

}  // namespace base