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

Commit 9082ba10 authored by Hyundo Moon's avatar Hyundo Moon
Browse files

Fix flaky BluetoothPbapActivityTest methods

This CL fixes following flaky tests methods:
- onPositive_finishesActivity
- onNegative_finishesActivity

Bug: 309032407
Test: atest BluetoothPbapActivityTest --rerun-until-failure 50
Change-Id: I3057fdc51c6da1cb02cbf673b7313f368a147687
parent 8e555b6a
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import static android.content.pm.PackageManager.DONT_KILL_APP;

import static androidx.lifecycle.Lifecycle.State;
import static androidx.lifecycle.Lifecycle.State.DESTROYED;
import static androidx.lifecycle.Lifecycle.State.RESUMED;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
@@ -97,20 +96,28 @@ public class BluetoothPbapActivityTest {

    @Test
    public void onPositive_finishesActivity() throws Exception {
        mActivityScenario.onActivity(activity -> {
        AtomicBoolean finishCalled = new AtomicBoolean(false);

        mActivityScenario.onActivity(
                activity -> {
                    activity.onPositive();
                    finishCalled.set(activity.isFinishing());
                });

        assertActivityState(DESTROYED);
        assertThat(finishCalled.get()).isTrue();
    }

    @Test
    public void onNegative_finishesActivity() throws Exception {
        mActivityScenario.onActivity(activity -> {
        AtomicBoolean finishCalled = new AtomicBoolean(false);

        mActivityScenario.onActivity(
                activity -> {
                    activity.onNegative();
                    finishCalled.set(activity.isFinishing());
                });

        assertActivityState(DESTROYED);
        assertThat(finishCalled.get()).isTrue();
    }

    @Test