chromium/third_party/blink/renderer/core/paint/paint_layer_scrollable_area_test.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"

#include "build/build_config.h"
#include "cc/layers/picture_layer.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/animation/scroll_timeline.h"
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.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/layout/hit_test_location.h"
#include "third_party/blink/renderer/core/layout/layout_box_model_object.h"
#include "third_party/blink/renderer/core/page/scrolling/snap_coordinator.h"
#include "third_party/blink/renderer/core/paint/paint_controller_paint_test.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/scroll/scroll_types.h"
#include "third_party/blink/renderer/core/scroll/scrollbar_theme.h"
#include "third_party/blink/renderer/core/testing/color_scheme_helper.h"
#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"

_;

namespace blink {
namespace {

class ScrollableAreaMockChromeClient : public RenderingTestChromeClient {};

}  // namespace

class PaintLayerScrollableAreaTest : public PaintControllerPaintTest {};

INSTANTIATE_PAINT_TEST_SUITE_P();

TEST_P(PaintLayerScrollableAreaTest, OpaqueContainedLayersPromoted) {}

TEST_P(PaintLayerScrollableAreaTest, NonStackingContextScrollerPromoted) {}

TEST_P(PaintLayerScrollableAreaTest, TransparentLayersNotPromoted) {}

TEST_P(PaintLayerScrollableAreaTest, OpaqueLayersDepromotedOnStyleChange) {}

TEST_P(PaintLayerScrollableAreaTest, OpaqueLayersPromotedOnStyleChange) {}

// Tests that a transform on the scroller or an ancestor doesn't prevent
// promotion.
TEST_P(PaintLayerScrollableAreaTest,
       TransformDoesNotPreventCompositedScrolling) {}

TEST_P(PaintLayerScrollableAreaTest,
       PromoteLayerRegardlessOfSelfAndAncestorOpacity) {}

// Test that will-change: transform applied to the scroller will cause the
// scrolling contents layer to be promoted.
TEST_P(PaintLayerScrollableAreaTest, CompositedScrollOnWillChangeTransform) {}

// Test that will-change: transform applied to the scroller will cause the
// scrolling contents layer to be promoted.
TEST_P(PaintLayerScrollableAreaTest, ScrollLayerOnPointerEvents) {}

// Test that <input> elements don't use composited scrolling even with
// "will-change:transform".
TEST_P(PaintLayerScrollableAreaTest, InputElementPromotionTest) {}

// Test that <select> elements use composited scrolling with
// "will-change:transform".
TEST_P(PaintLayerScrollableAreaTest, SelectElementPromotionTest) {}

// Ensure OverlayScrollbarColorTheme get updated when page load
TEST_P(PaintLayerScrollableAreaTest, OverlayScrollbarColorThemeUpdated) {}

TEST_P(PaintLayerScrollableAreaTest,
       RecalculatesScrollbarOverlayIfBackgroundChanges) {}

// The scrollbar overlay color theme should follow the used color scheme when a
// background color is not available on the scroller itself.
TEST_P(PaintLayerScrollableAreaTest, PreferredOverlayScrollbarColorTheme) {}

TEST_P(PaintLayerScrollableAreaTest, HideTooltipWhenScrollPositionChanges) {}

TEST_P(PaintLayerScrollableAreaTest, IncludeOverlayScrollbarsInVisibleWidth) {}

TEST_P(PaintLayerScrollableAreaTest, ShowAutoScrollbarsForVisibleContent) {}

TEST_P(PaintLayerScrollableAreaTest, FloatOverflowInRtlContainer) {}

TEST_P(PaintLayerScrollableAreaTest, ScrollOriginInRtlContainer) {}

TEST_P(PaintLayerScrollableAreaTest, OverflowHiddenScrollOffsetInvalidation) {}

TEST_P(PaintLayerScrollableAreaTest, ScrollDoesNotInvalidate) {}

TEST_P(PaintLayerScrollableAreaTest, ScrollWithStickyNeedsCompositingUpdate) {}

TEST_P(PaintLayerScrollableAreaTest,
       ScrollWithFixedDoesNotNeedCompositingUpdate) {}

TEST_P(PaintLayerScrollableAreaTest,
       ScrollWithLocalAttachmentBackgroundInScrollingContents) {}

TEST_P(PaintLayerScrollableAreaTest, ScrollWith3DPreserveParent) {}

TEST_P(PaintLayerScrollableAreaTest,
       ScrollWithLocalAttachmentBackgroundInMainLayer) {}

TEST_P(PaintLayerScrollableAreaTest, ViewScrollWithFixedAttachmentBackground) {}

TEST_P(PaintLayerScrollableAreaTest,
       ViewScrollWithSolidColorFixedAttachmentBackground) {}

TEST_P(PaintLayerScrollableAreaTest,
       ViewScrollWithFixedAttachmentBackgroundPreferCompositingToLCDText) {}

TEST_P(PaintLayerScrollableAreaTest, ViewScrollWithScrollAttachmentBackground) {}

TEST_P(PaintLayerScrollableAreaTest, ViewScrollWithLocalAttachmentBackground) {}

TEST_P(PaintLayerScrollableAreaTest, HitTestOverlayScrollbars) {}

TEST_P(PaintLayerScrollableAreaTest,
       ShowNonCompositedScrollbarOnCompositorScroll) {}

TEST_P(PaintLayerScrollableAreaTest, CompositedStickyDescendant) {}

TEST_P(PaintLayerScrollableAreaTest, StickyPositionUseCounter) {}

// Delayed scroll offset clamping should not crash. https://crbug.com/842495
TEST_P(PaintLayerScrollableAreaTest, IgnoreDelayedScrollOnDestroyedLayer) {}

TEST_P(PaintLayerScrollableAreaTest, ScrollbarMaximum) {}

TEST_P(PaintLayerScrollableAreaTest, ScrollingBackgroundVisualRect) {}

TEST_P(PaintLayerScrollableAreaTest, RtlScrollOriginSnapping) {}

TEST_P(PaintLayerScrollableAreaTest, ShowCustomResizerInTextarea) {}

TEST_P(PaintLayerScrollableAreaTest,
       ApplyPendingHistoryRestoreScrollOffsetTwice) {}

// Test that a trivial 3D transform results in composited scrolling.
TEST_P(PaintLayerScrollableAreaTest, CompositeWithTrivial3D) {}

class PaintLayerScrollableAreaTestLowEndPlatform
    : public TestingPlatformSupport {};

// Test that a trivial 3D transform results in composited scrolling even on
// low-end devices that may not composite trivial 3D transforms.
TEST_P(PaintLayerScrollableAreaTest, LowEndCompositeWithTrivial3D) {}

TEST_P(PaintLayerScrollableAreaTest,
       RootScrollbarShouldUseParentOfOverscrollNodeAsTransformNode) {}

TEST_P(PaintLayerScrollableAreaTest,
       ResizeSmallerToBeScrollableWithResizerAndStackedChild) {}

TEST_P(PaintLayerScrollableAreaTest, RemoveAddResizerWithoutScrollbars) {}

TEST_P(PaintLayerScrollableAreaTest, UsedColorSchemeRootScrollbarsDark) {}

TEST_P(PaintLayerScrollableAreaTest,
       UsedColorSchemeRootScrollbarsMetaLightDark) {}

TEST_P(PaintLayerScrollableAreaTest, UsedColorSchemeRootScrollbarsHtmlLight) {}

TEST_P(PaintLayerScrollableAreaTest, UsedColorSchemeRootScrollbarsBodyLight) {}

TEST_P(PaintLayerScrollableAreaTest,
       UsedColorSchemeRootScrollbarsInvalidateOnPreferredColorSchemeChange) {}

TEST_P(PaintLayerScrollableAreaTest,
       UsedColorSchemeRootScrollbarsInvalidateOnNormalToLightChange) {}

TEST_P(PaintLayerScrollableAreaTest,
       UsedColorSchemeRootScrollbarsInvalidateOnLightToNormalChange) {}

TEST_P(PaintLayerScrollableAreaTest,
       UsedColorSchemeRootScrollbarsUseCounterUpdated) {}

// TODO(crbug.com/1020913): Actually this tests a situation that should not
// exist but it does exist due to different or incorrect rounding methods for
// scroll geometries. This test can be converted to test the correct behavior
// when we fix the bug. For now it just ensures we won't crash.
TEST_P(PaintLayerScrollableAreaTest,
       NotScrollsOverflowWithScrollableScrollbar) {}

// TODO(crbug.com/340578714): The expectations match the current actual outputs
// which may not be fully correct.
TEST_P(PaintLayerScrollableAreaTest,
       ScrollbarGutterBothEdgesWithHorizontalScrollbar) {}

// TODO(crbug.com/340578714): The expectations match the current actual outputs
// which may not be fully correct.
TEST_P(PaintLayerScrollableAreaTest,
       ScrollbarGutterBothEdgesWithVerticalScrollbars) {}

// TODO(crbug.com/340578714): The expectations match the current actual outputs
// which may not be fully correct.
TEST_P(PaintLayerScrollableAreaTest,
       ScrollbarGutterBothEdgesWithBothScrollbars) {}

// TODO(crbug.com/340578714): The expectations match the current actual outputs
// which may not be fully correct.
TEST_P(PaintLayerScrollableAreaTest,
       ScrollbarGutterBothEdgesOverflowIntoGutter) {}

// TODO(crbug.com/340578714): The expectations match the current actual outputs
// which may not be fully correct.
TEST_P(PaintLayerScrollableAreaTest,
       ScrollbarGutterBothEdgesRtlWithHorizontalScrollbar) {}

// TODO(crbug.com/340578714): The expectations match the current actual outputs
// which may not be fully correct.
TEST_P(PaintLayerScrollableAreaTest,
       ScrollbarGutterBothEdgesRtlWithVerticalScrollbar) {}

// TODO(crbug.com/340578714): The expectations match the current actual outputs
// which may not be fully correct.
TEST_P(PaintLayerScrollableAreaTest,
       ScrollbarGutterBothEdgesRtlWithBothScrollbars) {}

class PaintLayerScrollableAreaWithWebFrameTest : public ::testing::Test {};

// This test needs a WebLocalFrame for accurate main thread scrolling reasons.
// Otherwise we'll force main-thread scrolling for reason kPopupNoThreadedInput
// because threaded scrolling is not possible without a WebLocalFrame.
TEST_F(PaintLayerScrollableAreaWithWebFrameTest,
       UpdateShouldAnimateScrollOnMainThread) {}

}  // namespace blink