Merge "Add test for private API forceAnimationOnUI" into nyc-dev

This commit is contained in:
Tenghui Zhu
2016-03-31 22:06:52 +00:00
committed by Android (Google) Code Review
3 changed files with 35 additions and 22 deletions

View File

@@ -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)

View File

@@ -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"

View File

@@ -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,35 +46,51 @@ 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++) {
Button button = new Button(this); for (int k = 0; k < forceOnUi.length; k++) {
button.setWidth(400); Button button = new Button(this);
button.setHeight(400); button.setWidth(300);
button.setLayerType(layerTypes[j], null); button.setHeight(300);
button.setBackgroundResource(icon[i]); button.setLayerType(layerTypes[j], null);
AnimatedVectorDrawable d = (AnimatedVectorDrawable) button.getBackground(); button.setBackgroundResource(icon[i]);
d.registerAnimationCallback(new Animatable2.AnimationCallback() { AnimatedVectorDrawable d = (AnimatedVectorDrawable) button.getBackground();
@Override if (forceOnUi[k] == true) {
public void onAnimationStart(Drawable drawable) { d.forceAnimationOnUI();
Log.v(LOGCAT, "Animator start");
} }
d.registerAnimationCallback(new Animatable2.AnimationCallback() {
@Override
public void onAnimationStart(Drawable drawable) {
Log.v(LOGCAT, "Animator start");
}
@Override @Override
public void onAnimationEnd(Drawable drawable) { public void onAnimationEnd(Drawable drawable) {
Log.v(LOGCAT, "Animator end"); Log.v(LOGCAT, "Animator end");
} }
}); });
container.addView(button); container.addView(button);
button.setOnClickListener(this); button.setOnClickListener(this);
}
} }
} }