Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1631dcd authored by George Mount's avatar George Mount Committed by Android (Google) Code Review
Browse files

Merge "Add test for Transition clone." into nyc-dev

parents 193b8218 bf7c3b4f
Loading
Loading
Loading
Loading
+103 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.transition;

import android.animation.AnimatorSetActivity;
import android.app.Activity;
import android.graphics.Rect;
import android.test.ActivityInstrumentationTestCase2;
import android.transition.Transition.EpicenterCallback;
import android.util.ArrayMap;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.widget.TextView;

import com.android.frameworks.coretests.R;

public class TransitionTest extends ActivityInstrumentationTestCase2<AnimatorSetActivity> {
    Activity mActivity;
    public TransitionTest() {
        super(AnimatorSetActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        mActivity = getActivity();
    }

    public void testClone() throws Throwable {
        View square1 = mActivity.findViewById(R.id.square1);
        View square2 = mActivity.findViewById(R.id.square2);
        View square3 = mActivity.findViewById(R.id.square3);
        Fade fade = new Fade();
        fade.setStartDelay(1000);
        fade.setDuration(1001);

        fade.addTarget(square1);
        fade.excludeTarget(square2, true);
        fade.excludeChildren(square3, true);

        fade.addTarget(R.id.square4);
        fade.excludeTarget(R.id.square3, true);
        fade.excludeChildren(R.id.square2, true);

        fade.addTarget("hello");
        fade.excludeTarget("world", true);

        fade.addTarget(View.class);
        fade.excludeTarget(TextView.class, true);

        fade.setMatchOrder(Transition.MATCH_ID);
        fade.setPropagation(new CircularPropagation());
        fade.setPathMotion(new ArcMotion());
        fade.setInterpolator(new AccelerateInterpolator());
        fade.setNameOverrides(new ArrayMap<>());

        EpicenterCallback epicenterCallback = new EpicenterCallback() {
            @Override
            public Rect onGetEpicenter(Transition transition) {
                return null;
            }
        };

        fade.setEpicenterCallback(epicenterCallback);

        Fade clone = (Fade) fade.clone();
        assertEquals(fade.mStartDelay, clone.mStartDelay);
        assertEquals(fade.mDuration, clone.mDuration);
        assertEquals(fade.mInterpolator, clone.mInterpolator);
        assertEquals(fade.mPropagation, clone.mPropagation);
        assertEquals(fade.getPathMotion(), clone.getPathMotion());
        assertEquals(fade.getEpicenterCallback(), clone.getEpicenterCallback());
        assertEquals(fade.mNameOverrides, clone.mNameOverrides);
        assertEquals(fade.mMatchOrder, clone.mMatchOrder);

        assertEquals(fade.mTargets, clone.mTargets);
        assertEquals(fade.mTargetExcludes, clone.mTargetExcludes);
        assertEquals(fade.mTargetChildExcludes, clone.mTargetChildExcludes);

        assertEquals(fade.mTargetIds, clone.mTargetIds);
        assertEquals(fade.mTargetIdExcludes, clone.mTargetIdExcludes);
        assertEquals(fade.mTargetIdChildExcludes, clone.mTargetIdChildExcludes);

        assertEquals(fade.mTargetNames, clone.mTargetNames);
        assertEquals(fade.mTargetNameExcludes, clone.mTargetNameExcludes);

        assertEquals(fade.mTargetTypes, clone.mTargetTypes);
        assertEquals(fade.mTargetTypeExcludes, clone.mTargetTypeExcludes);
    }
}