Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: ui/compositor/layer_animation_element_unittest.cc

Issue 22861008: Add support for inverse transform animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add support for inverse transform animations. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/compositor/layer_animation_element_unittest.cc
diff --git a/ui/compositor/layer_animation_element_unittest.cc b/ui/compositor/layer_animation_element_unittest.cc
index 2701200c0146488f0f1b8a9dfd2c2f26f713c4b7..e7b4c00b85d56fcee6119ed8559c95137871e02c 100644
--- a/ui/compositor/layer_animation_element_unittest.cc
+++ b/ui/compositor/layer_animation_element_unittest.cc
@@ -23,7 +23,7 @@ namespace {
// that the element can be reused after it completes.
TEST(LayerAnimationElementTest, TransformElement) {
TestLayerAnimationDelegate delegate;
- gfx::Transform start_transform, target_transform, middle_transform;
+ gfx::Transform start_transform, target_transform;
start_transform.Rotate(-30.0);
target_transform.Rotate(30.0);
base::TimeTicks start_time;
@@ -65,6 +65,61 @@ TEST(LayerAnimationElementTest, TransformElement) {
CheckApproximatelyEqual(target_transform, target_value.transform);
}
+// Checks that the equation Child_start * Parent_start = Child_current *
+// Parent_current is true.
+TEST(LayerAnimationElementTest, CounterTransformElement) {
+ TestLayerAnimationDelegate delegate, parent_delegate;
+ gfx::Transform parent_start, parent_target;
+ parent_start.Scale(0.5, 3);
+ parent_start.Translate(-20, 30);
+ parent_target.Translate(0, 100);
+
+ gfx::Transform child_transform;
+ child_transform.Rotate(-30.0);
+
+ const gfx::Transform effective_child_transform =
+ child_transform * parent_start;
+
+ base::TimeTicks start_time;
+ base::TimeTicks now;
+ base::TimeDelta duration = base::TimeDelta::FromSeconds(1);
+
+ start_time += 5 * duration;
+ scoped_ptr<LayerAnimationElement> element(
+ LayerAnimationElement::CreateInverseTransformElement(parent_start,
+ parent_target,
+ duration));
+ element->set_animation_group_id(1);
+ scoped_ptr<LayerAnimationElement> parent_element(
+ LayerAnimationElement::CreateTransformElement(parent_target, duration));
+
+ parent_delegate.SetTransformFromAnimation(parent_start);
+ delegate.SetTransformFromAnimation(child_transform);
+
+ parent_element->set_requested_start_time(start_time);
+ parent_element->Start(&parent_delegate, 1);
+ parent_element->set_effective_start_time(start_time);
+ parent_element->Progress(start_time, &parent_delegate);
+
+ element->set_requested_start_time(start_time);
+ element->Start(&delegate, 1);
+ element->set_effective_start_time(start_time);
+ element->Progress(start_time, &delegate);
+ CheckApproximatelyEqual(effective_child_transform,
+ delegate.GetTransformForAnimation() *
+ parent_delegate.GetTransformForAnimation());
+ const int steps = 1000;
+ now = start_time;
+ for (int i = 0; i != steps; ++i) {
+ now += duration/steps;
+ parent_element->Progress(start_time, &parent_delegate);
+ element->Progress(start_time, &delegate);
+ CheckApproximatelyEqual(effective_child_transform,
+ delegate.GetTransformForAnimation() *
ajuma 2013/08/20 15:32:41 For threaded animations, the delegate won't actual
avallee 2013/08/22 22:21:59 Moved this test to a new test file for the transfo
+ parent_delegate.GetTransformForAnimation());
+ }
+}
+
// Check that the bounds element progresses the delegate as expected and
// that the element can be reused after it completes.
TEST(LayerAnimationElementTest, BoundsElement) {
« ui/compositor/layer_animation_element.cc ('K') | « ui/compositor/layer_animation_element.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698