Home | History | Annotate | Download | only in surfacevalidator
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package android.view.cts.surfacevalidator;
     17 
     18 import android.animation.ValueAnimator;
     19 import android.content.Context;
     20 import android.view.View;
     21 import android.widget.FrameLayout;
     22 
     23 public class AnimationTestCase {
     24     private final ViewFactory mViewFactory;
     25     private final FrameLayout.LayoutParams mLayoutParams;
     26     private final AnimationFactory mAnimationFactory;
     27     private final PixelChecker mPixelChecker;
     28 
     29     private FrameLayout mParent;
     30     private ValueAnimator mAnimator;
     31 
     32     public AnimationTestCase(ViewFactory viewFactory,
     33             FrameLayout.LayoutParams layoutParams,
     34             AnimationFactory animationFactory,
     35             PixelChecker pixelChecker) {
     36         mViewFactory = viewFactory;
     37         mLayoutParams = layoutParams;
     38         mAnimationFactory = animationFactory;
     39         mPixelChecker = pixelChecker;
     40     }
     41 
     42     PixelChecker getChecker() {
     43         return mPixelChecker;
     44     }
     45 
     46     public void start(Context context, FrameLayout parent) {
     47         mParent = parent;
     48         mParent.removeAllViews();
     49         View view = mViewFactory.createView(context);
     50         mParent.addView(view, mLayoutParams);
     51         mAnimator = mAnimationFactory.createAnimator(view);
     52         mAnimator.start();
     53     }
     54 
     55     public void end() {
     56         mAnimator.cancel();
     57         mParent.removeAllViews();
     58     }
     59 }
     60