#include "ui/compositor/layer_animation_sequence.h"
#include <memory>
#include "base/compiler_specific.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/compositor/layer_animation_delegate.h"
#include "ui/compositor/layer_animation_element.h"
#include "ui/compositor/test/test_layer_animation_delegate.h"
#include "ui/compositor/test/test_layer_animation_observer.h"
#include "ui/compositor/test/test_utils.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/transform.h"
namespace ui {
namespace {
TEST(LayerAnimationSequenceTest, NoElement) { … }
TEST(LayerAnimationSequenceTest, SingleElement) { … }
TEST(LayerAnimationSequenceTest, SingleThreadedElement) { … }
TEST(LayerAnimationSequenceTest, MultipleElement) { … }
TEST(LayerAnimationSequenceTest, AbortingRepeatingSequence) { … }
TEST(LayerAnimationSequenceTest, SetTarget) { … }
TEST(LayerAnimationSequenceTest, AddObserver) { … }
TEST(LayerAnimationSequenceTest, ToString) { … }
#if !DCHECK_IS_ON()
TEST(LayerAnimationSequenceTest, RepeatingWithZeroDuration) {
const float final_brightness = 1.f;
const int num_steps_to_test = 3;
const base::TimeDelta animation_step_size = base::Seconds(1);
LayerAnimationSequence sequence;
sequence.set_is_repeating(true);
sequence.AddElement(
LayerAnimationElement::CreateBrightnessElement(0.5f, base::TimeDelta()));
sequence.AddElement(LayerAnimationElement::CreateBrightnessElement(
final_brightness, base::TimeDelta()));
TestLayerAnimationDelegate delegate;
delegate.SetBrightnessFromAnimation(0.f,
PropertyChangeReason::NOT_FROM_ANIMATION);
base::TimeTicks now = base::TimeTicks::Now();
sequence.set_start_time(now);
sequence.Start(&delegate);
for (int i = 0; i < num_steps_to_test; ++i, now += animation_step_size) {
sequence.Progress(now, &delegate);
EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), final_brightness);
}
}
#endif
}
}