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

Commit d1d7c7d7 authored by William Escande's avatar William Escande
Browse files

Reduce test flakyness

Sometimes the shared preference is not entirely cleaned up at start of
the test. Adding this should definitly prevent it from ever happening
again

Ignore-AOSP-First: Migration is only on tm-qpr-dev
Bug: 241152450
Test: atest BluetoothInstrumentationTests#DataMigrationTest
Change-Id: Iff81ee692ebfdfb01fc196574de0a69bd6fd2de8
parent edf576ff
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public class DataMigrationTest {

    private static final String AUTHORITY = "bluetooth_legacy.provider";

    private static final String TEST_PREF = "TestPref";
    private static final String TEST_PREF = "DatabaseTestPref";

    private MockContentResolver mMockContentResolver;

@@ -82,6 +82,7 @@ public class DataMigrationTest {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        mTargetContext.deleteSharedPreferences(TEST_PREF);
        mPrefs = mTargetContext.getSharedPreferences(TEST_PREF, Context.MODE_PRIVATE);
        mPrefs.edit().clear().apply();

        mMockContentResolver = new MockContentResolver(mTargetContext);
        when(mMockContext.getContentResolver()).thenReturn(mMockContentResolver);
@@ -93,7 +94,8 @@ public class DataMigrationTest {

    @After
    public void tearDown() throws Exception {
        mTargetContext.deleteSharedPreferences("TestPref");
        mPrefs.edit().clear().apply();
        mTargetContext.deleteSharedPreferences(TEST_PREF);
        mTargetContext.deleteDatabase("TestBluetoothDb");
        mTargetContext.deleteDatabase("TestOppDb");
    }