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

Commit 0f7340c9 authored by Hyundo Moon's avatar Hyundo Moon
Browse files

Fix flaky trimDatabase_trimsOldOrInvisibleRecords

Bug: 296033161
Test: atest BluetoothOppServiceTest#trimDatabase_trimsOldOrInvisibleRecords
              --rerun-until-failure 1000
Change-Id: I9020293ffd18b966b51caca6e394e16177449c2b
parent 40916534
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -19,10 +19,12 @@ import static com.android.bluetooth.opp.BluetoothOppService.WHERE_INVISIBLE_UNCO

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;

import static com.google.common.truth.Truth.assertThat;
@@ -47,6 +49,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

@MediumTest
@@ -82,6 +85,18 @@ public class BluetoothOppServiceTest {
        // Try getting the Bluetooth adapter
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        Assert.assertNotNull(mAdapter);

        // Wait until the initial trimDatabase operation is done.
        verify(mBluetoothMethodProxy, timeout(3_000))
                .contentResolverQuery(
                        any(),
                        eq(BluetoothShare.CONTENT_URI),
                        eq(new String[] {BluetoothShare._ID}),
                        any(),
                        isNull(),
                        eq(BluetoothShare._ID));

        Mockito.clearInvocations(mBluetoothMethodProxy);
    }

    @After