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) { |