diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 10:22:43 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 12:36:28 +0000 |
commit | 271a6c3487a14599023a9106329505597638d793 (patch) | |
tree | e040d58ffc86c1480b79ca8528020ca9ec919bf8 /chromium/third_party/blink/renderer/core/timing/profiler_group_test.cc | |
parent | 7b2ffa587235a47d4094787d72f38102089f402a (diff) | |
download | qtwebengine-chromium-271a6c3487a14599023a9106329505597638d793.tar.gz |
BASELINE: Update Chromium to 77.0.3865.59
Change-Id: I1e89a5f3b009a9519a6705102ad65c92fe736f21
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/timing/profiler_group_test.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/timing/profiler_group_test.cc | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/core/timing/profiler_group_test.cc b/chromium/third_party/blink/renderer/core/timing/profiler_group_test.cc index 410cc91aaeb..c54cdfe288c 100644 --- a/chromium/third_party/blink/renderer/core/timing/profiler_group_test.cc +++ b/chromium/third_party/blink/renderer/core/timing/profiler_group_test.cc @@ -62,4 +62,86 @@ TEST(ProfilerGroupTest, StopProfilerOnGroupDeallocate) { EXPECT_TRUE(profiler->stopped()); } +TEST(ProfilerGroupTest, CreateProfiler) { + V8TestingScope scope; + + ProfilerGroup* profiler_group = ProfilerGroup::From(scope.GetIsolate()); + + ProfilerInitOptions* init_options = ProfilerInitOptions::Create(); + init_options->setSampleInterval(10); + Profiler* profiler = profiler_group->CreateProfiler( + scope.GetScriptState(), *init_options, base::TimeTicks(), + scope.GetExceptionState()); + + EXPECT_FALSE(profiler->stopped()); + EXPECT_FALSE(scope.GetExceptionState().HadException()); +} + +TEST(ProfilerGroupTest, ClampedSamplingIntervalZero) { + V8TestingScope scope; + + ProfilerGroup* profiler_group = ProfilerGroup::From(scope.GetIsolate()); + + ProfilerInitOptions* init_options = ProfilerInitOptions::Create(); + init_options->setSampleInterval(0); + Profiler* profiler = profiler_group->CreateProfiler( + scope.GetScriptState(), *init_options, base::TimeTicks(), + scope.GetExceptionState()); + + EXPECT_FALSE(profiler->stopped()); + EXPECT_FALSE(scope.GetExceptionState().HadException()); + // Verify that the sample interval clamped to the next non-zero supported + // interval. + EXPECT_EQ(profiler->sampleInterval(), + ProfilerGroup::GetBaseSampleInterval().InMilliseconds()); +} + +TEST(ProfilerGroupTest, ClampedSamplingIntervalNext) { + V8TestingScope scope; + + ProfilerGroup* profiler_group = ProfilerGroup::From(scope.GetIsolate()); + + ProfilerInitOptions* init_options = ProfilerInitOptions::Create(); + init_options->setSampleInterval((ProfilerGroup::GetBaseSampleInterval() + + base::TimeDelta::FromMilliseconds(1)) + .InMilliseconds()); + Profiler* profiler = profiler_group->CreateProfiler( + scope.GetScriptState(), *init_options, base::TimeTicks(), + scope.GetExceptionState()); + + EXPECT_FALSE(profiler->stopped()); + EXPECT_FALSE(scope.GetExceptionState().HadException()); + // Verify that the sample interval clamped to the next highest supported + // interval. + EXPECT_EQ(profiler->sampleInterval(), + (ProfilerGroup::GetBaseSampleInterval() * 2).InMilliseconds()); +} + +TEST(ProfilerGroupTest, NegativeSamplingInterval) { + V8TestingScope scope; + + ProfilerGroup* profiler_group = ProfilerGroup::From(scope.GetIsolate()); + + ProfilerInitOptions* init_options = ProfilerInitOptions::Create(); + init_options->setSampleInterval(-10); + profiler_group->CreateProfiler(scope.GetScriptState(), *init_options, + base::TimeTicks(), scope.GetExceptionState()); + + EXPECT_TRUE(scope.GetExceptionState().HadException()); +} + +TEST(ProfilerGroupTest, OverflowSamplingInterval) { + V8TestingScope scope; + + ProfilerGroup* profiler_group = ProfilerGroup::From(scope.GetIsolate()); + + ProfilerInitOptions* init_options = ProfilerInitOptions::Create(); + init_options->setSampleInterval((double)std::numeric_limits<int>::max() + + 1.f); + profiler_group->CreateProfiler(scope.GetScriptState(), *init_options, + base::TimeTicks(), scope.GetExceptionState()); + + EXPECT_TRUE(scope.GetExceptionState().HadException()); +} + } // namespace blink |