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

Commit 9ac5a333 authored by Teng-Hui Zhu's avatar Teng-Hui Zhu
Browse files

Add test for private API forceAnimationOnUI

b/27343522

Change-Id: I5167a159f5630ab064f434930f3056754e2c0f44
parent e04ac3d7
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -23,6 +23,4 @@ LOCAL_PACKAGE_NAME := VectorDrawableTest


LOCAL_MODULE_TAGS := tests
LOCAL_MODULE_TAGS := tests


LOCAL_SDK_VERSION := current

include $(BUILD_PACKAGE)
include $(BUILD_PACKAGE)
+0 −2
Original line number Original line Diff line number Diff line
@@ -18,8 +18,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.test.dynamic" >
    package="com.android.test.dynamic" >


    <uses-sdk android:minSdkVersion="21" />

    <application
    <application
        android:hardwareAccelerated="true"
        android:hardwareAccelerated="true"
        android:label="vector"
        android:label="vector"
+35 −18
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import android.view.View;
import android.widget.Button;
import android.widget.Button;
import android.widget.GridLayout;
import android.widget.GridLayout;
import android.widget.ScrollView;
import android.widget.ScrollView;
import android.widget.TextView;


public class AnimatedVectorDrawableTest extends Activity implements View.OnClickListener {
public class AnimatedVectorDrawableTest extends Activity implements View.OnClickListener {
    private static final String LOGCAT = "AnimatedVectorDrawableTest";
    private static final String LOGCAT = "AnimatedVectorDrawableTest";
@@ -45,21 +46,36 @@ public class AnimatedVectorDrawableTest extends Activity implements View.OnClick
    @Override
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    protected void onCreate(Bundle savedInstanceState) {
        final int[] layerTypes = {View.LAYER_TYPE_SOFTWARE, View.LAYER_TYPE_HARDWARE};
        final int[] layerTypes = {View.LAYER_TYPE_SOFTWARE, View.LAYER_TYPE_HARDWARE};
        final boolean[] forceOnUi = {false, true};
        super.onCreate(savedInstanceState);
        super.onCreate(savedInstanceState);


        ScrollView scrollView = new ScrollView(this);
        ScrollView scrollView = new ScrollView(this);
        GridLayout container = new GridLayout(this);
        GridLayout container = new GridLayout(this);
        scrollView.addView(container);
        scrollView.addView(container);
        container.setColumnCount(2);
        container.setColumnCount(layerTypes.length * forceOnUi.length);


        for (int j = 0; j < layerTypes.length; j++) {
            for (int k = 0; k < forceOnUi.length; k++) {
                TextView textView = new TextView(this);
                String category = "Layer:"
                        + (layerTypes[j] == View.LAYER_TYPE_SOFTWARE ? "SW" : "HW")
                        + (forceOnUi[k] == true ? ",forceUI" : "");
                textView.setText(category);
                container.addView(textView);
            }
        }
        for (int i = 0; i < icon.length; i++) {
        for (int i = 0; i < icon.length; i++) {
            for (int j = 0; j < layerTypes.length; j++) {
            for (int j = 0; j < layerTypes.length; j++) {
                for (int k = 0; k < forceOnUi.length; k++) {
                    Button button = new Button(this);
                    Button button = new Button(this);
                button.setWidth(400);
                    button.setWidth(300);
                button.setHeight(400);
                    button.setHeight(300);
                    button.setLayerType(layerTypes[j], null);
                    button.setLayerType(layerTypes[j], null);
                    button.setBackgroundResource(icon[i]);
                    button.setBackgroundResource(icon[i]);
                    AnimatedVectorDrawable d = (AnimatedVectorDrawable) button.getBackground();
                    AnimatedVectorDrawable d = (AnimatedVectorDrawable) button.getBackground();
                    if (forceOnUi[k] == true) {
                        d.forceAnimationOnUI();
                    }
                    d.registerAnimationCallback(new Animatable2.AnimationCallback() {
                    d.registerAnimationCallback(new Animatable2.AnimationCallback() {
                        @Override
                        @Override
                        public void onAnimationStart(Drawable drawable) {
                        public void onAnimationStart(Drawable drawable) {
@@ -76,6 +92,7 @@ public class AnimatedVectorDrawableTest extends Activity implements View.OnClick
                    button.setOnClickListener(this);
                    button.setOnClickListener(this);
                }
                }
            }
            }
        }


        setContentView(scrollView);
        setContentView(scrollView);
    }
    }