chromium/ui/views/animation/animation_builder_unittest.cc

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

#include "ui/views/animation/animation_builder.h"

#include <memory>
#include <optional>
#include <utility>

#include "base/functional/bind.h"
#include "base/test/gtest_util.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/layer_owner.h"
#include "ui/compositor/property_change_reason.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor/test/layer_animator_test_controller.h"
#include "ui/compositor/test/test_layer_animation_delegate.h"
#include "ui/gfx/geometry/rounded_corners_f.h"
#include "ui/gfx/geometry/transform.h"
#include "ui/gfx/interpolated_transform.h"
#include "ui/views/animation/animation_abort_handle.h"

namespace views {

namespace {

class TestAnimatibleLayerOwner : public ui::LayerOwner {};

// Configures the layer animation on `layer_owner` and returns the builder.
AnimationBuilder BuildLayerOpacityAnimationAndReturnBuilder(
    ui::LayerOwner* layer_owner,
    const base::TimeDelta& duration) {}

}  // namespace

class AnimationBuilderTest : public testing::Test {};

// This test builds two animation sequences and checks that the properties are
// animated in the specified durations.

TEST_F(AnimationBuilderTest, SimpleAnimation) {}

// This test checks that after setting the animation duration scale to be larger
// than 1, animations behave as expected of that scale.
TEST_F(AnimationBuilderTest, ModifiedSlowAnimationDuration) {}

// This test checks that after setting the animation duration scale to be
// between 0 and 1, animations behave as expected of that scale.
TEST_F(AnimationBuilderTest, ModifiedFastAnimationDuration) {}

// This test checks that after setting the animation duration scale to be 0,
// animations behave as expected of that scale.
TEST_F(AnimationBuilderTest, ModifiedZeroAnimationDuration) {}

// This test checks that the callback supplied to .OnEnded is not called before
// all sequences have finished running. This test will crash if .OnEnded is
// called prematurely.
TEST_F(AnimationBuilderTest, ModifiedZeroAnimationDurationWithOnEndedCallback) {}

TEST_F(AnimationBuilderTest, ZeroDurationBlock) {}

TEST_F(AnimationBuilderTest, CheckTweenType) {}

// Verify that destroying the layers tracked by the animation abort handle
// before the animation ends should not cause any crash.
TEST_F(AnimationBuilderTest, DestroyLayerBeforeAnimationEnd) {}

// Verify that destroying layers tracked by the animation abort handle when
// the animation ends should not cause any crash.
TEST_F(AnimationBuilderTest, DestroyLayerWhenAnimationEnd) {}

// Verify that destroying layers tracked by the animation abort handle when
// the animation is aborted should not cause any crash.
TEST_F(AnimationBuilderTest, DestroyLayerWhenAnimationAborted) {}

TEST_F(AnimationBuilderTest, CheckStartEndCallbacks) {}

// This test checks that repeat callbacks are called after each sequence
// repetition and callbacks from one sequence do not affect calls from another
// sequence.
TEST_F(AnimationBuilderTest, CheckOnWillRepeatCallbacks) {}

// We use these notations to illustrate the tested timeline,
// Pause:    ---|
// KeyFrame: -->|
// Repeat:  [...]
//
// Opacity ---|-->|
TEST_F(AnimationBuilderTest, DelayedStart) {}

// Opacity -->|-->|
TEST_F(AnimationBuilderTest, TwoKeyFrame) {}

// Opacity -->|---|-->|
TEST_F(AnimationBuilderTest, PauseInTheMiddle) {}

// Opacity        -->|
// RoundedCorners ----->|
TEST_F(AnimationBuilderTest, TwoPropertiesOfDifferentDuration) {}

// Opacity        ----->|
// RoundedCorners    ----->|
TEST_F(AnimationBuilderTest, TwoPropertiesOfDifferentStartTime) {}

// Opacity        ----->|---|-->|
// RoundedCorners     ----->|-->|
TEST_F(AnimationBuilderTest, ThenAddsImplicitPause) {}

// Opacity [-->|-->]
TEST_F(AnimationBuilderTest, Repeat) {}

// Opacity [-->|-->|   ]
TEST_F(AnimationBuilderTest, RepeatWithExplicitTrailingPause) {}

// Opacity        [-->|-->]
// RoundedCorners [-->|-->]
TEST_F(AnimationBuilderTest, RepeatTwoProperties) {}

// Opacity        -->|-->|
// RoundedCorners   -->|-->|
TEST_F(AnimationBuilderTest, AtCanSkipThenBlock) {}

// Opacity        -->|-->|
// RoundedCorners   -->|
TEST_F(AnimationBuilderTest, OffsetCanRewindTime) {}

// Opacity        [-->|-->  ]
// RoundedCorners [-->|---->]
TEST_F(AnimationBuilderTest, RepeatedlyImplicitlyAppendsTrailingPause) {}

// Opacity -->|-->|--> with a loop for setting these blocks.
TEST_F(AnimationBuilderTest, RepeatedBlocks) {}

TEST_F(AnimationBuilderTest, PreemptionStrategyTest) {}

TEST_F(AnimationBuilderTest, AbortHandle) {}

// Verifies that configuring layer animations with an animation builder returned
// from a function works as expected.
TEST_F(AnimationBuilderTest, BuildAnimationWithBuilderFromScope) {}

// Verifies that it is disallowed to animate transform using both
// `SetInterpolatedTransform()` and `SetTransform()` in the same block on the
// same target.
TEST_F(AnimationBuilderTest,
       DisallowMultipleSameBlockSameTargetTransformPropertyAnimations) {}

// Verifies that transform can be animated using `SetInterpolatedTransform()`.
TEST_F(AnimationBuilderTest, SetInterpolatedTransform) {}

}  // namespace views