summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apct-tests/perftests/core/AndroidManifest.xml2
-rw-r--r--apct-tests/perftests/core/src/android/widget/TextViewSetTextLocalePerfTest.java1
-rw-r--r--apct-tests/perftests/graphics/Android.mk4
-rw-r--r--apct-tests/perftests/graphics/AndroidManifest.xml4
-rw-r--r--apct-tests/perftests/graphics/src/android/graphics/perftests/StubActivity.java6
-rw-r--r--apct-tests/perftests/graphics/src/android/graphics/perftests/VectorDrawablePerfTest.java35
-rw-r--r--apct-tests/perftests/utils/src/android/perftests/utils/BitmapUtils.java9
-rw-r--r--apct-tests/perftests/utils/src/android/perftests/utils/StubActivity.java (renamed from apct-tests/perftests/core/src/android/widget/StubActivity.java)5
8 files changed, 36 insertions, 30 deletions
diff --git a/apct-tests/perftests/core/AndroidManifest.xml b/apct-tests/perftests/core/AndroidManifest.xml
index b67e57f527fc..ecb8d9588c41 100644
--- a/apct-tests/perftests/core/AndroidManifest.xml
+++ b/apct-tests/perftests/core/AndroidManifest.xml
@@ -4,7 +4,7 @@
<application>
<uses-library android:name="android.test.runner" />
- <activity android:name="android.widget.StubActivity" />
+ <activity android:name="android.perftests.utils.StubActivity" />
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/apct-tests/perftests/core/src/android/widget/TextViewSetTextLocalePerfTest.java b/apct-tests/perftests/core/src/android/widget/TextViewSetTextLocalePerfTest.java
index c5e8db022576..030bd2cb94b7 100644
--- a/apct-tests/perftests/core/src/android/widget/TextViewSetTextLocalePerfTest.java
+++ b/apct-tests/perftests/core/src/android/widget/TextViewSetTextLocalePerfTest.java
@@ -21,6 +21,7 @@ import android.os.Bundle;
import android.util.Log;
import android.perftests.utils.BenchmarkState;
+import android.perftests.utils.StubActivity;
import android.support.test.filters.LargeTest;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.rule.ActivityTestRule;
diff --git a/apct-tests/perftests/graphics/Android.mk b/apct-tests/perftests/graphics/Android.mk
index ee0bdc19e797..afdd7438bf4b 100644
--- a/apct-tests/perftests/graphics/Android.mk
+++ b/apct-tests/perftests/graphics/Android.mk
@@ -3,13 +3,11 @@ include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := tests
-LOCAL_STATIC_JAVA_LIBRARIES := apct-perftests-utils
+LOCAL_STATIC_JAVA_LIBRARIES := apct-perftests-utils android-support-test
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
LOCAL_PACKAGE_NAME := GraphicsPerfTests
include $(BUILD_PACKAGE)
diff --git a/apct-tests/perftests/graphics/AndroidManifest.xml b/apct-tests/perftests/graphics/AndroidManifest.xml
index b41ec0cafecc..5416458996ff 100644
--- a/apct-tests/perftests/graphics/AndroidManifest.xml
+++ b/apct-tests/perftests/graphics/AndroidManifest.xml
@@ -6,7 +6,7 @@
<application>
<uses-library android:name="android.test.runner" />
- <activity android:name="android.graphics.perftests.StubActivity" >
+ <activity android:name="android.perftests.utils.StubActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@@ -15,7 +15,7 @@
<uses-library android:name="android.test.runner" />
</application>
- <instrumentation android:name="android.test.InstrumentationTestRunner"
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
android:targetPackage="com.android.frameworks.perftests"/>
</manifest>
diff --git a/apct-tests/perftests/graphics/src/android/graphics/perftests/StubActivity.java b/apct-tests/perftests/graphics/src/android/graphics/perftests/StubActivity.java
deleted file mode 100644
index 3b24f5db2204..000000000000
--- a/apct-tests/perftests/graphics/src/android/graphics/perftests/StubActivity.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package android.graphics.perftests;
-
-import android.app.Activity;
-
-public class StubActivity extends Activity {
-} \ No newline at end of file
diff --git a/apct-tests/perftests/graphics/src/android/graphics/perftests/VectorDrawablePerfTest.java b/apct-tests/perftests/graphics/src/android/graphics/perftests/VectorDrawablePerfTest.java
index 3e8d6d2345ee..fc203ee04f0d 100644
--- a/apct-tests/perftests/graphics/src/android/graphics/perftests/VectorDrawablePerfTest.java
+++ b/apct-tests/perftests/graphics/src/android/graphics/perftests/VectorDrawablePerfTest.java
@@ -16,22 +16,32 @@
package android.graphics.perftests;
+import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.VectorDrawable;
-
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.BitmapUtils;
-import android.test.ActivityInstrumentationTestCase2;
+import android.perftests.utils.StubActivity;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import com.android.frameworks.perftests.R;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.io.IOException;
+import static junit.framework.Assert.assertTrue;
+
+@RunWith(AndroidJUnit4.class)
@LargeTest
-public class VectorDrawablePerfTest extends ActivityInstrumentationTestCase2<StubActivity> {
+public class VectorDrawablePerfTest {
private static final boolean DUMP_BITMAP = false;
@@ -40,14 +50,16 @@ public class VectorDrawablePerfTest extends ActivityInstrumentationTestCase2<Stu
private String KEY_VECTORDRAWABLE_DRAW_TIME = "VectorDrawable_Draw_Time_NanoSec";
- public VectorDrawablePerfTest() {
- super(StubActivity.class);
- }
+ @Rule
+ public ActivityTestRule<StubActivity> mActivityRule =
+ new ActivityTestRule(StubActivity.class);
+
- @LargeTest
- public void testBitmapDrawPerf() throws IOException {
+ @Test
+ public void testBitmapDrawPerf() {
int resId = R.drawable.vector_drawable01;
- VectorDrawable vd = (VectorDrawable) getActivity().getDrawable(resId);
+ Activity activity = mActivityRule.getActivity();
+ VectorDrawable vd = (VectorDrawable) activity.getDrawable(resId);
int w = 1024, h = 1024;
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
@@ -72,9 +84,10 @@ public class VectorDrawablePerfTest extends ActivityInstrumentationTestCase2<Stu
assertTrue("The right bottom part should be empty", emptyColor == Color.TRANSPARENT);
if (DUMP_BITMAP) {
- BitmapUtils.saveBitmapIntoPNG(getActivity(), bmp, resId);
+ BitmapUtils.saveBitmapIntoPNG(activity, bmp, resId);
}
- state.sendFullStatusReport(getInstrumentation(), KEY_VECTORDRAWABLE_DRAW_TIME);
+ state.sendFullStatusReport(InstrumentationRegistry.getInstrumentation(),
+ KEY_VECTORDRAWABLE_DRAW_TIME);
}
}
diff --git a/apct-tests/perftests/utils/src/android/perftests/utils/BitmapUtils.java b/apct-tests/perftests/utils/src/android/perftests/utils/BitmapUtils.java
index 4d0d97196241..6a3a6da6e5f6 100644
--- a/apct-tests/perftests/utils/src/android/perftests/utils/BitmapUtils.java
+++ b/apct-tests/perftests/utils/src/android/perftests/utils/BitmapUtils.java
@@ -27,7 +27,7 @@ import java.io.IOException;
public class BitmapUtils {
private static final String TAG = "BitmapUtils";
- public static void saveBitmapIntoPNG(Context context, Bitmap bitmap, int resId) throws IOException {
+ public static void saveBitmapIntoPNG(Context context, Bitmap bitmap, int resId) {
// Save the image to the disk.
FileOutputStream out = null;
try {
@@ -44,13 +44,12 @@ public class BitmapUtils {
out = new FileOutputStream(outputFile, false);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
- Log.v(TAG, "Write test No." + outputFile.getAbsolutePath() + " to file successfully.");
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
if (out != null) {
out.close();
}
+ Log.v(TAG, "Write test No." + outputFile.getAbsolutePath() + " to file successfully.");
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
}
diff --git a/apct-tests/perftests/core/src/android/widget/StubActivity.java b/apct-tests/perftests/utils/src/android/perftests/utils/StubActivity.java
index f821d77561e0..6012f4b12b3d 100644
--- a/apct-tests/perftests/core/src/android/widget/StubActivity.java
+++ b/apct-tests/perftests/utils/src/android/perftests/utils/StubActivity.java
@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.widget;
+
+package android.perftests.utils;
import android.app.Activity;
public class StubActivity extends Activity {
-}
+} \ No newline at end of file