diff --git a/src/androidTest/java/de/dennisguse/opentracks/data/model/TrackPointTest.java b/src/androidTest/java/de/dennisguse/opentracks/data/model/TrackPointTest.java
index e90456f5a..1885114a5 100644
--- a/src/androidTest/java/de/dennisguse/opentracks/data/model/TrackPointTest.java
+++ b/src/androidTest/java/de/dennisguse/opentracks/data/model/TrackPointTest.java
@@ -1,33 +1,16 @@
package de.dennisguse.opentracks.data.model;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
import java.time.Instant;
-import java.time.temporal.ChronoUnit;
import de.dennisguse.opentracks.data.models.Distance;
import de.dennisguse.opentracks.data.models.TrackPoint;
public class TrackPointTest {
- @Test
- public void isRecent_true() {
- TrackPoint tp = new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.now());
-
- assertTrue(tp.isRecent());
- }
-
- @Test
- public void isRecent_false() {
- TrackPoint tp = new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.now().minus(2, ChronoUnit.MINUTES));
-
- assertFalse(tp.isRecent());
- }
-
@Test
public void distanceToPrevious() {
TrackPoint tp1 = new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochMilli(0))
diff --git a/src/androidTest/java/de/dennisguse/opentracks/io/file/exporter/KmlTrackExporterTest.java b/src/androidTest/java/de/dennisguse/opentracks/io/file/exporter/KmlTrackExporterTest.java
deleted file mode 100644
index a5d96614d..000000000
--- a/src/androidTest/java/de/dennisguse/opentracks/io/file/exporter/KmlTrackExporterTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package de.dennisguse.opentracks.io.file.exporter;
-
-import static org.junit.Assert.assertEquals;
-
-import android.content.Context;
-
-import androidx.test.core.app.ApplicationProvider;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.io.ByteArrayOutputStream;
-import java.time.Instant;
-import java.time.ZoneOffset;
-
-import de.dennisguse.opentracks.data.models.TrackPoint;
-import de.dennisguse.opentracks.io.file.TrackFileFormat;
-
-@RunWith(JUnit4.class)
-public class KmlTrackExporterTest {
-
- private final Context context = ApplicationProvider.getApplicationContext();
-
- /**
- * Sensor data by type should only be created if present in at least on TrackPoint.
- */
- @Test
- public void writeCloseSegment_only_write_sensordata_if_present() {
- String expected = """
- 1970-01-01T00:00:00Z
-
- 1970-01-01T01:00:00+01:00
-
-
-
-
-
-
- """;
-
- // given
- TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.ofEpochSecond(0));
-
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- KMLTrackExporter kmlTrackWriter = (KMLTrackExporter) TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA.createTrackExporter(context, null);
- kmlTrackWriter.prepare(outputStream);
-
- kmlTrackWriter.writeTrackPoint(ZoneOffset.UTC, trackPoint);
- kmlTrackWriter.writeTrackPoint(ZoneOffset.ofTotalSeconds(3600), trackPoint);
-
- // when
- kmlTrackWriter.writeCloseSegment();
- kmlTrackWriter.close();
-
- // then
- assertEquals(expected, outputStream.toString());
- }
-}
\ No newline at end of file
diff --git a/src/androidTest/java/de/dennisguse/opentracks/io/file/importer/ExportImportTest.java b/src/androidTest/java/de/dennisguse/opentracks/io/file/importer/ExportImportTest.java
index 24f1f3a4e..59464b9af 100644
--- a/src/androidTest/java/de/dennisguse/opentracks/io/file/importer/ExportImportTest.java
+++ b/src/androidTest/java/de/dennisguse/opentracks/io/file/importer/ExportImportTest.java
@@ -35,6 +35,7 @@ import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;
+import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.List;
import java.util.TimeZone;
@@ -168,9 +169,12 @@ public class ExportImportTest {
sendLocation(trackPointCreator, "2020-02-02T02:03:22Z", 3, 16, 10, 13, 15, 10, 0);
- sendLocation(trackPointCreator, "2020-02-02T02:03:23Z", 3, 16.001, 10, 27, 15, 10, 0);
+ trackPointCreator.setClock("2020-02-02T02:03:30Z");
+ service.getTrackRecordingManager().onIdle();
- trackPointCreator.setClock("2020-02-02T02:03:24Z");
+ sendLocation(trackPointCreator, "2020-02-02T02:03:50Z", 3, 16.001, 10, 27, 15, 10, 0);
+
+ trackPointCreator.setClock("2020-02-02T02:04:00Z");
service.endCurrentTrack();
Track track = contentProviderUtils.getTrack(trackId);
@@ -182,8 +186,103 @@ public class ExportImportTest {
track = contentProviderUtils.getTrack(trackId);
trackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, trackId);
markers = contentProviderUtils.getMarkers(trackId);
- assertEquals(12, trackPoints.size());
- assertEquals(2, markers.size());
+ }
+
+ @LargeTest
+ @Test
+ public void track() throws TimeoutException {
+ setUp();
+
+ Track track = contentProviderUtils.getTrack(trackId);
+ TrackStatistics trackStatistics = track.getTrackStatistics();
+
+ assertEquals(ZoneOffset.of("+01:00"), track.getZoneOffset());
+ assertEquals(Instant.parse("2020-02-02T02:02:02Z"), trackStatistics.getStartTime());
+ assertEquals(Instant.parse("2020-02-02T02:04:00Z"), trackStatistics.getStopTime());
+
+ assertEquals(Duration.ofSeconds(56), trackStatistics.getTotalTime());
+ assertEquals(Duration.ofSeconds(26), trackStatistics.getMovingTime()); //TODO Likely too low
+
+ // Distance
+ assertEquals(222125.53125, trackStatistics.getTotalDistance().toM(), 0.01); //TODO Too low
+
+ // Speed
+ assertEquals(8543.29, trackStatistics.getMaxSpeed().toMPS(), 0.01);
+ assertEquals(3966.52, trackStatistics.getAverageSpeed().toMPS(), 0.01);
+ assertEquals(8543.28, trackStatistics.getAverageMovingSpeed().toMPS(), 0.01);
+
+ // Altitude
+ assertEquals(10, trackStatistics.getMinAltitude(), 0.01);
+ assertEquals(10, trackStatistics.getMaxAltitude(), 0.01);
+
+ assertEquals(2, trackStatistics.getTotalAltitudeGain(), 0.01);
+ assertEquals(2, trackStatistics.getTotalAltitudeLoss(), 0.01);
+
+ List actual = TestDataUtil.getTrackPoints(contentProviderUtils, trackId);
+ new TrackPointAssert().assertEquals(List.of(
+ new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse("2020-02-02T02:02:02Z")),
+ new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:02:03Z"))
+ .setLatitude(3)
+ .setLongitude(14)
+ .setAltitude(10)
+ .setSpeed(Speed.of(15))
+ .setAltitudeLoss(1f)
+ .setAltitudeGain(1f)
+ .setHorizontalAccuracy(Distance.of(10)),
+ new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:02:04Z"))
+ .setSensorDistance(Distance.of(10))
+ .setSpeed(Speed.of(15))
+ .setHeartRate(HeartRate.of(66))
+ .setCadence(3)
+ .setPower(50)
+ .setAltitudeLoss(1f)
+ .setAltitudeGain(1f),
+ new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:02:15Z"))
+ .setHeartRate(HeartRate.of(68))
+ .setCadence(3)
+ .setPower(50),
+ new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:02:17Z"))
+ .setLatitude(3)
+ .setLongitude(14.001)
+ .setAltitude(10)
+ .setSensorDistance(Distance.of(2))
+ .setSpeed(Speed.of(5))
+ .setAltitudeLoss(0f)
+ .setAltitudeGain(0f)
+ .setHorizontalAccuracy(Distance.of(10))
+ .setHeartRate(HeartRate.of(69))
+ .setCadence(3)
+ .setPower(50),
+ new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse("2020-02-02T02:02:18Z")),
+ new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse("2020-02-02T02:03:20Z")),
+ new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:03:21Z"))
+ .setLatitude(3)
+ .setLongitude(14.002)
+ .setAltitude(10)
+ .setSpeed(Speed.of(15))
+ .setAltitudeLoss(0f)
+ .setAltitudeGain(0f)
+ .setHorizontalAccuracy(Distance.of(10)),
+ new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC, Instant.parse("2020-02-02T02:03:22Z"))
+ .setLatitude(3)
+ .setLongitude(16)
+ .setAltitude(10)
+ .setSpeed(Speed.of(15))
+ .setAltitudeLoss(0f)
+ .setAltitudeGain(0f)
+ .setHorizontalAccuracy(Distance.of(10)),
+ new TrackPoint(TrackPoint.Type.IDLE, Instant.parse("2020-02-02T02:03:30Z")),
+ new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:03:50Z"))
+ .setLatitude(3)
+ .setLongitude(16.001)
+ .setAltitude(10)
+ .setSpeed(Speed.of(15))
+ .setAltitudeLoss(0f)
+ .setAltitudeGain(0f)
+ .setHorizontalAccuracy(Distance.of(10)),
+ new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse("2020-02-02T02:04:00Z"))
+
+ ), actual);
}
//TODO Does not test marker images
@@ -225,43 +324,7 @@ public class ExportImportTest {
// Time
assertEquals(track.getZoneOffset(), importedTrack.getZoneOffset());
- assertEquals(Instant.parse("2020-02-02T02:02:02Z"), importedTrackStatistics.getStartTime());
- assertEquals(Instant.parse("2020-02-02T02:03:24Z"), importedTrackStatistics.getStopTime());
-
- TrackStatistics originalTrackStatistics = track.getTrackStatistics();
-
- assertEquals(originalTrackStatistics.getTotalTime(), importedTrackStatistics.getTotalTime());
- assertEquals(Duration.ofSeconds(20), importedTrackStatistics.getTotalTime());
-
- assertEquals(originalTrackStatistics.getMovingTime(), importedTrackStatistics.getMovingTime());
- assertEquals(Duration.ofSeconds(4), importedTrackStatistics.getMovingTime());
-
- // Distance
- assertEquals(originalTrackStatistics.getTotalDistance(), importedTrackStatistics.getTotalDistance());
- assertEquals(222238.70, importedTrackStatistics.getTotalDistance().toM(), 0.01);
-
- // Speed
- assertEquals(originalTrackStatistics.getMaxSpeed(), importedTrackStatistics.getMaxSpeed());
- assertEquals(55559.67, importedTrackStatistics.getMaxSpeed().toMPS(), 0.01);
-
- assertEquals(originalTrackStatistics.getAverageSpeed(), importedTrackStatistics.getAverageSpeed());
- assertEquals(11111.93, importedTrackStatistics.getAverageSpeed().toMPS(), 0.01);
-
- assertEquals(originalTrackStatistics.getAverageMovingSpeed(), importedTrackStatistics.getAverageMovingSpeed());
- assertEquals(55559.67, importedTrackStatistics.getMaxSpeed().toMPS(), 0.01);
-
- // Altitude
- assertEquals(originalTrackStatistics.getMinAltitude(), importedTrackStatistics.getMinAltitude(), 0.01);
- assertEquals(10, importedTrackStatistics.getMinAltitude(), 0.01);
-
- assertEquals(originalTrackStatistics.getMaxAltitude(), importedTrackStatistics.getMaxAltitude(), 0.01);
- assertEquals(10, importedTrackStatistics.getMaxAltitude(), 0.01);
-
- assertEquals(originalTrackStatistics.getTotalAltitudeGain(), importedTrackStatistics.getTotalAltitudeGain(), 0.01);
- assertEquals(2, importedTrackStatistics.getTotalAltitudeGain(), 0.01);
-
- assertEquals(originalTrackStatistics.getTotalAltitudeLoss(), importedTrackStatistics.getTotalAltitudeLoss(), 0.01);
- assertEquals(2, importedTrackStatistics.getTotalAltitudeLoss(), 0.01);
+ assertEquals(track.getTrackStatistics(), importedTrackStatistics);
// 4. markers
assertMarkers();
@@ -347,7 +410,7 @@ public class ExportImportTest {
.setSpeed(Speed.of(5))
.setAltitudeLoss(1f)
.setAltitudeGain(1f)
- .setSensorDistance(Distance.of(14))
+ .setSensorDistance(Distance.of(12))
.setHeartRate(69)
.setPower(50f)
.setCadence(3f)
@@ -368,7 +431,7 @@ public class ExportImportTest {
.setAltitudeGain(0f)
.setSpeed(Speed.of(15))
.setHorizontalAccuracy(Distance.of(10)),
- new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:03:23Z"))
+ new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:03:50Z"))
.setLatitude(3)
.setLongitude(16.001)
.setAltitude(10)
@@ -379,24 +442,23 @@ public class ExportImportTest {
), actual);
// 3. trackstatistics
- TrackStatistics trackStatistics = track.getTrackStatistics();
TrackStatistics importedTrackStatistics = importedTrack.getTrackStatistics();
// Time
assertEquals(track.getZoneOffset(), importedTrack.getZoneOffset());
assertEquals(Instant.parse("2020-02-02T02:02:03Z"), importedTrackStatistics.getStartTime());
- assertEquals(Instant.parse("2020-02-02T02:03:23Z"), importedTrackStatistics.getStopTime());
+ assertEquals(Instant.parse("2020-02-02T02:03:50Z"), importedTrackStatistics.getStopTime());
- assertEquals(Duration.ofSeconds(80), importedTrackStatistics.getTotalTime());
- assertEquals(Duration.ofSeconds(80), importedTrackStatistics.getMovingTime());
+ assertEquals(Duration.ofSeconds(107), importedTrackStatistics.getTotalTime());
+ assertEquals(Duration.ofSeconds(107), importedTrackStatistics.getMovingTime());
// Distance
- assertEquals(222349.85, importedTrackStatistics.getTotalDistance().toM(), 0.01);
+ assertEquals(222347.85, importedTrackStatistics.getTotalDistance().toM(), 0.01);
// Speed
- assertEquals(2779.37, importedTrackStatistics.getMaxSpeed().toMPS(), 0.01);
- assertEquals(2779.37, importedTrackStatistics.getAverageSpeed().toMPS(), 0.01);
- assertEquals(2779.37, importedTrackStatistics.getAverageMovingSpeed().toMPS(), 0.01);
+ assertEquals(2078.01, importedTrackStatistics.getMaxSpeed().toMPS(), 0.01);
+ assertEquals(2078.01, importedTrackStatistics.getAverageSpeed().toMPS(), 0.01);
+ assertEquals(2078.01, importedTrackStatistics.getAverageMovingSpeed().toMPS(), 0.01);
// Altitude
assertEquals(10, importedTrackStatistics.getMinAltitude(), 0.01);
@@ -487,14 +549,14 @@ public class ExportImportTest {
private void mockBLESensorData(TrackPointCreator trackPointCreator, Float speed, Distance distance, float heartRate, float cadence, Float power) {
- SensorDataSet sensorDataSet = new SensorDataSet();
- sensorDataSet.set(new SensorDataCyclingPower("power", "power", Power.of(power)));
- sensorDataSet.set(new SensorDataHeartRate("heartRate", "heartRate", HeartRate.of(heartRate)));
+ SensorDataSet sensorDataSet = new SensorDataSet();
+ sensorDataSet.set(new SensorDataCyclingPower("power", "power", Power.of(power)));
+ sensorDataSet.set(new SensorDataHeartRate("heartRate", "heartRate", HeartRate.of(heartRate)));
- SensorDataCyclingCadence cyclingCadence = Mockito.mock(SensorDataCyclingCadence.class);
- Mockito.when(cyclingCadence.hasValue()).thenReturn(true);
- Mockito.when(cyclingCadence.getValue()).thenReturn(Cadence.of(cadence));
- sensorDataSet.set(cyclingCadence);
+ SensorDataCyclingCadence cyclingCadence = Mockito.mock(SensorDataCyclingCadence.class);
+ Mockito.when(cyclingCadence.hasValue()).thenReturn(true);
+ Mockito.when(cyclingCadence.getValue()).thenReturn(Cadence.of(cadence));
+ sensorDataSet.set(cyclingCadence);
if (distance != null && speed != null) {
SensorDataCyclingDistanceSpeed.Data distanceSpeedData = Mockito.mock(SensorDataCyclingDistanceSpeed.Data.class);
diff --git a/src/androidTest/java/de/dennisguse/opentracks/io/file/importer/GPXTrackImporterTest.java b/src/androidTest/java/de/dennisguse/opentracks/io/file/importer/GPXTrackImporterTest.java
index 09a35936f..df1624d2f 100644
--- a/src/androidTest/java/de/dennisguse/opentracks/io/file/importer/GPXTrackImporterTest.java
+++ b/src/androidTest/java/de/dennisguse/opentracks/io/file/importer/GPXTrackImporterTest.java
@@ -141,8 +141,8 @@ public class GPXTrackImporterTest {
// 3. trackstatistics
TrackStatistics trackStatistics = importedTrack.getTrackStatistics();
- assertEquals(1.44, trackStatistics.getMaxSpeed().toMPS(), 0.01);
- assertEquals(Duration.ofSeconds(53), trackStatistics.getMovingTime());
+ assertEquals(0.75, trackStatistics.getMaxSpeed().toMPS(), 0.01);
+ assertEquals(Duration.ofSeconds(101), trackStatistics.getMovingTime());
// 4. trackpoints
List importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
@@ -189,7 +189,7 @@ public class GPXTrackImporterTest {
// 3. trackstatistics
TrackStatistics trackStatistics = importedTrack.getTrackStatistics();
- assertEquals(4.0, trackStatistics.getMaxSpeed().toMPS(), 0.01);
+ assertEquals(5.0, trackStatistics.getMaxSpeed().toMPS(), 0.01);
assertEquals(Duration.ofSeconds(101), trackStatistics.getMovingTime());
// 4. trackpoints
diff --git a/src/androidTest/java/de/dennisguse/opentracks/services/TrackRecordingServiceMarkerTest.java b/src/androidTest/java/de/dennisguse/opentracks/services/TrackRecordingServiceMarkerTest.java
index a1037d278..5964089c1 100644
--- a/src/androidTest/java/de/dennisguse/opentracks/services/TrackRecordingServiceMarkerTest.java
+++ b/src/androidTest/java/de/dennisguse/opentracks/services/TrackRecordingServiceMarkerTest.java
@@ -146,6 +146,7 @@ public class TrackRecordingServiceMarkerTest {
assertEquals(0.0, wpt.getLength().toM(), 0.01);
assertNotNull(wpt.getLocation());
+ trackPointCreator.setClock("2020-02-02T02:02:04Z");
service.endCurrentTrack();
}
}
diff --git a/src/androidTest/java/de/dennisguse/opentracks/services/TrackRecordingServiceRecordingTest.java b/src/androidTest/java/de/dennisguse/opentracks/services/TrackRecordingServiceRecordingTest.java
index 2ecc7c8db..95e35f88e 100644
--- a/src/androidTest/java/de/dennisguse/opentracks/services/TrackRecordingServiceRecordingTest.java
+++ b/src/androidTest/java/de/dennisguse/opentracks/services/TrackRecordingServiceRecordingTest.java
@@ -88,7 +88,7 @@ public class TrackRecordingServiceRecordingTest {
contentProviderUtils = new ContentProviderUtils(context);
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);
+ PreferencesUtils.setString(R.string.idle_duration_key, R.string.idle_duration_default);
service = startService();
}
@@ -122,7 +122,7 @@ public class TrackRecordingServiceRecordingTest {
service.endCurrentTrack();
// then
- assertEquals(new TrackStatistics(startTime, stopTime, 0, 1, 0, 0, 0f, 0f)
+ assertEquals(new TrackStatistics(startTime, stopTime, 0, 1, 1, 0, 0f, 0f)
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
new TrackPointAssert().assertEquals(List.of(
@@ -150,7 +150,7 @@ public class TrackRecordingServiceRecordingTest {
service.endCurrentTrack();
// then
- assertEquals(new TrackStatistics(startTime, pauseTime, 0, 1, 0, 0, 0f, 0f)
+ assertEquals(new TrackStatistics(startTime, pauseTime, 0, 1, 1, 0, 0f, 0f)
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
new TrackPointAssert().assertEquals(List.of(
@@ -166,7 +166,7 @@ public class TrackRecordingServiceRecordingTest {
service.resumeTrack(trackId);
// then
- assertEquals(new TrackStatistics(startTime, resumeTime, 0, 1, 0, 0, 0f, 0f)
+ assertEquals(new TrackStatistics(startTime, resumeTime, 0, 1, 1, 0, 0f, 0f)
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
new TrackPointAssert().assertEquals(List.of(
@@ -299,7 +299,7 @@ public class TrackRecordingServiceRecordingTest {
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
// then
- assertEquals(new TrackStatistics(startTime, gps1, 0, 1, 0, 0, 0f, 0f)
+ assertEquals(new TrackStatistics(startTime, gps1, 0, 1, 1, 15, 0f, 0f)
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
// when
@@ -307,7 +307,7 @@ public class TrackRecordingServiceRecordingTest {
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.0001, 35.0, 1, 15);
// then
- assertEquals(new TrackStatistics(startTime, gps2, 11.113178253173828f, 4, 3, 15, 0f, 0f)
+ assertEquals(new TrackStatistics(startTime, gps2, 11.113178253173828f, 4, 4, 15, 0f, 0f)
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
// when
@@ -315,7 +315,7 @@ public class TrackRecordingServiceRecordingTest {
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps3, 45.0002, 35.0, 1, 15);
// then
- assertEquals(new TrackStatistics(startTime, gps3, 22.226356506347656, 6, 5, 15, 0f, 0f)
+ assertEquals(new TrackStatistics(startTime, gps3, 22.226356506347656, 6, 6, 15, 0f, 0f)
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
@@ -325,7 +325,7 @@ public class TrackRecordingServiceRecordingTest {
service.endCurrentTrack();
// then
- assertEquals(new TrackStatistics(startTime, stopTime, 22.226356506347656, 10, 5, 15, 0f, 0f)
+ assertEquals(new TrackStatistics(startTime, stopTime, 22.226356506347656, 10, 10, 15, 0f, 0f)
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
new TrackPointAssert().assertEquals(List.of(
@@ -357,71 +357,6 @@ public class TrackRecordingServiceRecordingTest {
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
}
- @MediumTest
- @Test
- public void testRecording_gpsOnly_recordingDistance_above_speed_0() {
- // given
- String startTime = "2020-02-02T02:02:02Z";
- TrackPointCreator trackPointCreator = service.getTrackPointCreator();
- trackPointCreator.setClock(startTime);
- Track.Id trackId = service.startNewTrack();
- trackPointCreator.getSensorManager().setAltitudeSumManager(altitudeSumManager);
-
- // when
- String gps1 = "2020-02-02T02:02:03Z";
- TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 0);
-
- // then
- TrackStatistics gps1statistics = new TrackStatistics(startTime, gps1, 0, 1, 0, 0, 0f, 0f);
- assertEquals(gps1statistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
- // when
- String gps2 = "2020-02-02T02:02:06Z";
- TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.0001, 35.0, 1, 0);
-
- // then
- assertEquals(gps1statistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
- // when
- String gps3 = "2020-02-02T02:02:08Z";
- TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps3, 45.0002, 35.0, 1, 0);
-
-
- // then
- assertEquals(gps1statistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
- // when
- String stopTime = "2020-02-02T02:02:12Z";
- trackPointCreator.setClock(stopTime);
- service.endCurrentTrack();
-
-
- // then
- assertEquals(new TrackStatistics(startTime, stopTime, 0, 10, 0, 0, 0f, 0f)
- , contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
- new TrackPointAssert().assertEquals(List.of(
- new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
- new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse(gps1))
- .setLatitude(45)
- .setLongitude(35)
- .setHorizontalAccuracy(Distance.of(1))
- .setSpeed(Speed.of(0))
- .setAltitudeGain(0f)
- .setAltitudeLoss(0f),
- new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse(gps3))
- .setLatitude(45.0001)
- .setLongitude(35)
- .setHorizontalAccuracy(Distance.of(1))
- .setSpeed(Speed.of(0))
- .setAltitudeGain(0f)
- .setAltitudeLoss(0f),
- new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(stopTime))
- .setAltitudeGain(0f)
- .setAltitudeLoss(0f)
- ), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
- }
-
@MediumTest
@Test
public void testRecording_gpsOnly_recordingDistance_below() {
@@ -437,7 +372,7 @@ public class TrackRecordingServiceRecordingTest {
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
// then
- TrackStatistics gps1Statistics = new TrackStatistics(startTime, gps1, 0, 1, 0, 0, 0f, 0f);
+ TrackStatistics gps1Statistics = new TrackStatistics(startTime, gps1, 0, 1, 1, 15, 0f, 0f);
assertEquals(gps1Statistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
// when
@@ -461,7 +396,7 @@ public class TrackRecordingServiceRecordingTest {
service.endCurrentTrack();
// then
- assertEquals(new TrackStatistics(startTime, stopTime, 2.222635507583618, 10, 5, 15, 0f, 0f)
+ assertEquals(new TrackStatistics(startTime, stopTime, 2.222635507583618, 10, 10, 15, 0f, 0f)
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
new TrackPointAssert().assertEquals(List.of(
@@ -486,158 +421,6 @@ public class TrackRecordingServiceRecordingTest {
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
}
- @MediumTest
- @Test
- public void testRecording_gpsOnly_recordingDistance_idle() {
- // given
- String startTime = "2020-02-02T02:02:02Z";
- TrackPointCreator trackPointCreator = service.getTrackPointCreator();
- trackPointCreator.setClock(startTime);
- Track.Id trackId = service.startNewTrack();
- trackPointCreator.getSensorManager().setAltitudeSumManager(altitudeSumManager);
-
- // when
- String gps1 = "2020-02-02T02:02:03Z";
- TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 0);
-
- // then
- TrackStatistics gps1Statistics = new TrackStatistics(startTime, gps1, 0, 1, 0, 0, 0f, 0f);
- assertEquals(gps1Statistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
- // when
- String gps2 = "2020-02-02T02:02:06Z";
- TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.0, 35.0, 1, 0);
-
- // then
- assertEquals(gps1Statistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
- // when
- String gps3 = "2020-02-02T02:02:08Z";
- TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps3, 45.0, 35.0, 1, 0);
-
- // then
- assertEquals(gps1Statistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
-
- // when
- String stopTime = "2020-02-02T02:02:12Z";
- trackPointCreator.setClock(stopTime);
- service.endCurrentTrack();
-
- // then
- assertEquals(new TrackStatistics(startTime, stopTime, 0, 10, 0, 0, 0f, 0f)
- , contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
- new TrackPointAssert().assertEquals(List.of(
- new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
- new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse(gps1))
- .setLatitude(45)
- .setLongitude(35)
- .setHorizontalAccuracy(Distance.of(1))
- .setSpeed(Speed.of(0))
- .setAltitudeGain(0f)
- .setAltitudeLoss(0f),
- new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse(gps3))
- .setLatitude(45.00002)
- .setLongitude(35)
- .setHorizontalAccuracy(Distance.of(1))
- .setSpeed(Speed.of(0))
- .setAltitudeGain(0f)
- .setAltitudeLoss(0f),
- new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(stopTime))
- .setAltitudeGain(0f)
- .setAltitudeLoss(0f)
- ), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
- }
-
- @MediumTest
- @Test
- public void testRecording_gpsOnly_recordingDistance_idle_movement() {
- // given
- String startTime = "2020-02-02T02:02:02Z";
- TrackPointCreator trackPointCreator = service.getTrackPointCreator();
- trackPointCreator.setClock(startTime);
- Track.Id trackId = service.startNewTrack();
- trackPointCreator.getSensorManager().setAltitudeSumManager(altitudeSumManager);
-
- // when
- String gps1 = "2020-02-02T02:02:03Z";
- TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
-
- // then
- assertEquals(new TrackStatistics(startTime, gps1, 0, 1, 0, 0, 0f, 0f)
- , contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
- // when
- String gps2 = "2020-02-02T02:02:06Z";
- TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.0, 35.0, 1, 0);
-
- // then
- final TrackStatistics gps2statistics = new TrackStatistics(startTime, gps2, 0, 4, 0, 0, 0f, 0f);
- assertEquals(gps2statistics
- , contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
- // when
- String gps3 = "2020-02-02T02:02:08Z";
- TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps3, 45.0, 35.0, 1, 0);
-
- // then
- assertEquals(gps2statistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
-
- // when
- String gps4 = "2020-02-02T02:02:10Z";
- TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps4, 45.0, 35.0, 1, 15);
-
- // then
- assertEquals(new TrackStatistics(startTime, gps4, 0, 8, 0, 0, 0f, 0f)
- , contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
- // when
- String stopTime = "2020-02-02T02:02:12Z";
- trackPointCreator.setClock(stopTime);
- service.endCurrentTrack();
-
- // then
- assertEquals(new TrackStatistics(startTime, stopTime, 0, 10, 0, 0, 0f, 0f)
- , contentProviderUtils.getTrack(trackId).getTrackStatistics());
-
- new TrackPointAssert().assertEquals(List.of(
- new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
- new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse(gps1))
- .setLatitude(45)
- .setLongitude(35)
- .setHorizontalAccuracy(Distance.of(1))
- .setSpeed(Speed.of(15))
- .setAltitudeGain(0f)
- .setAltitudeLoss(0f),
- new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse(gps2))
- .setLatitude(45)
- .setLongitude(35)
- .setHorizontalAccuracy(Distance.of(1))
- .setSpeed(Speed.of(0))
- .setAltitudeGain(0f)
- .setAltitudeLoss(0f),
- new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse(gps3))
- .setLatitude(45)
- .setLongitude(35)
- .setHorizontalAccuracy(Distance.of(1))
- .setSpeed(Speed.of(0))
- .setAltitudeGain(0f)
- .setAltitudeLoss(0f),
- new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse(gps4))
- .setLatitude(45)
- .setLongitude(35)
- .setHorizontalAccuracy(Distance.of(1))
- .setSpeed(Speed.of(15))
- .setAltitudeGain(0f)
- .setAltitudeLoss(0f),
- new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(stopTime))
- .setAltitudeGain(0f)
- .setAltitudeLoss(0f)
- ), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
- }
-
@MediumTest
@Test
public void testRecording_gpsOnly_recordingDistance_movement_non_idle() {
@@ -721,7 +504,7 @@ public class TrackRecordingServiceRecordingTest {
service.endCurrentTrack();
// then
- assertEquals(new TrackStatistics(startTime, stopTime, 0, 10, 0, 0, 0f, 0f)
+ assertEquals(new TrackStatistics(startTime, stopTime, 0, 10, 10, 0, 0f, 0f)
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
@@ -749,14 +532,14 @@ public class TrackRecordingServiceRecordingTest {
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
// then
- assertEquals(new TrackStatistics(startTime, gps1, 0, 1, 0, 0, 0f, 0f), contentProviderUtils.getTrack(trackId).getTrackStatistics());
+ assertEquals(new TrackStatistics(startTime, gps1, 0, 1, 1, 15, 0f, 0f), contentProviderUtils.getTrack(trackId).getTrackStatistics());
// when
String gps2 = "2020-02-02T02:02:06Z";
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.1, 35.0, 1, 15);
// then
- assertEquals(new TrackStatistics(startTime, gps2, 11113.275390625, 4, 3, 3704.4251302083335f, 0f, 0f).toString(), contentProviderUtils.getTrack(trackId).getTrackStatistics().toString());
+ assertEquals(new TrackStatistics(startTime, gps2, 11113.275390625, 4, 4, 2778.31884765625f, 0f, 0f).toString(), contentProviderUtils.getTrack(trackId).getTrackStatistics().toString());
// when
@@ -765,7 +548,7 @@ public class TrackRecordingServiceRecordingTest {
service.endCurrentTrack();
// then
- assertEquals(new TrackStatistics(startTime, stopTime, 11113.275390625, 10, 3, 3704.4251302083335f, 0f, 0f).toString(), contentProviderUtils.getTrack(trackId).getTrackStatistics().toString());
+ assertEquals(new TrackStatistics(startTime, stopTime, 11113.275390625, 10, 10, 1111.3275390625f, 0f, 0f).toString(), contentProviderUtils.getTrack(trackId).getTrackStatistics().toString());
// then
diff --git a/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java b/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java
index ab805fad6..aac0d6b10 100644
--- a/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java
+++ b/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java
@@ -63,7 +63,7 @@ public class VoiceAnnouncementUtilsTest {
stats.setTotalAltitudeGain(6000f);
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, null, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.METRIC, true, null, null).toString();
// then
assertEquals("Total distance 20.0 kilometers. 1 hour 5 minutes 10 seconds. Average moving speed 18.4 kilometers per hour.", announcement);
@@ -79,7 +79,7 @@ public class VoiceAnnouncementUtilsTest {
stats.setTotalAltitudeGain(6000f);
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, null, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.METRIC, true, null, null).toString();
// then
assertEquals("Total distance 20.0 kilometers. 1 hour 1 second. Average moving speed 20.0 kilometers per hour.", announcement);
@@ -95,7 +95,7 @@ public class VoiceAnnouncementUtilsTest {
stats.setTotalAltitudeGain(6000f);
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, null, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.METRIC, true, null, null).toString();
// then
assertEquals("Total distance 20.0 kilometers. 1 hour. Average moving speed 20.0 kilometers per hour.", announcement);
@@ -111,7 +111,7 @@ public class VoiceAnnouncementUtilsTest {
stats.setTotalAltitudeGain(6000f);
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, null, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.METRIC, true, null, null).toString();
// then
assertEquals("Total distance 19.9 kilometers. 1 hour. Average moving speed 19.9 kilometers per hour.", announcement);
@@ -133,7 +133,7 @@ public class VoiceAnnouncementUtilsTest {
}
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, lastInterval, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.METRIC, true, lastInterval, null).toString();
// then
assertEquals("Total distance 14.2 kilometers. 16 minutes 39 seconds. Average moving speed 51.2 kilometers per hour. Lap speed 51.2 kilometers per hour.", announcement);
@@ -149,7 +149,7 @@ public class VoiceAnnouncementUtilsTest {
stats.setTotalAltitudeGain(6000f);
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, false, null, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.METRIC, false, null, null).toString();
// then
assertEquals("Total distance 20.0 kilometers. 1 hour 5 minutes 10 seconds. Pace 3 minutes 15 seconds per kilometer.", announcement);
@@ -171,7 +171,7 @@ public class VoiceAnnouncementUtilsTest {
}
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, false, lastInterval, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.METRIC, false, lastInterval, null).toString();
// then
assertEquals("Total distance 14.2 kilometers. 16 minutes 39 seconds. Pace 1 minute 10 seconds per kilometer. Lap time 1 minute 10 seconds per kilometer.", announcement);
@@ -187,7 +187,7 @@ public class VoiceAnnouncementUtilsTest {
stats.setTotalAltitudeGain(6000f);
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.IMPERIAL_FEET, true, null, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.IMPERIAL_FEET, true, null, null).toString();
// then
assertEquals("Total distance 12.4 miles. 1 hour 5 minutes 10 seconds. Average moving speed 11.4 miles per hour.", announcement);
@@ -201,7 +201,7 @@ public class VoiceAnnouncementUtilsTest {
stats.setMovingTime(Duration.ofHours(1));
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.IMPERIAL_FEET, true, null, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.IMPERIAL_FEET, true, null, null).toString();
// then
assertEquals("Total distance 1.1 miles. 1 hour. Average moving speed 1.1 miles per hour.", announcement);
@@ -215,7 +215,7 @@ public class VoiceAnnouncementUtilsTest {
stats.setMovingTime(Duration.ofHours(1));
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.IMPERIAL_METER, true, null, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.IMPERIAL_METER, true, null, null).toString();
// then
assertEquals("Total distance 1.1 miles. 1 hour. Average moving speed 1.1 miles per hour.", announcement);
@@ -229,7 +229,7 @@ public class VoiceAnnouncementUtilsTest {
stats.setMovingTime(Duration.ofHours(1));
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, null, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.METRIC, true, null, null).toString();
// then
assertEquals("Total distance 1.1 kilometers. 1 hour. Average moving speed 1.1 kilometers per hour.", announcement);
@@ -251,7 +251,7 @@ public class VoiceAnnouncementUtilsTest {
}
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.IMPERIAL_FEET, true, lastInterval, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.IMPERIAL_FEET, true, lastInterval, null).toString();
// then
assertEquals("Total distance 8.8 miles. 16 minutes 39 seconds. Average moving speed 31.8 miles per hour. Lap speed 31.8 miles per hour.", announcement);
@@ -267,7 +267,7 @@ public class VoiceAnnouncementUtilsTest {
stats.setTotalAltitudeGain(6000f);
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.IMPERIAL_FEET, false, null, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.IMPERIAL_FEET, false, null, null).toString();
// then
assertEquals("Total distance 12.4 miles. 1 hour 5 minutes 10 seconds. Pace 5 minutes 15 seconds per mile.", announcement);
@@ -289,7 +289,7 @@ public class VoiceAnnouncementUtilsTest {
}
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.IMPERIAL_FEET, false, lastInterval, null).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.IMPERIAL_FEET, false, lastInterval, null).toString();
// then
assertEquals("Total distance 8.8 miles. 16 minutes 39 seconds. Pace 1 minute 53 seconds per mile. Lap time 1 minute 53 seconds per mile.", announcement);
@@ -315,7 +315,7 @@ public class VoiceAnnouncementUtilsTest {
SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null);
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString();
// then
assertEquals("Total distance 14.2 kilometers. 16 minutes 39 seconds. Average moving speed 51.2 kilometers per hour. Lap speed 51.2 kilometers per hour. Average heart rate 180 bpm. Current heart rate 133 bpm.", announcement);
@@ -345,7 +345,7 @@ public class VoiceAnnouncementUtilsTest {
SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null);
// when
- String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString();
+ String announcement = VoiceAnnouncementUtils.createStatistics(context, stats, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString();
// then
assertEquals(" Current heart rate 133 bpm.", announcement);
diff --git a/src/androidTest/java/de/dennisguse/opentracks/stats/TrackStatisticsUpdaterTest.java b/src/androidTest/java/de/dennisguse/opentracks/stats/TrackStatisticsUpdaterTest.java
index 4c797f2c0..59c9425a9 100644
--- a/src/androidTest/java/de/dennisguse/opentracks/stats/TrackStatisticsUpdaterTest.java
+++ b/src/androidTest/java/de/dennisguse/opentracks/stats/TrackStatisticsUpdaterTest.java
@@ -83,35 +83,17 @@ public class TrackStatisticsUpdaterTest {
TrackStatistics statistics = subject.getTrackStatistics();
assertEquals(142.26, statistics.getTotalDistance().toM(), 0.01);
assertEquals(Duration.ofSeconds(12), statistics.getTotalTime());
- assertEquals(Duration.ofSeconds(10), statistics.getMovingTime());
+ assertEquals(Duration.ofSeconds(12), statistics.getMovingTime());
assertEquals(2.5, statistics.getMinAltitude(), 0.01);
assertEquals(32.5, statistics.getMaxAltitude(), 0.01);
assertEquals(36, statistics.getTotalAltitudeGain(), 0.01);
assertEquals(36, statistics.getTotalAltitudeLoss(), 0.01);
- assertEquals(14.226, statistics.getMaxSpeed().toMPS(), 0.01);
- assertEquals(14.226, statistics.getAverageMovingSpeed().toMPS(), 0.01);
+ assertEquals(11.85, statistics.getMaxSpeed().toMPS(), 0.01);
+ assertEquals(11.85, statistics.getAverageMovingSpeed().toMPS(), 0.01);
assertEquals(11.85, statistics.getAverageSpeed().toMPS(), 0.01);
- assertEquals(106.64f, statistics.getAverageHeartRate().getBPM(), 0.01);
- }
-
- @Test
- public void addTrackPoint_distance_from_GPS_not_moving() {
- // given
- TrackStatisticsUpdater subject = new TrackStatisticsUpdater();
-
- TrackPoint tp1 = new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.ofEpochMilli(1000));
- TrackPoint tp2 = new TrackPoint(0, 0, Altitude.WGS84.of(5.0), Instant.ofEpochMilli(2000));
- TrackPoint tp3 = new TrackPoint(0.00001, 0, Altitude.WGS84.of(5.0), Instant.ofEpochMilli(3000));
-
- // when
- subject.addTrackPoint(tp1);
- subject.addTrackPoint(tp2);
- subject.addTrackPoint(tp3);
-
- // then
- assertEquals(0, subject.getTrackStatistics().getTotalDistance().toM(), 0.01);
+ assertEquals(106.834f, statistics.getAverageHeartRate().getBPM(), 0.01);
}
@Test
@@ -165,35 +147,6 @@ public class TrackStatisticsUpdaterTest {
assertEquals(125.57, subject.getTrackStatistics().getTotalDistance().toM(), 0.01);
}
- @Test
- public void addTrackPoint_distance_from_GPS_not_moving_and_sensor_moving() {
- // given
- TrackStatisticsUpdater subject = new TrackStatisticsUpdater();
-
- TrackPoint tp1 = new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.ofEpochMilli(1000));
- TrackPoint tp2 = new TrackPoint(0, 0, Altitude.WGS84.of(5.0), Instant.ofEpochMilli(2000));
- TrackPoint tp3 = new TrackPoint(0.00001, 0, Altitude.WGS84.of(5.0), Instant.ofEpochMilli(3000));
- TrackPoint tp4 = new TrackPoint(0.00001, 0, Altitude.WGS84.of(5.0), Instant.ofEpochMilli(4000));
- tp4.setSensorDistance(Distance.of(5f));
- TrackPoint tp5 = new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.ofEpochMilli(5000));
- tp5.setSensorDistance(Distance.of(10f));
-
- // when
- subject.addTrackPoint(tp1);
- subject.addTrackPoint(tp2);
- subject.addTrackPoint(tp3);
-
- // then
- assertEquals(0, subject.getTrackStatistics().getTotalDistance().toM(), 0.01);
-
- // when
- subject.addTrackPoint(tp4);
- subject.addTrackPoint(tp5);
-
- // then
- assertEquals(15, subject.getTrackStatistics().getTotalDistance().toM(), 0.01);
- }
-
@Test
public void addTrackPoint_distance_from_GPS_moving_and_sensor_disconnecting() {
// given
@@ -225,42 +178,6 @@ public class TrackStatisticsUpdaterTest {
assertEquals(59.18, subject.getTrackStatistics().getTotalDistance().toM(), 0.01);
}
-
- @Test
- public void addTrackPoint_maxSpeed_ignore_above_acceleration() {
- TrackStatisticsUpdater subject = new TrackStatisticsUpdater();
- assertEquals(Speed.of(0f), subject.getTrackStatistics().getMaxSpeed());
-
- subject.addTrackPoint(new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.ofEpochSecond(0)));
- assertEquals(Speed.of(0f), subject.getTrackStatistics().getMaxSpeed());
-
- // Ignore as we set max speed if two consecutive trackpoints were considered moving
- subject.addTrackPoint(new TrackPoint(0, 0, Altitude.WGS84.of(0), Instant.ofEpochSecond(1))
- .setSpeed(Speed.of(1f)));
- assertEquals(Speed.of(0f), subject.getTrackStatistics().getMaxSpeed());
-
- // Update max speed
- subject.addTrackPoint(new TrackPoint(0, 0, Altitude.WGS84.of(0), Instant.ofEpochSecond(2))
- .setSpeed(Speed.of(1f)));
- assertEquals(Speed.of(1f), subject.getTrackStatistics().getMaxSpeed());
-
- // Update max speed
- subject.addTrackPoint(new TrackPoint(0, 0, Altitude.WGS84.of(0), Instant.ofEpochSecond(12))
- .setSpeed(Speed.of(50f)));
- assertEquals(Speed.of(50f), subject.getTrackStatistics().getMaxSpeed());
-
- // Ignore; we were getting slower
- subject.addTrackPoint(new TrackPoint(0, 0, Altitude.WGS84.of(0), Instant.ofEpochSecond(13))
- .setSpeed(Speed.of(5f)));
- assertEquals(Speed.of(50f), subject.getTrackStatistics().getMaxSpeed());
-
- // Ignore acceleration above 2g
- subject.addTrackPoint(new TrackPoint(0, 0, Altitude.WGS84.of(0), Instant.ofEpochSecond(14))
- .setSpeed(Speed.of(500f)));
- assertEquals(Speed.of(50f), subject.getTrackStatistics().getMaxSpeed());
-
- }
-
@Test
public void addTrackPoint_maxSpeed_multiple_segments() {
TrackStatisticsUpdater subject = new TrackStatisticsUpdater();
@@ -290,6 +207,64 @@ public class TrackStatisticsUpdaterTest {
assertEquals(Speed.of(2f), subject.getTrackStatistics().getMaxSpeed());
}
+ @Test
+ public void addTrackPoint_idle_withoutDistance() {
+ TrackStatisticsUpdater subject = new TrackStatisticsUpdater();
+
+ // when
+ subject.addTrackPoints(List.of(
+ new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.ofEpochSecond(0)),
+ new TrackPoint(0, 0, Altitude.WGS84.of(0), Instant.ofEpochSecond(1))
+ .setSpeed(Speed.of(2f)),
+ new TrackPoint(0, 0, Altitude.WGS84.of(0), Instant.ofEpochSecond(2))
+ .setSpeed(Speed.of(2f)),
+
+ new TrackPoint(TrackPoint.Type.IDLE, Instant.ofEpochSecond(30)),
+ new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochSecond(40))
+ .setHeartRate(50),
+ new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochSecond(45))
+ .setHeartRate(50),
+ new TrackPoint(0, 1, Altitude.WGS84.of(0), Instant.ofEpochSecond(50)),
+ new TrackPoint(0, 2, Altitude.WGS84.of(0), Instant.ofEpochSecond(55)),
+
+ new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.ofEpochSecond(60))
+ ));
+
+ // then
+ assertEquals(Duration.ofSeconds(40), subject.getTrackStatistics().getMovingTime());
+ }
+
+ @Test
+ public void addTrackPoint_idle_withDistance() {
+ TrackStatisticsUpdater subject = new TrackStatisticsUpdater();
+
+ // when
+ subject.addTrackPoints(List.of(
+ new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.ofEpochSecond(0)),
+ new TrackPoint(0, 0, Altitude.WGS84.of(0), Instant.ofEpochSecond(1))
+ .setSensorDistance(Distance.of(10)),
+ new TrackPoint(0, 0, Altitude.WGS84.of(0), Instant.ofEpochSecond(2))
+ .setSensorDistance(Distance.of(10)),
+
+ new TrackPoint(TrackPoint.Type.IDLE, Instant.ofEpochSecond(30))
+ .setSensorDistance(Distance.ofKilometer(1)),
+ new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochSecond(40))
+ .setHeartRate(50),
+ new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochSecond(45))
+ .setHeartRate(50),
+ new TrackPoint(0, 0, Altitude.WGS84.of(0), Instant.ofEpochSecond(50))
+ .setSensorDistance(Distance.of(10)),
+ new TrackPoint(0, 0, Altitude.WGS84.of(0), Instant.ofEpochSecond(55))
+ .setSensorDistance(Distance.of(10)),
+
+ new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.ofEpochSecond(60))
+ ));
+
+ // then
+ assertEquals(Duration.ofSeconds(45), subject.getTrackStatistics().getMovingTime());
+ assertEquals(Distance.of(1040), subject.getTrackStatistics().getTotalDistance());
+ }
+
@Test
public void copy_constructor() {
// given
@@ -314,7 +289,6 @@ public class TrackStatisticsUpdaterTest {
subject.addTrackPoint(tp5);
copy.addTrackPoint(tp5);
-
// then
assertEquals(55.287, subject.getTrackStatistics().getTotalDistance().toM(), 0.01);
assertEquals(55.287, copy.getTrackStatistics().getTotalDistance().toM(), 0.01);
diff --git a/src/androidTest/res/raw/csv_export.csv b/src/androidTest/res/raw/csv_export.csv
index bc32fdb45..cdefb81a1 100644
--- a/src/androidTest/res/raw/csv_export.csv
+++ b/src/androidTest/res/raw/csv_export.csv
@@ -3,11 +3,11 @@
"2020-02-02T03:02:03+01:00","TRACKPOINT",3,14,10,10,,54,1,1,,,,
"2020-02-02T03:02:04+01:00","TRACKPOINT",,,,,,54,1,1,10,66,3,50
"2020-02-02T03:02:15+01:00","TRACKPOINT",,,,,,,,,,68,3,50
-"2020-02-02T03:02:16+01:00","TRACKPOINT",,,,,,18,,,2,69,3,50
"2020-02-02T03:02:17+01:00","TRACKPOINT",3,14.001,10,10,,18,0,0,2,69,3,50
"2020-02-02T03:02:18+01:00","SEGMENT_END_MANUAL",,,,,,,,,,,,
"2020-02-02T03:03:20+01:00","SEGMENT_START_MANUAL",,,,,,,,,,,,
"2020-02-02T03:03:21+01:00","TRACKPOINT",3,14.002,10,10,,54,0,0,,,,
"2020-02-02T03:03:22+01:00","SEGMENT_START_AUTOMATIC",3,16,10,10,,54,0,0,,,,
-"2020-02-02T03:03:23+01:00","TRACKPOINT",3,16.001,10,10,,54,0,0,,,,
-"2020-02-02T03:03:24+01:00","SEGMENT_END_MANUAL",,,,,,,,,,,,
\ No newline at end of file
+"2020-02-02T03:03:30+01:00","IDLE",,,,,,,,,,,,
+"2020-02-02T03:03:50+01:00","TRACKPOINT",3,16.001,10,10,,54,0,0,,,,
+"2020-02-02T03:04:00+01:00","SEGMENT_END_MANUAL",,,,,,,,,,,,
\ No newline at end of file
diff --git a/src/main/java/de/dennisguse/opentracks/AbstractActivity.java b/src/main/java/de/dennisguse/opentracks/AbstractActivity.java
index 169b55915..aae4c9b7d 100644
--- a/src/main/java/de/dennisguse/opentracks/AbstractActivity.java
+++ b/src/main/java/de/dennisguse/opentracks/AbstractActivity.java
@@ -21,7 +21,7 @@ import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
-import de.dennisguse.opentracks.services.announcement.VoiceAnnouncement;
+import de.dennisguse.opentracks.services.announcement.TTSManager;
/**
* @author Jimmy Shih
@@ -33,7 +33,7 @@ public abstract class AbstractActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
// Set volume control stream for text to speech
- setVolumeControlStream(VoiceAnnouncement.AUDIO_STREAM);
+ setVolumeControlStream(TTSManager.AUDIO_STREAM);
setContentView(getRootView());
}
diff --git a/src/main/java/de/dennisguse/opentracks/data/models/Speed.java b/src/main/java/de/dennisguse/opentracks/data/models/Speed.java
index 7714b678a..60bd1e84b 100644
--- a/src/main/java/de/dennisguse/opentracks/data/models/Speed.java
+++ b/src/main/java/de/dennisguse/opentracks/data/models/Speed.java
@@ -2,7 +2,6 @@ package de.dennisguse.opentracks.data.models;
import java.time.Duration;
-import de.dennisguse.opentracks.settings.PreferencesUtils;
import de.dennisguse.opentracks.settings.UnitSystem;
public record Speed(double speed_mps) {
@@ -56,10 +55,6 @@ public record Speed(double speed_mps) {
return Double.isNaN(speed_mps) || Double.isInfinite(speed_mps);
}
- public boolean isMoving() {
- return !isInvalid() && greaterThan(PreferencesUtils.getIdleSpeed());
- }
-
public boolean lessThan(Speed speed) {
return !greaterThan(speed);
}
diff --git a/src/main/java/de/dennisguse/opentracks/data/models/TrackPoint.java b/src/main/java/de/dennisguse/opentracks/data/models/TrackPoint.java
index 9e9a31bc6..03eaf6c73 100644
--- a/src/main/java/de/dennisguse/opentracks/data/models/TrackPoint.java
+++ b/src/main/java/de/dennisguse/opentracks/data/models/TrackPoint.java
@@ -66,6 +66,7 @@ public class TrackPoint {
public final int type_db;
+
Type(int type_db) {
this.type_db = type_db;
}
@@ -287,11 +288,6 @@ public class TrackPoint {
this.speed = speed;
return this;
}
-
- public boolean isMoving() {
- return hasSpeed() && getSpeed().isMoving();
- }
-
public boolean hasBearing() {
return bearing != null;
}
@@ -352,9 +348,8 @@ public class TrackPoint {
return hasHorizontalAccuracy() && horizontalAccuracy.lessThan(thresholdHorizontalAccuracy);
}
- //TODO Bearing requires a location; what do we do if we don't have any?
public float bearingTo(@NonNull TrackPoint dest) {
- return getLocation().bearingTo(dest.getLocation());
+ return bearingTo(dest.getLocation());
}
//TODO Bearing requires a location; what do we do if we don't have any?
@@ -449,13 +444,14 @@ public class TrackPoint {
", latitude=" + latitude +
", longitude=" + longitude +
", horizontalAccuracy=" + horizontalAccuracy +
+ ", verticalAccuracy=" + verticalAccuracy +
", altitude=" + altitude +
", speed=" + speed +
", bearing=" + bearing +
", sensorDistance=" + sensorDistance +
", type=" + type +
- ", heartRate_bpm=" + heartRate +
- ", cadence_rpm=" + cadence +
+ ", heartRate=" + heartRate +
+ ", cadence=" + cadence +
", power=" + power +
", altitudeGain_m=" + altitudeGain_m +
", altitudeLoss_m=" + altitudeLoss_m +
diff --git a/src/main/java/de/dennisguse/opentracks/io/file/exporter/GPXTrackExporter.java b/src/main/java/de/dennisguse/opentracks/io/file/exporter/GPXTrackExporter.java
index a4de84eab..7a7362a05 100644
--- a/src/main/java/de/dennisguse/opentracks/io/file/exporter/GPXTrackExporter.java
+++ b/src/main/java/de/dennisguse/opentracks/io/file/exporter/GPXTrackExporter.java
@@ -171,6 +171,9 @@ public class GPXTrackExporter implements TrackExporter {
sensorPoints.add(trackPoint);
}
}
+ case IDLE -> {
+ // Not supported as IDLE-TrackPoints have no location.
+ }
default ->
throw new RuntimeException("Exporting this TrackPoint type is not implemented: " + trackPoint.getType());
}
diff --git a/src/main/java/de/dennisguse/opentracks/io/file/exporter/KMLTrackExporter.java b/src/main/java/de/dennisguse/opentracks/io/file/exporter/KMLTrackExporter.java
index 3de5f615a..7ba372323 100644
--- a/src/main/java/de/dennisguse/opentracks/io/file/exporter/KMLTrackExporter.java
+++ b/src/main/java/de/dennisguse/opentracks/io/file/exporter/KMLTrackExporter.java
@@ -61,6 +61,7 @@ public class KMLTrackExporter implements TrackExporter {
public static final String EXTENDED_DATA_TYPE_ACTIVITYTYPE = "type";
+ public static final String EXTENDED_DATA_TYPE_TRACKPOINT = "trackpoint_type";
public static final String EXTENDED_DATA_TYPE_SPEED = "speed";
public static final String EXTENDED_DATA_TYPE_DISTANCE = "distance";
public static final String EXTENDED_DATA_TYPE_CADENCE = "cadence";
@@ -83,6 +84,9 @@ public class KMLTrackExporter implements TrackExporter {
private final ContentProviderUtils contentProviderUtils;
private PrintWriter printWriter;
+
+ private ArrayList trackpointTypeList = new ArrayList<>();
+
private final List speedList = new ArrayList<>();
private final List distanceList = new ArrayList<>();
private final List powerList = new ArrayList<>();
@@ -177,12 +181,13 @@ public class KMLTrackExporter implements TrackExporter {
writeCloseSegment();
wroteSegment = false;
}
- case TRACKPOINT -> {
+ case TRACKPOINT, IDLE -> {
if (!wroteSegment) {
// Might happen for older data (pre v3.15.0)
writeOpenSegment();
wroteSegment = true;
}
+
writeTrackPoint(track.getZoneOffset(), trackPoint);
}
default ->
@@ -309,6 +314,7 @@ public class KMLTrackExporter implements TrackExporter {
@VisibleForTesting
void writeOpenSegment() {
printWriter.println("