forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsample_metadata_unittest.cc
38 lines (30 loc) · 1008 Bytes
/
sample_metadata_unittest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/profiler/sample_metadata.h"
#include "base/metrics/metrics_hashes.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
TEST(SampleMetadataTest, ScopedSampleMetadata) {
base::ProfileBuilder::MetadataItemArray items;
{
auto get_items = GetSampleMetadataRecorder()->CreateMetadataProvider();
ASSERT_EQ(0u, get_items->GetItems(&items));
}
{
ScopedSampleMetadata m("myname", 100);
{
ASSERT_EQ(1u,
GetSampleMetadataRecorder()->CreateMetadataProvider()->GetItems(
&items));
EXPECT_EQ(base::HashMetricName("myname"), items[0].name_hash);
EXPECT_EQ(100, items[0].value);
}
}
{
ASSERT_EQ(0u,
GetSampleMetadataRecorder()->CreateMetadataProvider()->GetItems(
&items));
}
}
} // namespace base