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

Unified Diff: ui/compositor/layer_animation_element_unittest.cc

Issue 10800020: Add brightness/grayscale animations and use them for OOBE boot transition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix hide animation Created 8 years, 5 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/compositor/layer_animation_element.cc ('k') | ui/compositor/layer_animator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7aadab79ff40e1870c2fd3994be3e8882e35bb07..ca6433eb7f0b356230fe12205dd89afeebbcb12a 100644
--- a/ui/compositor/layer_animation_element_unittest.cc
+++ b/ui/compositor/layer_animation_element_unittest.cc
@@ -136,6 +136,62 @@ TEST(LayerAnimationElementTest, VisibilityElement) {
EXPECT_EQ(delta, element->duration());
}
+// Check that the Brightness element progresses the delegate as expected and
+// that the element can be reused after it completes.
+TEST(LayerAnimationElementTest, BrightnessElement) {
+ 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::CreateBrightnessElement(target, delta));
+
+ for (int i = 0; i < 2; ++i) {
+ delegate.SetBrightnessFromAnimation(start);
+ element->Progress(0.0, &delegate);
+ EXPECT_FLOAT_EQ(start, delegate.GetBrightnessForAnimation());
+ element->Progress(0.5, &delegate);
+ EXPECT_FLOAT_EQ(middle, delegate.GetBrightnessForAnimation());
+ element->Progress(1.0, &delegate);
+ EXPECT_FLOAT_EQ(target, delegate.GetBrightnessForAnimation());
+ }
+
+ LayerAnimationElement::TargetValue target_value(&delegate);
+ element->GetTargetValue(&target_value);
+ EXPECT_FLOAT_EQ(target, target_value.brightness);
+
+ EXPECT_EQ(delta, element->duration());
+}
+
+// Check that the Grayscale element progresses the delegate as expected and
+// that the element can be reused after it completes.
+TEST(LayerAnimationElementTest, GrayscaleElement) {
+ 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::CreateGrayscaleElement(target, delta));
+
+ for (int i = 0; i < 2; ++i) {
+ delegate.SetGrayscaleFromAnimation(start);
+ element->Progress(0.0, &delegate);
+ EXPECT_FLOAT_EQ(start, delegate.GetGrayscaleForAnimation());
+ element->Progress(0.5, &delegate);
+ EXPECT_FLOAT_EQ(middle, delegate.GetGrayscaleForAnimation());
+ element->Progress(1.0, &delegate);
+ EXPECT_FLOAT_EQ(target, delegate.GetGrayscaleForAnimation());
+ }
+
+ LayerAnimationElement::TargetValue target_value(&delegate);
+ element->GetTargetValue(&target_value);
+ EXPECT_FLOAT_EQ(target, target_value.grayscale);
+
+ 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) {
@@ -143,6 +199,8 @@ TEST(LayerAnimationElementTest, PauseElement) {
properties.insert(LayerAnimationElement::TRANSFORM);
properties.insert(LayerAnimationElement::BOUNDS);
properties.insert(LayerAnimationElement::OPACITY);
+ properties.insert(LayerAnimationElement::BRIGHTNESS);
+ properties.insert(LayerAnimationElement::GRAYSCALE);
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
scoped_ptr<LayerAnimationElement> element(
@@ -160,6 +218,10 @@ TEST(LayerAnimationElementTest, PauseElement) {
copy.GetTransformForAnimation());
EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(),
copy.GetOpacityForAnimation());
+ EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(),
+ copy.GetBrightnessForAnimation());
+ EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(),
+ copy.GetGrayscaleForAnimation());
// Pause should last for |delta|.
EXPECT_EQ(delta, element->duration());
« no previous file with comments | « ui/compositor/layer_animation_element.cc ('k') | ui/compositor/layer_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698