Home | History | Annotate | Download | only in test
      1 // Copyright 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CC_TEST_ANIMATION_TEST_COMMON_H_
      6 #define CC_TEST_ANIMATION_TEST_COMMON_H_
      7 
      8 #include "cc/animation/animation.h"
      9 #include "cc/animation/animation_curve.h"
     10 #include "cc/animation/layer_animation_controller.h"
     11 #include "cc/animation/layer_animation_value_observer.h"
     12 
     13 namespace cc {
     14 class LayerImpl;
     15 class Layer;
     16 }
     17 
     18 namespace cc {
     19 
     20 class FakeFloatAnimationCurve : public FloatAnimationCurve {
     21  public:
     22   FakeFloatAnimationCurve();
     23   explicit FakeFloatAnimationCurve(double duration);
     24   virtual ~FakeFloatAnimationCurve();
     25 
     26   virtual double Duration() const OVERRIDE;
     27   virtual float GetValue(double now) const OVERRIDE;
     28   virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE;
     29 
     30  private:
     31   double duration_;
     32 };
     33 
     34 class FakeTransformTransition : public TransformAnimationCurve {
     35  public:
     36   explicit FakeTransformTransition(double duration);
     37   virtual ~FakeTransformTransition();
     38 
     39   virtual double Duration() const OVERRIDE;
     40   virtual gfx::Transform GetValue(double time) const OVERRIDE;
     41 
     42   virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE;
     43 
     44  private:
     45   double duration_;
     46 };
     47 
     48 class FakeFloatTransition : public FloatAnimationCurve {
     49  public:
     50   FakeFloatTransition(double duration, float from, float to);
     51   virtual ~FakeFloatTransition();
     52 
     53   virtual double Duration() const OVERRIDE;
     54   virtual float GetValue(double time) const OVERRIDE;
     55 
     56   virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE;
     57 
     58  private:
     59   double duration_;
     60   float from_;
     61   float to_;
     62 };
     63 
     64 class FakeLayerAnimationValueObserver : public LayerAnimationValueObserver {
     65  public:
     66   FakeLayerAnimationValueObserver();
     67   virtual ~FakeLayerAnimationValueObserver();
     68 
     69   // LayerAnimationValueObserver implementation
     70   virtual void OnOpacityAnimated(float opacity) OVERRIDE;
     71   virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE;
     72   virtual bool IsActive() const OVERRIDE;
     73 
     74   float opacity() const  { return opacity_; }
     75   const gfx::Transform& transform() const { return transform_; }
     76 
     77  private:
     78   float opacity_;
     79   gfx::Transform transform_;
     80 };
     81 
     82 class FakeInactiveLayerAnimationValueObserver
     83     : public FakeLayerAnimationValueObserver {
     84  public:
     85   virtual bool IsActive() const OVERRIDE;
     86 };
     87 
     88 int AddOpacityTransitionToController(LayerAnimationController* controller,
     89                                      double duration,
     90                                      float start_opacity,
     91                                      float end_opacity,
     92                                      bool use_timing_function);
     93 
     94 int AddAnimatedTransformToController(LayerAnimationController* controller,
     95                                      double duration,
     96                                      int delta_x,
     97                                      int delta_y);
     98 
     99 int AddOpacityTransitionToLayer(Layer* layer,
    100                                 double duration,
    101                                 float start_opacity,
    102                                 float end_opacity,
    103                                 bool use_timing_function);
    104 
    105 int AddOpacityTransitionToLayer(LayerImpl* layer,
    106                                 double duration,
    107                                 float start_opacity,
    108                                 float end_opacity,
    109                                 bool use_timing_function);
    110 
    111 int AddAnimatedTransformToLayer(Layer* layer,
    112                                 double duration,
    113                                 int delta_x,
    114                                 int delta_y);
    115 
    116 int AddAnimatedTransformToLayer(LayerImpl* layer,
    117                                 double duration,
    118                                 int delta_x,
    119                                 int delta_y);
    120 
    121 }  // namespace cc
    122 
    123 #endif  // CC_TEST_ANIMATION_TEST_COMMON_H_
    124