19 #include "gmock/gmock.h"
20 #include "gtest/gtest.h"
21 #include "absl/base/attributes.h"
22 #include "absl/base/macros.h"
26 namespace profiling_internal {
33 class MockPeriodicSampler :
public PeriodicSamplerBase {
35 virtual ~MockPeriodicSampler() =
default;
42 StrictMock<MockPeriodicSampler> sampler;
62 TEST(PeriodicSamplerBaseTest, ImmediatelySample) {
63 StrictMock<MockPeriodicSampler> sampler;
80 TEST(PeriodicSamplerBaseTest, Disabled) {
81 StrictMock<MockPeriodicSampler> sampler;
90 TEST(PeriodicSamplerBaseTest, AlwaysOn) {
91 StrictMock<MockPeriodicSampler> sampler;
100 TEST(PeriodicSamplerBaseTest, Disable) {
101 StrictMock<MockPeriodicSampler> sampler;
114 TEST(PeriodicSamplerBaseTest, Enable) {
115 StrictMock<MockPeriodicSampler> sampler;
123 .WillRepeatedly(
Return(3));
133 TEST(PeriodicSamplerTest, ConstructConstInit) {
139 TEST(PeriodicSamplerTest, DefaultPeriod0) {
141 PeriodicSampler<Tag> sampler;
145 TEST(PeriodicSamplerTest, DefaultPeriod) {
147 PeriodicSampler<Tag, 100> sampler;
151 TEST(PeriodicSamplerTest, SetGlobalPeriod) {
154 PeriodicSampler<Tag1, 25> sampler1;
155 PeriodicSampler<Tag2, 50> sampler2;
161 PeriodicSampler<Tag1, 25> sampler1;
162 PeriodicSampler<Tag2, 50> sampler2;
165 sampler1.SetGlobalPeriod(10);
166 sampler2.SetGlobalPeriod(20);