chromium/ui/lottie/animation_unittest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "ui/lottie/animation.h"

#include <map>
#include <optional>
#include <string>
#include <string_view>

#include "base/check.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/scoped_observation.h"
#include "base/test/simple_test_tick_clock.h"
#include "cc/paint/display_item_list.h"
#include "cc/paint/paint_op_buffer.h"
#include "cc/paint/paint_op_buffer_iterator.h"
#include "cc/paint/paint_record.h"
#include "cc/paint/record_paint_canvas.h"
#include "cc/paint/skottie_frame_data.h"
#include "cc/paint/skottie_frame_data_provider.h"
#include "cc/paint/skottie_resource_metadata.h"
#include "cc/paint/skottie_wrapper.h"
#include "cc/test/lottie_test_data.h"
#include "cc/test/paint_image_matchers.h"
#include "cc/test/paint_op_matchers.h"
#include "cc/test/skia_common.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkStream.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/lottie/animation_observer.h"

namespace lottie {
namespace {

PaintOpIs;
AllOf;
ElementsAre;
Eq;
FieldsAre;
FloatEq;
FloatNear;
IsEmpty;
NotNull;
Pair;
ResultOf;
SizeIs;

// A skottie animation with solid green color for the first 2.5 seconds and then
// a solid blue color for the next 2.5 seconds.
constexpr char kData[] =;
constexpr float kAnimationWidth =;
constexpr float kAnimationHeight =;
constexpr auto kAnimationDuration =;
constexpr float kCanvasImageScale =;
constexpr float kFrameTimestampToleranceSec =;

class TestAnimationObserver : public AnimationObserver {};

class TestSkottieFrameDataProvider : public cc::SkottieFrameDataProvider {};

}  // namespace

class AnimationTest : public testing::Test {};

class AnimationWithImageAssetsTest : public AnimationTest {};

TEST_F(AnimationTest, InitializationAndLoadingData) {}

TEST_F(AnimationTest, PlayLinearAnimation) {}

TEST_F(AnimationTest, ReducedAnimations) {}

TEST_F(AnimationTest, StopLinearAnimation) {}

TEST_F(AnimationTest, PlaySubsectionOfLinearAnimation) {}

TEST_F(AnimationTest, PausingLinearAnimation) {}

TEST_F(AnimationTest, PlayLoopAnimation) {}

TEST_F(AnimationTest, PlaySubsectionOfLoopAnimation) {}

TEST_F(AnimationTest, PlayDifferentSubsectionsOfLoopingAnimation) {}

TEST_F(AnimationTest, HandlesLargeStepsInLoopingAnimation) {}

TEST_F(AnimationTest, PausingLoopAnimation) {}

TEST_F(AnimationTest, PlayThrobbingAnimation) {}

TEST_F(AnimationTest, PlaySubsectionOfThrobbingAnimation) {}

TEST_F(AnimationTest, PlayDifferentSubsectionsOfThrobbingAnimation) {}

TEST_F(AnimationTest, HandlesLargeStepsInThrobbingAnimation) {}

TEST_F(AnimationTest, PausingThrobbingAnimation) {}

// Test to see if the race condition is handled correctly. It may happen that we
// pause the video before it even starts playing.
TEST_F(AnimationTest, PauseBeforePlay) {}

TEST_F(AnimationTest, PaintTest) {}

TEST_F(AnimationTest, NotifiesObserverFramePainted) {}

TEST_F(AnimationTest, SetsPlaybackSpeed) {}

TEST_F(AnimationWithImageAssetsTest, PaintsAnimationImagesToCanvas) {}

TEST_F(AnimationWithImageAssetsTest, GracefullyHandlesNullImages) {}

TEST_F(AnimationWithImageAssetsTest, LoadsCorrectFrameTimestamp) {}

TEST_F(AnimationWithImageAssetsTest, LoadsCorrectImageScale) {}

TEST_F(AnimationTest, HandlesTimeStepGreaterThanAnimationDuration) {}

class AnimationRestarter : public AnimationObserver {};

TEST_F(AnimationTest, HandlesChangingAnimationStateWithinObserverCall) {}

TEST_F(AnimationTest, NotifiesAnimationIsDeleting) {}

TEST_F(AnimationTest, GetPlaybackConfig) {}

TEST_F(AnimationTest, GetNumCompletedCycles) {}

TEST_F(AnimationTest, GetNumCompletedCyclesLinear) {}

TEST_F(AnimationTest, StartsAtArbitraryInitialTimestamp) {}

TEST_F(AnimationTest, GetCurrentCycleBoundaries) {}

}  // namespace lottie