chromium/cc/input/scrollbar_animation_controller_unittest.cc

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

#include "cc/input/scrollbar_animation_controller.h"

#include <utility>

#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "cc/layers/solid_color_scrollbar_layer_impl.h"
#include "cc/test/layer_tree_impl_test_base.h"
#include "cc/trees/layer_tree_impl.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

_;
AtLeast;
Bool;
Mock;
NiceMock;

namespace cc {
namespace {

// Redefinition from ui/native_theme/overlay_scrollbar_constants_aura.h
const float kIdleThicknessScale =;
const int kThumbThickness =;

class MockScrollbarAnimationControllerClient
    : public ScrollbarAnimationControllerClient {};

class ScrollbarAnimationControllerOverlayTest
    : public LayerTreeImplTestBase,
      public testing::Test,
      public testing::WithParamInterface<bool> {};

class ScrollbarAnimationControllerAuraOverlayTest
    : public ScrollbarAnimationControllerOverlayTest {};

class ScrollbarAnimationControllerFluentOverlayTest
    : public ScrollbarAnimationControllerOverlayTest {};

// Check initialization of scrollbar. Should start off invisible and thin.
TEST_P(ScrollbarAnimationControllerOverlayTest, Idle) {}

// Check that scrollbar appears again when the layer becomes scrollable.
TEST_P(ScrollbarAnimationControllerOverlayTest, AppearOnResize) {}

// Check that scrollbar disappears when the layer becomes non-scrollable.
TEST_P(ScrollbarAnimationControllerOverlayTest, HideOnResize) {}

// Scroll content. Confirm the scrollbar appears and fades out.
TEST_P(ScrollbarAnimationControllerOverlayTest, BasicAppearAndFadeOut) {}

// Confirm the scrollbar appears by WillUpdateScroll and fade out.
TEST_P(ScrollbarAnimationControllerOverlayTest,
       BasicAppearByWillUpdateScrollThenFadeOut) {}

// Scroll content. Move the mouse near the scrollbar track but not near thumb
// and confirm it stay thin. Move the mouse near the scrollbar thumb and
// confirm it becomes thick.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
       MoveNearTrackThenNearThumb) {}

// Scroll content. Move the mouse near the scrollbar thumb and confirm it
// becomes thick. Ensure it remains visible as long as the mouse is near the
// scrollbar.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MoveNearAndDontFadeOut) {}

// Scroll content. Move the mouse over the scrollbar and confirm it becomes
// thick. Ensure it remains visible as long as the mouse is over the scrollbar.
TEST_P(ScrollbarAnimationControllerOverlayTest, MoveOverAndDontFadeOut) {}

// Make sure a scrollbar captured before the thickening animation doesn't try
// to fade out.
TEST_P(ScrollbarAnimationControllerOverlayTest,
       DontFadeWhileCapturedBeforeThick) {}

// Make sure a scrollbar captured then move mouse away doesn't try to fade out.
TEST_P(ScrollbarAnimationControllerOverlayTest, DontFadeWhileCapturedThenAway) {}

// Make sure a scrollbar captured after a thickening animation doesn't try to
// fade out.
TEST_P(ScrollbarAnimationControllerOverlayTest, DontFadeWhileCaptured) {}

// Make sure releasing a captured scrollbar when the mouse isn't near it causes
// the scrollbar to fade out.
TEST_P(ScrollbarAnimationControllerOverlayTest, FadeAfterReleasedFar) {}

// Make sure releasing a captured scrollbar when the mouse is near/over it,
// doesn't cause the scrollbar to fade out.
TEST_P(ScrollbarAnimationControllerOverlayTest, DontFadeAfterReleasedNear) {}

// Make sure moving near a scrollbar while it's fading out causes it to reset
// the opacity and thicken.
TEST_P(ScrollbarAnimationControllerOverlayTest, MoveNearScrollbarWhileFading) {}

// Make sure we can't capture scrollbar that's completely faded out.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, TestCantCaptureWhenFaded) {}

// Initiate a scroll when the pointer is already near the scrollbar. It should
// appear thick and remain thick.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, ScrollWithMouseNear) {}

// Tests that main thread scroll updates immediately queue a fade out animation
TEST_P(ScrollbarAnimationControllerOverlayTest, MainThreadScrollQueuesFade) {}

// Tests that the fade effect is animated.
TEST_P(ScrollbarAnimationControllerOverlayTest, FadeAnimated) {}

// Tests that the controller tells the client when the scrollbars hide/show.
TEST_P(ScrollbarAnimationControllerOverlayTest, NotifyChangedVisibility) {}

// Move the pointer near each scrollbar. Confirm it gets thick and narrow when
// moved away.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearEach) {}

// Move mouse near both scrollbars at the same time.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, MouseNearBoth) {}

// Move mouse on top of the vertical scrollbar, then to the horizontal scrollbar
// before the fade out animation is finished. Then, move the pointer away from
// both scrollbars before animation the animation is finished.
TEST_P(ScrollbarAnimationControllerOverlayTest,
       MouseNearOtherBeforeAnimationFinished) {}

// Ensure we have a delay fadeout animation after mouse leave without a mouse
// move.
TEST_P(ScrollbarAnimationControllerOverlayTest, MouseLeaveFadeOut) {}

// Scrollbars should schedule a delay fade in when mouse hover the show
// scrollbar region of a hidden scrollbar.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverFadeIn) {}

// Scrollbars should not schedule a new delay fade in when the mouse hovers
// inside a scrollbar already scheduled a delay fade in.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
       MouseHoverScrollbarAndMoveInside) {}

// Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then
// move far away.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
       MouseHoverThenOutShouldCancelFadeIn) {}

// Scrollbars should cancel delay fade in when mouse hover hidden scrollbar then
// move out of window.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
       MouseHoverThenLeaveShouldCancelShowThenEnterShouldFadeIn) {}

// Make sure mouse down will cancel hover fade in timer, then mouse move with
// press will not trigger hover fade in, mouse release near will trigger new
// hover fade in.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
       MouseHoverThenMouseDownShouldCancelFadeInThenReleaseNearShouldFadeIn) {}

// Make sure mouse down will cancel hover fade in timer, then mouse move with
// press will not trigger hover fade in, mouse release far will not trigger new
// hover fade in.
TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
       MouseReleaseFarShouldNotFadeIn) {}

// Ensure overlay scrollbars show and don't fade out when tickmarks are visible,
// and fade out when tickmarks hide.
TEST_P(ScrollbarAnimationControllerOverlayTest, TickmarksShowHide) {}

// Test that Fluent scrollbar animations get properly queued when moving the
// mouse while the scrollbar is visible.
TEST_F(ScrollbarAnimationControllerFluentOverlayTest,
       DidMouseMoveWithVisibleScrollbarQueuesAnimations) {}

// Ensure Fluent overlay scrollbar remains hidden when invisible and being
// moused over.
TEST_F(ScrollbarAnimationControllerFluentOverlayTest,
       DidMouseMoveWithHiddenScrollbarRemainsHidden) {}

// Ensure Fluent overlay scrollbar gets shown when scrolling, goes to Full Mode
// when mousing over it and disappears when the mouse moves away.
TEST_F(ScrollbarAnimationControllerFluentOverlayTest,
       ScrollAndMouseOverGoesToFullMode) {}

// Move the pointer out of the scroll area after scrolling and expect the
// scrollbar to fade.
TEST_F(ScrollbarAnimationControllerFluentOverlayTest, FadeWhenMouseLeaves) {}

// Test that scrollbars disappear when it is captured and then is released after
// the mouse leaves the scrollable area.
TEST_F(ScrollbarAnimationControllerFluentOverlayTest,
       HidesWhenReleasedOutsideArea) {}

class ScrollbarAnimationControllerAndroidTest
    : public LayerTreeImplTestBase,
      public testing::Test,
      public ScrollbarAnimationControllerClient {};

class VerticalScrollbarAnimationControllerAndroidTest
    : public ScrollbarAnimationControllerAndroidTest {};

TEST_F(ScrollbarAnimationControllerAndroidTest, HiddenInBegin) {}

TEST_F(ScrollbarAnimationControllerAndroidTest,
       HiddenAfterNonScrollingGesture) {}

// Confirm the scrollbar does not appear on WillUpdateScroll on Android.
TEST_F(ScrollbarAnimationControllerAndroidTest,
       WillUpdateScrollNotAppearScrollbar) {}

TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnResize) {}

TEST_F(VerticalScrollbarAnimationControllerAndroidTest, HideOnResize) {}

TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnUserNonScrollableHorz) {}

TEST_F(ScrollbarAnimationControllerAndroidTest, ShowOnUserNonScrollableVert) {}

TEST_F(VerticalScrollbarAnimationControllerAndroidTest,
       HideOnUserNonScrollableVert) {}

TEST_F(VerticalScrollbarAnimationControllerAndroidTest,
       ShowOnUserNonScrollableHorz) {}

TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByScrollingGesture) {}

TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByProgrammaticScroll) {}

TEST_F(ScrollbarAnimationControllerAndroidTest,
       AnimationPreservedByNonScrollingGesture) {}

TEST_F(ScrollbarAnimationControllerAndroidTest,
       AnimationOverriddenByScrollingGesture) {}

INSTANTIATE_TEST_SUITE_P();
}  // namespace

}  // namespace cc