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

Commit 82d9e15a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Switch APCT Perf test to JUnit 4.11 friendly"

parents b3dcc225 578f4714
Loading
Loading
Loading
Loading
+34 −27
Original line number Diff line number Diff line
@@ -18,8 +18,9 @@ package android.perftests.utils;

import android.support.test.InstrumentationRegistry;

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

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

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

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

    @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();
                // validate and simplify the function name.
                // First, remove the "test" prefix which normally comes from CTS test.
@@ -80,8 +84,11 @@ public class PerfStatusReporter extends TestWatcher {
                            allDigits);
                }

                base.evaluate();

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

        };
    }
}