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

Commit a3f16a8e authored by Lais Andrade's avatar Lais Andrade
Browse files

Switch APCT VibratorPerfTest to use Jetpack Benchmark

Bug: 170370918
Test: atest CorePerfTests:VibratorPerfTest
Change-Id: I79d3877987553f873dc295978440baac299c9062
parent a2a25399
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -19,9 +19,9 @@ package android.os;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;


import android.content.Context;
import android.content.Context;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;


import androidx.benchmark.BenchmarkState;
import androidx.benchmark.junit4.BenchmarkRule;
import androidx.test.InstrumentationRegistry;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.filters.LargeTest;


@@ -32,7 +32,7 @@ import org.junit.Test;
@LargeTest
@LargeTest
public class VibratorPerfTest {
public class VibratorPerfTest {
    @Rule
    @Rule
    public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
    public final BenchmarkRule mBenchmarkRule = new BenchmarkRule();


    private Vibrator mVibrator;
    private Vibrator mVibrator;


@@ -44,7 +44,7 @@ public class VibratorPerfTest {


    @Test
    @Test
    public void testEffectClick() {
    public void testEffectClick() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        while (state.keepRunning()) {
        while (state.keepRunning()) {
            mVibrator.vibrate(VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK));
            mVibrator.vibrate(VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK));
        }
        }
@@ -52,7 +52,7 @@ public class VibratorPerfTest {


    @Test
    @Test
    public void testOneShot() {
    public void testOneShot() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        while (state.keepRunning()) {
        while (state.keepRunning()) {
            mVibrator.vibrate(VibrationEffect.createOneShot(SECONDS.toMillis(2),
            mVibrator.vibrate(VibrationEffect.createOneShot(SECONDS.toMillis(2),
                    VibrationEffect.DEFAULT_AMPLITUDE));
                    VibrationEffect.DEFAULT_AMPLITUDE));
@@ -61,7 +61,7 @@ public class VibratorPerfTest {


    @Test
    @Test
    public void testWaveform() {
    public void testWaveform() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        long[] timings = new long[]{SECONDS.toMillis(1), SECONDS.toMillis(2), SECONDS.toMillis(1)};
        long[] timings = new long[]{SECONDS.toMillis(1), SECONDS.toMillis(2), SECONDS.toMillis(1)};
        while (state.keepRunning()) {
        while (state.keepRunning()) {
            mVibrator.vibrate(VibrationEffect.createWaveform(timings, -1));
            mVibrator.vibrate(VibrationEffect.createWaveform(timings, -1));
@@ -70,7 +70,7 @@ public class VibratorPerfTest {


    @Test
    @Test
    public void testCompose() {
    public void testCompose() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        while (state.keepRunning()) {
        while (state.keepRunning()) {
            mVibrator.vibrate(
            mVibrator.vibrate(
                    VibrationEffect.startComposition()
                    VibrationEffect.startComposition()
@@ -82,7 +82,7 @@ public class VibratorPerfTest {


    @Test
    @Test
    public void testAreEffectsSupported() {
    public void testAreEffectsSupported() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        int[] effects = new int[]{VibrationEffect.EFFECT_CLICK, VibrationEffect.EFFECT_TICK};
        int[] effects = new int[]{VibrationEffect.EFFECT_CLICK, VibrationEffect.EFFECT_TICK};
        while (state.keepRunning()) {
        while (state.keepRunning()) {
            mVibrator.areEffectsSupported(effects);
            mVibrator.areEffectsSupported(effects);
@@ -91,7 +91,7 @@ public class VibratorPerfTest {


    @Test
    @Test
    public void testArePrimitivesSupported() {
    public void testArePrimitivesSupported() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final BenchmarkState state = mBenchmarkRule.getState();
        int[] primitives = new int[]{VibrationEffect.Composition.PRIMITIVE_CLICK,
        int[] primitives = new int[]{VibrationEffect.Composition.PRIMITIVE_CLICK,
                VibrationEffect.Composition.PRIMITIVE_TICK};
                VibrationEffect.Composition.PRIMITIVE_TICK};
        while (state.keepRunning()) {
        while (state.keepRunning()) {