transform_animation_curve_adapter_unittest.cc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ui/compositor/transform_animation_curve_adapter.h"
  5. #include "base/time/time.h"
  6. #include "testing/gtest/include/gtest/gtest.h"
  7. namespace ui {
  8. namespace {
  9. TEST(TransformAnimationCurveAdapterTest, MaximumAnimationScale) {
  10. auto duration = base::Seconds(1);
  11. float kArbitraryScale = 123.f;
  12. float scale = kArbitraryScale;
  13. EXPECT_TRUE(TransformAnimationCurveAdapter(gfx::Tween::LINEAR,
  14. gfx::Transform(), gfx::Transform(),
  15. duration)
  16. .MaximumScale(&scale));
  17. EXPECT_EQ(1.0f, scale);
  18. gfx::Transform initial;
  19. gfx::Transform target;
  20. initial.Scale(1.0f, 2.0f);
  21. target.Scale(3.0f, 4.0f);
  22. scale = kArbitraryScale;
  23. EXPECT_TRUE(TransformAnimationCurveAdapter(gfx::Tween::LINEAR, initial,
  24. target, duration)
  25. .MaximumScale(&scale));
  26. EXPECT_EQ(4.0f, scale);
  27. scale = kArbitraryScale;
  28. EXPECT_TRUE(TransformAnimationCurveAdapter(gfx::Tween::LINEAR, target,
  29. initial, duration)
  30. .MaximumScale(&scale));
  31. EXPECT_EQ(4.0f, scale);
  32. target.ApplyPerspectiveDepth(2.0f);
  33. target.RotateAboutYAxis(10.0f);
  34. scale = kArbitraryScale;
  35. EXPECT_TRUE(TransformAnimationCurveAdapter(gfx::Tween::LINEAR, initial,
  36. target, duration)
  37. .MaximumScale(&scale));
  38. EXPECT_EQ(2.0f, scale);
  39. scale = kArbitraryScale;
  40. EXPECT_TRUE(TransformAnimationCurveAdapter(gfx::Tween::LINEAR, target,
  41. initial, duration)
  42. .MaximumScale(&scale));
  43. EXPECT_EQ(2.0f, scale);
  44. initial.ApplyPerspectiveDepth(3.0f);
  45. initial.RotateAboutYAxis(10.0f);
  46. EXPECT_FALSE(TransformAnimationCurveAdapter(gfx::Tween::LINEAR, initial,
  47. target, duration)
  48. .MaximumScale(&scale));
  49. EXPECT_FALSE(TransformAnimationCurveAdapter(gfx::Tween::LINEAR, target,
  50. initial, duration)
  51. .MaximumScale(&scale));
  52. }
  53. } // namespace
  54. } // namespace ui