847f6d9aba
HAS_PROGRESS_BAR is set after page initialization at which point all flags are assumed to be immutable while a GC is running. Separating out the progress bar from flags allows setting it lazily at allocation time. Bug: v8:11915 Change-Id: I48a877e0e80d583d7a0fadef2546fc70417806e7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3085268 Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Omer Katz <omerkatz@chromium.org> Reviewed-by: Hannes Payer <hpayer@chromium.org> Cr-Commit-Position: refs/heads/main@{#76382}
81 lines
2.1 KiB
C++
81 lines
2.1 KiB
C++
// Copyright 2021 the V8 project 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 "src/heap/progress-bar.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
TEST(ProgressBar, DefaultDisabled) {
|
|
ProgressBar progress_bar;
|
|
progress_bar.Initialize();
|
|
EXPECT_FALSE(progress_bar.IsEnabled());
|
|
}
|
|
|
|
TEST(ProgressBar, EnabledAfterExplicitEnable) {
|
|
ProgressBar progress_bar;
|
|
progress_bar.Initialize();
|
|
progress_bar.Enable();
|
|
EXPECT_TRUE(progress_bar.IsEnabled());
|
|
}
|
|
|
|
TEST(ProgressBar, ZeroValueAfterEnable) {
|
|
ProgressBar progress_bar;
|
|
progress_bar.Initialize();
|
|
progress_bar.Enable();
|
|
ASSERT_TRUE(progress_bar.IsEnabled());
|
|
EXPECT_EQ(0u, progress_bar.Value());
|
|
}
|
|
|
|
TEST(ProgressBar, TrySetValue) {
|
|
ProgressBar progress_bar;
|
|
progress_bar.Initialize();
|
|
progress_bar.Enable();
|
|
ASSERT_TRUE(progress_bar.IsEnabled());
|
|
EXPECT_TRUE(progress_bar.TrySetNewValue(0, 17));
|
|
EXPECT_EQ(17u, progress_bar.Value());
|
|
}
|
|
|
|
TEST(ProgressBar, MultipleTrySetValue) {
|
|
ProgressBar progress_bar;
|
|
progress_bar.Initialize();
|
|
progress_bar.Enable();
|
|
ASSERT_TRUE(progress_bar.IsEnabled());
|
|
EXPECT_TRUE(progress_bar.TrySetNewValue(0, 23));
|
|
EXPECT_EQ(23u, progress_bar.Value());
|
|
EXPECT_TRUE(progress_bar.TrySetNewValue(23, 127));
|
|
EXPECT_EQ(127u, progress_bar.Value());
|
|
}
|
|
|
|
TEST(ProgressBar, ResetIfEnabledOnDisabled) {
|
|
ProgressBar progress_bar;
|
|
progress_bar.Initialize();
|
|
progress_bar.ResetIfEnabled();
|
|
EXPECT_FALSE(progress_bar.IsEnabled());
|
|
}
|
|
|
|
TEST(ProgressBar, ResetIfEnabledOnEnabled) {
|
|
ProgressBar progress_bar;
|
|
progress_bar.Initialize();
|
|
progress_bar.Enable();
|
|
ASSERT_TRUE(progress_bar.TrySetNewValue(0, 1));
|
|
progress_bar.ResetIfEnabled();
|
|
ASSERT_TRUE(progress_bar.IsEnabled());
|
|
EXPECT_EQ(0u, progress_bar.Value());
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
TEST(ProgressBarDeathTest, DiesOnTrySetValueOnDisabled) {
|
|
ProgressBar progress_bar;
|
|
progress_bar.Initialize();
|
|
EXPECT_DEATH_IF_SUPPORTED(progress_bar.TrySetNewValue(0, 1), "");
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|