chromium/components/metrics/call_stacks/call_stack_profile_metadata_unittest.cc

// Copyright 2018 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/metrics/call_stacks/call_stack_profile_metadata.h"

#include <tuple>
#include <utility>

#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/metrics_proto/sampled_profile.pb.h"

namespace metrics {

namespace {

// Expects that |expected_item| was applied to |samples| at |sample_index| and
// |metadata_index|. Because of the "edge-triggered" metadata encoding, this
// expectation will be valid for the first sample seeing the item only.
void ExpectMetadataApplied(
    const base::MetadataRecorder::Item& expected_item,
    const google::protobuf::RepeatedPtrField<CallStackProfile::StackSample>&
        samples,
    int sample_index,
    int metadata_index,
    const google::protobuf::RepeatedField<uint64_t>& name_hashes) {}

// Expects that the |item| was unapplied at |sample|. Because of the
// "edge-triggered" metadata encoding, this expectation will be valid for the
// sample following the last sample with the item only.
void ExpectMetadataUnapplied(
    const base::MetadataRecorder::Item& expected_item,
    const google::protobuf::RepeatedPtrField<CallStackProfile::StackSample>&
        samples,
    int sample_index,
    int metadata_index,
    const google::protobuf::RepeatedField<uint64_t>& name_hashes) {}

}  // namespace

TEST(CallStackProfileMetadataTest, MetadataRecorder_NoItems) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_SetItem) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_SetKeyedItem) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_SetThreadItem) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_RepeatItem) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_RepeatKeyedItem) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_ModifiedItem) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_ModifiedKeyedItem) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_NewItem) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_NewKeyedItem) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_RemovedItem) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_RemovedKeyedItem) {}

TEST(CallStackProfileMetadataTest, MetadataRecorder_RemovedThreadItem) {}

TEST(CallStackProfileMetadataTest,
     MetadataRecorder_SetMixedUnkeyedAndKeyedItems) {}

TEST(CallStackProfileMetadataTest,
     MetadataRecorder_RemoveMixedUnkeyedAndKeyedItems) {}

// Checks that applying metadata results in the expected application and removal
// of the metadata.
TEST(CallStackProfileMetadataTest, ApplyMetadata_Basic) {}

// Checks that metadata items with different name hashes are applied
// independently.
TEST(CallStackProfileMetadataTest, ApplyMetadata_DifferentNameHashes) {}

// Checks that metadata items with different keys are applied independently.
TEST(CallStackProfileMetadataTest, ApplyMetadata_DifferentKeys) {}

// Checks that applying to an empty range has no effect.
TEST(CallStackProfileMetadataTest, ApplyMetadata_EmptyRange) {}

// Checks that applying metadata through the end is recorded as unapplied on the
// next sample taken.
TEST(CallStackProfileMetadataTest, ApplyMetadata_ThroughEnd) {}

// Checks that metadata is properly applied when mixing RecordMetadata and
// ApplyMetadata over the same samples.
TEST(CallStackProfileMetadataTest, ApplyMetadata_WithRecordMetadata) {}

// Checks that metadata is properly applied when using ApplyMetadata while
// a RecordMetadata-applied value is active.
TEST(CallStackProfileMetadataTest, ApplyMetadata_WithActiveMetadata) {}

// Checks application of the same item across non-overlapping ranges.
TEST(CallStackProfileMetadataTest, ApplyMetadata_IndependentRanges) {}

// Checks application of the same item across back-to-back ranges. The common
// sample should not have a metadata item set because it's unnecessary.
TEST(CallStackProfileMetadataTest, ApplyMetadata_BackToBackRanges) {}

// Checks application of different values across back-to-back ranges. The common
// sample must have the second metadata value set.
TEST(CallStackProfileMetadataTest,
     ApplyMetadata_BackToBackRangesWithDifferentValues) {}

// Checks application of the same item over a range within a range where the
// item was already set. No metadata changes should be recorded on the interior
// range because they are unnecessary.
TEST(CallStackProfileMetadataTest, ApplyMetadata_UpdateWithinExistingRange) {}

// Checks application of a second value over a range within a range where the
// first value was already set. Metadata changes for the second value must be
// recorded on the interior range.
TEST(CallStackProfileMetadataTest,
     ApplyMetadata_UpdateWithinExistingRangeWithDifferentValues) {}

// Checks application of the same item over a range enclosing a range where the
// item was already set. No metadata changes should be recorded on the interior
// range because they are unnecessary.
TEST(CallStackProfileMetadataTest, ApplyMetadata_UpdateEnclosesExistingRange) {}

// Checks application of a second value over a range enclosing a range where the
// first value was already set. Metadata changes for both values must be
// recorded.
TEST(CallStackProfileMetadataTest,
     ApplyMetadata_UpdateEnclosesExistingRangeWithDifferentValues) {}

// Checks application of an item over a range overlapping the start (but not
// end) of a range where the item was already set. No metadata changes should be
// recorded on the interior application because it is unnecessary.
TEST(CallStackProfileMetadataTest, ApplyMetadata_UpdateOverlapsBegin) {}

// Checks application of a second different value over a range overlapping the
// start (but not end) of a range where the first value was already
// set. Metadata changes must be recorded on the interior application.
TEST(CallStackProfileMetadataTest,
     ApplyMetadata_UpdateOverlapsBeginWithDifferentValues) {}

// Checks application of an item over a range overlapping the end (but not
// start) of a range where the item was already set. No metadata changes should
// be recorded on the interior application because it is unnecessary.
TEST(CallStackProfileMetadataTest, ApplyMetadata_UpdateOverlapsEnd) {}

// Checks application of a second different value over a range overlapping the
// end (but not start) of a range where the first value was already
// set. Metadata changes must be recorded on the interior application.
TEST(CallStackProfileMetadataTest,
     ApplyMetadata_UpdateOverlapsEndWithDifferentValues) {}

// Checks that updating the same range multiple times with the same item
// produces the same result as what we'd expect with just one update.
TEST(CallStackProfileMetadataTest, ApplyMetadata_Update) {}

// Checks that applying to the same range with a different value overwrites the
// initial value.
TEST(CallStackProfileMetadataTest, ApplyMetadata_UpdateWithDifferentValues) {}

}  // namespace metrics