forked from upstream-mirrors/OpenTracks
ExportImportTest: made tests deterministic (simulate GPS/sensors).
Fixes #761.
This commit is contained in:
@@ -203,6 +203,9 @@ public class TrackPoint {
|
||||
if (hasAltitude()) {
|
||||
location.setAltitude(altitude.toM());
|
||||
}
|
||||
if (hasSpeed()) {
|
||||
location.setSpeed((float) speed.toMPS());
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
@@ -169,9 +169,9 @@ public final class SensorDataCycling {
|
||||
}
|
||||
|
||||
public static class Data {
|
||||
public final Distance distance;
|
||||
public final Distance distanceOverall;
|
||||
public final Speed speed;
|
||||
private final Distance distance;
|
||||
private final Distance distanceOverall;
|
||||
private final Speed speed;
|
||||
|
||||
private Data(Distance distance, Distance distanceOverall, Speed speed) {
|
||||
this.distance = distance;
|
||||
@@ -179,12 +179,24 @@ public final class SensorDataCycling {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public Distance getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public Distance getDistanceOverall() {
|
||||
return distanceOverall;
|
||||
}
|
||||
|
||||
public Speed getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Data{" +
|
||||
"distance_m=" + distance +
|
||||
", distance_overall_m=" + distanceOverall +
|
||||
", speed_mps=" + speed +
|
||||
"distance=" + getDistance() +
|
||||
", distance_overall=" + getDistanceOverall() +
|
||||
", speed=" + getSpeed() +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ public final class SensorDataSet {
|
||||
}
|
||||
|
||||
if (cyclingDistanceSpeed != null && cyclingDistanceSpeed.hasValue()) {
|
||||
trackPoint.setSensorDistance(cyclingDistanceSpeed.getValue().distanceOverall);
|
||||
trackPoint.setSpeed(cyclingDistanceSpeed.getValue().speed);
|
||||
trackPoint.setSensorDistance(cyclingDistanceSpeed.getValue().getDistanceOverall());
|
||||
trackPoint.setSpeed(cyclingDistanceSpeed.getValue().getSpeed());
|
||||
}
|
||||
|
||||
if (cyclingPower != null && cyclingPower.hasValue()) {
|
||||
|
||||
@@ -258,7 +258,7 @@ public class StatisticsRecordingFragment extends Fragment {
|
||||
if (sensorDataSet != null && sensorDataSet.getCyclingDistanceSpeed() != null) {
|
||||
SensorDataCycling.DistanceSpeed data = sensorDataSet.getCyclingDistanceSpeed();
|
||||
if (data.hasValue() && data.isRecent()) {
|
||||
speed = data.getValue().speed;
|
||||
speed = data.getValue().getSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -177,6 +177,11 @@ public class HandlerServer {
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public LocationHandler getLocationHandler() {
|
||||
return locationHandler;
|
||||
}
|
||||
|
||||
void sendGpsStatus(GpsStatusValue gpsStatusValue) {
|
||||
service.newGpsStatus(gpsStatusValue);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@@ -18,7 +19,8 @@ import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||
import de.dennisguse.opentracks.util.LocationUtils;
|
||||
import de.dennisguse.opentracks.util.PreferencesUtils;
|
||||
|
||||
class LocationHandler implements LocationListener, GpsStatus.GpsStatusListener {
|
||||
@VisibleForTesting(otherwise = 3)
|
||||
public class LocationHandler implements LocationListener, GpsStatus.GpsStatusListener {
|
||||
|
||||
private final String TAG = LocationHandler.class.getSimpleName();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user