#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "cc/base/features.h"
#include "cc/paint/record_paint_canvas.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/input/web_coalesced_input_event.h"
#include "third_party/blink/public/common/input/web_pointer_properties.h"
#include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "third_party/blink/public/platform/web_theme_engine.h"
#include "third_party/blink/public/web/web_script_source.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/inspector/dev_tools_emulator.h"
#include "third_party/blink/renderer/core/layout/custom_scrollbar.h"
#include "third_party/blink/renderer/core/layout/layout_custom_scrollbar_part.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/scroll/scroll_types.h"
#include "third_party/blink/renderer/core/scroll/scrollbar_theme_overlay_mock.h"
#include "third_party/blink/renderer/core/testing/color_scheme_helper.h"
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h"
#include "third_party/blink/renderer/platform/theme/web_theme_engine_helper.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-blink.h"
namespace blink {
namespace {
class StubWebThemeEngine : public WebThemeEngine { … };
constexpr int StubWebThemeEngine::kMinimumHorizontalLength;
constexpr int StubWebThemeEngine::kMinimumVerticalLength;
class ScopedStubThemeEngine { … };
}
class ScrollbarsTest : public PaintTestConfigurations, public SimTest { … };
INSTANTIATE_PAINT_TEST_SUITE_P(…);
class ScrollbarsTestWithVirtualTimer : public ScrollbarsTest { … };
INSTANTIATE_PAINT_TEST_SUITE_P(…);
#define ENABLE_OVERLAY_SCROLLBARS(b) …
TEST_P(ScrollbarsTest, DocumentStyleRecalcPreservesScrollbars) { … }
TEST_P(ScrollbarsTest, ScrollbarsUpdatedOnOverlaySettingsChange) { … }
TEST(ScrollbarsTestWithOwnWebViewHelper, ScrollbarSizeF) { … }
TEST_P(ScrollbarsTest, CustomScrollbarsCauseLayoutOnExistenceChange) { … }
TEST_P(ScrollbarsTest, TransparentBackgroundUsesLightOverlayColorScheme) { … }
TEST_P(ScrollbarsTest, BodyBackgroundChangesOverlayColorTheme) { … }
TEST_P(ScrollbarsTest, OverlayScrollbarChangeToDisplayNoneDynamically) { … }
TEST_P(ScrollbarsTest, OverlayScrolblarNotCreatedInUnscrollableAxis) { … }
TEST_P(ScrollbarsTest, HidingScrollbarsOnScrollableAreaDisablesScrollbars) { … }
TEST_P(ScrollbarsTest, MouseOverScrollbarInCustomCursorElement) { … }
TEST_P(ScrollbarsTest, MouseOverCustomScrollbarInCustomCursorElement) { … }
TEST_P(ScrollbarsTest, MouseOverCustomScrollbarWithCustomCursor) { … }
TEST_P(ScrollbarsTest, MouseOverCustomScrollbarThumbWithCustomCursor) { … }
TEST_P(ScrollbarsTest, MouseOverCustomScrollbarTrackPieceWithCustomCursor) { … }
TEST_P(ScrollbarsTest, MouseOverCustomScrollbarTrackPieceWithoutStyle) { … }
TEST_P(ScrollbarsTest,
MouseOverCustomScrollbarTrackPieceBothTrackAndTrackPieceWithoutStyle) { … }
TEST_P(ScrollbarsTest, MouseOverCustomScrollbarButtonTrackWithCustomCursor) { … }
TEST_P(ScrollbarsTest, MouseOverCustomScrollbarCornerTrackWithCustomCursor) { … }
TEST_P(ScrollbarsTest, MouseOverCustomScrollbarCornerFrame) { … }
TEST_P(ScrollbarsTest, MouseOverLinkAndOverlayScrollbar) { … }
TEST_P(ScrollbarsTest, MouseOverCustomScrollbar) { … }
TEST_P(ScrollbarsTest, MouseOverScrollbarAndIFrame) { … }
TEST_P(ScrollbarsTest, MouseOverScrollbarAndParentElement) { … }
TEST_P(ScrollbarsTest, MouseOverRootScrollbar) { … }
TEST_P(ScrollbarsTest, MouseReleaseUpdatesScrollbarHoveredPart) { … }
TEST_P(ScrollbarsTest, ContextMenuUpdatesScrollbarPressedPart) { … }
TEST_P(ScrollbarsTest,
CustomScrollbarInOverlayScrollbarThemeWillNotCauseDCHECKFails) { … }
TEST_P(ScrollbarsTest, CustomScrollbarChangeToMobileByEmulator) { … }
TEST_P(ScrollbarsTest, CustomScrollbarWhenStyleOwnerChange) { … }
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
TEST_P(ScrollbarsTestWithVirtualTimer,
DISABLED_TestNonCompositedOverlayScrollbarsFade) {
#else
TEST_P(ScrollbarsTestWithVirtualTimer, TestNonCompositedOverlayScrollbarsFade) { … }
enum { … };
class ScrollbarAppearanceTest : public ScrollbarsTest { … };
INSTANTIATE_TEST_SUITE_P(…);
#if BUILDFLAG(IS_ANDROID)
TEST_P(ScrollbarAppearanceTest,
DISABLED_NativeScrollbarChangeToMobileByEmulator) {
#else
TEST_P(ScrollbarAppearanceTest, NativeScrollbarChangeToMobileByEmulator) { … }
#if !BUILDFLAG(IS_MAC)
TEST_P(ScrollbarAppearanceTest, ThemeEngineDefinesMinimumThumbLength) { … }
TEST_P(ScrollbarAppearanceTest, HugeScrollingThumbPosition) { … }
#endif
TEST_P(ScrollbarsTest, WideBodyShouldNotHaveScrollbars) { … }
TEST_P(ScrollbarsTest, TallBodyShouldNotHaveScrollbars) { … }
TEST_P(ScrollbarsTest, TallAndWideBodyShouldNotHaveScrollbars) { … }
TEST_P(ScrollbarsTest, BodySizeEqualWindowSizeShouldNotHaveScrollbars) { … }
TEST_P(ScrollbarsTest, WidePercentageBodyShouldHaveScrollbar) { … }
TEST_P(ScrollbarsTest, WidePercentageAndTallBodyShouldHaveScrollbar) { … }
TEST_P(ScrollbarsTest, TallPercentageBodyShouldHaveScrollbar) { … }
TEST_P(ScrollbarsTest, TallPercentageAndWideBodyShouldHaveScrollbar) { … }
TEST_P(ScrollbarsTest, TallAndWidePercentageBodyShouldHaveScrollbars) { … }
TEST_P(ScrollbarsTest, MouseOverIFrameScrollbar) { … }
TEST_P(ScrollbarsTest, AutosizeTest) { … }
TEST_P(ScrollbarsTest, AutosizeAlmostRemovableScrollbar) { … }
TEST_P(ScrollbarsTest, AutosizeExpandingContentScrollable) { … }
TEST_P(ScrollbarsTest,
HideTheOverlayScrollbarNotCrashAfterPLSADisposedPaintLayer) { … }
TEST_P(ScrollbarsTest, PLSADisposeShouldClearPointerInLayers) { … }
TEST_P(ScrollbarsTest, OverlayScrollbarHitTest) { … }
TEST_P(ScrollbarsTest, RecorderedOverlayScrollbarHitTest) { … }
TEST_P(ScrollbarsTest,
AllowMiddleButtonPressOnScrollbarWhenDisableMiddleClickAutoScroll) { … }
TEST_P(ScrollbarsTest,
NotAllowMiddleButtonPressOnScrollbarWhenEnableMiddleClickAutoScroll) { … }
TEST_P(ScrollbarsTest, NotAllowNonLeftButtonPressOnScrollbar) { … }
TEST_P(ScrollbarsTest, MiddleDownShouldNotAffectScrollbarPress) { … }
TEST_P(ScrollbarsTest, UseCounterNegativeWhenThumbIsNotScrolledWithMouse) { … }
TEST_P(ScrollbarsTest, UseCounterPositiveWhenThumbIsScrolledWithMouse) { … }
TEST_P(ScrollbarsTest, UseCounterNegativeWhenThumbIsNotScrolledWithTouch) { … }
TEST_P(ScrollbarsTest, UseCounterPositiveWhenThumbIsScrolledWithTouch) { … }
TEST_P(ScrollbarsTest, UseCounterCustomScrollbarPercentSize) { … }
TEST_P(ScrollbarsTest, CheckScrollCornerIfThereIsNoScrollbar) { … }
TEST_P(ScrollbarsTest, NoNeedsBeginFrameForCustomScrollbarAfterBeginFrame) { … }
TEST_P(ScrollbarsTest, CustomScrollbarHypotheticalThickness) { … }
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
TEST_P(ScrollbarsTestWithVirtualTimer,
DISABLED_PressScrollbarButtonOnInfiniteScrolling) {
#else
TEST_P(ScrollbarsTestWithVirtualTimer,
PressScrollbarButtonOnInfiniteScrolling) { … }
class ScrollbarTrackMarginsTest : public ScrollbarsTest { … };
INSTANTIATE_PAINT_TEST_SUITE_P(…);
TEST_P(ScrollbarTrackMarginsTest,
CustomScrollbarFractionalMarginsWillNotCauseDCHECKFailure) { … }
TEST_P(ScrollbarTrackMarginsTest,
CustomScrollbarScaledMarginsWillNotCauseDCHECKFailure) { … }
class ScrollbarColorSchemeTest : public ScrollbarAppearanceTest { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(ScrollbarColorSchemeTest, ThemeEnginePaint) { … }
TEST_P(ScrollbarsTest, ScrollbarGutterWithHorizontalTextAndClassicScrollbars) { … }
TEST_P(ScrollbarsTest, ScrollbarGutterWithVerticalTextAndClassicScrollbars) { … }
TEST_P(ScrollbarsTest, ScrollbarGutterWithHorizontalTextAndOverlayScrollbars) { … }
TEST_P(ScrollbarsTest, ScrollbarGutterWithVerticalTextAndOverlayScrollbars) { … }
TEST_P(ScrollbarsTest, ScrollbarGutterBothEdgesKeywordWithClassicScrollbars) { … }
TEST_P(ScrollbarsTest, ScrollbarsRestoredAfterCapturePaintPreview) { … }
TEST_P(ScrollbarsTest, ScrollbarsUsedColorSchemeFollowsOverlayTheme) { … }
}