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

Unified Diff: ui/gfx/compositor/layer_animation_element_unittest.cc

Issue 10365007: ui: Move compositor/ directory out of gfx/, up to ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix DEPS Created 8 years, 8 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
« no previous file with comments | « ui/gfx/compositor/layer_animation_element.cc ('k') | ui/gfx/compositor/layer_animation_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/compositor/layer_animation_element_unittest.cc
diff --git a/ui/gfx/compositor/layer_animation_element_unittest.cc b/ui/gfx/compositor/layer_animation_element_unittest.cc
deleted file mode 100644
index d6287b03c724f90bc147d2b7ae752aae3603afb1..0000000000000000000000000000000000000000
--- a/ui/gfx/compositor/layer_animation_element_unittest.cc
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright (c) 2012 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 "ui/gfx/compositor/layer_animation_element.h"
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/time.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/transform.h"
-#include "ui/gfx/compositor/layer_animation_delegate.h"
-#include "ui/gfx/compositor/test/test_layer_animation_delegate.h"
-#include "ui/gfx/compositor/test/test_utils.h"
-
-namespace ui {
-
-namespace {
-
-// Check that the transformation element progresses the delegate as expected and
-// that the element can be reused after it completes.
-TEST(LayerAnimationElementTest, TransformElement) {
- TestLayerAnimationDelegate delegate;
- Transform start_transform, target_transform, middle_transform;
- start_transform.SetRotate(-90);
- target_transform.SetRotate(90);
- base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
-
- scoped_ptr<LayerAnimationElement> element(
- LayerAnimationElement::CreateTransformElement(target_transform, delta));
-
- for (int i = 0; i < 2; ++i) {
- delegate.SetTransformFromAnimation(start_transform);
- element->Progress(0.0, &delegate);
- CheckApproximatelyEqual(start_transform,
- delegate.GetTransformForAnimation());
- element->Progress(0.5, &delegate);
- CheckApproximatelyEqual(middle_transform,
- delegate.GetTransformForAnimation());
- element->Progress(1.0, &delegate);
- CheckApproximatelyEqual(target_transform,
- delegate.GetTransformForAnimation());
- }
-
- LayerAnimationElement::TargetValue target_value(&delegate);
- element->GetTargetValue(&target_value);
- CheckApproximatelyEqual(target_transform, target_value.transform);
-
- EXPECT_EQ(delta, element->duration());
-}
-
-// Check that the bounds element progresses the delegate as expected and
-// that the element can be reused after it completes.
-TEST(LayerAnimationElementTest, BoundsElement) {
- TestLayerAnimationDelegate delegate;
- gfx::Rect start, target, middle;
- start = target = middle = gfx::Rect(0, 0, 50, 50);
- start.set_x(-90);
- target.set_x(90);
- base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
-
- scoped_ptr<LayerAnimationElement> element(
- LayerAnimationElement::CreateBoundsElement(target, delta));
-
- for (int i = 0; i < 2; ++i) {
- delegate.SetBoundsFromAnimation(start);
- element->Progress(0.0, &delegate);
- CheckApproximatelyEqual(start, delegate.GetBoundsForAnimation());
- element->Progress(0.5, &delegate);
- CheckApproximatelyEqual(middle, delegate.GetBoundsForAnimation());
- element->Progress(1.0, &delegate);
- CheckApproximatelyEqual(target, delegate.GetBoundsForAnimation());
- }
-
- LayerAnimationElement::TargetValue target_value(&delegate);
- element->GetTargetValue(&target_value);
- CheckApproximatelyEqual(target, target_value.bounds);
-
- EXPECT_EQ(delta, element->duration());
-}
-
-// Check that the opacity element progresses the delegate as expected and
-// that the element can be reused after it completes.
-TEST(LayerAnimationElementTest, OpacityElement) {
- TestLayerAnimationDelegate delegate;
- float start = 0.0;
- float middle = 0.5;
- float target = 1.0;
- base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<LayerAnimationElement> element(
- LayerAnimationElement::CreateOpacityElement(target, delta));
-
- for (int i = 0; i < 2; ++i) {
- delegate.SetOpacityFromAnimation(start);
- element->Progress(0.0, &delegate);
- EXPECT_FLOAT_EQ(start, delegate.GetOpacityForAnimation());
- element->Progress(0.5, &delegate);
- EXPECT_FLOAT_EQ(middle, delegate.GetOpacityForAnimation());
- element->Progress(1.0, &delegate);
- EXPECT_FLOAT_EQ(target, delegate.GetOpacityForAnimation());
- }
-
- LayerAnimationElement::TargetValue target_value(&delegate);
- element->GetTargetValue(&target_value);
- EXPECT_FLOAT_EQ(target, target_value.opacity);
-
- EXPECT_EQ(delta, element->duration());
-}
-
-// Check that the visibility element progresses the delegate as expected and
-// that the element can be reused after it completes.
-TEST(LayerAnimationElementTest, VisibilityElement) {
- TestLayerAnimationDelegate delegate;
- bool start = true;
- bool target = false;
- base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
- scoped_ptr<LayerAnimationElement> element(
- LayerAnimationElement::CreateVisibilityElement(target, delta));
-
- for (int i = 0; i < 2; ++i) {
- delegate.SetVisibilityFromAnimation(start);
- element->Progress(0.0, &delegate);
- EXPECT_TRUE(delegate.GetVisibilityForAnimation());
- element->Progress(0.5, &delegate);
- EXPECT_TRUE(delegate.GetVisibilityForAnimation());
- element->Progress(1.0, &delegate);
- EXPECT_FALSE(delegate.GetVisibilityForAnimation());
- }
-
- LayerAnimationElement::TargetValue target_value(&delegate);
- element->GetTargetValue(&target_value);
- EXPECT_FALSE(target_value.visibility);
-
- EXPECT_EQ(delta, element->duration());
-}
-
-// Check that the pause element progresses the delegate as expected and
-// that the element can be reused after it completes.
-TEST(LayerAnimationElementTest, PauseElement) {
- LayerAnimationElement::AnimatableProperties properties;
- properties.insert(LayerAnimationElement::TRANSFORM);
- properties.insert(LayerAnimationElement::BOUNDS);
- properties.insert(LayerAnimationElement::OPACITY);
- base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
-
- scoped_ptr<LayerAnimationElement> element(
- LayerAnimationElement::CreatePauseElement(properties, delta));
-
- TestLayerAnimationDelegate delegate;
- TestLayerAnimationDelegate copy = delegate;
-
- element->Progress(1.0, &delegate);
-
- // Nothing should have changed.
- CheckApproximatelyEqual(delegate.GetBoundsForAnimation(),
- copy.GetBoundsForAnimation());
- CheckApproximatelyEqual(delegate.GetTransformForAnimation(),
- copy.GetTransformForAnimation());
- EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(),
- copy.GetOpacityForAnimation());
-
- // Pause should last for |delta|.
- EXPECT_EQ(delta, element->duration());
-}
-
-} // namespace
-
-} // namespace ui
« no previous file with comments | « ui/gfx/compositor/layer_animation_element.cc ('k') | ui/gfx/compositor/layer_animation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698