forked from upstream-mirrors/OpenTracks
Test: do not request GPS permissions for test that use fake locations anyhow.
This commit is contained in:
@@ -18,7 +18,6 @@ import androidx.test.core.app.ApplicationProvider;
|
|||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import androidx.test.filters.LargeTest;
|
import androidx.test.filters.LargeTest;
|
||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
import androidx.test.rule.GrantPermissionRule;
|
|
||||||
import androidx.test.rule.ServiceTestRule;
|
import androidx.test.rule.ServiceTestRule;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -84,9 +83,6 @@ public class ExportImportTest {
|
|||||||
@Rule
|
@Rule
|
||||||
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
|
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
@Rule
|
|
||||||
public GrantPermissionRule mRuntimePermissionRule = GrantPermissionRule.grant(android.Manifest.permission.ACCESS_FINE_LOCATION);
|
|
||||||
|
|
||||||
//For csv_export_only() as we the timezone is hardcoded in the expectation.
|
//For csv_export_only() as we the timezone is hardcoded in the expectation.
|
||||||
@Rule
|
@Rule
|
||||||
public TimezoneRule timezoneRule = new TimezoneRule(TimeZone.getTimeZone("Europe/Berlin"));
|
public TimezoneRule timezoneRule = new TimezoneRule(TimeZone.getTimeZone("Europe/Berlin"));
|
||||||
|
|||||||
-5
@@ -29,7 +29,6 @@ import android.os.Looper;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import androidx.test.filters.MediumTest;
|
import androidx.test.filters.MediumTest;
|
||||||
import androidx.test.rule.GrantPermissionRule;
|
|
||||||
import androidx.test.rule.ServiceTestRule;
|
import androidx.test.rule.ServiceTestRule;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -57,9 +56,6 @@ public class TrackRecordingServiceTestMarker {
|
|||||||
@Rule
|
@Rule
|
||||||
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
|
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
@Rule
|
|
||||||
public GrantPermissionRule mRuntimePermissionRule = GrantPermissionRule.grant(android.Manifest.permission.ACCESS_FINE_LOCATION);
|
|
||||||
|
|
||||||
private final Context context = ApplicationProvider.getApplicationContext();
|
private final Context context = ApplicationProvider.getApplicationContext();
|
||||||
private ContentProviderUtils contentProviderUtils;
|
private ContentProviderUtils contentProviderUtils;
|
||||||
|
|
||||||
@@ -128,7 +124,6 @@ public class TrackRecordingServiceTestMarker {
|
|||||||
public void recording_GPSfix_createsMarker() {
|
public void recording_GPSfix_createsMarker() {
|
||||||
// given
|
// given
|
||||||
TrackPointCreator trackPointCreator = service.getTrackPointCreator();
|
TrackPointCreator trackPointCreator = service.getTrackPointCreator();
|
||||||
trackPointCreator.stopGPS();
|
|
||||||
|
|
||||||
trackPointCreator.setClock("2020-02-02T02:02:02Z");
|
trackPointCreator.setClock("2020-02-02T02:02:02Z");
|
||||||
Track.Id trackId = service.startNewTrack();
|
Track.Id trackId = service.startNewTrack();
|
||||||
|
|||||||
-11
@@ -11,7 +11,6 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import androidx.test.filters.MediumTest;
|
import androidx.test.filters.MediumTest;
|
||||||
import androidx.test.rule.GrantPermissionRule;
|
|
||||||
import androidx.test.rule.ServiceTestRule;
|
import androidx.test.rule.ServiceTestRule;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -53,9 +52,6 @@ public class TrackRecordingServiceTestRecording {
|
|||||||
@Rule
|
@Rule
|
||||||
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
|
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
@Rule
|
|
||||||
public GrantPermissionRule mRuntimePermissionRule = GrantPermissionRule.grant(android.Manifest.permission.ACCESS_FINE_LOCATION);
|
|
||||||
|
|
||||||
private final Context context = ApplicationProvider.getApplicationContext();
|
private final Context context = ApplicationProvider.getApplicationContext();
|
||||||
private ContentProviderUtils contentProviderUtils;
|
private ContentProviderUtils contentProviderUtils;
|
||||||
|
|
||||||
@@ -95,7 +91,6 @@ public class TrackRecordingServiceTestRecording {
|
|||||||
PreferencesUtils.setString(R.string.idle_speed_key, R.string.idle_speed_default);
|
PreferencesUtils.setString(R.string.idle_speed_key, R.string.idle_speed_default);
|
||||||
|
|
||||||
service = startService();
|
service = startService();
|
||||||
service.getTrackPointCreator().stopGPS();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -117,7 +112,6 @@ public class TrackRecordingServiceTestRecording {
|
|||||||
String startTime = "2020-02-02T02:02:02Z";
|
String startTime = "2020-02-02T02:02:02Z";
|
||||||
trackPointCreator.setClock(startTime);
|
trackPointCreator.setClock(startTime);
|
||||||
Track.Id trackId = service.startNewTrack();
|
Track.Id trackId = service.startNewTrack();
|
||||||
trackPointCreator.stopGPS();
|
|
||||||
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
@@ -155,7 +149,6 @@ public class TrackRecordingServiceTestRecording {
|
|||||||
|
|
||||||
trackPointCreator.setClock(startTime);
|
trackPointCreator.setClock(startTime);
|
||||||
Track.Id trackId = service.startNewTrack();
|
Track.Id trackId = service.startNewTrack();
|
||||||
trackPointCreator.stopGPS();
|
|
||||||
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@@ -202,7 +195,6 @@ public class TrackRecordingServiceTestRecording {
|
|||||||
String starTime = "2020-02-02T02:02:02Z";
|
String starTime = "2020-02-02T02:02:02Z";
|
||||||
trackPointCreator.setClock(starTime);
|
trackPointCreator.setClock(starTime);
|
||||||
Track.Id trackId = service.startNewTrack();
|
Track.Id trackId = service.startNewTrack();
|
||||||
trackPointCreator.stopGPS();
|
|
||||||
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
||||||
|
|
||||||
String pauseTime = "2020-02-02T02:02:03Z";
|
String pauseTime = "2020-02-02T02:02:03Z";
|
||||||
@@ -235,7 +227,6 @@ public class TrackRecordingServiceTestRecording {
|
|||||||
|
|
||||||
trackPointCreator.setClock(startTime);
|
trackPointCreator.setClock(startTime);
|
||||||
Track.Id trackId = service.startNewTrack();
|
Track.Id trackId = service.startNewTrack();
|
||||||
trackPointCreator.stopGPS();
|
|
||||||
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
||||||
|
|
||||||
String stopTime = "2020-02-02T02:02:03Z";
|
String stopTime = "2020-02-02T02:02:03Z";
|
||||||
@@ -246,7 +237,6 @@ public class TrackRecordingServiceTestRecording {
|
|||||||
String resumeTime = "2020-02-02T02:02:04Z";
|
String resumeTime = "2020-02-02T02:02:04Z";
|
||||||
trackPointCreator.setClock(resumeTime);
|
trackPointCreator.setClock(resumeTime);
|
||||||
service.resumeTrack(trackId);
|
service.resumeTrack(trackId);
|
||||||
trackPointCreator.stopGPS();
|
|
||||||
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
@@ -268,7 +258,6 @@ public class TrackRecordingServiceTestRecording {
|
|||||||
|
|
||||||
trackPointCreator.setClock(startTime);
|
trackPointCreator.setClock(startTime);
|
||||||
Track.Id trackId = service.startNewTrack();
|
Track.Id trackId = service.startNewTrack();
|
||||||
trackPointCreator.stopGPS();
|
|
||||||
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
trackPointCreator.setAltitudeSumManager(altitudeSumManager);
|
||||||
BluetoothRemoteSensorManager remoteSensorManager = trackPointCreator.getRemoteSensorManager();
|
BluetoothRemoteSensorManager remoteSensorManager = trackPointCreator.getRemoteSensorManager();
|
||||||
|
|
||||||
|
|||||||
-4
@@ -8,7 +8,6 @@ import android.os.Looper;
|
|||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import androidx.test.rule.GrantPermissionRule;
|
|
||||||
import androidx.test.rule.ServiceTestRule;
|
import androidx.test.rule.ServiceTestRule;
|
||||||
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
@@ -31,9 +30,6 @@ public class VoiceAnnouncementManagerTest {
|
|||||||
@Rule
|
@Rule
|
||||||
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
|
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
@Rule
|
|
||||||
public GrantPermissionRule mRuntimePermissionRule = GrantPermissionRule.grant(android.Manifest.permission.ACCESS_FINE_LOCATION);
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void preSetUp() {
|
public static void preSetUp() {
|
||||||
// Prepare looper for Android's message queue
|
// Prepare looper for Android's message queue
|
||||||
|
|||||||
@@ -66,13 +66,6 @@ public class TrackPointCreator implements BluetoothRemoteSensorManager.SensorDat
|
|||||||
return context != null;
|
return context != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
//There should be a cooler way to do this; we want to send fake locations without getting affected by real GPS data.
|
|
||||||
@VisibleForTesting
|
|
||||||
public void stopGPS() {
|
|
||||||
gpsHandler.onStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void reset() {
|
public synchronized void reset() {
|
||||||
if (remoteSensorManager == null || altitudeSumManager == null) {
|
if (remoteSensorManager == null || altitudeSumManager == null) {
|
||||||
Log.d(TAG, "No recording running and no reset necessary.");
|
Log.d(TAG, "No recording running and no reset necessary.");
|
||||||
|
|||||||
Reference in New Issue
Block a user