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

Commit 3b732c01 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Switch APCT View tests to Jetpack Benchmark"

parents 172b4510 6523a4fb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ android_test {
        "androidx.appcompat_appcompat",
        "androidx.test.rules",
        "androidx.annotation_annotation",
        "androidx.benchmark_benchmark-common",
        "androidx.benchmark_benchmark-junit4",
        "apct-perftests-overlay-apps",
        "apct-perftests-resources-manager-apps",
        "apct-perftests-utils",
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@

    </application>

    <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
    <instrumentation android:name="androidx.benchmark.junit4.AndroidBenchmarkRunner"
        android:targetPackage="com.android.perftests.core"/>

</manifest>
+7 −7
Original line number Diff line number Diff line
@@ -22,13 +22,13 @@ import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.PathParser;

import androidx.benchmark.BenchmarkState;
import androidx.benchmark.junit4.BenchmarkRule;
import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
@@ -67,7 +67,7 @@ public class CutoutSpecificationBenchmark {
            + "Z\n"
            + "@dp";
    @Rule
    public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
    public BenchmarkRule mBenchmarkRule = new BenchmarkRule();

    private Context mContext;
    private DisplayMetrics mDisplayMetrics;
@@ -168,7 +168,7 @@ public class CutoutSpecificationBenchmark {

    @Test
    public void parseByOldMethodForDoubleCutout() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        while (state.keepRunning()) {
            oldMethodParsingSpec(DOUBLE_CUTOUT_SPEC, mDisplayMetrics.widthPixels,
                    mDisplayMetrics.heightPixels, mDisplayMetrics.density);
@@ -177,7 +177,7 @@ public class CutoutSpecificationBenchmark {

    @Test
    public void parseByNewMethodForDoubleCutout() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        while (state.keepRunning()) {
            new CutoutSpecification.Parser(mDisplayMetrics.density,
                    mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)
@@ -209,7 +209,7 @@ public class CutoutSpecificationBenchmark {
                + "@right\n"
                + "@dp";

        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        while (state.keepRunning()) {
            new CutoutSpecification.Parser(mDisplayMetrics.density,
                    mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels).parse(spec);
@@ -231,7 +231,7 @@ public class CutoutSpecificationBenchmark {
                + "Z\n"
                + "@dp";

        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        while (state.keepRunning()) {
            new CutoutSpecification.Parser(mDisplayMetrics.density,
                    mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels).parse(spec);
+6 −6
Original line number Diff line number Diff line
@@ -19,11 +19,11 @@ package android.view;
import static junit.framework.Assert.assertTrue;

import android.content.Context;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;
import android.perftests.utils.PerfTestActivity;
import android.widget.FrameLayout;

import androidx.benchmark.BenchmarkState;
import androidx.benchmark.junit4.BenchmarkRule;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
@@ -37,7 +37,7 @@ import org.junit.Test;
@LargeTest
public class ViewPerfTest {
    @Rule
    public final PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
    public final BenchmarkRule mBenchmarkRule = new BenchmarkRule();

    @Rule
    public final ActivityTestRule<PerfTestActivity> mActivityRule =
@@ -52,7 +52,7 @@ public class ViewPerfTest {

    @Test
    public void testSimpleViewInflate() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        LayoutInflater inflater = LayoutInflater.from(mContext);
        FrameLayout root = new FrameLayout(mContext);
        while (state.keepRunning()) {
@@ -62,7 +62,7 @@ public class ViewPerfTest {

    @Test
    public void testTwelveKeyInflate() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        LayoutInflater inflater = LayoutInflater.from(mContext);
        FrameLayout root = new FrameLayout(mContext);
        while (state.keepRunning()) {
@@ -72,7 +72,7 @@ public class ViewPerfTest {

    @Test
    public void testPerformHapticFeedback() throws Throwable {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        mActivityRule.runOnUiThread(() -> {
            state.pauseTiming();
            View view = new View(mContext);
+4 −4
Original line number Diff line number Diff line
@@ -21,14 +21,14 @@ import static org.junit.Assert.assertTrue;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;
import android.perftests.utils.PerfTestActivity;
import android.view.View.MeasureSpec;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.benchmark.BenchmarkState;
import androidx.benchmark.junit4.BenchmarkRule;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
@@ -50,7 +50,7 @@ public class ViewShowHidePerfTest {
            new ActivityTestRule<>(PerfTestActivity.class);

    @Rule
    public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
    public final BenchmarkRule mBenchmarkRule = new BenchmarkRule();

    public Context getContext() {
        return InstrumentationRegistry.getInstrumentation().getTargetContext();
@@ -143,7 +143,7 @@ public class ViewShowHidePerfTest {

    private void testParentWithChild(TestCallback callback) throws Throwable {
        mActivityRule.runOnUiThread(() -> {
            final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
            final BenchmarkState state = mBenchmarkRule.getState();

            FrameLayout parent = new FrameLayout(getContext());
            mActivityRule.getActivity().setContentView(parent);