diff options
author | ztenghui <ztenghui@google.com> | 2014-11-21 11:32:29 -0800 |
---|---|---|
committer | Tenghui Zhu <ztenghui@google.com> | 2014-11-21 19:40:34 +0000 |
commit | 996f22f4dfff977806106013e6042aaa3cc1f42d (patch) | |
tree | 6cf360a8598b8cabbc465aa8475af87b9340168e /tests/VectorDrawableTest/src/com | |
parent | 002bc810882c0a322a09d0e4527ab8083547e145 (diff) | |
download | frameworks_base-996f22f4dfff977806106013e6042aaa3cc1f42d.zip frameworks_base-996f22f4dfff977806106013e6042aaa3cc1f42d.tar.gz frameworks_base-996f22f4dfff977806106013e6042aaa3cc1f42d.tar.bz2 |
Supporrt tapas build for vector tests
Such that UX team has less pain on building the VD / AVD assets.
This also requires removing internal API dependence in the test.
To build the VectorDrawableTest with prebuilt SDK.
<root dir>/tapas VectorDrawableTest
<root dir>/make -j64 showcommand
Then later for incremental build.
<root dir>/mmm ./frameworks/base/tests/VectorDrawableTest/ -j20
b/18260896
Change-Id: Id559074df78d7c2a5c529c545834da23986bc15f
Diffstat (limited to 'tests/VectorDrawableTest/src/com')
-rw-r--r-- | tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java index 5a2e5a7..d029050 100644 --- a/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java +++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/VectorDrawablePerformance.java @@ -17,11 +17,18 @@ import android.app.Activity; import android.content.res.Resources; import android.graphics.drawable.VectorDrawable; import android.os.Bundle; +import android.util.AttributeSet; +import android.util.Log; +import android.util.Xml; import android.widget.TextView; import android.widget.Button; import android.widget.GridLayout; import android.widget.ScrollView; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import java.io.IOException; import java.text.DecimalFormat; @SuppressWarnings({"UnusedDeclaration"}) @@ -60,6 +67,31 @@ public class VectorDrawablePerformance extends Activity { R.drawable.vector_drawable30, }; + public static VectorDrawable create(Resources resources, int rid) { + try { + final XmlPullParser parser = resources.getXml(rid); + final AttributeSet attrs = Xml.asAttributeSet(parser); + int type; + while ((type=parser.next()) != XmlPullParser.START_TAG && + type != XmlPullParser.END_DOCUMENT) { + // Empty loop + } + if (type != XmlPullParser.START_TAG) { + throw new XmlPullParserException("No start tag found"); + } + + final VectorDrawable drawable = new VectorDrawable(); + drawable.inflate(resources, parser, attrs); + + return drawable; + } catch (XmlPullParserException e) { + Log.e(LOGCAT, "parser error", e); + } catch (IOException e) { + Log.e(LOGCAT, "parser error", e); + } + return null; + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -72,7 +104,7 @@ public class VectorDrawablePerformance extends Activity { VectorDrawable []d = new VectorDrawable[icon.length]; long time = android.os.SystemClock.elapsedRealtimeNanos(); for (int i = 0; i < icon.length; i++) { - d[i] = VectorDrawable.create(res,icon[i]); + d[i] = create(res,icon[i]); } time = android.os.SystemClock.elapsedRealtimeNanos()-time; TextView t = new TextView(this); |