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

Commit 578f4714 authored by Teng-Hui Zhu's avatar Teng-Hui Zhu
Browse files

Switch APCT Perf test to JUnit 4.11 friendly

b/31928255

Test: run LayoutPerfTest VectorDrawablePerfTest before and after the change
      data is consistent.

Change-Id: I30de1f09b1df571479009048d621fef57b94f316
parent 275f6bc8
Loading
Loading
Loading
Loading
+34 −27
Original line number Original line Diff line number Diff line
@@ -18,8 +18,9 @@ package android.perftests.utils;


import android.support.test.InstrumentationRegistry;
import android.support.test.InstrumentationRegistry;


import org.junit.rules.TestWatcher;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;


import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.assertTrue;
@@ -47,7 +48,7 @@ import static junit.framework.Assert.assertTrue;
 * name when using parameterization.
 * name when using parameterization.
 */
 */


public class PerfStatusReporter extends TestWatcher {
public class PerfStatusReporter implements TestRule {
    private final BenchmarkState mState = new BenchmarkState();
    private final BenchmarkState mState = new BenchmarkState();


    public BenchmarkState getBenchmarkState() {
    public BenchmarkState getBenchmarkState() {
@@ -55,7 +56,10 @@ public class PerfStatusReporter extends TestWatcher {
    }
    }


    @Override
    @Override
    protected void succeeded(Description description) {
    public Statement apply(Statement base, Description description) {
        return new Statement() {
            @Override
            public void evaluate() throws Throwable {
                String invokeMethodName = description.getMethodName();
                String invokeMethodName = description.getMethodName();
                // validate and simplify the function name.
                // validate and simplify the function name.
                // First, remove the "test" prefix which normally comes from CTS test.
                // First, remove the "test" prefix which normally comes from CTS test.
@@ -80,8 +84,11 @@ public class PerfStatusReporter extends TestWatcher {
                            allDigits);
                            allDigits);
                }
                }


                base.evaluate();

                mState.sendFullStatusReport(InstrumentationRegistry.getInstrumentation(),
                mState.sendFullStatusReport(InstrumentationRegistry.getInstrumentation(),
                        invokeMethodName);
                        invokeMethodName);
            }
            }

        };
    }
}
}