summaryrefslogtreecommitdiffstats
path: root/app/multi_animation_unittest.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 17:33:39 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-07 17:33:39 +0000
commitf676780687464428e340d008a0d1ca13d9944628 (patch)
tree489e8bd8188e31a7f6c53f15e8d1d9c6ba36d023 /app/multi_animation_unittest.cc
parent3b65bfd55c56cf8a6db025087d937494f49dc15f (diff)
downloadchromium_src-f676780687464428e340d008a0d1ca13d9944628.zip
chromium_src-f676780687464428e340d008a0d1ca13d9944628.tar.gz
chromium_src-f676780687464428e340d008a0d1ca13d9944628.tar.bz2
Move animation code to new ui/base/animation directory.
BUG=none TEST=none TBR=brettw Review URL: http://codereview.chromium.org/6154001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/multi_animation_unittest.cc')
-rw-r--r--app/multi_animation_unittest.cc89
1 files changed, 0 insertions, 89 deletions
diff --git a/app/multi_animation_unittest.cc b/app/multi_animation_unittest.cc
deleted file mode 100644
index 393b01c..0000000
--- a/app/multi_animation_unittest.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "app/animation_container_element.h"
-#include "app/multi_animation.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-typedef testing::Test MultiAnimationTest;
-
-TEST_F(MultiAnimationTest, Basic) {
- // Create a MultiAnimation with two parts.
- MultiAnimation::Parts parts;
- parts.push_back(MultiAnimation::Part(100, Tween::LINEAR));
- parts.push_back(MultiAnimation::Part(100, Tween::EASE_OUT));
-
- MultiAnimation animation(parts);
- AnimationContainerElement* as_element =
- static_cast<AnimationContainerElement*>(&animation);
- as_element->SetStartTime(base::TimeTicks());
-
- // Step to 50, which is half way through the first part.
- as_element->Step(base::TimeTicks() + base::TimeDelta::FromMilliseconds(50));
- EXPECT_EQ(.5, animation.GetCurrentValue());
-
- // Step to 120, which is 20% through the second part.
- as_element->Step(base::TimeTicks() +
- base::TimeDelta::FromMilliseconds(120));
- EXPECT_EQ(Tween::CalculateValue(Tween::EASE_OUT, .2),
- animation.GetCurrentValue());
-
- // Step to 320, which is 20% through the second part.
- as_element->Step(base::TimeTicks() +
- base::TimeDelta::FromMilliseconds(320));
- EXPECT_EQ(Tween::CalculateValue(Tween::EASE_OUT, .2),
- animation.GetCurrentValue());
-}
-
-TEST_F(MultiAnimationTest, DifferingStartAndEnd) {
- // Create a MultiAnimation with two parts.
- MultiAnimation::Parts parts;
- parts.push_back(MultiAnimation::Part(200, Tween::LINEAR));
- parts[0].start_time_ms = 100;
- parts[0].end_time_ms = 400;
-
- MultiAnimation animation(parts);
- AnimationContainerElement* as_element =
- static_cast<AnimationContainerElement*>(&animation);
- as_element->SetStartTime(base::TimeTicks());
-
- // Step to 0. Because the start_time is 100, this should be 100ms into the
- // animation
- as_element->Step(base::TimeTicks());
- EXPECT_EQ(.25, animation.GetCurrentValue());
-
- // Step to 100, which is effectively 200ms into the animation.
- as_element->Step(base::TimeTicks() + base::TimeDelta::FromMilliseconds(100));
- EXPECT_EQ(.5, animation.GetCurrentValue());
-}
-
-// Makes sure multi-animation stops if cycles is false.
-TEST_F(MultiAnimationTest, DontCycle) {
- MultiAnimation::Parts parts;
- parts.push_back(MultiAnimation::Part(200, Tween::LINEAR));
- MultiAnimation animation(parts);
- AnimationContainerElement* as_element =
- static_cast<AnimationContainerElement*>(&animation);
- as_element->SetStartTime(base::TimeTicks());
- animation.set_continuous(false);
-
- // Step to 300, which is greater than the cycle time.
- as_element->Step(base::TimeTicks() + base::TimeDelta::FromMilliseconds(300));
- EXPECT_EQ(1.0, animation.GetCurrentValue());
- EXPECT_FALSE(animation.is_animating());
-}
-
-// Makes sure multi-animation cycles correctly.
-TEST_F(MultiAnimationTest, Cycle) {
- MultiAnimation::Parts parts;
- parts.push_back(MultiAnimation::Part(200, Tween::LINEAR));
- MultiAnimation animation(parts);
- AnimationContainerElement* as_element =
- static_cast<AnimationContainerElement*>(&animation);
- as_element->SetStartTime(base::TimeTicks());
-
- // Step to 300, which is greater than the cycle time.
- as_element->Step(base::TimeTicks() + base::TimeDelta::FromMilliseconds(300));
- EXPECT_EQ(.5, animation.GetCurrentValue());
-}