Merge pull request #4181 from ByteHamster/tests-clear

Disabled auto update for tests
This commit is contained in:
H. Lehmann 2020-05-22 21:06:16 +02:00 committed by GitHub
commit 65dc10e8f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 7 additions and 9 deletions

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import androidx.annotation.IdRes;
import androidx.annotation.StringRes;
import androidx.preference.PreferenceManager;
import androidx.test.InstrumentationRegistry;
import androidx.test.espresso.PerformException;
import androidx.test.espresso.UiController;
@ -16,6 +17,7 @@ import androidx.test.espresso.util.TreeIterables;
import android.view.View;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.download.DownloadService;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
@ -121,14 +123,17 @@ public class EspressoTestUtils {
InstrumentationRegistry.getTargetContext().getSharedPreferences(
fileName.replace(".xml", ""), Context.MODE_PRIVATE).edit().clear().commit();
}
}
public static void makeNotFirstRun() {
InstrumentationRegistry.getTargetContext().getSharedPreferences(MainActivity.PREF_NAME, Context.MODE_PRIVATE)
.edit()
.putBoolean(MainActivity.PREF_IS_FIRST_LAUNCH, false)
.commit();
PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getTargetContext())
.edit()
.putString(UserPreferences.PREF_UPDATE_INTERVAL, "0")
.commit();
RatingDialog.init(InstrumentationRegistry.getTargetContext());
RatingDialog.saveRated();
}

View File

@ -88,7 +88,6 @@ public class PlaybackTest {
context = InstrumentationRegistry.getInstrumentation().getTargetContext();
EspressoTestUtils.clearPreferences();
EspressoTestUtils.clearDatabase();
EspressoTestUtils.makeNotFirstRun();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putString(UserPreferences.PREF_MEDIA_PLAYER, playerToUse).apply();

View File

@ -64,7 +64,6 @@ public class PlaybackServiceMediaPlayerTest {
public void setUp() throws Exception {
assertionError = null;
EspressoTestUtils.clearPreferences();
EspressoTestUtils.makeNotFirstRun();
EspressoTestUtils.clearDatabase();
final Context context = getInstrumentation().getTargetContext();

View File

@ -51,7 +51,6 @@ public class MainActivityTest {
@Before
public void setUp() throws IOException {
EspressoTestUtils.clearPreferences();
EspressoTestUtils.makeNotFirstRun();
EspressoTestUtils.clearDatabase();
mActivityRule.launchActivity(new Intent());

View File

@ -63,7 +63,6 @@ public class NavigationDrawerTest {
uiTestUtils.setup();
EspressoTestUtils.clearPreferences();
EspressoTestUtils.makeNotFirstRun();
EspressoTestUtils.clearDatabase();
}

View File

@ -36,7 +36,6 @@ public class QueueFragmentTest {
@Before
public void setUp() {
EspressoTestUtils.clearPreferences();
EspressoTestUtils.makeNotFirstRun();
EspressoTestUtils.clearDatabase();
EspressoTestUtils.setLastNavFragment(QueueFragment.TAG);
activityRule.launchActivity(new Intent());

View File

@ -55,7 +55,6 @@ public class SpeedChangeTest {
@Before
public void setUp() throws Exception {
EspressoTestUtils.clearPreferences();
EspressoTestUtils.makeNotFirstRun();
EspressoTestUtils.clearDatabase();
EspressoTestUtils.setLastNavFragment(QueueFragment.TAG);

View File

@ -42,7 +42,6 @@ public class TextOnlyFeedsTest {
@Before
public void setUp() throws IOException {
EspressoTestUtils.clearPreferences();
EspressoTestUtils.makeNotFirstRun();
EspressoTestUtils.clearDatabase();
uiTestUtils = new UITestUtils(InstrumentationRegistry.getInstrumentation().getTargetContext());