diff options
Diffstat (limited to 'tests')
23 files changed, 607 insertions, 22 deletions
diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeLtr.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeLtr.java index 2b5e674f6334..ea08a6af02ae 100644 --- a/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeLtr.java +++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeLtr.java @@ -22,11 +22,25 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.FrameLayout; import android.widget.GridLayout; -import android.widget.*; +import android.widget.Space; +import android.widget.TextView; -import static android.text.InputType.*; -import static android.widget.GridLayout.*; +import static android.text.InputType.TYPE_CLASS_TEXT; +import static android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; +import static android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD; +import static android.widget.GridLayout.ALIGN_BOUNDS; +import static android.widget.GridLayout.BASELINE; +import static android.widget.GridLayout.CENTER; +import static android.widget.GridLayout.FILL; +import static android.widget.GridLayout.LEFT; +import static android.widget.GridLayout.RIGHT; +import static android.widget.GridLayout.START; +import static android.widget.GridLayout.Spec; +import static android.widget.GridLayout.spec; public class BiDiTestGridLayoutCodeLtr extends Fragment { diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeRtl.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeRtl.java index 3a03c6cd65a7..fc3a92ce05fa 100644 --- a/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeRtl.java +++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestGridLayoutCodeRtl.java @@ -22,11 +22,25 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.FrameLayout; import android.widget.GridLayout; -import android.widget.*; +import android.widget.Space; +import android.widget.TextView; -import static android.text.InputType.*; -import static android.widget.GridLayout.*; +import static android.text.InputType.TYPE_CLASS_TEXT; +import static android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; +import static android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD; +import static android.widget.GridLayout.ALIGN_BOUNDS; +import static android.widget.GridLayout.BASELINE; +import static android.widget.GridLayout.CENTER; +import static android.widget.GridLayout.FILL; +import static android.widget.GridLayout.LEFT; +import static android.widget.GridLayout.RIGHT; +import static android.widget.GridLayout.START; +import static android.widget.GridLayout.Spec; +import static android.widget.GridLayout.spec; public class BiDiTestGridLayoutCodeRtl extends Fragment { diff --git a/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java b/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java index 4d3a843cdf87..196a5c1eb01c 100644 --- a/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java +++ b/tests/GridLayoutTest/src/com/android/test/layout/AbstractLayoutTest.java @@ -24,7 +24,13 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; -import static android.view.Gravity.*; +import static android.view.Gravity.BOTTOM; +import static android.view.Gravity.CENTER; +import static android.view.Gravity.FILL; +import static android.view.Gravity.LEFT; +import static android.view.Gravity.NO_GRAVITY; +import static android.view.Gravity.RIGHT; +import static android.view.Gravity.TOP; public abstract class AbstractLayoutTest extends Activity { diff --git a/tests/GridLayoutTest/src/com/android/test/layout/AlignmentTest.java b/tests/GridLayoutTest/src/com/android/test/layout/AlignmentTest.java index b1c4486a7d33..5559707500d2 100644 --- a/tests/GridLayoutTest/src/com/android/test/layout/AlignmentTest.java +++ b/tests/GridLayoutTest/src/com/android/test/layout/AlignmentTest.java @@ -20,15 +20,25 @@ import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.GridLayout; +import android.widget.GridLayout.Alignment; +import android.widget.GridLayout.LayoutParams; import android.widget.TextView; -import static android.widget.GridLayout.*; +import static android.widget.GridLayout.BASELINE; +import static android.widget.GridLayout.BOTTOM; +import static android.widget.GridLayout.CENTER; +import static android.widget.GridLayout.FILL; +import static android.widget.GridLayout.LEFT; +import static android.widget.GridLayout.RIGHT; +import static android.widget.GridLayout.TOP; +import static android.widget.GridLayout.spec; -public class AlignmentTest extends Activity { +public class AlignmentTest extends Activity { public static final String[] HORIZONTAL_NAMES = {"LEFT", "center", "east", "fill"}; public static final Alignment[] HORIZONTAL_ALIGNMENTS = {LEFT, CENTER, RIGHT, FILL}; diff --git a/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java b/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java index 4ce449ac0f11..8047c5f1e41e 100644 --- a/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java +++ b/tests/GridLayoutTest/src/com/android/test/layout/GridLayoutTest.java @@ -21,7 +21,10 @@ import android.view.View; import android.view.ViewGroup; import android.widget.GridLayout; -import static android.widget.GridLayout.*; +import static android.widget.GridLayout.Spec; +import static android.widget.GridLayout.UNDEFINED; +import static android.widget.GridLayout.VERTICAL; +import static android.widget.GridLayout.spec; public class GridLayoutTest extends AbstractLayoutTest { public ViewGroup create(Context context) { diff --git a/tests/GridLayoutTest/src/com/android/test/layout/LinearLayoutTest.java b/tests/GridLayoutTest/src/com/android/test/layout/LinearLayoutTest.java index c7f466561339..dc5b12c17a8d 100644 --- a/tests/GridLayoutTest/src/com/android/test/layout/LinearLayoutTest.java +++ b/tests/GridLayoutTest/src/com/android/test/layout/LinearLayoutTest.java @@ -20,9 +20,9 @@ import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; -import static android.widget.LinearLayout.*; -import static android.widget.LinearLayout.LayoutParams.*; +import static android.widget.LinearLayout.LayoutParams.WRAP_CONTENT; public class LinearLayoutTest extends AbstractLayoutTest { public ViewGroup create(Context context) { diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml index 1bb0db097500..6f774f85ffbb 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -706,6 +706,15 @@ </activity> <activity + android:name="ColorFiltersMutateActivity" + android:label="ColorFilters/Mutate Filters"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + + <activity android:name="LinesActivity" android:label="Draw/Lines"> <intent-filter> diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java new file mode 100644 index 000000000000..808b5d39b44e --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ColorFiltersMutateActivity.java @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2010 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 com.android.test.hwui; + +import android.animation.ArgbEvaluator; +import android.animation.ObjectAnimator; +import android.app.Activity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.ColorMatrix; +import android.graphics.ColorMatrixColorFilter; +import android.graphics.LightingColorFilter; +import android.graphics.Paint; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; +import android.os.Bundle; +import android.view.View; + +@SuppressWarnings({"UnusedDeclaration"}) +public class ColorFiltersMutateActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final BitmapsView view = new BitmapsView(this); + setContentView(view); + } + + static class BitmapsView extends View { + private final Bitmap mBitmap1; + private final Bitmap mBitmap2; + private final Paint mColorMatrixPaint; + private final Paint mLightingPaint; + private final Paint mBlendPaint; + + private float mSaturation = 0.0f; + private int mLightAdd = 0; + private int mLightMul = 0; + private int mPorterDuffColor = 0; + + BitmapsView(Context c) { + super(c); + + mBitmap1 = BitmapFactory.decodeResource(c.getResources(), R.drawable.sunset1); + mBitmap2 = BitmapFactory.decodeResource(c.getResources(), R.drawable.sunset2); + + mColorMatrixPaint = new Paint(); + final ColorMatrix colorMatrix = new ColorMatrix(); + colorMatrix.setSaturation(0); + mColorMatrixPaint.setColorFilter(new ColorMatrixColorFilter(colorMatrix)); + + mLightingPaint = new Paint(); + mLightingPaint.setColorFilter(new LightingColorFilter(0, 0)); + + mBlendPaint = new Paint(); + mBlendPaint.setColorFilter(new PorterDuffColorFilter(0, PorterDuff.Mode.SRC_OVER)); + + ObjectAnimator sat = ObjectAnimator.ofFloat(this, "saturation", 1.0f); + sat.setDuration(1000); + sat.setRepeatCount(ObjectAnimator.INFINITE); + sat.setRepeatMode(ObjectAnimator.REVERSE); + sat.start(); + + ObjectAnimator light = ObjectAnimator.ofInt(this, "lightAdd", 0x00101030); + light.setEvaluator(new ArgbEvaluator()); + light.setDuration(1000); + light.setRepeatCount(ObjectAnimator.INFINITE); + light.setRepeatMode(ObjectAnimator.REVERSE); + light.start(); + + ObjectAnimator mult = ObjectAnimator.ofInt(this, "lightMul", 0x0060ffff); + mult.setEvaluator(new ArgbEvaluator()); + mult.setDuration(1000); + mult.setRepeatCount(ObjectAnimator.INFINITE); + mult.setRepeatMode(ObjectAnimator.REVERSE); + mult.start(); + + ObjectAnimator color = ObjectAnimator.ofInt(this, "porterDuffColor", 0x7f990040); + color.setEvaluator(new ArgbEvaluator()); + color.setDuration(1000); + color.setRepeatCount(ObjectAnimator.INFINITE); + color.setRepeatMode(ObjectAnimator.REVERSE); + color.start(); + } + + public int getPorterDuffColor() { + return mPorterDuffColor; + } + + public void setPorterDuffColor(int porterDuffColor) { + mPorterDuffColor = porterDuffColor; + final PorterDuffColorFilter filter = + (PorterDuffColorFilter) mBlendPaint.getColorFilter(); + filter.setColor(mPorterDuffColor); + invalidate(); + } + + public int getLightAdd() { + return mLightAdd; + } + + public void setLightAdd(int lightAdd) { + mLightAdd = lightAdd; + final LightingColorFilter filter = + (LightingColorFilter) mLightingPaint.getColorFilter(); + filter.setColorAdd(lightAdd); + invalidate(); + } + + public int getLightMul() { + return mLightAdd; + } + + public void setLightMul(int lightMul) { + mLightMul = lightMul; + final LightingColorFilter filter = + (LightingColorFilter) mLightingPaint.getColorFilter(); + filter.setColorMultiply(lightMul); + invalidate(); + } + + public void setSaturation(float saturation) { + mSaturation = saturation; + final ColorMatrixColorFilter filter = + (ColorMatrixColorFilter) mColorMatrixPaint.getColorFilter(); + final ColorMatrix m = filter.getColorMatrix(); + m.setSaturation(saturation); + filter.setColorMatrix(m); + invalidate(); + } + + public float getSaturation() { + return mSaturation; + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + canvas.drawARGB(255, 255, 255, 255); + + canvas.save(); + canvas.translate(120.0f, 50.0f); + canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mColorMatrixPaint); + + canvas.translate(0.0f, 50.0f + mBitmap1.getHeight()); + canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mLightingPaint); + + canvas.translate(0.0f, 50.0f + mBitmap1.getHeight()); + canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mBlendPaint); + canvas.restore(); + + canvas.save(); + canvas.translate(120.0f + mBitmap1.getWidth() + 120.0f, 50.0f); + canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mColorMatrixPaint); + + canvas.translate(0.0f, 50.0f + mBitmap2.getHeight()); + canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mLightingPaint); + + canvas.translate(0.0f, 50.0f + mBitmap2.getHeight()); + canvas.drawBitmap(mBitmap2, 0.0f, 0.0f, mBlendPaint); + canvas.restore(); + } + } +} diff --git a/tests/RenderThreadTest/Android.mk b/tests/RenderThreadTest/Android.mk new file mode 100644 index 000000000000..bdcba2e6a15a --- /dev/null +++ b/tests/RenderThreadTest/Android.mk @@ -0,0 +1,18 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +# Only compile source java files in this apk. +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := RenderThreadTest + +LOCAL_STATIC_JAVA_LIBRARIES += android-common + +LOCAL_PROGUARD_ENABLED := disabled + +include $(BUILD_PACKAGE) + +# Use the following include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/RenderThreadTest/AndroidManifest.xml b/tests/RenderThreadTest/AndroidManifest.xml new file mode 100644 index 000000000000..c76cfcead8f0 --- /dev/null +++ b/tests/RenderThreadTest/AndroidManifest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.example.renderthread" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk + android:minSdkVersion="18" + android:targetSdkVersion="18" /> + + <application + android:allowBackup="true" + android:icon="@drawable/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" > + <activity + android:name=".MainActivity" + android:label="@string/app_name" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity android:name=".SubActivity" + android:theme="@style/AppTheme.Transparent" /> + </application> + +</manifest> diff --git a/tests/RenderThreadTest/res/drawable-hdpi/ic_launcher.png b/tests/RenderThreadTest/res/drawable-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 000000000000..96a442e5b8e9 --- /dev/null +++ b/tests/RenderThreadTest/res/drawable-hdpi/ic_launcher.png diff --git a/tests/RenderThreadTest/res/drawable-mdpi/ic_launcher.png b/tests/RenderThreadTest/res/drawable-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 000000000000..359047dfa4ed --- /dev/null +++ b/tests/RenderThreadTest/res/drawable-mdpi/ic_launcher.png diff --git a/tests/RenderThreadTest/res/drawable-xhdpi/ic_launcher.png b/tests/RenderThreadTest/res/drawable-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 000000000000..71c6d760f051 --- /dev/null +++ b/tests/RenderThreadTest/res/drawable-xhdpi/ic_launcher.png diff --git a/tests/RenderThreadTest/res/drawable-xhdpi/starry_night_bg.jpg b/tests/RenderThreadTest/res/drawable-xhdpi/starry_night_bg.jpg Binary files differnew file mode 100644 index 000000000000..755232deea0e --- /dev/null +++ b/tests/RenderThreadTest/res/drawable-xhdpi/starry_night_bg.jpg diff --git a/tests/RenderThreadTest/res/layout/activity_main.xml b/tests/RenderThreadTest/res/layout/activity_main.xml new file mode 100644 index 000000000000..1fd545946f3c --- /dev/null +++ b/tests/RenderThreadTest/res/layout/activity_main.xml @@ -0,0 +1,12 @@ +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".MainActivity" > + + <ListView android:id="@android:id/list" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:divider="@null" /> + +</FrameLayout> diff --git a/tests/RenderThreadTest/res/layout/activity_sub.xml b/tests/RenderThreadTest/res/layout/activity_sub.xml new file mode 100644 index 000000000000..713cee49de53 --- /dev/null +++ b/tests/RenderThreadTest/res/layout/activity_sub.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + + <View + android:id="@+id/bg_container" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/starry_night_bg" /> + + <LinearLayout + android:id="@+id/my_container" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <View + android:id="@+id/from_left" + android:layout_width="match_parent" + android:layout_height="48dip" + android:background="#7000FF00" /> + + <View + android:id="@+id/from_right" + android:layout_width="match_parent" + android:layout_height="0dip" + android:layout_margin="80dip" + android:layout_weight="1" + android:background="#90FF0000" /> + + <View + android:id="@+id/from_left" + android:layout_width="match_parent" + android:layout_height="48dip" + android:background="#7000FF00" /> + </LinearLayout> + +</FrameLayout>
\ No newline at end of file diff --git a/tests/RenderThreadTest/res/layout/item_layout.xml b/tests/RenderThreadTest/res/layout/item_layout.xml new file mode 100644 index 000000000000..5bdb1ac422f5 --- /dev/null +++ b/tests/RenderThreadTest/res/layout/item_layout.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceListItemSmall" + android:gravity="center_vertical" + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" + android:minHeight="?android:attr/listPreferredItemHeightSmall" + android:background="#33b5e5" +/>
\ No newline at end of file diff --git a/tests/RenderThreadTest/res/values/strings.xml b/tests/RenderThreadTest/res/values/strings.xml new file mode 100644 index 000000000000..f782e98f43f8 --- /dev/null +++ b/tests/RenderThreadTest/res/values/strings.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">Render Thread</string> + <string name="action_settings">Settings</string> + <string name="hello_world">Hello world!</string> + +</resources> diff --git a/tests/RenderThreadTest/res/values/styles.xml b/tests/RenderThreadTest/res/values/styles.xml new file mode 100644 index 000000000000..f6b5d6aa6dbc --- /dev/null +++ b/tests/RenderThreadTest/res/values/styles.xml @@ -0,0 +1,11 @@ +<resources> + <!-- Application theme. --> + <style name="AppTheme" parent="android:Theme.Holo.Light"> + </style> + + <style name="AppTheme.Transparent"> + <item name="android:windowIsTranslucent">true</item> + <item name="android:windowBackground">@android:color/transparent</item> + </style> + +</resources> diff --git a/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java b/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java new file mode 100644 index 000000000000..a39aba80e65c --- /dev/null +++ b/tests/RenderThreadTest/src/com/example/renderthread/MainActivity.java @@ -0,0 +1,158 @@ + +package com.example.renderthread; + +import android.animation.TimeInterpolator; +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.SystemClock; +import android.view.DisplayList; +import android.view.HardwareRenderer; +import android.view.ThreadedRenderer; +import android.view.View; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ListView; +import android.widget.SimpleAdapter; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class MainActivity extends Activity implements OnItemClickListener { + + static final int DURATION = 400; + + static final String KEY_NAME = "name"; + static final String KEY_CLASS = "clazz"; + + static Map<String,?> make(String name) { + Map<String,Object> ret = new HashMap<String,Object>(); + ret.put(KEY_NAME, name); + return ret; + } + + @SuppressWarnings("serial") + static final ArrayList<Map<String,?>> SAMPLES = new ArrayList<Map<String,?>>() {{ + for (int i = 1; i < 25; i++) { + add(make("List Item: " + i)); + } + }}; + + Handler mHandler = new Handler(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + HardwareRenderer.sUseRenderThread = true; + setContentView(R.layout.activity_main); + ListView lv = (ListView) findViewById(android.R.id.list); + lv.setDrawSelectorOnTop(true); + lv.setAdapter(new SimpleAdapter(this, SAMPLES, + R.layout.item_layout, new String[] { KEY_NAME }, + new int[] { android.R.id.text1 })); + lv.setOnItemClickListener(this); + getActionBar().setTitle("MainActivity"); + } + + @Override + protected void onResume() { + super.onResume(); + ListView lv = (ListView) findViewById(android.R.id.list); + for (int i = 0; i < lv.getChildCount(); i++) { + lv.getChildAt(i).animate().translationY(0).setDuration(DURATION); + } + } + + private static class DisplayListAnimator { + private static final TimeInterpolator sDefaultInterpolator = + new AccelerateDecelerateInterpolator(); + + DisplayList mDisplayList; + float mFromValue; + float mDelta; + long mDuration = DURATION * 2; + long mStartTime; + + DisplayListAnimator(View view, float translateXBy) { + mDelta = translateXBy; + mFromValue = view.getTranslationY(); + mDisplayList = view.getDisplayList(); + } + + boolean animate(long currentTime) { + if (mStartTime == 0) mStartTime = currentTime; + + float fraction = (float)(currentTime - mStartTime) / mDuration; + if (fraction > 1) { + return false; + } + fraction = sDefaultInterpolator.getInterpolation(fraction); + float translation = mFromValue + (mDelta * fraction); + mDisplayList.setTranslationY(translation); + return fraction < 1f; + } + } + + private static class AnimationExecutor implements Runnable { + DisplayListAnimator[] mAnimations; + ThreadedRenderer mRenderer; + + AnimationExecutor(ThreadedRenderer renderer, DisplayListAnimator[] animations) { + mRenderer = renderer; + mAnimations = animations; + ThreadedRenderer.postToRenderThread(this); + } + + @Override + public void run() { + boolean hasMore = false; + long now = SystemClock.uptimeMillis(); + for (DisplayListAnimator animator : mAnimations) { + hasMore |= animator.animate(now); + } + mRenderer.repeatLastDraw(); + if (hasMore) { + ThreadedRenderer.postToRenderThread(this); + } + } + + } + + @Override + public void onItemClick(final AdapterView<?> adapterView, View clickedView, + int clickedPosition, long clickedId) { + int topPosition = adapterView.getFirstVisiblePosition(); + int dy = adapterView.getHeight(); + final DisplayListAnimator[] animators = new DisplayListAnimator[adapterView.getChildCount()]; + for (int i = 0; i < adapterView.getChildCount(); i++) { + int pos = topPosition + i; + View child = adapterView.getChildAt(i); + float delta = (pos - clickedPosition) * 1.1f; + if (delta == 0) delta = -1; + animators[i] = new DisplayListAnimator(child, dy * delta); + } + adapterView.invalidate(); + adapterView.post(new Runnable() { + + @Override + public void run() { + new AnimationExecutor((ThreadedRenderer) adapterView.getHardwareRenderer(), animators); + } + }); + //mHandler.postDelayed(mLaunchActivity, (long) (DURATION * .4)); + mLaunchActivity.run(); + } + + private Runnable mLaunchActivity = new Runnable() { + + @Override + public void run() { + startActivity(new Intent(MainActivity.this, SubActivity.class)); + overridePendingTransition(0, 0); + } + }; + +} diff --git a/tests/RenderThreadTest/src/com/example/renderthread/SubActivity.java b/tests/RenderThreadTest/src/com/example/renderthread/SubActivity.java new file mode 100644 index 000000000000..892cbae50560 --- /dev/null +++ b/tests/RenderThreadTest/src/com/example/renderthread/SubActivity.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2013 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 com.example.renderthread; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Process; +import android.os.SystemClock; +import android.view.View; +import android.view.ViewGroup; + +public class SubActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + long before = SystemClock.currentThreadTimeMillis(); + setContentView(R.layout.activity_sub); + getActionBar().setTitle("SubActivity"); + // Simulate being a real app! + while (SystemClock.currentThreadTimeMillis() - before < 100) { + View v = new View(this, null); + } + } + + @Override + protected void onResume() { + super.onResume(); + ViewGroup container = (ViewGroup) findViewById(R.id.my_container); + int dx = getWindowManager().getDefaultDisplay().getWidth(); + for (int i = 0; i < container.getChildCount(); i++) { + View child = container.getChildAt(i); + int dir = child.getId() == R.id.from_left ? 1 : -1; + child.setTranslationX(dx * dir); + child.animate().translationX(0).setDuration(MainActivity.DURATION); + } + View bg = findViewById(R.id.bg_container); + bg.setAlpha(0f); + bg.animate().alpha(1f).setDuration(MainActivity.DURATION); + } + + @Override + public void onBackPressed() { + super.onBackPressed(); + overridePendingTransition(0, 0); + } +} diff --git a/tests/SmokeTest/tests/AndroidManifest.xml b/tests/SmokeTest/tests/AndroidManifest.xml index cad37c576ceb..f1a0a4c1d54e 100644 --- a/tests/SmokeTest/tests/AndroidManifest.xml +++ b/tests/SmokeTest/tests/AndroidManifest.xml @@ -27,15 +27,6 @@ </application> <!-- - This declares that this app uses the instrumentation test runner targeting the package of - com.android.smoketest. To run the tests use the command: - `adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner` - --> - <instrumentation android:name="android.test.InstrumentationTestRunner" - android:targetPackage="com.android.smoketest" - android:label="System Smoke Tests"/> - - <!-- This declares a method to run the instrumentation with a special runner, which will run each app as a separate testcase. To do so, use the command: `adb shell am instrument -w com.android.smoketest.tests/com.android.smoketest.SmokeTestRunner` diff --git a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java index 03c2923900f6..946299b599e6 100644 --- a/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java +++ b/tests/SmokeTest/tests/src/com/android/smoketest/ProcessErrorsTest.java @@ -154,6 +154,11 @@ public class ProcessErrorsTest extends AndroidTestCase { // launch app, and wait 7 seconds for it to start/settle final Intent intent = intentForActivity(app); + if (intent == null) { + Log.i(TAG, String.format("Activity %s/%s is disabled, skipping", + app.activityInfo.packageName, app.activityInfo.name)); + return Collections.EMPTY_LIST; + } getContext().startActivity(intent); try { Thread.sleep(appLaunchWait); @@ -238,10 +243,16 @@ public class ProcessErrorsTest extends AndroidTestCase { /** * A helper function to create an {@link Intent} to run, given a {@link ResolveInfo} specifying * an activity to be launched. + * + * @return the {@link Intent} or <code>null</code> if given app is disabled */ - static Intent intentForActivity(ResolveInfo app) { + Intent intentForActivity(ResolveInfo app) { final ComponentName component = new ComponentName(app.activityInfo.packageName, app.activityInfo.name); + if (getContext().getPackageManager().getComponentEnabledSetting(component) == + PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { + return null; + } final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(component); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |