forked from upstream-mirrors/OpenTracks
Tests: remove workaround for not stopping TrackRecordingService properly below API24.
This commit is contained in:
@@ -64,7 +64,6 @@ import de.dennisguse.opentracks.sensors.sensorData.SensorDataCyclingPower;
|
||||
import de.dennisguse.opentracks.sensors.sensorData.SensorDataHeartRate;
|
||||
import de.dennisguse.opentracks.sensors.sensorData.SensorDataSet;
|
||||
import de.dennisguse.opentracks.services.TrackRecordingService;
|
||||
import de.dennisguse.opentracks.services.TrackRecordingServiceTestUtils;
|
||||
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
|
||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
||||
|
||||
@@ -113,14 +112,10 @@ public class ExportImportTest {
|
||||
|
||||
@Before
|
||||
public void fileSetup() throws IOException {
|
||||
TrackRecordingServiceTestUtils.resetService(mServiceRule, context);
|
||||
|
||||
tmpFile = File.createTempFile("test", "test", context.getFilesDir());
|
||||
tmpFileUri = Uri.fromFile(tmpFile);
|
||||
|
||||
trackImporter = new TrackImporter(context, contentProviderUtils, Distance.of(200), true);
|
||||
|
||||
TrackRecordingServiceTestUtils.resetService(mServiceRule, context);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -130,8 +125,6 @@ public class ExportImportTest {
|
||||
|
||||
// Ensure that the database is empty after every test
|
||||
contentProviderUtils.deleteAllTracks(context);
|
||||
|
||||
TrackRecordingServiceTestUtils.resetService(mServiceRule, context);
|
||||
}
|
||||
|
||||
public void setUp() throws TimeoutException {
|
||||
|
||||
-2
@@ -87,8 +87,6 @@ public class TrackRecordingServiceMarkerTest {
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
TrackRecordingServiceTestUtils.resetService(mServiceRule, context);
|
||||
|
||||
// Ensure that the database is empty after every test
|
||||
contentProviderUtils.deleteAllTracks(context);
|
||||
}
|
||||
|
||||
-9
@@ -13,7 +13,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.MediumTest;
|
||||
import androidx.test.rule.ServiceTestRule;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -87,7 +86,6 @@ public class TrackRecordingServiceRecordingTest {
|
||||
@Before
|
||||
public void setUp() throws TimeoutException {
|
||||
contentProviderUtils = new ContentProviderUtils(context);
|
||||
tearDown();
|
||||
|
||||
PreferencesUtils.setString(R.string.recording_distance_interval_key, R.string.recording_distance_interval_default);
|
||||
PreferencesUtils.setString(R.string.idle_speed_key, R.string.idle_speed_default);
|
||||
@@ -95,13 +93,6 @@ public class TrackRecordingServiceRecordingTest {
|
||||
service = startService();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
TrackRecordingServiceTestUtils.resetService(mServiceRule, context);
|
||||
// Ensure that the database is empty after every test
|
||||
contentProviderUtils.deleteAllTracks(context);
|
||||
}
|
||||
|
||||
@MediumTest
|
||||
@Test
|
||||
public void recording_startStop() {
|
||||
|
||||
-1
@@ -94,7 +94,6 @@ public class TrackRecordingServiceStateMachineTest {
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
TrackRecordingServiceTestUtils.resetService(mServiceRule, context);
|
||||
// Ensure that the database is empty after every test
|
||||
contentProviderUtils.deleteAllTracks(context);
|
||||
}
|
||||
|
||||
-13
@@ -1,24 +1,11 @@
|
||||
package de.dennisguse.opentracks.services;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
|
||||
import androidx.test.rule.ServiceTestRule;
|
||||
|
||||
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
|
||||
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
||||
|
||||
public class TrackRecordingServiceTestUtils {
|
||||
|
||||
|
||||
//TODO Workaround as service is not stopped on API23; thus sharedpreferences are not reset between tests.
|
||||
//TODO Anyhow, the service should re-create all it's resources if a recording starts and makes sure that there is no leftovers from previous recordings.
|
||||
@Deprecated
|
||||
public static void resetService(ServiceTestRule mServiceRule, Context context) {
|
||||
// Let's use default values.
|
||||
PreferencesUtils.clear();
|
||||
}
|
||||
|
||||
static void sendGPSLocation(TrackPointCreator trackPointCreator, String time, double latitude, double longitude, float accuracy, long speed) {
|
||||
Location location = new Location("mock");
|
||||
location.setTime(1L); // Should be ignored anyhow.
|
||||
|
||||
Reference in New Issue
Block a user