forked from upstream-mirrors/OpenTracks
Compare commits
243 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ae4d2da262 | |||
| 708cbf0b2a | |||
| 60e2fe57f9 | |||
| 14cebf3fec | |||
| b651a8ca6a | |||
| d75472ef11 | |||
| 0b849c3d55 | |||
| 1c767c41a7 | |||
| dfa80d61d7 | |||
| fa558c9ab7 | |||
| a1a363698f | |||
| b79acfb942 | |||
| 24ea718ff2 | |||
| 6d187fa66d | |||
| ea27db13fa | |||
| 29d2e7c78c | |||
| 4b7badbecc | |||
| 0dcb8010e2 | |||
| 0a9d4b207c | |||
| c6cb388ce4 | |||
| e6e009ba14 | |||
| f8aa456549 | |||
| 167d90332e | |||
| 719a052f34 | |||
| 244ca26210 | |||
| 476f3a517b | |||
| 289e93eb5d | |||
| 18ff96733e | |||
| 0f2c5adf26 | |||
| 74954df600 | |||
| 1a14fed287 | |||
| 744853ee91 | |||
| 597e1b2c7f | |||
| 8156993921 | |||
| 9890dc28bd | |||
| b65d83010d | |||
| 1a5d06f9c6 | |||
| 723c21d7ec | |||
| 8fe0c3be7d | |||
| e64792bf3f | |||
| 21bafff761 | |||
| c33c2de51d | |||
| a6b11c1c37 | |||
| 315788308b | |||
| 547c1c5c65 | |||
| 69efd6fb82 | |||
| 3a0524f96d | |||
| 05456b44ef | |||
| b449dad619 | |||
| ccefe36489 | |||
| 90e9ab6d2a | |||
| d1061fa6cd | |||
| c0c813001f | |||
| 51498bbcf9 | |||
| 4ef1fcefbc | |||
| 9a572130a7 | |||
| e931f5ab7c | |||
| 9affe28fad | |||
| 4905a37951 | |||
| 439671d0a4 | |||
| 825e8dda6e | |||
| 661c839c78 | |||
| 8eb42a7ecb | |||
| 660a55ff5a | |||
| 958697bcb3 | |||
| 6029eb0317 | |||
| 8b56d53a6a | |||
| e9deebea6c | |||
| 54844b9a9a | |||
| 738201c1c2 | |||
| 48b6be0bd1 | |||
| 6b924cd936 | |||
| 5f083de530 | |||
| 278f6323f1 | |||
| 5baa8fa21e | |||
| 707f4add71 | |||
| b583f8f23d | |||
| c847f622e4 | |||
| 70dd58f484 | |||
| 015352c989 | |||
| 42ae582cd8 | |||
| 6e0ad50397 | |||
| d43efad52a | |||
| 693904529d | |||
| 08143a546a | |||
| eb49156ee7 | |||
| 51c03d8d75 | |||
| 666cbbad68 | |||
| 1cbc93c303 | |||
| afd1232940 | |||
| a3407ccbea | |||
| c259f9b8bd | |||
| b1a556bf91 | |||
| ab70874d59 | |||
| e6367b1dfa | |||
| 8db381c448 | |||
| ef111b7959 | |||
| 56c6cb1f19 | |||
| 874c5eb8ae | |||
| 1a087b1117 | |||
| 3120cd8da0 | |||
| 4263c000c0 | |||
| f4073ead63 | |||
| 2f90784442 | |||
| 2cab394d03 | |||
| 55f1bcb30b | |||
| 33a17784e6 | |||
| 7cb97b0e6b | |||
| 1cb3db496a | |||
| d49d6c9857 | |||
| 12f0c3313f | |||
| a78e059612 | |||
| 0774ee512f | |||
| 4c55468571 | |||
| 201f2d1b27 | |||
| 595ad7f7b5 | |||
| d518507193 | |||
| 888f59133d | |||
| 5bb5b3b344 | |||
| b584a95c9c | |||
| 9ba152c469 | |||
| 1191f2e1e2 | |||
| e5aed794ba | |||
| 7956063598 | |||
| 0f356de2ca | |||
| 5b4b54694c | |||
| 9c271972d2 | |||
| 744f11eaa0 | |||
| 3c16f67882 | |||
| 12d1a50995 | |||
| 21404fed50 | |||
| 990c91f978 | |||
| 6a262426a5 | |||
| 1b2998f423 | |||
| d24dd2b005 | |||
| 341fd02f9a | |||
| 6833ea7282 | |||
| a1da53864e | |||
| 28d49de047 | |||
| 4ae9d24960 | |||
| 0b0b1a0d8d | |||
| 090cdbf712 | |||
| 8258d607c3 | |||
| 686a2a9b8f | |||
| 7ddb6b32bb | |||
| 5cd639c852 | |||
| ae9906fb18 | |||
| 96bcac397b | |||
| d7b207afac | |||
| 1672ba99ad | |||
| a6d4a05839 | |||
| 860b90da37 | |||
| 46d7385d25 | |||
| 25fbd9490c | |||
| 6d33adffce | |||
| 92cecb6f3a | |||
| e6bdc9a41d | |||
| e234e9c493 | |||
| 73d6ca6ca6 | |||
| 1ef7a6ecc4 | |||
| 94a0b57362 | |||
| 4ebaf366d6 | |||
| 911f2c525f | |||
| a310f773a1 | |||
| 8a247e5b38 | |||
| 1045ade71a | |||
| 4307dceb70 | |||
| 59ea50b96f | |||
| 8d015fee6c | |||
| 653352255e | |||
| ebcdd87481 | |||
| 8d1af8f2cf | |||
| 766739c222 | |||
| 54fa6aa3e2 | |||
| 1dc737410b | |||
| 4093899a82 | |||
| 9236eb6944 | |||
| 9f00b0606b | |||
| 20a18b86dc | |||
| 34cfc235c3 | |||
| f733d18a60 | |||
| 221b61c7f1 | |||
| ca64f2c749 | |||
| 3d083928eb | |||
| f47ab142f2 | |||
| 6e4d46a14d | |||
| fffeb40200 | |||
| a5e5d0ca51 | |||
| 7791ff8659 | |||
| 3db0a53377 | |||
| 58dac8b706 | |||
| f29b6d4088 | |||
| 80fb4f9998 | |||
| 6340e55fff | |||
| 625549d381 | |||
| 7d9878b32e | |||
| a5553211af | |||
| 044e84154c | |||
| f61d718b2d | |||
| c7a54dcee8 | |||
| 3dc2ee3462 | |||
| 6817ff3234 | |||
| fb0400001a | |||
| 16591b3e80 | |||
| 28da32f573 | |||
| c687308d97 | |||
| 65c8e8542e | |||
| ca4cb648e7 | |||
| 53240c3d1a | |||
| 95b27f66fb | |||
| f31e146cda | |||
| 696939112a | |||
| 73ce97a63e | |||
| 5988ae3d3f | |||
| 58655814b2 | |||
| 11f1b6e72d | |||
| 8f537f33a7 | |||
| 4db72230ff | |||
| fd92793c2a | |||
| 05e45b6870 | |||
| 7521f906ed | |||
| 3222a0c497 | |||
| caf3d957cd | |||
| 005d00cfaa | |||
| c227d54f26 | |||
| bc62320b9f | |||
| 0ad32f676c | |||
| fff5f2d406 | |||
| be653b73ee | |||
| 4580f2a7bb | |||
| 5dd56892fb | |||
| e3460d94ed | |||
| 920ad5129a | |||
| fba08fe8dd | |||
| 291633c1d5 | |||
| 00990076fb | |||
| e672df7a60 | |||
| 82eb237117 | |||
| 894699f009 | |||
| f45dba258b | |||
| 17be49af70 | |||
| e91d36fc16 | |||
| 56f333180b |
+1
-1
@@ -4,7 +4,7 @@ end_of_line = lf
|
|||||||
indent_size = 4
|
indent_size = 4
|
||||||
indent_style = space
|
indent_style = space
|
||||||
insert_final_newline = false
|
insert_final_newline = false
|
||||||
max_line_length = 100
|
max_line_length = 200
|
||||||
tab_width = 4
|
tab_width = 4
|
||||||
ij_continuation_indent_size = 8
|
ij_continuation_indent_size = 8
|
||||||
ij_formatter_off_tag = @formatter:off
|
ij_formatter_off_tag = @formatter:off
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ jobs:
|
|||||||
image: 'ubuntu:android-24.04'
|
image: 'ubuntu:android-24.04'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ jobs:
|
|||||||
image: 'ubuntu:android-24.04'
|
image: 'ubuntu:android-24.04'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ _OpenTracks_ is a sport tracking application that completely respects your priva
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
Translations are hosted on <a href="https://translate.codeberg.org/engage/opentracks/">
|
Translations are hosted on <a href="https://translate.codeberg.org/engage/opentracks/">translate.codeberg.org/projects/opentracks/</a>.
|
||||||
translate.codeberg.org/projects/opentracks/</a>.
|
|
||||||
<a href="https://translate.codeberg.org/engage/opentracks/">
|
<a href="https://translate.codeberg.org/engage/opentracks/">
|
||||||
<img src="https://translate.codeberg.org/widget/opentracks/opentracks-src-main-res-values-strings-xml-main/horizontal-auto.svg" alt="Translation status" />
|
<img src="https://translate.codeberg.org/widget/opentracks/opentracks-src-main-res-values-strings-xml-main/horizontal-auto.svg" alt="Translation status" />
|
||||||
</a>
|
</a>
|
||||||
@@ -112,8 +111,7 @@ The API is disabled by default to protect the user's privacy, but it can easily
|
|||||||
`Classes`:
|
`Classes`:
|
||||||
* **Start a recording:** `de.dennisguse.opentracks.publicapi.StartRecording`
|
* **Start a recording:** `de.dennisguse.opentracks.publicapi.StartRecording`
|
||||||
* Set track data: `TRACK_NAME`, `TRACK_DESCRIPTION`, `TRACK_CATEGORY`, and `TRACK_ICON` (
|
* Set track data: `TRACK_NAME`, `TRACK_DESCRIPTION`, `TRACK_CATEGORY`, and `TRACK_ICON` (
|
||||||
non-localized identifier
|
see `ActivityType.id` defined in [/src/main/java/de/dennisguse/opentracks/util/TrackIconUtils.java#L38](/src/main/java/de/dennisguse/opentracks/data/model/ActivityType.java)).
|
||||||
see [/src/main/java/de/dennisguse/opentracks/util/TrackIconUtils.java#L38](/src/main/java/de/dennisguse/opentracks/util/TrackIconUtils.java#L38)).
|
|
||||||
NOTE: if `TRACK_ICON` is not present, `TRACK_CATEGORY` will be used to determine the icon (
|
NOTE: if `TRACK_ICON` is not present, `TRACK_CATEGORY` will be used to determine the icon (
|
||||||
localized).
|
localized).
|
||||||
* Send recorded data to another application via _Dashboard API_: `STATS_TARGET_PACKAGE` and
|
* Send recorded data to another application via _Dashboard API_: `STATS_TARGET_PACKAGE` and
|
||||||
@@ -134,6 +132,10 @@ adb shell am start -n "de.dennisguse.opentracks.playstore/de.dennisguse.opentrac
|
|||||||
```
|
```
|
||||||
|
|
||||||
## File formats compatibility with open-source software
|
## File formats compatibility with open-source software
|
||||||
|
|
||||||
|
KML/KMZ can be used to export indoor activities (no GPS present).
|
||||||
|
GPX exports only those points that have a GPS coordinate present (sensor data is aggregated though).
|
||||||
|
|
||||||
| | [GPX 1.1](https://www.topografix.com/GPX/1/1/) | [KML 2.3](https://docs.opengeospatial.org/is/12-007r2/12-007r2.html) | [KMZ 2.3](https://docs.opengeospatial.org/is/12-007r2/12-007r2.html) |
|
| | [GPX 1.1](https://www.topografix.com/GPX/1/1/) | [KML 2.3](https://docs.opengeospatial.org/is/12-007r2/12-007r2.html) | [KMZ 2.3](https://docs.opengeospatial.org/is/12-007r2/12-007r2.html) |
|
||||||
|-----------------------------------------------------------|--------------------------------------------------------------------------------|----------------------------------------------------------------------|----------------------------------------------------------------------|
|
|-----------------------------------------------------------|--------------------------------------------------------------------------------|----------------------------------------------------------------------|----------------------------------------------------------------------|
|
||||||
| [OpenLayers 7.1.0](https://openlayers.org/) | ? | [no](https://github.com/openlayers/openlayers/issues/14104) | [no](https://github.com/openlayers/openlayers/issues/14104) |
|
| [OpenLayers 7.1.0](https://openlayers.org/) | ? | [no](https://github.com/openlayers/openlayers/issues/14104) | [no](https://github.com/openlayers/openlayers/issues/14104) |
|
||||||
@@ -143,8 +145,8 @@ adb shell am start -n "de.dennisguse.opentracks.playstore/de.dennisguse.opentrac
|
|||||||
| [FitTrackee](https://github.com/SamR1/FitTrackee) | yes | n/a | n/a |
|
| [FitTrackee](https://github.com/SamR1/FitTrackee) | yes | n/a | n/a |
|
||||||
| [SportsTracker](https://github.com/ssaring/sportstracker) | yes, [single tracks only](https://github.com/ssaring/sportstracker/issues/260) | no | no |
|
| [SportsTracker](https://github.com/ssaring/sportstracker) | yes, [single tracks only](https://github.com/ssaring/sportstracker/issues/260) | no | no |
|
||||||
| [ExifTool](https://exiftool.org) | [yes](https://exiftool.org/forum/index.php?topic=15972.0) | no | no |
|
| [ExifTool](https://exiftool.org) | [yes](https://exiftool.org/forum/index.php?topic=15972.0) | no | no |
|
||||||
| [Wanderer](https://wanderer.to/) | yes | yes | yes |
|
| [Wanderer](https://wanderer.to/) | yes | yes | yes |
|
||||||
|
| [GPX.Studio]https://gpx.studio/) | yes | no | no |
|
||||||
|
|
||||||
## Dashboard API (incl. map)
|
## Dashboard API (incl. map)
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,10 @@ However, often only one value is provided.
|
|||||||
We only support _Instantaneous Power_.
|
We only support _Instantaneous Power_.
|
||||||
|
|
||||||
For cycling (incl. cadence):
|
For cycling (incl. cadence):
|
||||||
* Assioma Duo Powermeter
|
|
||||||
|
* Assioma
|
||||||
|
* Duo Powermeter
|
||||||
|
* Pro MX-2
|
||||||
* Elite drivo II
|
* Elite drivo II
|
||||||
* QUARQ Red DZero Powermeter
|
* QUARQ Red DZero Powermeter
|
||||||
* Tacx Satori Smart
|
* Tacx Satori Smart
|
||||||
|
|||||||
+2
-5
@@ -11,9 +11,6 @@ CHANGELOG_FILE="$CHANGELOG_DIR/$VERSIONID.txt"
|
|||||||
|
|
||||||
git diff --exit-code || echo -e "\nWARNING WARNING WARNING WARNING WARNING: this branch contains uncommit changes."
|
git diff --exit-code || echo -e "\nWARNING WARNING WARNING WARNING WARNING: this branch contains uncommit changes."
|
||||||
|
|
||||||
#TODO Execute all tests: we are destroying data, running on a real device.
|
|
||||||
# ./gradlew connectedCheck
|
|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
echo -e "\nPrevious changelog\n------------"
|
echo -e "\nPrevious changelog\n------------"
|
||||||
PREVIOUS_CHANGELOG=$(find "$CHANGELOG_DIR" -iname "[[:digit:]]**.txt" | sort -n | tail -1)
|
PREVIOUS_CHANGELOG=$(find "$CHANGELOG_DIR" -iname "[[:digit:]]**.txt" | sort -n | tail -1)
|
||||||
@@ -34,8 +31,8 @@ gedit -w "$CHANGELOG_FILE"
|
|||||||
git add "$CHANGELOG_FILE"
|
git add "$CHANGELOG_FILE"
|
||||||
|
|
||||||
echo "Updating build.gradle"
|
echo "Updating build.gradle"
|
||||||
sed -i s/versionCode\ .*/versionCode\ "$VERSIONID"/g build.gradle
|
sed -i -e "s/versionCode\ [0-9]\{1,\}/versionCode\ $VERSIONID/g" build.gradle
|
||||||
sed -i s/versionName\ .*/versionName\ "\"$VERSIONNAME\""/g build.gradle
|
sed -i -e "s/versionName\ \"v[0-9\.]\{1,\}\"/versionName\ \"$VERSIONNAME\"/g" build.gradle
|
||||||
|
|
||||||
git diff
|
git diff
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -6,8 +6,13 @@ export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64/
|
|||||||
|
|
||||||
JAVA_VERSION=`java --version`
|
JAVA_VERSION=`java --version`
|
||||||
if [[ $JAVA_VERSION != "openjdk 21."* ]]; then
|
if [[ $JAVA_VERSION != "openjdk 21."* ]]; then
|
||||||
echo "OpenJDK version should be 21.X"
|
echo -e "OpenJDK version should be 21.X"
|
||||||
exit -1;
|
fi
|
||||||
|
|
||||||
|
git diff --exit-code || echo -e "\nWARNING WARNING WARNING WARNING WARNING: this branch contains uncommit changes."
|
||||||
|
|
||||||
|
if [[ $(git log "$(git describe --tags --abbrev=0)..HEAD" --no-merges --oneline | wc -l) -gt 0 ]]; then
|
||||||
|
echo -e "No version tag for this commit; please use RELEASE.sh";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RELEASE_STORE_PASSWORD=
|
RELEASE_STORE_PASSWORD=
|
||||||
|
|||||||
+31
-25
@@ -6,7 +6,7 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:8.11.1'
|
classpath 'com.android.tools.build:gradle:9.0.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ def getVersionName = { ->
|
|||||||
return 'git describe --tags'.execute().text.trim()
|
return 'git describe --tags'.execute().text.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
def getVersionCode = { ->
|
def getVersionCodeNightly = { ->
|
||||||
return Integer.valueOf('git rev-list HEAD --count'.execute().text.trim())
|
return Integer.valueOf('git rev-list HEAD --count'.execute().text.trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,6 +38,7 @@ android {
|
|||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding = true
|
viewBinding = true
|
||||||
buildConfig = true
|
buildConfig = true
|
||||||
|
resValues = true
|
||||||
}
|
}
|
||||||
|
|
||||||
androidResources {
|
androidResources {
|
||||||
@@ -46,8 +47,8 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId 'de.dennisguse.opentracks'
|
applicationId 'de.dennisguse.opentracks'
|
||||||
versionCode 6353
|
versionCode 6564
|
||||||
versionName "v4.23.1"
|
versionName "v4.25.2"
|
||||||
|
|
||||||
buildConfigField "String", "VERSION_NAME_FULL", "\"${getVersionName()}\""
|
buildConfigField "String", "VERSION_NAME_FULL", "\"${getVersionName()}\""
|
||||||
|
|
||||||
@@ -57,6 +58,17 @@ android {
|
|||||||
testInstrumentationRunner 'de.dennisguse.opentracks.TestRunner'
|
testInstrumentationRunner 'de.dennisguse.opentracks.TestRunner'
|
||||||
testInstrumentationRunnerArguments clearPackageData: 'true'
|
testInstrumentationRunnerArguments clearPackageData: 'true'
|
||||||
}
|
}
|
||||||
|
testOptions {
|
||||||
|
managedDevices {
|
||||||
|
localDevices {
|
||||||
|
mediumPhone {
|
||||||
|
device = "Medium Phone"
|
||||||
|
apiLevel = 35
|
||||||
|
systemImageSource = "aosp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
nightly {
|
nightly {
|
||||||
if (System.getProperty('nightly_store_file') != null) {
|
if (System.getProperty('nightly_store_file') != null) {
|
||||||
@@ -95,12 +107,19 @@ android {
|
|||||||
nightly {
|
nightly {
|
||||||
dimension 'version'
|
dimension 'version'
|
||||||
applicationId 'de.dennisguse.opentracks.nightly'
|
applicationId 'de.dennisguse.opentracks.nightly'
|
||||||
|
resValue 'string', 'applicationId', 'de.dennisguse.opentracks.nightly'
|
||||||
|
|
||||||
|
versionCode getVersionCodeNightly()
|
||||||
|
versionName getVersionName()
|
||||||
|
base.archivesName = "de.dennisguse.opentracks.nightly_${getVersionCodeNightly()}"
|
||||||
|
|
||||||
signingConfig = signingConfigs.nightly
|
signingConfig = signingConfigs.nightly
|
||||||
}
|
}
|
||||||
irreproducible {
|
irreproducible {
|
||||||
// Non-reproducible: https://f-droid.org/de/packages/de.dennisguse.opentracks/
|
// Non-reproducible: https://f-droid.org/de/packages/de.dennisguse.opentracks/
|
||||||
dimension 'version'
|
dimension 'version'
|
||||||
applicationId 'de.dennisguse.opentracks'
|
applicationId 'de.dennisguse.opentracks'
|
||||||
|
resValue 'string', 'applicationId', 'de.dennisguse.opentracks'
|
||||||
versionNameSuffix 'irreproducible'
|
versionNameSuffix 'irreproducible'
|
||||||
}
|
}
|
||||||
reproducible {
|
reproducible {
|
||||||
@@ -109,27 +128,14 @@ android {
|
|||||||
// PlayStore: https://play.google.com/store/apps/details?id=de.dennisguse.opentracks.playstore
|
// PlayStore: https://play.google.com/store/apps/details?id=de.dennisguse.opentracks.playstore
|
||||||
dimension 'version'
|
dimension 'version'
|
||||||
applicationId 'de.dennisguse.opentracks.playstore'
|
applicationId 'de.dennisguse.opentracks.playstore'
|
||||||
|
resValue 'string', 'applicationId', 'de.dennisguse.opentracks.playstore'
|
||||||
|
|
||||||
|
base.archivesName = "de.dennisguse.opentracks.playstore_${getVersionName()}_${android.defaultConfig.versionCode}"
|
||||||
|
|
||||||
signingConfig = signingConfigs.release
|
signingConfig = signingConfigs.release
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applicationVariants.configureEach { variant ->
|
|
||||||
variant.resValue 'string', 'applicationId', variant.applicationId
|
|
||||||
|
|
||||||
variant.outputs.configureEach {
|
|
||||||
if (variant.flavorName == 'nightly') {
|
|
||||||
setVersionCodeOverride(getVersionCode())
|
|
||||||
setVersionNameOverride(getVersionName())
|
|
||||||
}
|
|
||||||
|
|
||||||
if (variant.flavorName == 'reproducible') {
|
|
||||||
outputFileName = "${applicationId}_${variant.versionName}.apk"
|
|
||||||
} else {
|
|
||||||
outputFileName = "${applicationId}_${variant.versionCode}.apk"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependenciesInfo {
|
dependenciesInfo {
|
||||||
// Disables dependency metadata when building APKs.
|
// Disables dependency metadata when building APKs.
|
||||||
includeInApk = false
|
includeInApk = false
|
||||||
@@ -149,17 +155,17 @@ dependencies {
|
|||||||
implementation 'com.google.android.material:material:1.13.0'
|
implementation 'com.google.android.material:material:1.13.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
|
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
|
||||||
implementation 'androidx.core:core:1.17.0'
|
implementation 'androidx.core:core:1.17.0'
|
||||||
implementation 'androidx.core:core-splashscreen:1.0.1'
|
implementation 'androidx.core:core-splashscreen:1.2.0'
|
||||||
implementation 'androidx.mediarouter:mediarouter:1.8.1'
|
implementation 'androidx.mediarouter:mediarouter:1.8.1'
|
||||||
implementation 'androidx.core:core-location-altitude:1.0.0-alpha03'
|
implementation 'androidx.core:core-location-altitude:1.0.0-beta01'
|
||||||
implementation 'androidx.work:work-runtime:2.10.5'
|
implementation 'androidx.work:work-runtime:2.11.1'
|
||||||
|
|
||||||
androidTestImplementation 'androidx.test:core:1.7.0'
|
androidTestImplementation 'androidx.test:core:1.7.0'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
|
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
|
||||||
androidTestImplementation 'androidx.test:rules:1.7.0'
|
androidTestImplementation 'androidx.test:rules:1.7.0'
|
||||||
androidTestImplementation 'androidx.test:runner:1.7.0'
|
androidTestImplementation 'androidx.test:runner:1.7.0'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
|
||||||
androidTestImplementation 'org.mockito:mockito-android:5.19.0'
|
androidTestImplementation 'org.mockito:mockito-android:5.21.0'
|
||||||
|
|
||||||
androidTestUtil 'androidx.test:orchestrator:1.6.1'
|
androidTestUtil 'androidx.test:orchestrator:1.6.1'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
v3.0.1: OpenTracks
|
||||||
|
|
||||||
|
Änderungen:
|
||||||
|
- Markierungen teilen
|
||||||
|
- Umstrukturierte Einstellungen
|
||||||
|
- Zurück-Schaltfläche in der Aktionsleiste entfernt
|
||||||
|
- Export: Option zur Einstellung der Fotogröße entfernt
|
||||||
|
- Export: KML als Format ist jetzt auswählbar
|
||||||
|
|
||||||
|
Fehlerbehebungen:
|
||||||
|
- Exportverzeichnis ist jetzt /OpenTracks/
|
||||||
|
- Querformatmodus stürzt nicht mehr ab
|
||||||
|
- KML/KMZ-Export behoben
|
||||||
|
|
||||||
|
Entwickler:
|
||||||
|
- Tests sind ausführbar (aber viele schlagen fehl)
|
||||||
|
- Kontinuierliche Integration mit TravisCI aktiviert (keine Tests)
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
v3.1.0: OpenTracks
|
||||||
|
|
||||||
|
Änderungen:
|
||||||
|
- Anzeige der Strecke in Karten-Apps hinzugefügt (getestet mit OsmAnd und Maps.ME)
|
||||||
|
- Während der Verfolgung werden Streckenstatistiken angezeigt, ohne das Gerät entsperren zu müssen
|
||||||
|
- Querformat für die Detailansicht der Strecke entfernt (war fehlerhaft)
|
||||||
|
- Verlauf der Suchvorschläge entfernt
|
||||||
|
|
||||||
|
Fehlerbehebung:
|
||||||
|
- Speicherberechtigung für „Alle importieren/Alle exportieren” anfordern
|
||||||
|
|
||||||
|
Entwickler:
|
||||||
|
- Upgrade auf Gradle 5.6
|
||||||
|
- Release-Builds nicht minimieren
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
v4.23.0: OpenTracks
|
||||||
|
|
||||||
|
Änderungen:
|
||||||
|
- Benutzeroberfläche: Durchschnittsgeschwindigkeit des aktuellen Segments hinzugefügt
|
||||||
|
(derzeit nur in neuen Layouts verfügbar)
|
||||||
|
- Durch Klicken auf die Benachrichtigung wird die eigentliche Aufzeichnungs-Benutzeroberfläche geöffnet
|
||||||
|
|
||||||
|
Entwickler:
|
||||||
|
- Veralteter JobIntentService durch WorkManager ersetzt
|
||||||
|
- Verwende .isEmpty() außer für CharSequence und Stream.toList()
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
v4.23.1: OpenTracks
|
||||||
|
|
||||||
|
Änderungen:
|
||||||
|
|
||||||
|
- Neue UI-Komponente zur Anzeige der verstrichenen Zeit im aktuellen Segment
|
||||||
|
|
||||||
|
Fehlerbehebung:
|
||||||
|
- Sofortiger Export nach Workout abgestürzt (eingeführt in v4.23.0)
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
v4.23.2: OpenTracks
|
||||||
|
|
||||||
|
Änderungen:
|
||||||
|
- Vorausschauende Rückwärtsfunktion funktioniert vollständig
|
||||||
|
|
||||||
|
Fehlerbehebung:
|
||||||
|
- Absturz im Zusammenhang mit dem Dateinamen der Strecke in den Einstellungen behoben
|
||||||
|
|
||||||
|
Entwickler:
|
||||||
|
- Datenklasse für Statistiken eingeführt
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
v4.23.2: OpenTracks
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
- Predictive back works completely
|
||||||
|
|
||||||
|
Bugfix:
|
||||||
|
- Fixed in crash related to the track filename in the settings
|
||||||
|
|
||||||
|
Developer:
|
||||||
|
- Introduced data class for Statistics
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
v4.24.0: OpenTracks
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
- PublicAPI: start track only sets field if data is present
|
||||||
|
- Marker photos can be shared again
|
||||||
|
- Removed KMZ without photos
|
||||||
|
- Heart rate of 0.0 is treated as invalid (except for SensorStatistics)
|
||||||
|
- Removed import workaround for special coordinates (100/200)
|
||||||
|
(was used by MyTracks to export/import special trackpoints)
|
||||||
|
|
||||||
|
Developer:
|
||||||
|
- Track and Marker are records
|
||||||
|
- AggregatedStatistics are computed in database
|
||||||
|
- Split into TrackStatisticsUpdater and SegmentStatisticUpdater
|
||||||
|
- Introduced Iterator classes (instead of passing Cursor or List)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
v4.24.1: OpenTracks
|
||||||
|
|
||||||
|
Bugfix:
|
||||||
|
- Restore compatibility with OSM Dashboard v6.4.1 and earlier (introduced in v4.24.0)
|
||||||
|
- Crash when using default track name by number (introduced in v4.24.0)
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
v4.24.2: OpenTracks
|
||||||
|
|
||||||
|
Bugfix:
|
||||||
|
- Crash when select all (introduced in v4.24.0)
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
v4.25.0: OpenTracks
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
- Record button is centered
|
||||||
|
- Support for BLE thermometer (Environmental Sensing)
|
||||||
|
|
||||||
|
Bugfix:
|
||||||
|
- On import: get type from filename (not URI)
|
||||||
|
|
||||||
|
Developer:
|
||||||
|
- TrackPoint is a record
|
||||||
|
- Update to Android Gradle Plugin 9.0
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
v4.25.1: OpenTracks
|
||||||
|
|
||||||
|
Bugfix:
|
||||||
|
- Since v4.24.0, the API for transferring data to OSM Dashboard was broken.
|
||||||
|
Sadly, the changes in OpenTracks could not be reverted.
|
||||||
|
Thus, the protocol version was bumped to 3.
|
||||||
|
This requires updating OSM Dashboard to a version AFTER v6.5.7.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
v4.25.2: OpenTracks
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
- Restored compatibility with OSMDashboard (Dashboard API protocol version 2)
|
||||||
|
|
||||||
|
Bugfix:
|
||||||
|
- Update UI immediately after resuming a track
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
v4.23.2: OpenTracks
|
||||||
|
|
||||||
|
Cambios:
|
||||||
|
- a volta predictiva funciona
|
||||||
|
|
||||||
|
Arranxo:
|
||||||
|
- do fallo que daba relacionado co nome do ficheiro nos axustes
|
||||||
|
|
||||||
|
Desenvolvemento:
|
||||||
|
- Engádese data class para as Estatísticas
|
||||||
@@ -4,7 +4,7 @@ Modifiche:
|
|||||||
- Velocità degli annunci vocali configurabile
|
- Velocità degli annunci vocali configurabile
|
||||||
- API <26: L'icona del lanciatore omette lo sfondo
|
- API <26: L'icona del lanciatore omette lo sfondo
|
||||||
|
|
||||||
Bugfix:
|
Correzioni:
|
||||||
- UI di registrazione: mostra i valori corretti
|
- UI di registrazione: mostra i valori corretti
|
||||||
- Registrazione UI: mostra (di nuovo) l'altitudine in EGM2008
|
- Registrazione UI: mostra (di nuovo) l'altitudine in EGM2008
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v4.22.1: OpenTracks
|
v4.22.1: OpenTracks
|
||||||
|
|
||||||
Modiciche:
|
Modifiche:
|
||||||
- Primo rilascio da Codeberg
|
- Primo rilascio da Codeberg
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v4.22.2: OpenTracks
|
v4.22.2: OpenTracks
|
||||||
|
|
||||||
Correzione di errori:
|
Correzioni:
|
||||||
- L'impostazione degli annunci vocali per l'ora e l'unità di misura è stata collegata
|
- L'impostazione degli annunci vocali per l'ora e l'unità di misura è stata collegata
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Modifiche:
|
Modifiche:
|
||||||
-
|
-
|
||||||
|
|
||||||
Correzioni di errori:
|
Correzioni:
|
||||||
-
|
-
|
||||||
|
|
||||||
Sviluppatore:
|
Sviluppatore:
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Un tracker sportivo che rispetta completamente la tua privacy.
|
Un tracker sportivo che rispetta la tua privacy.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
v3.0.0: Opentracks
|
v3.0.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
ஓபன்ட்ராக்சின் முதல் வெளியீடு (அதாவது, மைட்ராக்சிலிருந்து ஆர்ட் ஃபோர்க்)
|
திறந்தபாதைகளின் முதல் வெளியீடு (அதாவது, மைட்ராக்சிலிருந்து ஆர்ட் ஃபோர்க்)
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- மைட்ராக்சிலிருந்து ஓபன்ட்ராக்சுக்கு மறுபெயரிடப்பட்டது
|
- மைட்ராக்சிலிருந்து ஓபன்ட்ராக்சுக்கு மறுபெயரிடப்பட்டது
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.8.0: Opentracks
|
v3.8.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றத்தை உடைத்தல்:
|
மாற்றத்தை உடைத்தல்:
|
||||||
- சிபிஎக்ச் இறக்குமதி/ஏற்றுமதி விரைவு, கேடென்ச் மற்றும் ஆர்ட்ரேட் டிராக் பாயிண்ட் எக்ச்டென்சன்/வி 2 வழியாக
|
- சிபிஎக்ச் இறக்குமதி/ஏற்றுமதி விரைவு, கேடென்ச் மற்றும் ஆர்ட்ரேட் டிராக் பாயிண்ட் எக்ச்டென்சன்/வி 2 வழியாக
|
||||||
@@ -6,7 +6,7 @@ v3.8.0: Opentracks
|
|||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- டாச்போர்டு ஏபிஐ: குறிப்பான்களுக்கான அணுகலை வழங்குதல் (ஓபன்ட்ராக்சில் காண்பிக்க திரும்பப்பெறுதல்)
|
- டாச்போர்டு ஏபிஐ: குறிப்பான்களுக்கான அணுகலை வழங்குதல் (ஓபன்ட்ராக்சில் காண்பிக்க திரும்பப்பெறுதல்)
|
||||||
- புதிய மார்க்கர் படவுரு (ஆரஞ்சு புச் முள், எச்.வி.சி)
|
- புதிய மார்க்கர் படவுரு (ஆரஞ்சு புச் முள், எச்.வி.சி)
|
||||||
- இறக்குமதிக்கான கோப்புகளை கோப்பு மேலாளர் வழியாக தேர்ந்தெடுக்கலாம்
|
- இறக்குமதிக்கான கோப்புகளைக் கோப்பு மேலாளர் வழியாகத் தேர்ந்தெடுக்கலாம்
|
||||||
|
|
||||||
பிழைத்திருத்தங்கள்:
|
பிழைத்திருத்தங்கள்:
|
||||||
- ஒருங்கிணைந்த புள்ளிவிவரங்கள் இடைமுகம் விருப்பமான விகிதத்தை மதிக்கிறது
|
- ஒருங்கிணைந்த புள்ளிவிவரங்கள் இடைமுகம் விருப்பமான விகிதத்தை மதிக்கிறது
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.9.0: Opentracks
|
v3.9.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- தடங்களை அவற்றின் UUID உடன் ஏற்றுமதி செய்யுங்கள்
|
- தடங்களை அவற்றின் UUID உடன் ஏற்றுமதி செய்யுங்கள்
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.12.0: ஓபன்ட்ராக்ச்
|
v3.12.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- ஊடலை சென்சார் முகவரிகள்
|
- ஊடலை சென்சார் முகவரிகள்
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.15.0: ஓபன்ட்ராக்ச்
|
v3.15.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
எச்சரிக்கை:
|
எச்சரிக்கை:
|
||||||
இந்த வெளியீடு மாற்ற முடியாத தரவுத்தள மாற்றங்களைப் பயன்படுத்துகிறது.
|
இந்த வெளியீடு மாற்ற முடியாத தரவுத்தள மாற்றங்களைப் பயன்படுத்துகிறது.
|
||||||
@@ -14,7 +14,7 @@ v3.15.0: ஓபன்ட்ராக்ச்
|
|||||||
(தயவுசெய்து OSMDashboard 2.10.0 ஐ மேம்படுத்தவும்)
|
(தயவுசெய்து OSMDashboard 2.10.0 ஐ மேம்படுத்தவும்)
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- KML/KMZ சரியாக காப்புப் பிரதி எடுக்கவும் மீட்டமைக்கவும் பயன்படுத்தலாம் (புள்ளிவிவரங்கள் உட்பட)
|
- KML/KMZ சரியாகக் காப்புப் பிரதி எடுக்கவும் மீட்டமைக்கவும் பயன்படுத்தலாம் (புள்ளிவிவரங்கள் உட்பட)
|
||||||
|
|
||||||
டெவலப்பர்:
|
டெவலப்பர்:
|
||||||
- மறுவேலை செய்யப்பட்ட தட பிரிவு மற்றும் அது சேமிப்பு (முன்னர் இடைநிறுத்தம்/மீண்டும் மார்க்கர்)
|
- மறுவேலை செய்யப்பட்ட தட பிரிவு மற்றும் அது சேமிப்பு (முன்னர் இடைநிறுத்தம்/மீண்டும் மார்க்கர்)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.16.0: ஓபன்ட்ராக்ச்
|
v3.16.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- சைக்கிள் ஓட்டுதல்: பி.எல்.இ வேக சென்சாரிலிருந்து தூரத்தைப் பெறுங்கள்
|
- சைக்கிள் ஓட்டுதல்: பி.எல்.இ வேக சென்சாரிலிருந்து தூரத்தைப் பெறுங்கள்
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.17.0: Opentracks
|
v3.17.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- கயாக்கிங்கிற்கு ஐகானைச் சேர்க்கவும்
|
- கயாக்கிங்கிற்கு ஐகானைச் சேர்க்கவும்
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.18.0: ஓபன்ட்ராக்ச்
|
v3.18.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- உயரம் EGM2008 இல் காட்டப்பட்டுள்ளது (WGS84 எனச் சேமிக்கப்படுகிறது/ஏற்றுமதி செய்யப்படுகிறது)
|
- உயரம் EGM2008 இல் காட்டப்பட்டுள்ளது (WGS84 எனச் சேமிக்கப்படுகிறது/ஏற்றுமதி செய்யப்படுகிறது)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.18.3: ஓபன்ட்ராக்ச்
|
v3.18.3: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- KML பாகுபடுத்தலுக்கு/GX: KOURS இன் ஆர்டர் தேவையில்லை
|
- KML பாகுபடுத்தலுக்கு/GX: KOURS இன் ஆர்டர் தேவையில்லை
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.18.6: Opentracks
|
v3.18.6: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- "வரைபடத்தில் காட்டு"- KMZ க்கு பதிலாக KML வழியாகச் செயல்பாடு
|
- "வரைபடத்தில் காட்டு"- KMZ க்கு பதிலாக KML வழியாகச் செயல்பாடு
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.19.0: Opentracks
|
v3.19.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- இயங்கும் விரைவு மற்றும் கேடென்ச் (ஆர்.சி.எச்) சென்சார்களுக்கான உதவி செயல்படுத்தப்பட்டது
|
- இயங்கும் விரைவு மற்றும் கேடென்ச் (ஆர்.சி.எச்) சென்சார்களுக்கான உதவி செயல்படுத்தப்பட்டது
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.20.2: ஓபன்ட்ராக்ச்
|
v3.20.2: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- மிதவைகளுக்குப் பதிலாக உயரத்தை ஆதாயம் மற்றும் இழப்பு என்பது எண்கள்
|
- மிதவைகளுக்குப் பதிலாக உயரத்தை ஆதாயம் மற்றும் இழப்பு என்பது எண்கள்
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.21.0: Opentracks
|
v3.21.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- பதிவு செய்யும்போது: டிராக் பாயிண்டுகளின் செயலற்ற அல்லாத உருவாக்கத்தை அகற்று
|
- பதிவு செய்யும்போது: டிராக் பாயிண்டுகளின் செயலற்ற அல்லாத உருவாக்கத்தை அகற்று
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.24.0: Opentracks
|
v3.24.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- சி.பி.எச் விருப்பமானது (உட்புற பயன்பாட்டிற்கும்): தூரத்தை வழங்கும் பி.எல்.இ சென்சார்களைப் பயன்படுத்தினால் பயன்படுத்தப்பட்டால்
|
- சி.பி.எச் விருப்பமானது (உட்புற பயன்பாட்டிற்கும்): தூரத்தை வழங்கும் பி.எல்.இ சென்சார்களைப் பயன்படுத்தினால் பயன்படுத்தப்பட்டால்
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v3.24.1: Opentracks
|
v3.24.1: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- பிற பயன்பாடுகளிலிருந்து பதிவுகளைத் தொடங்க பநிஇ சேர்க்கப்பட்டது (இயல்பாக முடக்கப்பட்டுள்ளது)
|
- பிற பயன்பாடுகளிலிருந்து பதிவுகளைத் தொடங்க பநிஇ சேர்க்கப்பட்டது (இயல்பாக முடக்கப்பட்டுள்ளது)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
V3.27.0: Opentracks
|
V3.27.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- குரல் அன்னியூசென்ச்: 100 மீ, 200 மீ மற்றும் 500 மீ
|
- குரல் அன்னியூசென்ச்: 100 மீ, 200 மீ மற்றும் 500 மீ
|
||||||
- இடைவெளி: 100 மீ மற்றும் 500 மீ சேர்க்கவும்
|
- இடைவெளி: 100 மீ மற்றும் 500 மீ சேர்
|
||||||
- கடிகாரம் இப்போது விநாடிகளையும் காட்டுகிறது
|
- கடிகாரம் இப்போது விநாடிகளையும் காட்டுகிறது
|
||||||
- சி.பி.எக்ச், கே.எம்.எல், கே.எம்.இசட்: கிடைமட்ட துல்லியத்தை ஏற்றுமதி செய்து இறக்குமதி செய்க
|
- சி.பி.எக்ச், கே.எம்.எல், கே.எம்.இசட்: கிடைமட்ட துல்லியத்தை ஏற்றுமதி செய்து இறக்குமதி செய்க
|
||||||
- சி.பி.எக்ச்: கிளச்ட்ரச்ட் நீட்டிப்பு வழியாக ஒட்டுமொத்த தூரத்தை ஏற்றுமதி செய்யுங்கள்
|
- சி.பி.எக்ச்: கிளச்ட்ரச்ட் நீட்டிப்பு வழியாக ஒட்டுமொத்த தூரத்தை ஏற்றுமதி செய்யுங்கள்
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v4.0.0: Opentracks
|
v4.0.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- கீழ் பயன்பாட்டு பட்டியுடன் இடைமுகம் மறுசீரமைப்பு.
|
- கீழ் பயன்பாட்டு பட்டியுடன் இடைமுகம் மறுசீரமைப்பு.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
V4.0.1: Opentracks
|
V4.0.1: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- குரல் அறிவிப்புகள் இப்போது கட்டமைக்கப்படுகின்றன
|
- குரல் அறிவிப்புகள் இப்போது கட்டமைக்கப்படுகின்றன
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
V4.9.0: Opentracks
|
V4.9.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
குறிப்பு: மாற்றத்தை உடைத்தல்
|
குறிப்பு: மாற்றத்தை உடைத்தல்
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
V4.10.0: Opentracks
|
V4.10.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- BLE சுற்றுச்சூழல் உணர்திறன் (காற்றழுத்தமானி) வழியாக உதவி ஆதாயம்/இழப்பு
|
- BLE சுற்றுச்சூழல் உணர்திறன் (காற்றழுத்தமானி) வழியாக உதவி ஆதாயம்/இழப்பு
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
v4.13.0: ஓபன்ட்ராக்ச்
|
v4.13.0: திறந்தபாதைகள்
|
||||||
|
|
||||||
மாற்றங்கள்:
|
மாற்றங்கள்:
|
||||||
- பொது பநிஇ வழியாகக் குறிப்பான்களை உருவாக்க முடியும்
|
- பொது பநிஇ வழியாகக் குறிப்பான்களை உருவாக்க முடியும்
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
v4.22.0: OpenTracks
|
||||||
|
|
||||||
|
மாற்றங்கள்:
|
||||||
|
- https://codeberg.org/OpenTracksApp/OpenTracks க்கு இடம்பெயர்தல்
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
v4.22.1: OpenTracks
|
||||||
|
|
||||||
|
மாற்றங்கள்:
|
||||||
|
- கோட்பெர்க் வழியாக முதல் வெளியீடு
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
v4.22.2: திறந்தபாதைகள்
|
||||||
|
பிழைத்திருத்தம்:
|
||||||
|
- நேரம் மற்றும் அலகுக்கான குரல் அறிவிப்பு அமைப்பு இணைக்கப்பட்டது
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
v4.23.0: OpenTracks
|
||||||
|
|
||||||
|
மாற்றங்கள்:
|
||||||
|
- UI: தற்போதைய பிரிவின் சராசரி வேகத்தைச் சேர்த்தது
|
||||||
|
(தற்போது புதிய தளவமைப்புகளில் மட்டுமே கிடைக்கிறது)
|
||||||
|
- அறிவிப்பைக் சொடுக்கு செய்வதன் மூலம் உண்மையான பதிவு இடைமுகம் திறக்கும்
|
||||||
|
|
||||||
|
டெவலப்பர்:
|
||||||
|
- நிராகரிக்கப்பட்ட JobIntentService, WorkManager உடன் மாற்றப்பட்டது
|
||||||
|
- CharSequence மற்றும் Stream.toList() தவிர .isEmpty() ஐப் பயன்படுத்தவும்
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
v4.23.1: OpenTracks
|
||||||
|
|
||||||
|
மாற்றங்கள்:
|
||||||
|
- தற்போதைய பிரிவில் கழிந்த நேரத்தைக் காட்ட புதிய இடைமுகம் கூறு
|
||||||
|
|
||||||
|
பிழைத்திருத்தம்:
|
||||||
|
- உடற்பயிற்சிக்குப் பிந்தைய உடனடி ஏற்றுமதி செயலிழந்தது (v4.23.0 இல் அறிமுகப்படுத்தப்பட்டது)
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
v4.23.2: OpenTracks
|
||||||
|
|
||||||
|
மாற்றங்கள்:
|
||||||
|
- முன்கணிப்பு முற்றிலும் வேலை செய்கிறது
|
||||||
|
|
||||||
|
பிழைத்திருத்தம்:
|
||||||
|
- அமைப்புகளில் டிராக் கோப்புப் பெயருடன் தொடர்புடைய செயலிழப்பில் சரி செய்யப்பட்டது
|
||||||
|
|
||||||
|
டெவலப்பர்:
|
||||||
|
- புள்ளிவிவரங்களுக்கான தரவு வகுப்பு அறிமுகப்படுத்தப்பட்டது
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
v4.24.0: OpenTracks
|
||||||
|
|
||||||
|
மாற்றங்கள்:
|
||||||
|
- PublicAPI: தரவு இருந்தால் ஸ்டார்ட் டிராக் மட்டுமே புலத்தை அமைக்கும்
|
||||||
|
- மார்க்கர் புகைப்படங்களை மீண்டும் பகிரலாம்
|
||||||
|
- புகைப்படங்கள் இல்லாமல் KMZ அகற்றப்பட்டது
|
||||||
|
- இதயத் துடிப்பு 0.0 தவறானதாகக் கருதப்படுகிறது (சென்சார் ஸ்டாடிஸ்டிக்ஸ் தவிர)
|
||||||
|
- சிறப்பு ஒருங்கிணைப்புகளுக்கான இறக்குமதி தீர்வு நீக்கப்பட்டது (100/200)
|
||||||
|
(சிறப்பு டிராக் பாயிண்ட்களை ஏற்றுமதி/இறக்குமதி செய்ய MyTracks பயன்படுத்தியது)
|
||||||
|
|
||||||
|
டெவலப்பர்:
|
||||||
|
- ட்ராக் மற்றும் மார்க்கர் பதிவுகள்
|
||||||
|
- திரட்டப்பட்ட புள்ளிவிவரங்கள் தரவுத்தளத்தில் கணக்கிடப்படுகின்றன
|
||||||
|
- TrackStatisticsUpdater மற்றும் SegmentStatisticUpdater எனப் பிரிக்கவும்
|
||||||
|
- அறிமுகப்படுத்தப்பட்ட இட்டரேட்டர் வகுப்புகள் (கர்சர் அல்லது பட்டியலைக் கடந்து செல்வதற்குப் பதிலாக)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
v4.24.1: OpenTracks
|
||||||
|
|
||||||
|
பிழைத்திருத்தம்:
|
||||||
|
- OSM டாஷ்போர்டு v6.4.1 மற்றும் அதற்கு முந்தையவற்றுடன் இணக்கத்தன்மையை மீட்டெடுக்கவும் (v4.24.0 இல் அறிமுகப்படுத்தப்பட்டது)
|
||||||
|
- எண்ணின்படி இயல்புநிலை ட்ராக் பெயரைப் பயன்படுத்தும்போது செயலிழக்கிறது (v4.24.0 இல் அறிமுகப்படுத்தப்பட்டது)
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
v4.24.2: OpenTracks
|
||||||
|
|
||||||
|
பிழைத்திருத்தம்:
|
||||||
|
- அனைத்தையும் தேர்ந்தெடுக்கும்போது செயலிழக்க (v4.24.0 இல் அறிமுகப்படுத்தப்பட்டது)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
v4.25.0: OpenTracks
|
||||||
|
|
||||||
|
மாற்றங்கள்:
|
||||||
|
- பதிவுப் பொத்தான் மையமாக உள்ளது
|
||||||
|
- BLE தெர்மோமீட்டருக்கான ஆதரவு (சுற்றுச்சூழல் உணர்தல்)
|
||||||
|
|
||||||
|
பிழைத்திருத்தம்:
|
||||||
|
- இறக்குமதியில்: கோப்பு பெயரிலிருந்து வகையைப் பெறுங்கள் (URI அல்ல)
|
||||||
|
|
||||||
|
டெவலப்பர்:
|
||||||
|
- TrackPoint ஒரு பதிவு
|
||||||
|
- Android Gradle செருகுநிரல் 9.0 க்கு புதுப்பிக்கவும்
|
||||||
@@ -17,6 +17,6 @@
|
|||||||
* 深色和浅色主题,跟随系统设置。
|
* 深色和浅色主题,跟随系统设置。
|
||||||
* 无广告。
|
* 无广告。
|
||||||
|
|
||||||
自由软件/开放源代码
|
自由软件/开放源代码
|
||||||
意味着您可以使用、研究、修改和分享源代码。
|
意味着您可以使用、研究、修改和分享源代码。
|
||||||
采用 Apache 2.0 许可
|
采用 Apache 2.0 许可
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH="\\\"\\\""
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@@ -172,7 +171,6 @@ fi
|
|||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if "$cygwin" || "$msys" ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
@@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-2
@@ -70,11 +70,10 @@ goto fail
|
|||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||||
|
}
|
||||||
@@ -36,7 +36,8 @@ public class EspressoDeleteTrackTest {
|
|||||||
@Test
|
@Test
|
||||||
public void espressoDeleteTrackTest() {
|
public void espressoDeleteTrackTest() {
|
||||||
// TrackListActivity: start recording
|
// TrackListActivity: start recording
|
||||||
onView(withId(R.id.track_list_fab_action)).perform(click());
|
onView(withId(R.id.track_list_fab_action))
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
// TrackRecordingActivity
|
// TrackRecordingActivity
|
||||||
onView(withId(R.id.track_recording_fab_action))
|
onView(withId(R.id.track_recording_fab_action))
|
||||||
@@ -46,13 +47,14 @@ public class EspressoDeleteTrackTest {
|
|||||||
.perform(longClick());
|
.perform(longClick());
|
||||||
|
|
||||||
// TrackStoppedActivity
|
// TrackStoppedActivity
|
||||||
onView(withId(R.id.finish_button)).perform(click());
|
onView(withId(R.id.finish_button))
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
// select track
|
// select track
|
||||||
onView(allOf(withParent(withId(R.id.track_list)), withParentIndex(0))).perform(longClick());
|
onView(allOf(withParent(withId(R.id.track_list)), withParentIndex(0)))
|
||||||
|
.perform(longClick());
|
||||||
|
|
||||||
// open menu and delete selected track
|
// open menu and delete selected track
|
||||||
//TODO openActionBarOverflowOrOptionsMenu(); doesn't work
|
|
||||||
onView(
|
onView(
|
||||||
allOf(withContentDescription("More options"),
|
allOf(withContentDescription("More options"),
|
||||||
childAtPosition(
|
childAtPosition(
|
||||||
@@ -63,9 +65,11 @@ public class EspressoDeleteTrackTest {
|
|||||||
isDisplayed()))
|
isDisplayed()))
|
||||||
.perform(click());
|
.perform(click());
|
||||||
|
|
||||||
onView(withText("Delete")).perform(click());
|
onView(withText("Delete"))
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
onView(withText("OK")).perform(click());
|
onView(withText("OK"))
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
// tracklist is empty now
|
// tracklist is empty now
|
||||||
onView(allOf(withText("Start recording your next adventure here"), isDisplayed()));
|
onView(allOf(withText("Start recording your next adventure here"), isDisplayed()));
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
|||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
import static de.dennisguse.opentracks.util.EspressoUtils.waitFor;
|
import static de.dennisguse.opentracks.util.EspressoUtils.waitFor;
|
||||||
|
|
||||||
import androidx.test.espresso.ViewInteraction;
|
|
||||||
import androidx.test.ext.junit.rules.ActivityScenarioRule;
|
import androidx.test.ext.junit.rules.ActivityScenarioRule;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import androidx.test.filters.LargeTest;
|
import androidx.test.filters.LargeTest;
|
||||||
@@ -45,41 +44,43 @@ public class EspressoEditTrackRecordingTest {
|
|||||||
public void espressoEditTrackRecordingTest() {
|
public void espressoEditTrackRecordingTest() {
|
||||||
{
|
{
|
||||||
// TrackListActivity: start recording
|
// TrackListActivity: start recording
|
||||||
ViewInteraction fabRecordButton = onView(withId(R.id.track_list_fab_action));
|
onView(withId(R.id.track_list_fab_action))
|
||||||
fabRecordButton.perform(click());
|
.perform(click());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// TrackRecordingActivity
|
// TrackRecordingActivity
|
||||||
ViewInteraction trackControllerStopButton = onView(withId(R.id.track_recording_fab_action));
|
|
||||||
|
|
||||||
// wait; stay recording
|
// wait; stay recording
|
||||||
trackControllerStopButton.perform(waitFor(4000));
|
onView(withId(R.id.track_recording_fab_action))
|
||||||
|
.perform(waitFor(4000));
|
||||||
|
|
||||||
// open menu
|
// open menu
|
||||||
openContextualActionModeOverflowMenu();
|
openContextualActionModeOverflowMenu();
|
||||||
|
|
||||||
// Click the item.
|
// Click the item.
|
||||||
onView(withText(R.string.menu_edit)).perform(click());
|
onView(withText(R.string.menu_edit))
|
||||||
|
.perform(click());
|
||||||
|
|
||||||
// change name for "New Name"
|
// change name for "New Name"
|
||||||
ViewInteraction textInputEditText = onView(withId(R.id.track_edit_name));
|
onView(withId(R.id.track_edit_name))
|
||||||
textInputEditText.perform(scrollTo(), replaceText("New Name"));
|
.perform(scrollTo(), replaceText("New Name"));
|
||||||
|
|
||||||
ViewInteraction textInputEditText2 = onView(allOf(withId(R.id.track_edit_name), withText("New Name"), isDisplayed()));
|
onView(allOf(withId(R.id.track_edit_name), withText("New Name"), isDisplayed()))
|
||||||
textInputEditText2.perform(closeSoftKeyboard());
|
.perform(closeSoftKeyboard());
|
||||||
|
|
||||||
// save edition
|
// save edition
|
||||||
ViewInteraction appCompatButton = onView(withId(R.id.track_edit_save));
|
onView(withId(R.id.track_edit_save))
|
||||||
appCompatButton.perform(click());
|
.perform(click());
|
||||||
|
|
||||||
// stop;
|
// stop;
|
||||||
trackControllerStopButton.perform(longClick());
|
onView(withId(R.id.track_recording_fab_action))
|
||||||
|
.perform(longClick());
|
||||||
|
|
||||||
// it's on track stopped activity and there are two buttons
|
// it's on track stopped activity and there are two buttons
|
||||||
ViewInteraction resumeButton = onView(withId(R.id.resume_button));
|
onView(withId(R.id.resume_button))
|
||||||
resumeButton.check(matches(isDisplayed()));
|
.check(matches(isDisplayed()));
|
||||||
ViewInteraction finishButton = onView(withId(R.id.finish_button));
|
onView(withId(R.id.finish_button))
|
||||||
finishButton.check(matches(isDisplayed()));
|
.check(matches(isDisplayed()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ public class EspressoUITest {
|
|||||||
public void record_stop_resume_stop_finish() {
|
public void record_stop_resume_stop_finish() {
|
||||||
{
|
{
|
||||||
// TrackListActivity: start recording
|
// TrackListActivity: start recording
|
||||||
ViewInteraction trackControllerRecordButton = onView(withId(R.id.track_list_fab_action));
|
onView(withId(R.id.track_list_fab_action))
|
||||||
trackControllerRecordButton.perform(click());
|
.perform(click());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// TrackRecordingActivity: wait to record some time and then stop
|
// TrackRecordingActivity: wait to record some time and then stop
|
||||||
@@ -66,13 +66,12 @@ public class EspressoUITest {
|
|||||||
public void record_move_through_tabs() {
|
public void record_move_through_tabs() {
|
||||||
{
|
{
|
||||||
// TrackListActivity: start recording
|
// TrackListActivity: start recording
|
||||||
ViewInteraction trackControllerRecordButton = onView(withId(R.id.track_list_fab_action));
|
onView(withId(R.id.track_list_fab_action))
|
||||||
trackControllerRecordButton.perform(click());
|
.perform(click());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// TrackRecordingActivity
|
// TrackRecordingActivity
|
||||||
ViewInteraction tabLayout = onView(withId(R.id.track_detail_activity_tablayout));
|
ViewInteraction tabLayout = onView(withId(R.id.track_detail_activity_tablayout));
|
||||||
ViewInteraction trackControllerStopButton = onView(withId(R.id.track_recording_fab_action));
|
|
||||||
|
|
||||||
tabLayout.perform(selectTabAtIndex(1));
|
tabLayout.perform(selectTabAtIndex(1));
|
||||||
tabLayout.perform(waitFor(1000));
|
tabLayout.perform(waitFor(1000));
|
||||||
@@ -87,7 +86,8 @@ public class EspressoUITest {
|
|||||||
tabLayout.perform(waitFor(1000));
|
tabLayout.perform(waitFor(1000));
|
||||||
|
|
||||||
// stop
|
// stop
|
||||||
trackControllerStopButton.perform(longClick());
|
onView(withId(R.id.track_recording_fab_action)).
|
||||||
|
perform(longClick());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
package de.dennisguse.opentracks.chart;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Altitude;
|
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
|
||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
|
||||||
import de.dennisguse.opentracks.settings.UnitSystem;
|
|
||||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class ChartPointTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void create_by_time() {
|
|
||||||
// given
|
|
||||||
TrackStatistics statistics = new TrackStatistics();
|
|
||||||
statistics.setTotalTime(Duration.ofSeconds(1000));
|
|
||||||
|
|
||||||
// when
|
|
||||||
ChartPoint point = ChartPoint.create(statistics, TrackStubUtils.createDefaultTrackPoint(), Speed.of(0), false, UnitSystem.IMPERIAL_FEET);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertEquals(1000000, (long) point.timeOrDistance());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void create_by_distance() {
|
|
||||||
// given
|
|
||||||
TrackStatistics statistics = new TrackStatistics();
|
|
||||||
statistics.setTotalDistance(Distance.of(1000));
|
|
||||||
|
|
||||||
// when
|
|
||||||
ChartPoint point = ChartPoint.create(statistics, TrackStubUtils.createDefaultTrackPoint(), Speed.of(0), true, UnitSystem.METRIC);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertEquals(1, (long) point.timeOrDistance());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void create_get_altitude_speed_and_pace() {
|
|
||||||
// given
|
|
||||||
TrackStatistics statistics = new TrackStatistics();
|
|
||||||
TrackPoint trackPoint = TrackStubUtils.createDefaultTrackPoint()
|
|
||||||
.setAltitude(Altitude.EGM2008.of(50));
|
|
||||||
|
|
||||||
// when
|
|
||||||
ChartPoint point = ChartPoint.create(statistics, trackPoint, Speed.of(10), false, UnitSystem.METRIC);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertEquals(50, point.altitude(), 0.01);
|
|
||||||
assertEquals(36, point.speed(), 0.01);
|
|
||||||
assertEquals(1.66, point.pace(), 0.01);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void create_sensorNotAvailable() {
|
|
||||||
// given
|
|
||||||
TrackStatistics statistics = new TrackStatistics();
|
|
||||||
TrackPoint trackPoint = TrackStubUtils.createDefaultTrackPoint()
|
|
||||||
.setAltitude(Altitude.EGM2008.of(50));
|
|
||||||
// when
|
|
||||||
ChartPoint point = ChartPoint.create(statistics, trackPoint, Speed.of(10), false, UnitSystem.METRIC);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertNull(point.heartRate());
|
|
||||||
assertNull(point.cadence());
|
|
||||||
assertNull(point.power());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void create_sensorAvailable() {
|
|
||||||
// given
|
|
||||||
TrackPoint trackPoint = TrackStubUtils.createDefaultTrackPoint()
|
|
||||||
.setAltitude(Altitude.EGM2008.of(50))
|
|
||||||
.setHeartRate(100f)
|
|
||||||
.setCadence(101f)
|
|
||||||
.setPower(102f);
|
|
||||||
|
|
||||||
TrackStatistics statistics = new TrackStatistics();
|
|
||||||
|
|
||||||
// when
|
|
||||||
ChartPoint point = ChartPoint.create(statistics, trackPoint, Speed.of(10), false, UnitSystem.METRIC);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertEquals(100.0, point.heartRate(), 0.01);
|
|
||||||
assertEquals(101.0, point.cadence(), 0.01);
|
|
||||||
assertEquals(102.0, point.power(), 0.01);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012 Google Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
||||||
* use this file except in compliance with the License. You may obtain a copy of
|
|
||||||
* the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations under
|
|
||||||
* the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.dennisguse.opentracks.chart;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Altitude;
|
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
|
||||||
import de.dennisguse.opentracks.data.models.Position;
|
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
|
||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Commons utilities for creating stubs of track, location.
|
|
||||||
*
|
|
||||||
* @author Youtao Liu
|
|
||||||
*/
|
|
||||||
//TODO Move to ChartPointTest
|
|
||||||
class TrackStubUtils {
|
|
||||||
|
|
||||||
public static final double INITIAL_ALTITUDE = 22;
|
|
||||||
public static final long INITIAL_TIME = 1000L;
|
|
||||||
private static final double INITIAL_LATITUDE = 22;
|
|
||||||
private static final double INITIAL_LONGITUDE = 22;
|
|
||||||
private static final Distance INITIAL_ACCURACY = Distance.of(5);
|
|
||||||
private static final Speed INITIAL_SPEED = Speed.of(10);
|
|
||||||
private static final float INITIAL_BEARING = 3.0f;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a MyTracks location with default values.
|
|
||||||
*
|
|
||||||
* @return a track stub.
|
|
||||||
*/
|
|
||||||
public static TrackPoint createDefaultTrackPoint() {
|
|
||||||
return createDefaultTrackPoint(INITIAL_LATITUDE, INITIAL_LONGITUDE, INITIAL_ALTITUDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a {@link TrackPoint} stub with specified values.
|
|
||||||
*
|
|
||||||
* @return a SensorDataSetLocation stub.
|
|
||||||
*/
|
|
||||||
private static TrackPoint createDefaultTrackPoint(double latitude, double longitude, double altitude) {
|
|
||||||
return new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
|
||||||
new Position(
|
|
||||||
Instant.ofEpochMilli(INITIAL_TIME),
|
|
||||||
latitude,
|
|
||||||
longitude,
|
|
||||||
INITIAL_ACCURACY,
|
|
||||||
Altitude.WGS84.of(altitude),
|
|
||||||
INITIAL_ACCURACY,
|
|
||||||
INITIAL_BEARING,
|
|
||||||
INITIAL_SPEED
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,22 +6,28 @@ import android.util.Pair;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
||||||
|
import de.dennisguse.opentracks.data.MarkerIterator;
|
||||||
import de.dennisguse.opentracks.data.TrackPointIterator;
|
import de.dennisguse.opentracks.data.TrackPointIterator;
|
||||||
|
import de.dennisguse.opentracks.data.models.ActivityType;
|
||||||
import de.dennisguse.opentracks.data.models.Altitude;
|
import de.dennisguse.opentracks.data.models.Altitude;
|
||||||
|
import de.dennisguse.opentracks.data.models.AltitudeGainLoss;
|
||||||
|
import de.dennisguse.opentracks.data.models.Cadence;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
|
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||||
import de.dennisguse.opentracks.data.models.Marker;
|
import de.dennisguse.opentracks.data.models.Marker;
|
||||||
import de.dennisguse.opentracks.data.models.Position;
|
import de.dennisguse.opentracks.data.models.Position;
|
||||||
|
import de.dennisguse.opentracks.data.models.Power;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
|
import de.dennisguse.opentracks.data.models.Statistics;
|
||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
|
||||||
import de.dennisguse.opentracks.stats.TrackStatisticsUpdater;
|
|
||||||
import de.dennisguse.opentracks.ui.markers.MarkerUtils;
|
import de.dennisguse.opentracks.ui.markers.MarkerUtils;
|
||||||
import de.dennisguse.opentracks.util.FileUtils;
|
import de.dennisguse.opentracks.util.FileUtils;
|
||||||
|
|
||||||
@@ -37,11 +43,15 @@ public class TestDataUtil {
|
|||||||
* Create a track without any trackPoints.
|
* Create a track without any trackPoints.
|
||||||
*/
|
*/
|
||||||
public static Track createTrack(Track.Id trackId) {
|
public static Track createTrack(Track.Id trackId) {
|
||||||
Track track = new Track();
|
return new Track(
|
||||||
track.setId(trackId);
|
trackId,
|
||||||
track.setName("Test: " + trackId.id());
|
UUID.randomUUID(),
|
||||||
|
"Test: " + trackId.id(),
|
||||||
return track;
|
"",
|
||||||
|
"",
|
||||||
|
ActivityType.UNKNOWN,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
Statistics.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,14 +95,10 @@ public class TestDataUtil {
|
|||||||
createTrackPoint(i, TrackPoint.Type.SEGMENT_END_MANUAL)
|
createTrackPoint(i, TrackPoint.Type.SEGMENT_END_MANUAL)
|
||||||
);
|
);
|
||||||
|
|
||||||
//TODO Use TrackStatisticsUpdater
|
|
||||||
TrackStatistics stats = new TrackStatistics();
|
|
||||||
stats.setTotalDistance(Distance.of(0));
|
|
||||||
stats.setTotalTime(Duration.ofMillis(0));
|
|
||||||
List<Marker> markers = List.of(
|
List<Marker> markers = List.of(
|
||||||
new Marker(trackId, trackPoints.get(1), "Marker 1", "Marker description 1", "Marker category 3", "", null),
|
new Marker(null, trackId, "Marker 1", "Marker description 1", "Marker typeLocalized 3", trackPoints.get(1).position(), null),
|
||||||
new Marker(trackId, trackPoints.get(4), "Marker 2", "Marker description 2", "Marker category 3", "", null),
|
new Marker(null, trackId, "Marker 2", "Marker description 2", "Marker typeLocalized 3", trackPoints.get(4).position(), null),
|
||||||
new Marker(trackId, trackPoints.get(5), "Marker 3", "Marker description 3", "Marker category 3", "", null)
|
new Marker(null, trackId, "Marker 3", "Marker description 3", "Marker typeLocalized 3", trackPoints.get(5).position(), null)
|
||||||
);
|
);
|
||||||
|
|
||||||
return new TrackData(track, trackPoints, markers);
|
return new TrackData(track, trackPoints, markers);
|
||||||
@@ -110,8 +116,10 @@ public class TestDataUtil {
|
|||||||
return pair.first;
|
return pair.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TrackPoint createTrackPoint(int i) {
|
public static TrackPoint createTrackPoint(int i, TrackPoint.Type type, AltitudeGainLoss altitudeGainLoss) {
|
||||||
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
return new TrackPoint(
|
||||||
|
null,
|
||||||
|
type,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.ofEpochSecond(i),
|
Instant.ofEpochSecond(i),
|
||||||
INITIAL_LATITUDE + (double) i / 10000.0,
|
INITIAL_LATITUDE + (double) i / 10000.0,
|
||||||
@@ -121,22 +129,25 @@ public class TestDataUtil {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
Speed.of(5f + (i / 10f))
|
Speed.of(5f + (i / 10f))
|
||||||
));
|
),
|
||||||
|
null,
|
||||||
trackPoint.setHeartRate(100f + i % 80);
|
HeartRate.of(100f + i % 80),
|
||||||
trackPoint.setCadence(300f + i);
|
null,
|
||||||
trackPoint.setPower(400f + i);
|
Cadence.of(300f + i),
|
||||||
trackPoint.setAltitudeGain(ALTITUDE_GAIN);
|
Power.of(400f + i),
|
||||||
trackPoint.setAltitudeLoss(ALTITUDE_LOSS);
|
altitudeGainLoss
|
||||||
return trackPoint;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TrackPoint createTrackPoint(int i, TrackPoint.Type type) {
|
public static TrackPoint createTrackPoint(int i, TrackPoint.Type type) {
|
||||||
TrackPoint trackPoint = createTrackPoint(i);
|
return createTrackPoint(i, TrackPoint.Type.TRACKPOINT, new AltitudeGainLoss(ALTITUDE_GAIN, ALTITUDE_LOSS));
|
||||||
trackPoint.setType(type);
|
|
||||||
return trackPoint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TrackPoint createTrackPoint(int i) {
|
||||||
|
return createTrackPoint(i, TrackPoint.Type.TRACKPOINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a track with locations into the database.
|
* Inserts a track with locations into the database.
|
||||||
*
|
*
|
||||||
@@ -145,45 +156,41 @@ public class TestDataUtil {
|
|||||||
*/
|
*/
|
||||||
public static void insertTrackWithLocations(ContentProviderUtils contentProviderUtils, Track track, List<TrackPoint> trackPoints) {
|
public static void insertTrackWithLocations(ContentProviderUtils contentProviderUtils, Track track, List<TrackPoint> trackPoints) {
|
||||||
contentProviderUtils.insertTrack(track);
|
contentProviderUtils.insertTrack(track);
|
||||||
contentProviderUtils.bulkInsertTrackPoint(trackPoints, track.getId());
|
contentProviderUtils.bulkInsertTrackPoint(trackPoints, track.id());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Marker createMarkerWithPhoto(Context context, Track.Id trackId, TrackPoint trackPoint) throws IOException {
|
public static Marker createMarkerWithPhoto(Context context, Track.Id trackId, TrackPoint trackPoint) throws IOException {
|
||||||
|
return createMarkerWithPhoto(context, trackId, trackPoint, "Marker description");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Marker createMarkerWithPhoto(Context context, Track.Id trackId, TrackPoint trackPoint, String description) throws IOException {
|
||||||
File dstFile = new File(MarkerUtils.getImageUrl(context, trackId));
|
File dstFile = new File(MarkerUtils.getImageUrl(context, trackId));
|
||||||
dstFile.createNewFile();
|
dstFile.createNewFile();
|
||||||
Uri photoUri = FileUtils.getUriForFile(context, dstFile);
|
Uri photoUri = FileUtils.getUriForFile(context, dstFile);
|
||||||
|
|
||||||
//TODO Use TrackStatisticsUpdater
|
return new Marker(
|
||||||
TrackStatistics stats = new TrackStatistics();
|
null,
|
||||||
stats.setTotalDistance(Distance.of(0));
|
trackId,
|
||||||
stats.setTotalTime(Duration.ofMillis(0));
|
"Marker name",
|
||||||
|
description,
|
||||||
return new Marker(trackId, trackPoint, "Marker name", "Marker description", "Marker category", "", photoUri);
|
"Marker typeLocalized",
|
||||||
|
trackPoint.position(),
|
||||||
|
photoUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<TrackPoint> getTrackPoints(ContentProviderUtils contentProviderUtils, Track.Id trackId) {
|
public static List<TrackPoint> getTrackPoints(ContentProviderUtils contentProviderUtils, Track.Id trackId) {
|
||||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointIterator(trackId, null)) {
|
||||||
ArrayList<TrackPoint> trackPoints = new ArrayList<>();
|
ArrayList<TrackPoint> trackPoints = new ArrayList<>();
|
||||||
while (trackPointIterator.hasNext()) {
|
trackPointIterator.forEachRemaining(trackPoints::add);
|
||||||
trackPoints.add(trackPointIterator.next());
|
|
||||||
}
|
|
||||||
return trackPoints;
|
return trackPoints;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Pair<Track.Id, TrackStatistics> buildTrackWithTrackPoints(ContentProviderUtils contentProviderUtils, int numberOfPoints) {
|
public static List<Marker> getMarkers(ContentProviderUtils contentProviderUtils, Track.Id trackId) {
|
||||||
Track dummyTrack = new Track();
|
try (MarkerIterator trackPointIterator = contentProviderUtils.getMarkerIterator(trackId)) {
|
||||||
dummyTrack.setId(new Track.Id(System.currentTimeMillis()));
|
ArrayList<Marker> markers = new ArrayList<>();
|
||||||
dummyTrack.setName("Dummy Track");
|
trackPointIterator.forEachRemaining(markers::add);
|
||||||
contentProviderUtils.insertTrack(dummyTrack);
|
return markers;
|
||||||
TrackStatisticsUpdater trackStatisticsUpdater = new TrackStatisticsUpdater();
|
|
||||||
for (int i = 0; i < numberOfPoints; i++) {
|
|
||||||
TrackPoint tp = TestDataUtil.createTrackPoint(i);
|
|
||||||
contentProviderUtils.insertTrackPoint(tp, dummyTrack.getId());
|
|
||||||
trackStatisticsUpdater.addTrackPoint(tp);
|
|
||||||
}
|
}
|
||||||
dummyTrack.setTrackStatistics(trackStatisticsUpdater.getTrackStatistics());
|
|
||||||
contentProviderUtils.updateTrack(dummyTrack);
|
|
||||||
return new Pair<>(dummyTrack.getId(), trackStatisticsUpdater.getTrackStatistics());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-13
@@ -6,8 +6,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Altitude;
|
import de.dennisguse.opentracks.data.models.Altitude;
|
||||||
|
import de.dennisguse.opentracks.data.models.AltitudeGainLoss;
|
||||||
|
import de.dennisguse.opentracks.data.models.Cadence;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
|
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||||
import de.dennisguse.opentracks.data.models.Position;
|
import de.dennisguse.opentracks.data.models.Position;
|
||||||
|
import de.dennisguse.opentracks.data.models.Power;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||||
|
|
||||||
@@ -20,7 +24,9 @@ public class TestSensorDataUtil {
|
|||||||
sensorDataList.add(new TestSensorDataUtil.SensorData(time, hr, cadence, power, type));
|
sensorDataList.add(new TestSensorDataUtil.SensorData(time, hr, cadence, power, type));
|
||||||
int i = trackPointList.size() + 1;
|
int i = trackPointList.size() + 1;
|
||||||
|
|
||||||
TrackPoint tp = new TrackPoint(type,
|
TrackPoint tp = new TrackPoint(
|
||||||
|
null,
|
||||||
|
type,
|
||||||
new Position(
|
new Position(
|
||||||
time,
|
time,
|
||||||
TestDataUtil.INITIAL_LATITUDE + (double) i / 10000.0,
|
TestDataUtil.INITIAL_LATITUDE + (double) i / 10000.0,
|
||||||
@@ -30,19 +36,15 @@ public class TestSensorDataUtil {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
Speed.of(5f + (i / 10f))
|
Speed.of(5f + (i / 10f))
|
||||||
)
|
),
|
||||||
|
null,
|
||||||
|
HeartRate.ofOrNull(hr),
|
||||||
|
null,
|
||||||
|
cadence != null ? Cadence.of(cadence) : null,
|
||||||
|
power != null ? Power.of(power) : null,
|
||||||
|
new AltitudeGainLoss(3, 3)
|
||||||
);
|
);
|
||||||
if (hr != null) {
|
|
||||||
tp.setHeartRate(hr);
|
|
||||||
}
|
|
||||||
if (cadence != null) {
|
|
||||||
tp.setCadence(cadence);
|
|
||||||
}
|
|
||||||
if (power != null) {
|
|
||||||
tp.setPower(power);
|
|
||||||
}
|
|
||||||
tp.setAltitudeGain(3f);
|
|
||||||
tp.setAltitudeLoss(3f);
|
|
||||||
trackPointList.add(tp);
|
trackPointList.add(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012 Google Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
||||||
* use this file except in compliance with the License. You may obtain a copy of
|
|
||||||
* the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations under
|
|
||||||
* the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.dennisguse.opentracks.data;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import android.content.ContentUris;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.Uri;
|
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.tables.MarkerColumns;
|
|
||||||
import de.dennisguse.opentracks.data.tables.TrackPointsColumns;
|
|
||||||
import de.dennisguse.opentracks.data.tables.TracksColumns;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests {@link CustomContentProvider}.
|
|
||||||
*
|
|
||||||
* @author Youtao Liu
|
|
||||||
*/
|
|
||||||
public class CustomContentProviderTest {
|
|
||||||
|
|
||||||
private CustomContentProvider customContentProvider;
|
|
||||||
private final Context context = ApplicationProvider.getApplicationContext();
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
customContentProvider = new CustomContentProvider() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests {@link CustomContentProvider#onCreate(android.content.Context)}.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testOnCreate() {
|
|
||||||
assertTrue(customContentProvider.onCreate(context));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests {@link CustomContentProvider#getType(Uri)}.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testGetType() {
|
|
||||||
assertEquals(TracksColumns.CONTENT_TYPE, customContentProvider.getType(TracksColumns.CONTENT_URI));
|
|
||||||
assertEquals(TracksColumns.CONTENT_ITEMTYPE, customContentProvider.getType(ContentUris.appendId(TracksColumns.CONTENT_URI.buildUpon(), 1).build()));
|
|
||||||
|
|
||||||
assertEquals(TrackPointsColumns.CONTENT_TYPE, customContentProvider.getType(TrackPointsColumns.CONTENT_URI_BY_ID));
|
|
||||||
assertEquals(TrackPointsColumns.CONTENT_ITEMTYPE, customContentProvider.getType(ContentUris.appendId(TrackPointsColumns.CONTENT_URI_BY_TRACKID.buildUpon(), 1).build()));
|
|
||||||
|
|
||||||
assertEquals(MarkerColumns.CONTENT_TYPE, customContentProvider.getType(MarkerColumns.CONTENT_URI));
|
|
||||||
assertEquals(MarkerColumns.CONTENT_ITEMTYPE, customContentProvider.getType(ContentUris.appendId(MarkerColumns.CONTENT_URI.buildUpon(), 1).build()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+231
-211
@@ -27,7 +27,6 @@ import android.content.ContentUris;
|
|||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.location.Location;
|
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
@@ -42,6 +41,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -50,19 +50,26 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.content.data.TestDataUtil;
|
import de.dennisguse.opentracks.content.data.TestDataUtil;
|
||||||
import de.dennisguse.opentracks.content.data.TestSensorDataUtil;
|
import de.dennisguse.opentracks.content.data.TestSensorDataUtil;
|
||||||
|
import de.dennisguse.opentracks.data.models.ActivityType;
|
||||||
import de.dennisguse.opentracks.data.models.Altitude;
|
import de.dennisguse.opentracks.data.models.Altitude;
|
||||||
|
import de.dennisguse.opentracks.data.models.AltitudeExtremities;
|
||||||
|
import de.dennisguse.opentracks.data.models.AltitudeGainLoss;
|
||||||
|
import de.dennisguse.opentracks.data.models.Cadence;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
import de.dennisguse.opentracks.data.models.HeartRate;
|
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||||
import de.dennisguse.opentracks.data.models.Marker;
|
import de.dennisguse.opentracks.data.models.Marker;
|
||||||
|
import de.dennisguse.opentracks.data.models.MarkerBuilder;
|
||||||
import de.dennisguse.opentracks.data.models.Position;
|
import de.dennisguse.opentracks.data.models.Position;
|
||||||
|
import de.dennisguse.opentracks.data.models.Power;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
|
import de.dennisguse.opentracks.data.models.Statistics;
|
||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
|
import de.dennisguse.opentracks.data.models.TrackBuilder;
|
||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||||
|
import de.dennisguse.opentracks.data.statistics.SensorStatistics;
|
||||||
import de.dennisguse.opentracks.data.tables.MarkerColumns;
|
import de.dennisguse.opentracks.data.tables.MarkerColumns;
|
||||||
import de.dennisguse.opentracks.data.tables.TrackPointsColumns;
|
import de.dennisguse.opentracks.data.tables.TrackPointsColumns;
|
||||||
import de.dennisguse.opentracks.data.tables.TracksColumns;
|
import de.dennisguse.opentracks.data.tables.TracksColumns;
|
||||||
import de.dennisguse.opentracks.stats.SensorStatistics;
|
|
||||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
|
||||||
import de.dennisguse.opentracks.util.FileUtils;
|
import de.dennisguse.opentracks.util.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,24 +121,32 @@ public class CustomContentProviderUtilsTest {
|
|||||||
private void testIterator(Track.Id trackId, int numPoints) {
|
private void testIterator(Track.Id trackId, int numPoints) {
|
||||||
TrackPoint.Id lastPointId = initializeTrack(trackId, numPoints);
|
TrackPoint.Id lastPointId = initializeTrack(trackId, numPoints);
|
||||||
List<TrackPoint> locations = new ArrayList<>(numPoints);
|
List<TrackPoint> locations = new ArrayList<>(numPoints);
|
||||||
try (TrackPointIterator it = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
try (TrackPointIterator it = contentProviderUtils.getTrackPointIterator(trackId, null)) {
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
TrackPoint trackPoint = it.next();
|
TrackPoint trackPoint = it.next();
|
||||||
assertNotNull(trackPoint);
|
assertNotNull(trackPoint);
|
||||||
locations.add(trackPoint);
|
locations.add(trackPoint);
|
||||||
// Make sure the IDs are returned in the right order.
|
// Make sure the IDs are returned in the right order.
|
||||||
assertEquals(lastPointId.id() - numPoints + locations.size(), trackPoint.getId().id());
|
assertEquals(lastPointId.id() - numPoints + locations.size(), trackPoint.id().id());
|
||||||
}
|
}
|
||||||
assertEquals(numPoints, locations.size());
|
assertEquals(numPoints, locations.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TrackPoint.Id initializeTrack(Track.Id id, int numPoints) {
|
private TrackPoint.Id initializeTrack(Track.Id id, int numPoints) {
|
||||||
Track track = new Track();
|
Track createdTrack = new Track(
|
||||||
track.setId(id);
|
id,
|
||||||
track.setName("Test: " + id.id());
|
UUID.randomUUID(),
|
||||||
contentProviderUtils.insertTrack(track);
|
"Test: " + id,
|
||||||
track = contentProviderUtils.getTrack(id);
|
"",
|
||||||
|
"",
|
||||||
|
ActivityType.UNKNOWN,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
Statistics.DEFAULT);
|
||||||
|
|
||||||
|
contentProviderUtils.insertTrack(createdTrack);
|
||||||
|
|
||||||
|
Track track = contentProviderUtils.getTrack(id);
|
||||||
assertNotNull(track);
|
assertNotNull(track);
|
||||||
|
|
||||||
List<TrackPoint> trackPoints = new ArrayList<>(numPoints);
|
List<TrackPoint> trackPoints = new ArrayList<>(numPoints);
|
||||||
@@ -152,10 +167,10 @@ public class CustomContentProviderUtilsTest {
|
|||||||
// Load all inserted trackPoints.
|
// Load all inserted trackPoints.
|
||||||
TrackPoint.Id lastPointId = null;
|
TrackPoint.Id lastPointId = null;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
try (TrackPointIterator it = contentProviderUtils.getTrackPointLocationIterator(id, null)) {
|
try (TrackPointIterator it = contentProviderUtils.getTrackPointIterator(id, null)) {
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
TrackPoint trackPoint = it.next();
|
TrackPoint trackPoint = it.next();
|
||||||
lastPointId = trackPoint.getId();
|
lastPointId = trackPoint.id();
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,8 +208,8 @@ public class CustomContentProviderUtilsTest {
|
|||||||
when(cursorMock.getString(columnIndex)).thenReturn(name);
|
when(cursorMock.getString(columnIndex)).thenReturn(name);
|
||||||
|
|
||||||
Track track = ContentProviderUtils.createTrack(cursorMock);
|
Track track = ContentProviderUtils.createTrack(cursorMock);
|
||||||
assertEquals(trackId, track.getId());
|
assertEquals(trackId, track.id());
|
||||||
assertEquals(name, track.getName());
|
assertEquals(name, track.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertCount(int trackCount, int trackPointCount, int markerCount) {
|
private void assertCount(int trackCount, int trackPointCount, int markerCount) {
|
||||||
@@ -219,8 +234,15 @@ public class CustomContentProviderUtilsTest {
|
|||||||
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
Marker marker = new Marker(trackId, contentProviderUtils.getLastValidTrackPoint(trackId));
|
contentProviderUtils.insertMarker(new Marker(
|
||||||
contentProviderUtils.insertMarker(marker);
|
null,
|
||||||
|
trackId,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
getLastValidTrackPoint(trackId).position(),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
assertCount(1, 10, 1);
|
assertCount(1, 10, 1);
|
||||||
|
|
||||||
@@ -238,14 +260,14 @@ public class CustomContentProviderUtilsTest {
|
|||||||
public void testDeleteAllTracks_withMarkerAndPhoto() throws IOException {
|
public void testDeleteAllTracks_withMarkerAndPhoto() throws IOException {
|
||||||
// Insert track, points and marker with photo at first.
|
// Insert track, points and marker with photo at first.
|
||||||
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
||||||
Track track = TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
TrackPoint trackPoint = contentProviderUtils.getLastValidTrackPoint(trackId);
|
TrackPoint trackPoint = getLastValidTrackPoint(trackId);
|
||||||
Marker marker = TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint);
|
Marker marker = TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint);
|
||||||
contentProviderUtils.insertMarker(marker);
|
contentProviderUtils.insertMarker(marker);
|
||||||
|
|
||||||
assertCount(1, 10, 1);
|
assertCount(1, 10, 1);
|
||||||
assertTrue(marker.hasPhoto());
|
assertNotNull(marker.photoUrl());
|
||||||
File dir = FileUtils.getPhotoDir(context, trackId);
|
File dir = FileUtils.getPhotoDir(context, trackId);
|
||||||
assertTrue(dir.isDirectory());
|
assertTrue(dir.isDirectory());
|
||||||
assertEquals(1, dir.list().length);
|
assertEquals(1, dir.list().length);
|
||||||
@@ -275,8 +297,15 @@ public class CustomContentProviderUtilsTest {
|
|||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId2, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId2, 10);
|
||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId3, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId3, 10);
|
||||||
|
|
||||||
Marker marker = new Marker(trackId1, contentProviderUtils.getLastValidTrackPoint(trackId2));
|
contentProviderUtils.insertMarker(new Marker(
|
||||||
contentProviderUtils.insertMarker(marker);
|
null,
|
||||||
|
trackId1,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
getLastValidTrackPoint(trackId1).position(),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
assertCount(3, 30, 1);
|
assertCount(3, 30, 1);
|
||||||
|
|
||||||
@@ -303,19 +332,19 @@ public class CustomContentProviderUtilsTest {
|
|||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId3, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId3, 10);
|
||||||
|
|
||||||
// Insert a marker in tracks trackId and trackId + 1.
|
// Insert a marker in tracks trackId and trackId + 1.
|
||||||
TrackPoint trackPoint1 = contentProviderUtils.getLastValidTrackPoint(trackId1);
|
TrackPoint trackPoint1 = getLastValidTrackPoint(trackId1);
|
||||||
Marker marker1 = TestDataUtil.createMarkerWithPhoto(context, trackId1, trackPoint1);
|
Marker marker1 = TestDataUtil.createMarkerWithPhoto(context, trackId1, trackPoint1);
|
||||||
contentProviderUtils.insertMarker(marker1);
|
contentProviderUtils.insertMarker(marker1);
|
||||||
File dir1 = FileUtils.getPhotoDir(context, trackId1);
|
File dir1 = FileUtils.getPhotoDir(context, trackId1);
|
||||||
|
|
||||||
TrackPoint trackPoint2 = contentProviderUtils.getLastValidTrackPoint(trackId2);
|
TrackPoint trackPoint2 = getLastValidTrackPoint(trackId2);
|
||||||
Marker marker2 = TestDataUtil.createMarkerWithPhoto(context, trackId2, trackPoint2);
|
Marker marker2 = TestDataUtil.createMarkerWithPhoto(context, trackId2, trackPoint2);
|
||||||
contentProviderUtils.insertMarker(marker2);
|
contentProviderUtils.insertMarker(marker2);
|
||||||
File dir2 = FileUtils.getPhotoDir(context, trackId2);
|
File dir2 = FileUtils.getPhotoDir(context, trackId2);
|
||||||
|
|
||||||
// Check.
|
// Check.
|
||||||
assertCount(3, 30, 2);
|
assertCount(3, 30, 2);
|
||||||
assertTrue(marker1.hasPhoto());
|
assertNotNull(marker1.photoUrl());
|
||||||
assertTrue(dir1.isDirectory());
|
assertTrue(dir1.isDirectory());
|
||||||
assertEquals(1, dir1.list().length);
|
assertEquals(1, dir1.list().length);
|
||||||
assertTrue(dir1.exists());
|
assertTrue(dir1.exists());
|
||||||
@@ -347,7 +376,7 @@ public class CustomContentProviderUtilsTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(initialTrackNumber + 1, allTracks.size());
|
assertEquals(initialTrackNumber + 1, allTracks.size());
|
||||||
assertEquals(trackId, allTracks.get(allTracks.size() - 1).getId());
|
assertEquals(trackId, allTracks.get(allTracks.size() - 1).id());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -374,61 +403,57 @@ public class CustomContentProviderUtilsTest {
|
|||||||
contentProviderUtils.insertTrack(track);
|
contentProviderUtils.insertTrack(track);
|
||||||
|
|
||||||
// when / then
|
// when / then
|
||||||
assertNotNull(contentProviderUtils.getTrack(track.getUuid()));
|
assertNotNull(contentProviderUtils.getTrack(track.uuid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link ContentProviderUtils#updateTrack(Track)}
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateTrack() {
|
public void testUpdateTrack() {
|
||||||
// given
|
// given
|
||||||
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
||||||
Track track = TestDataUtil.createTrack(trackId);
|
TrackBuilder track = new TrackBuilder(TestDataUtil.createTrack(trackId));
|
||||||
String nameOld = "name1";
|
String nameOld = "name1";
|
||||||
String nameNew = "name2";
|
String nameNew = "name2";
|
||||||
track.setName(nameOld);
|
track.setName(nameOld);
|
||||||
|
|
||||||
// when / then
|
// when / then
|
||||||
contentProviderUtils.insertTrack(track);
|
contentProviderUtils.insertTrack(track.getTrack());
|
||||||
assertEquals(nameOld, contentProviderUtils.getTrack(trackId).getName());
|
assertEquals(nameOld, contentProviderUtils.getTrack(trackId).name());
|
||||||
track.setName(nameNew);
|
track.setName(nameNew);
|
||||||
contentProviderUtils.updateTrack(track);
|
contentProviderUtils.updateTrack(track.getTrack());
|
||||||
assertEquals(nameNew, contentProviderUtils.getTrack(trackId).getName());
|
assertEquals(nameNew, contentProviderUtils.getTrack(trackId).name());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link ContentProviderUtils#createContentValues(Marker)}.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateContentValues_marker() {
|
public void testCreateContentValues_marker() {
|
||||||
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
||||||
Pair<Track, List<TrackPoint>> track = TestDataUtil.createTrack(trackId, 10);
|
Pair<Track, List<TrackPoint>> track = TestDataUtil.createTrack(trackId, 10);
|
||||||
|
|
||||||
|
TrackBuilder trackBuilder = new TrackBuilder(track.first);
|
||||||
|
|
||||||
// AverageSpeed
|
// AverageSpeed
|
||||||
TrackStatistics statistics = new TrackStatistics();
|
trackBuilder.setStatistics(new Statistics(
|
||||||
statistics.setStartTime(Instant.ofEpochMilli(1000));
|
Instant.ofEpochMilli(1000),
|
||||||
statistics.setStopTime(Instant.ofEpochMilli(2500));
|
Instant.ofEpochMilli(2500),
|
||||||
statistics.setTotalTime(Duration.ofMillis(1500));
|
Duration.ofMillis(1500),
|
||||||
statistics.setMovingTime(Duration.ofMillis(700));
|
Duration.ofMillis(700),
|
||||||
statistics.setTotalDistance(Distance.of(750.0));
|
Distance.of(750),
|
||||||
statistics.setTotalAltitudeGain(50.0f);
|
Speed.of(60),
|
||||||
statistics.setMaxSpeed(Speed.of(60.0));
|
new AltitudeExtremities(1250, 1200),
|
||||||
statistics.setMaxAltitude(1250.0);
|
new AltitudeGainLoss(50, 50),
|
||||||
statistics.setMinAltitude(1200.0);
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
contentProviderUtils.insertTrack(trackBuilder.getTrack());
|
||||||
|
|
||||||
track.first.setTrackStatistics(statistics);
|
MarkerBuilder marker = new MarkerBuilder(trackId, track.second.get(0));
|
||||||
contentProviderUtils.insertTrack(track.first);
|
|
||||||
|
|
||||||
Marker marker = new Marker(trackId, track.second.get(0));
|
|
||||||
marker.setDescription(TEST_DESC);
|
marker.setDescription(TEST_DESC);
|
||||||
contentProviderUtils.insertMarker(marker);
|
contentProviderUtils.insertMarker(marker.getMarker());
|
||||||
|
|
||||||
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(contentResolverMock);
|
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(contentResolverMock);
|
||||||
|
|
||||||
Marker.Id markerId = new Marker.Id(System.currentTimeMillis());
|
Marker.Id markerId = new Marker.Id(System.currentTimeMillis());
|
||||||
marker.setId(markerId);
|
marker.setId(markerId);
|
||||||
ContentValues contentValues = contentProviderUtils.createContentValues(marker);
|
ContentValues contentValues = contentProviderUtils.createContentValues(marker.getMarker(), trackId);
|
||||||
assertEquals(markerId.id(), contentValues.get(MarkerColumns._ID));
|
assertEquals(markerId.id(), contentValues.get(MarkerColumns._ID));
|
||||||
assertEquals((int) (TestDataUtil.INITIAL_LONGITUDE * 1000000), contentValues.get(MarkerColumns.LONGITUDE));
|
assertEquals((int) (TestDataUtil.INITIAL_LONGITUDE * 1000000), contentValues.get(MarkerColumns.LONGITUDE));
|
||||||
assertEquals(TEST_DESC, contentValues.get(MarkerColumns.DESCRIPTION));
|
assertEquals(TEST_DESC, contentValues.get(MarkerColumns.DESCRIPTION));
|
||||||
@@ -445,15 +470,18 @@ public class CustomContentProviderUtilsTest {
|
|||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
// Insert at first.
|
// Insert at first.
|
||||||
Marker marker1 = new Marker(trackId, contentProviderUtils.getLastValidTrackPoint(trackId));
|
Marker.Id marker1Id = contentProviderUtils.insertMarker(new Marker(
|
||||||
marker1.setDescription(TEST_DESC);
|
null,
|
||||||
contentProviderUtils.insertMarker(marker1);
|
trackId,
|
||||||
|
"",
|
||||||
|
TEST_DESC,
|
||||||
|
"",
|
||||||
|
getLastValidTrackPoint(trackId).position(),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
// Check insert was done.
|
// Check insert was done.
|
||||||
assertEquals(1, contentProviderUtils.getMarkers(trackId).size());
|
assertEquals(1, TestDataUtil.getMarkers(contentProviderUtils, trackId).size());
|
||||||
|
|
||||||
// Get marker id that needs to delete.
|
|
||||||
Marker.Id marker1Id = contentProviderUtils.insertMarker(marker1);
|
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
contentProviderUtils.deleteMarker(context, marker1Id);
|
contentProviderUtils.deleteMarker(context, marker1Id);
|
||||||
@@ -472,18 +500,18 @@ public class CustomContentProviderUtilsTest {
|
|||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
// Insert at first.
|
// Insert at first.
|
||||||
TrackPoint trackPoint = contentProviderUtils.getLastValidTrackPoint(trackId);
|
TrackPoint trackPoint = getLastValidTrackPoint(trackId);
|
||||||
Marker marker1 = TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint);
|
Marker marker1 = TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint);
|
||||||
contentProviderUtils.insertMarker(marker1);
|
contentProviderUtils.insertMarker(marker1);
|
||||||
|
|
||||||
// Check insert was done.
|
// Check insert was done.
|
||||||
assertEquals(1, contentProviderUtils.getMarkers(trackId).size());
|
assertEquals(1, TestDataUtil.getMarkers(contentProviderUtils, trackId).size());
|
||||||
|
|
||||||
// Get marker id that needs to delete.
|
// Get marker id that needs to delete.
|
||||||
Marker.Id marker1Id = contentProviderUtils.insertMarker(marker1);
|
Marker.Id marker1Id = contentProviderUtils.insertMarker(marker1);
|
||||||
|
|
||||||
// Check marker has photo and it's in the external storage.
|
// Check marker has photo and it's in the external storage.
|
||||||
assertTrue(marker1.hasPhoto());
|
assertNotNull(marker1.photoUrl());
|
||||||
File dir = FileUtils.getPhotoDir(context, trackId);
|
File dir = FileUtils.getPhotoDir(context, trackId);
|
||||||
assertTrue(dir.isDirectory());
|
assertTrue(dir.isDirectory());
|
||||||
assertEquals(1, dir.list().length);
|
assertEquals(1, dir.list().length);
|
||||||
@@ -522,20 +550,31 @@ public class CustomContentProviderUtilsTest {
|
|||||||
// TestDataUtil.insertTrackWithLocations(contentProviderUtils, track);
|
// TestDataUtil.insertTrackWithLocations(contentProviderUtils, track);
|
||||||
|
|
||||||
// Insert at first.
|
// Insert at first.
|
||||||
Marker marker1 = new Marker(trackId, contentProviderUtils.getLastValidTrackPoint(trackId));
|
Marker.Id marker1Id = contentProviderUtils.insertMarker(new Marker(
|
||||||
marker1.setDescription(MOCK_DESC);
|
null,
|
||||||
Marker.Id marker1Id = contentProviderUtils.insertMarker(marker1);
|
trackId,
|
||||||
|
"",
|
||||||
Marker marker2 = new Marker(trackId, contentProviderUtils.getLastValidTrackPoint(trackId));
|
MOCK_DESC,
|
||||||
marker2.setDescription(MOCK_DESC);
|
"",
|
||||||
Marker.Id marker2Id = contentProviderUtils.insertMarker(marker2);
|
getLastValidTrackPoint(trackId).position(),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
Marker.Id marker2Id = contentProviderUtils.insertMarker(new Marker(
|
||||||
|
null,
|
||||||
|
trackId,
|
||||||
|
"",
|
||||||
|
MOCK_DESC,
|
||||||
|
"",
|
||||||
|
getLastValidTrackPoint(trackId).position(),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
assertNotNull(contentProviderUtils.getMarker(marker1Id));
|
assertNotNull(contentProviderUtils.getMarker(marker1Id));
|
||||||
contentProviderUtils.deleteMarker(context, marker1Id);
|
contentProviderUtils.deleteMarker(context, marker1Id);
|
||||||
assertNull(contentProviderUtils.getMarker(marker1Id));
|
assertNull(contentProviderUtils.getMarker(marker1Id));
|
||||||
|
|
||||||
assertEquals(MOCK_DESC, contentProviderUtils.getMarker(marker2Id).getDescription());
|
assertEquals(MOCK_DESC, contentProviderUtils.getMarker(marker2Id).description());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -546,14 +585,17 @@ public class CustomContentProviderUtilsTest {
|
|||||||
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
Marker marker1 = new Marker(trackId, contentProviderUtils.getLastValidTrackPoint(trackId));
|
for (int i = 0; i < 4; i++) {
|
||||||
Marker marker2 = new Marker(trackId, contentProviderUtils.getLastValidTrackPoint(trackId));
|
contentProviderUtils.insertMarker(new Marker(
|
||||||
Marker marker3 = new Marker(trackId, contentProviderUtils.getLastValidTrackPoint(trackId));
|
null,
|
||||||
Marker marker4 = new Marker(trackId, contentProviderUtils.getLastValidTrackPoint(trackId));
|
trackId,
|
||||||
contentProviderUtils.insertMarker(marker1);
|
"",
|
||||||
contentProviderUtils.insertMarker(marker2);
|
MOCK_DESC,
|
||||||
contentProviderUtils.insertMarker(marker3);
|
"",
|
||||||
contentProviderUtils.insertMarker(marker4);
|
getLastValidTrackPoint(trackId).position(),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals(Integer.valueOf(4), contentProviderUtils.getNextMarkerNumber(trackId));
|
assertEquals(Integer.valueOf(4), contentProviderUtils.getNextMarkerNumber(trackId));
|
||||||
}
|
}
|
||||||
@@ -567,11 +609,18 @@ public class CustomContentProviderUtilsTest {
|
|||||||
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
Marker marker = new Marker(trackId, contentProviderUtils.getLastValidTrackPoint(trackId));
|
Marker.Id markerId = contentProviderUtils.insertMarker(
|
||||||
marker.setDescription(TEST_DESC);
|
new Marker(
|
||||||
Marker.Id markerId = contentProviderUtils.insertMarker(marker);
|
null,
|
||||||
|
trackId,
|
||||||
|
"",
|
||||||
|
TEST_DESC,
|
||||||
|
"",
|
||||||
|
getLastValidTrackPoint(trackId).position(),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
assertEquals(TEST_DESC, contentProviderUtils.getMarker(markerId).getDescription());
|
assertEquals(TEST_DESC, contentProviderUtils.getMarker(markerId).description());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -583,16 +632,29 @@ public class CustomContentProviderUtilsTest {
|
|||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
// Insert at first.
|
// Insert at first.
|
||||||
Marker marker = new Marker(trackId, contentProviderUtils.getLastValidTrackPoint(trackId));
|
Marker.Id markerId = contentProviderUtils.insertMarker(
|
||||||
marker.setDescription(TEST_DESC);
|
new Marker(
|
||||||
Marker.Id markerId = contentProviderUtils.insertMarker(marker);
|
null,
|
||||||
|
trackId,
|
||||||
|
"",
|
||||||
|
TEST_DESC,
|
||||||
|
"",
|
||||||
|
getLastValidTrackPoint(trackId).position(),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
marker = contentProviderUtils.getMarker(markerId);
|
contentProviderUtils.updateMarker(context, new Marker(
|
||||||
marker.setDescription(TEST_DESC_NEW);
|
markerId,
|
||||||
contentProviderUtils.updateMarker(context, marker);
|
trackId,
|
||||||
|
"",
|
||||||
|
TEST_DESC_NEW,
|
||||||
|
"",
|
||||||
|
getLastValidTrackPoint(trackId).position(),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
assertEquals(TEST_DESC_NEW, contentProviderUtils.getMarker(markerId).getDescription());
|
assertEquals(TEST_DESC_NEW, contentProviderUtils.getMarker(markerId).description());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -606,10 +668,8 @@ public class CustomContentProviderUtilsTest {
|
|||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
// Insert at first.
|
// Insert at first.
|
||||||
TrackPoint trackPoint = contentProviderUtils.getLastValidTrackPoint(trackId);
|
TrackPoint trackPoint = getLastValidTrackPoint(trackId);
|
||||||
Marker marker = TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint);
|
Marker.Id markerId = contentProviderUtils.insertMarker(TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint, TEST_DESC));
|
||||||
marker.setDescription(TEST_DESC);
|
|
||||||
Marker.Id markerId = contentProviderUtils.insertMarker(marker);
|
|
||||||
|
|
||||||
File dir = new File(FileUtils.getPhotoDir(context), "" + trackId.id());
|
File dir = new File(FileUtils.getPhotoDir(context), "" + trackId.id());
|
||||||
assertTrue(dir.exists());
|
assertTrue(dir.exists());
|
||||||
@@ -617,14 +677,13 @@ public class CustomContentProviderUtilsTest {
|
|||||||
assertEquals(1, dir.list().length);
|
assertEquals(1, dir.list().length);
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
marker = contentProviderUtils.getMarker(markerId);
|
MarkerBuilder marker = new MarkerBuilder(contentProviderUtils.getMarker(markerId));
|
||||||
marker.setName(TEST_NAME_NEW);
|
marker.setName(TEST_NAME_NEW);
|
||||||
marker.setDescription(TEST_DESC_NEW);
|
marker.setDescription(TEST_DESC_NEW);
|
||||||
contentProviderUtils.updateMarker(context, marker);
|
contentProviderUtils.updateMarker(context, marker.getMarker());
|
||||||
|
|
||||||
assertEquals(TEST_NAME_NEW, contentProviderUtils.getMarker(markerId).getName());
|
assertEquals(TEST_NAME_NEW, contentProviderUtils.getMarker(markerId).name());
|
||||||
assertEquals(TEST_DESC_NEW, contentProviderUtils.getMarker(markerId).getDescription());
|
assertEquals(TEST_DESC_NEW, contentProviderUtils.getMarker(markerId).description());
|
||||||
assertTrue(marker.hasPhoto());
|
|
||||||
assertTrue(dir.exists());
|
assertTrue(dir.exists());
|
||||||
assertTrue(dir.isDirectory());
|
assertTrue(dir.isDirectory());
|
||||||
assertEquals(1, dir.list().length);
|
assertEquals(1, dir.list().length);
|
||||||
@@ -641,9 +700,8 @@ public class CustomContentProviderUtilsTest {
|
|||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
// Insert at first.
|
// Insert at first.
|
||||||
TrackPoint trackPoint = contentProviderUtils.getLastValidTrackPoint(trackId);
|
TrackPoint trackPoint = getLastValidTrackPoint(trackId);
|
||||||
Marker marker = TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint);
|
Marker marker = TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint, TEST_DESC);
|
||||||
marker.setDescription(TEST_DESC);
|
|
||||||
Marker.Id markerId = contentProviderUtils.insertMarker(marker);
|
Marker.Id markerId = contentProviderUtils.insertMarker(marker);
|
||||||
|
|
||||||
File dir = new File(FileUtils.getPhotoDir(context), "" + trackId.id());
|
File dir = new File(FileUtils.getPhotoDir(context), "" + trackId.id());
|
||||||
@@ -652,15 +710,14 @@ public class CustomContentProviderUtilsTest {
|
|||||||
assertEquals(1, dir.list().length);
|
assertEquals(1, dir.list().length);
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
marker = contentProviderUtils.getMarker(markerId);
|
MarkerBuilder markerBuilder = new MarkerBuilder(contentProviderUtils.getMarker(markerId));
|
||||||
marker.setName(TEST_NAME_NEW);
|
markerBuilder.setName(TEST_NAME_NEW);
|
||||||
marker.setDescription(TEST_DESC_NEW);
|
markerBuilder.setDescription(TEST_DESC_NEW);
|
||||||
marker.setPhotoUrl(null);
|
markerBuilder.setPhotoUrl(null);
|
||||||
contentProviderUtils.updateMarker(context, marker);
|
contentProviderUtils.updateMarker(context, markerBuilder.getMarker());
|
||||||
|
|
||||||
assertEquals(TEST_NAME_NEW, contentProviderUtils.getMarker(markerId).getName());
|
assertEquals(TEST_NAME_NEW, contentProviderUtils.getMarker(markerId).name());
|
||||||
assertEquals(TEST_DESC_NEW, contentProviderUtils.getMarker(markerId).getDescription());
|
assertEquals(TEST_DESC_NEW, contentProviderUtils.getMarker(markerId).description());
|
||||||
assertFalse(marker.hasPhoto());
|
|
||||||
assertFalse(dir.exists());
|
assertFalse(dir.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -675,11 +732,9 @@ public class CustomContentProviderUtilsTest {
|
|||||||
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
// Insert two markers with photos.
|
// Insert two markers with photos.
|
||||||
TrackPoint trackPoint = contentProviderUtils.getLastValidTrackPoint(trackId);
|
TrackPoint trackPoint = getLastValidTrackPoint(trackId);
|
||||||
Marker marker = TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint);
|
Marker marker = TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint, TEST_DESC);
|
||||||
marker.setDescription(TEST_DESC);
|
Marker otherMarker = TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint, TEST_DESC);
|
||||||
Marker otherMarker = TestDataUtil.createMarkerWithPhoto(context, trackId, trackPoint);
|
|
||||||
otherMarker.setDescription(TEST_DESC);
|
|
||||||
Marker.Id markerId = contentProviderUtils.insertMarker(marker);
|
Marker.Id markerId = contentProviderUtils.insertMarker(marker);
|
||||||
contentProviderUtils.insertMarker(otherMarker);
|
contentProviderUtils.insertMarker(otherMarker);
|
||||||
|
|
||||||
@@ -689,12 +744,14 @@ public class CustomContentProviderUtilsTest {
|
|||||||
assertEquals(2, dir.list().length);
|
assertEquals(2, dir.list().length);
|
||||||
|
|
||||||
// Update one marker deleting photo.
|
// Update one marker deleting photo.
|
||||||
marker = contentProviderUtils.getMarker(markerId);
|
MarkerBuilder markerBuilder = new MarkerBuilder(contentProviderUtils.getMarker(markerId));
|
||||||
marker.setPhotoUrl(null);
|
markerBuilder.setPhotoUrl(null);
|
||||||
contentProviderUtils.updateMarker(context, marker);
|
contentProviderUtils.updateMarker(context, markerBuilder.getMarker());
|
||||||
|
|
||||||
assertEquals(TEST_DESC, contentProviderUtils.getMarker(markerId).getDescription());
|
// then
|
||||||
assertFalse(marker.hasPhoto());
|
marker = contentProviderUtils.getMarker(markerId);
|
||||||
|
assertEquals(TEST_DESC, contentProviderUtils.getMarker(markerId).description());
|
||||||
|
assertNull(marker.photoUrl());
|
||||||
assertTrue(dir.exists());
|
assertTrue(dir.exists());
|
||||||
assertTrue(dir.isDirectory());
|
assertTrue(dir.isDirectory());
|
||||||
assertEquals(1, dir.list().length);
|
assertEquals(1, dir.list().length);
|
||||||
@@ -725,50 +782,6 @@ public class CustomContentProviderUtilsTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link ContentProviderUtils#createTrackPoint(Cursor)}.
|
|
||||||
*/
|
|
||||||
//TODO incomplete
|
|
||||||
@Test
|
|
||||||
public void testCreateTrackPoint() {
|
|
||||||
// given
|
|
||||||
when(cursorMock.getColumnIndex(TrackPointsColumns._ID)).thenReturn(1);
|
|
||||||
|
|
||||||
when(cursorMock.getColumnIndexOrThrow(TrackPointsColumns.LONGITUDE)).thenReturn(2);
|
|
||||||
when(cursorMock.isNull(2)).thenReturn(false);
|
|
||||||
int longitude = 11;
|
|
||||||
when(cursorMock.getInt(2)).thenReturn(longitude * 1000000);
|
|
||||||
|
|
||||||
when(cursorMock.getColumnIndexOrThrow(TrackPointsColumns.LATITUDE)).thenReturn(3);
|
|
||||||
when(cursorMock.isNull(3)).thenReturn(false);
|
|
||||||
int latitude = 22;
|
|
||||||
when(cursorMock.getInt(3)).thenReturn(latitude * 1000000);
|
|
||||||
|
|
||||||
when(cursorMock.getColumnIndexOrThrow(TrackPointsColumns.TIME)).thenReturn(4);
|
|
||||||
when(cursorMock.isNull(4)).thenReturn(false);
|
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
when(cursorMock.getLong(4)).thenReturn(time);
|
|
||||||
|
|
||||||
when(cursorMock.getColumnIndexOrThrow(TrackPointsColumns.SPEED)).thenReturn(5);
|
|
||||||
when(cursorMock.isNull(5)).thenReturn(false);
|
|
||||||
float speed = 2.2f;
|
|
||||||
when(cursorMock.getFloat(5)).thenReturn(speed);
|
|
||||||
|
|
||||||
when(cursorMock.getColumnIndexOrThrow(TrackPointsColumns.SENSOR_HEARTRATE)).thenReturn(6);
|
|
||||||
when(cursorMock.isNull(6)).thenReturn(false);
|
|
||||||
when(cursorMock.getFloat(6)).thenReturn(75f);
|
|
||||||
|
|
||||||
// when
|
|
||||||
TrackPoint trackPoint = contentProviderUtils.createTrackPoint(cursorMock);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertEquals(latitude, trackPoint.getPosition().latitude(), 0.01);
|
|
||||||
assertEquals(longitude, trackPoint.getPosition().longitude(), 0.01);
|
|
||||||
assertEquals(time, trackPoint.getTime().toEpochMilli());
|
|
||||||
assertEquals(speed, trackPoint.getSpeed().toMPS(), 0.01);
|
|
||||||
assertEquals(HeartRate.of(75f), trackPoint.getHeartRate());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the method
|
* Tests the method
|
||||||
* {@link ContentProviderUtils#insertTrackPoint(TrackPoint, Track.Id)}.
|
* {@link ContentProviderUtils#insertTrackPoint(TrackPoint, Track.Id)}.
|
||||||
@@ -777,7 +790,7 @@ public class CustomContentProviderUtilsTest {
|
|||||||
public void testInsertTrackPoint() {
|
public void testInsertTrackPoint() {
|
||||||
// Insert track, point at first.
|
// Insert track, point at first.
|
||||||
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
||||||
Track track = TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
contentProviderUtils.insertTrackPoint(TestDataUtil.createTrackPoint(22), trackId);
|
contentProviderUtils.insertTrackPoint(TestDataUtil.createTrackPoint(22), trackId);
|
||||||
// when
|
// when
|
||||||
@@ -791,35 +804,29 @@ public class CustomContentProviderUtilsTest {
|
|||||||
public void testInsertAndLoadTrackPoint() {
|
public void testInsertAndLoadTrackPoint() {
|
||||||
// given
|
// given
|
||||||
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
||||||
Track track = TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
||||||
|
|
||||||
TrackPoint trackPoint = TestDataUtil.createTrackPoint(5);
|
TrackPoint trackPoint = new TrackPoint(
|
||||||
trackPoint.setHeartRate(1F);
|
null,
|
||||||
trackPoint.setCadence(2F);
|
TrackPoint.Type.TRACKPOINT,
|
||||||
trackPoint.setPower(3F);
|
TestDataUtil.createTrackPoint(5).position(),
|
||||||
|
null,
|
||||||
|
HeartRate.of(1),
|
||||||
|
null,
|
||||||
|
Cadence.of(2),
|
||||||
|
Power.of(3),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
contentProviderUtils.insertTrackPoint(trackPoint, trackId);
|
contentProviderUtils.insertTrackPoint(trackPoint, trackId);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
List<TrackPoint> trackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, trackId);
|
List<TrackPoint> trackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, trackId);
|
||||||
assertTrue(trackPoints.get(10).hasHeartRate());
|
assertNotNull(trackPoints.get(10).heartRate());
|
||||||
assertEquals(trackPoint.getHeartRate(), trackPoints.get(10).getHeartRate());
|
assertEquals(trackPoint.heartRate(), trackPoints.get(10).heartRate());
|
||||||
assertEquals(trackPoint.getCadence(), trackPoints.get(10).getCadence());
|
assertEquals(trackPoint.cadence(), trackPoints.get(10).cadence());
|
||||||
assertEquals(trackPoint.getPower(), trackPoints.get(10).getPower());
|
assertEquals(trackPoint.power(), trackPoints.get(10).power());
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link ContentProviderUtils#getLastValidTrackPoint(Track.Id)}.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testGetLastValidTrackPoint() {
|
|
||||||
// Insert track, points at first.
|
|
||||||
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
|
||||||
Track track = TestDataUtil.createTrackAndInsert(contentProviderUtils, trackId, 10);
|
|
||||||
|
|
||||||
TrackPoint lastTrackPoint = contentProviderUtils.getLastValidTrackPoint(trackId);
|
|
||||||
checkLocation(9, lastTrackPoint.getLocation());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -830,7 +837,7 @@ public class CustomContentProviderUtilsTest {
|
|||||||
contentProviderUtils.insertTrack(track.first);
|
contentProviderUtils.insertTrack(track.first);
|
||||||
|
|
||||||
List<TrackPoint.Id> trackpointIds = track.second.stream()
|
List<TrackPoint.Id> trackpointIds = track.second.stream()
|
||||||
.map(it -> ContentUris.parseId(contentProviderUtils.insertTrackPoint(it, track.first.getId())))
|
.map(it -> ContentUris.parseId(contentProviderUtils.insertTrackPoint(it, track.first.id())))
|
||||||
.map(TrackPoint.Id::new).toList();
|
.map(TrackPoint.Id::new).toList();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@@ -841,45 +848,36 @@ public class CustomContentProviderUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTrackPointLocationIterator_asc() {
|
public void testGetTrackPointIterator_asc() {
|
||||||
// given
|
// given
|
||||||
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
||||||
Pair<Track, List<TrackPoint>> track = TestDataUtil.createTrack(trackId, 10);
|
Pair<Track, List<TrackPoint>> track = TestDataUtil.createTrack(trackId, 10);
|
||||||
contentProviderUtils.insertTrack(track.first);
|
contentProviderUtils.insertTrack(track.first);
|
||||||
|
|
||||||
List<TrackPoint.Id> trackpointIds = track.second.stream()
|
List<TrackPoint.Id> trackpointIds = track.second.stream()
|
||||||
.map(it -> ContentUris.parseId(contentProviderUtils.insertTrackPoint(it, track.first.getId())))
|
.map(it -> ContentUris.parseId(contentProviderUtils.insertTrackPoint(it, track.first.id())))
|
||||||
.map(TrackPoint.Id::new).toList();
|
.map(TrackPoint.Id::new).toList();
|
||||||
|
|
||||||
TrackPoint.Id startTrackPointId = trackpointIds.get(0);
|
TrackPoint.Id startTrackPointId = trackpointIds.get(0);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, trackpointIds.get(0));
|
TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointIterator(trackId, trackpointIds.get(0));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
for (int i = 0; i < trackpointIds.size(); i++) {
|
for (int i = 0; i < trackpointIds.size(); i++) {
|
||||||
assertTrue(trackPointIterator.hasNext());
|
assertTrue(trackPointIterator.hasNext());
|
||||||
TrackPoint trackPoint = trackPointIterator.next();
|
TrackPoint trackPoint = trackPointIterator.next();
|
||||||
assertEquals(startTrackPointId.id() + i, trackPoint.getId().id());
|
assertEquals(startTrackPointId.id() + i, trackPoint.id().id());
|
||||||
|
|
||||||
checkLocation(i, trackPoint.getLocation());
|
Position position = trackPoint.position();
|
||||||
|
assertEquals(TestDataUtil.INITIAL_LATITUDE + i / 10000.0, position.latitude(), 0.01);
|
||||||
|
assertEquals(TestDataUtil.INITIAL_LONGITUDE - i / 10000.0, position.longitude(), 0.01);
|
||||||
|
assertEquals(i / 100.0, position.horizontalAccuracy().distance_m(), 0.01);
|
||||||
|
assertEquals(i * TestDataUtil.ALTITUDE_INTERVAL, position.altitude().toM(), 0.01);
|
||||||
}
|
}
|
||||||
assertFalse(trackPointIterator.hasNext());
|
assertFalse(trackPointIterator.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks the value of a location.
|
|
||||||
*
|
|
||||||
* @param i the index of this location which created in the method {@link TestDataUtil#createTrack(Track.Id, int)}
|
|
||||||
* @param location the location to be checked
|
|
||||||
*/
|
|
||||||
private void checkLocation(int i, Location location) {
|
|
||||||
assertEquals(TestDataUtil.INITIAL_LATITUDE + (double) i / 10000.0, location.getLatitude(), 0.01);
|
|
||||||
assertEquals(TestDataUtil.INITIAL_LONGITUDE - (double) i / 10000.0, location.getLongitude(), 0.01);
|
|
||||||
assertEquals((float) i / 100.0f, location.getAccuracy(), 0.01);
|
|
||||||
assertEquals(i * TestDataUtil.ALTITUDE_INTERVAL, location.getAltitude(), 0.01);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormatIdListForUri() {
|
public void testFormatIdListForUri() {
|
||||||
assertEquals("", ContentProviderUtils.formatIdListForUri());
|
assertEquals("", ContentProviderUtils.formatIdListForUri());
|
||||||
@@ -891,11 +889,18 @@ public class CustomContentProviderUtilsTest {
|
|||||||
public void testGetSensorStats_noSensorData() {
|
public void testGetSensorStats_noSensorData() {
|
||||||
// given
|
// given
|
||||||
List<TrackPoint> trackPointList = new ArrayList<>();
|
List<TrackPoint> trackPointList = new ArrayList<>();
|
||||||
TrackPoint trackPoint = TestDataUtil.createTrackPoint(1);
|
TrackPoint trackPoint = new TrackPoint(
|
||||||
trackPoint.setType(TrackPoint.Type.TRACKPOINT);
|
null,
|
||||||
trackPoint.setPower(null);
|
TrackPoint.Type.TRACKPOINT,
|
||||||
trackPoint.setCadence(null);
|
TestDataUtil.createTrackPoint(1).position(),
|
||||||
trackPoint.setHeartRate(null);
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
trackPointList.add(trackPoint);
|
trackPointList.add(trackPoint);
|
||||||
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
Track.Id trackId = new Track.Id(System.currentTimeMillis());
|
||||||
Track track = TestDataUtil.createTrack(trackId);
|
Track track = TestDataUtil.createTrack(trackId);
|
||||||
@@ -1219,4 +1224,19 @@ public class CustomContentProviderUtilsTest {
|
|||||||
public void testGetSensorStats_withSeveralRandomStartSegments() {
|
public void testGetSensorStats_withSeveralRandomStartSegments() {
|
||||||
testGetSensorStats_randomData(5000, true);
|
testGetSensorStats_randomData(5000, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TrackPoint getLastValidTrackPoint(Track.Id trackId) {
|
||||||
|
try (TrackPointIterator trackPointsCursor = contentProviderUtils.getTrackPointIterator(trackId, null)) {
|
||||||
|
List<TrackPoint> trackpoints = new ArrayList<>();
|
||||||
|
while (trackPointsCursor.hasNext())
|
||||||
|
trackpoints.add(trackPointsCursor.next());
|
||||||
|
trackpoints = trackpoints.reversed();
|
||||||
|
|
||||||
|
return trackpoints.reversed()
|
||||||
|
.stream()
|
||||||
|
.filter(it -> List.of(TrackPoint.Type.TRACKPOINT, TrackPoint.Type.SEGMENT_START_AUTOMATIC).contains(it.type()))
|
||||||
|
.findFirst().orElseThrow();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-23
@@ -100,18 +100,18 @@ public class CustomSQLiteOpenHelperTest {
|
|||||||
// Open database with SQL upgrade
|
// Open database with SQL upgrade
|
||||||
Map<String, String> tableByUpgrade;
|
Map<String, String> tableByUpgrade;
|
||||||
Map<String, String> indicesByUpgrade;
|
Map<String, String> indicesByUpgrade;
|
||||||
try (SQLiteDatabase dbUpgraded = new CustomSQLiteOpenHelper(context, DATABASE_NAME).getReadableDatabase()) {
|
try (CustomSQLiteOpenHelper dbUpgraded = new CustomSQLiteOpenHelper(context, DATABASE_NAME)) {
|
||||||
tableByUpgrade = getSQL(dbUpgraded, "table");
|
tableByUpgrade = getSQL(dbUpgraded.getReadableDatabase(), "table");
|
||||||
indicesByUpgrade = getSQL(dbUpgraded, "index");
|
indicesByUpgrade = getSQL(dbUpgraded.getReadableDatabase(), "index");
|
||||||
}
|
}
|
||||||
context.deleteDatabase(DATABASE_NAME);
|
context.deleteDatabase(DATABASE_NAME);
|
||||||
|
|
||||||
// Open database via creation script
|
// Open database via creation script
|
||||||
Map<String, String> tablesByCreate;
|
Map<String, String> tablesByCreate;
|
||||||
Map<String, String> indicesByCreate;
|
Map<String, String> indicesByCreate;
|
||||||
try (SQLiteDatabase dbCreated = new CustomSQLiteOpenHelper(context, DATABASE_NAME).getReadableDatabase()) {
|
try (CustomSQLiteOpenHelper dbCreated = new CustomSQLiteOpenHelper(context, DATABASE_NAME)) {
|
||||||
tablesByCreate = getSQL(dbCreated, "table");
|
tablesByCreate = getSQL(dbCreated.getReadableDatabase(), "table");
|
||||||
indicesByCreate = getSQL(dbCreated, "index");
|
indicesByCreate = getSQL(dbCreated.getReadableDatabase(), "index");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -134,14 +134,16 @@ public class CustomSQLiteOpenHelperTest {
|
|||||||
@Test
|
@Test
|
||||||
public void onDowngrade_ToVersion23() {
|
public void onDowngrade_ToVersion23() {
|
||||||
// Create most recent database schema
|
// Create most recent database schema
|
||||||
new CustomSQLiteOpenHelper(context, DATABASE_NAME).getReadableDatabase().close();
|
try(CustomSQLiteOpenHelper db = new CustomSQLiteOpenHelper(context, DATABASE_NAME)) {
|
||||||
|
db.getReadableDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
// Downgrade schema to version 23 (base version)
|
// Downgrade schema to version 23 (base version)
|
||||||
Map<String, String> tablesByDowngrade;
|
Map<String, String> tablesByDowngrade;
|
||||||
Map<String, String> indicesByDowngrade;
|
Map<String, String> indicesByDowngrade;
|
||||||
try (SQLiteDatabase db = new CustomSQLiteOpenHelper(context, DATABASE_NAME, 23).getReadableDatabase()) {
|
try (CustomSQLiteOpenHelper db = new CustomSQLiteOpenHelper(context, DATABASE_NAME, 23)) {
|
||||||
tablesByDowngrade = getSQL(db, "table");
|
tablesByDowngrade = getSQL(db.getReadableDatabase(), "table");
|
||||||
indicesByDowngrade = getSQL(db, "index");
|
indicesByDowngrade = getSQL(db.getReadableDatabase(), "index");
|
||||||
}
|
}
|
||||||
|
|
||||||
// then - verify table structure
|
// then - verify table structure
|
||||||
@@ -155,9 +157,9 @@ public class CustomSQLiteOpenHelperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void track_uuid_unique() {
|
public void track_uuid_unique() {
|
||||||
try (SQLiteDatabase db = new CustomSQLiteOpenHelper(context, DATABASE_NAME).getWritableDatabase()) {
|
try (CustomSQLiteOpenHelper db = new CustomSQLiteOpenHelper(context, DATABASE_NAME)) {
|
||||||
db.execSQL("INSERT INTO tracks (uuid) VALUES (0x00)");
|
db.getWritableDatabase().execSQL("INSERT INTO tracks (uuid) VALUES (0x00)");
|
||||||
db.execSQL("INSERT INTO tracks (uuid) VALUES (0x00)");
|
db.getWritableDatabase().execSQL("INSERT INTO tracks (uuid) VALUES (0x00)");
|
||||||
fail("unique constraint not enforced");
|
fail("unique constraint not enforced");
|
||||||
} catch (SQLiteConstraintException e) {
|
} catch (SQLiteConstraintException e) {
|
||||||
assertTrue(e.getMessage().contains("UNIQUE constraint failed: tracks.uuid"));
|
assertTrue(e.getMessage().contains("UNIQUE constraint failed: tracks.uuid"));
|
||||||
@@ -168,7 +170,8 @@ public class CustomSQLiteOpenHelperTest {
|
|||||||
public void upgrade_data_to_30() {
|
public void upgrade_data_to_30() {
|
||||||
// given: a track in version 29
|
// given: a track in version 29
|
||||||
createVersion23();
|
createVersion23();
|
||||||
try (SQLiteDatabase db29 = new CustomSQLiteOpenHelper(context, DATABASE_NAME, 29).getWritableDatabase()) {
|
try (CustomSQLiteOpenHelper db = new CustomSQLiteOpenHelper(context, DATABASE_NAME, 29)) {
|
||||||
|
SQLiteDatabase db29 = db.getWritableDatabase();
|
||||||
db29.beginTransaction();
|
db29.beginTransaction();
|
||||||
db29.execSQL("INSERT INTO tracks (_id) VALUES (1)");
|
db29.execSQL("INSERT INTO tracks (_id) VALUES (1)");
|
||||||
|
|
||||||
@@ -201,7 +204,8 @@ public class CustomSQLiteOpenHelperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// when / then
|
// when / then
|
||||||
try (SQLiteDatabase db30 = new CustomSQLiteOpenHelper(context, DATABASE_NAME, 30).getWritableDatabase()) {
|
try (CustomSQLiteOpenHelper db = new CustomSQLiteOpenHelper(context, DATABASE_NAME, 30)) {
|
||||||
|
SQLiteDatabase db30 = db.getWritableDatabase();
|
||||||
{
|
{
|
||||||
// Track 1
|
// Track 1
|
||||||
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
|
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
|
||||||
@@ -261,7 +265,7 @@ public class CustomSQLiteOpenHelperTest {
|
|||||||
|
|
||||||
private void createVersion23() {
|
private void createVersion23() {
|
||||||
// Manually create database schema with version 23 (base version)
|
// Manually create database schema with version 23 (base version)
|
||||||
SQLiteDatabase dbBase = new SQLiteOpenHelper(context, DATABASE_NAME, null, 23) {
|
try(SQLiteOpenHelper dbBase = new SQLiteOpenHelper(context, DATABASE_NAME, null, 23) {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(SQLiteDatabase db) {
|
public void onCreate(SQLiteDatabase db) {
|
||||||
}
|
}
|
||||||
@@ -269,12 +273,10 @@ public class CustomSQLiteOpenHelperTest {
|
|||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
}
|
}
|
||||||
}.getWritableDatabase();
|
}) {
|
||||||
|
dbBase.getWritableDatabase().execSQL(TRACKS_CREATE_TABLE_V23);
|
||||||
dbBase.execSQL(TRACKS_CREATE_TABLE_V23);
|
dbBase.getWritableDatabase().execSQL(TRACKPOINTS_CREATE_TABLE_V23);
|
||||||
dbBase.execSQL(TRACKPOINTS_CREATE_TABLE_V23);
|
dbBase.getWritableDatabase().execSQL(WAYPOINTS_CREATE_TABLE_V23);
|
||||||
dbBase.execSQL(WAYPOINTS_CREATE_TABLE_V23);
|
}
|
||||||
|
|
||||||
dbBase.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import org.junit.runner.RunWith;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ public class TrackSelectionTest extends TestCase {
|
|||||||
TrackSelection filter = new TrackSelection();
|
TrackSelection filter = new TrackSelection();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SelectionData selection = filter.buildSelection();
|
ContentProviderUtils.SelectionData selection = filter.buildSelection();
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
assertNull(selection.selection());
|
assertNull(selection.selection());
|
||||||
@@ -34,12 +35,11 @@ public class TrackSelectionTest extends TestCase {
|
|||||||
TrackSelection filter = new TrackSelection().addTrackId(trackId);
|
TrackSelection filter = new TrackSelection().addTrackId(trackId);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SelectionData selection = filter.buildSelection();
|
ContentProviderUtils.SelectionData selection = filter.buildSelection();
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
assertEquals("_id IN (?)", selection.selection());
|
assertEquals("_id IN (?)", selection.selection());
|
||||||
assertEquals(1, selection.selectionArgs().length);
|
assertEquals(List.of("1"), selection.selectionArgs());
|
||||||
assertEquals("1", selection.selectionArgs()[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -54,28 +54,24 @@ public class TrackSelectionTest extends TestCase {
|
|||||||
.addTrackId(trackId3);
|
.addTrackId(trackId3);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SelectionData selection = filter.buildSelection();
|
ContentProviderUtils.SelectionData selection = filter.buildSelection();
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
assertEquals("_id IN (?,?,?)", selection.selection());
|
assertEquals("_id IN (?,?,?)", selection.selection());
|
||||||
assertEquals(3, selection.selectionArgs().length);
|
assertEquals(List.of("1", "2", "3"), selection.selectionArgs());
|
||||||
assertEquals("1", selection.selectionArgs()[0]);
|
|
||||||
assertEquals("2", selection.selectionArgs()[1]);
|
|
||||||
assertEquals("3", selection.selectionArgs()[2]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFilterBuildSelection_onlyOneCategory() {
|
public void testFilterBuildSelection_onlyOneactivity_type_localized() {
|
||||||
// given
|
// given
|
||||||
TrackSelection filter = new TrackSelection().addActivityType("running");
|
TrackSelection filter = new TrackSelection().addActivityType("running");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SelectionData selection = filter.buildSelection();
|
ContentProviderUtils.SelectionData selection = filter.buildSelection();
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
assertEquals("category IN (?)", selection.selection());
|
assertEquals("activity_type_localized IN (?)", selection.selection());
|
||||||
assertEquals(1, selection.selectionArgs().length);
|
assertEquals(List.of("running"), selection.selectionArgs());
|
||||||
assertEquals("running", selection.selectionArgs()[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -88,15 +84,11 @@ public class TrackSelectionTest extends TestCase {
|
|||||||
.addActivityType("trail walking");
|
.addActivityType("trail walking");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SelectionData selection = filter.buildSelection();
|
ContentProviderUtils.SelectionData selection = filter.buildSelection();
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
assertEquals("category IN (?,?,?,?)", selection.selection());
|
assertEquals("activity_type_localized IN (?,?,?,?)", selection.selection());
|
||||||
assertEquals(4, selection.selectionArgs().length);
|
assertEquals(List.of("running", "road biking", "mountain biking", "trail walking"), selection.selectionArgs());
|
||||||
assertEquals("running", selection.selectionArgs()[0]);
|
|
||||||
assertEquals("road biking", selection.selectionArgs()[1]);
|
|
||||||
assertEquals("mountain biking", selection.selectionArgs()[2]);
|
|
||||||
assertEquals("trail walking", selection.selectionArgs()[3]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -109,9 +101,9 @@ public class TrackSelectionTest extends TestCase {
|
|||||||
TrackSelection filterOk = new TrackSelection().addDateRange(instant, instant.plus(Duration.ofDays(1)));
|
TrackSelection filterOk = new TrackSelection().addDateRange(instant, instant.plus(Duration.ofDays(1)));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SelectionData selectionWrong1 = filterWrong1.buildSelection();
|
ContentProviderUtils.SelectionData selectionWrong1 = filterWrong1.buildSelection();
|
||||||
SelectionData selectionWrong2 = filterWrong2.buildSelection();
|
ContentProviderUtils.SelectionData selectionWrong2 = filterWrong2.buildSelection();
|
||||||
SelectionData selectionOk = filterOk.buildSelection();
|
ContentProviderUtils.SelectionData selectionOk = filterOk.buildSelection();
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
assertNull(selectionWrong1.selection());
|
assertNull(selectionWrong1.selection());
|
||||||
@@ -120,10 +112,8 @@ public class TrackSelectionTest extends TestCase {
|
|||||||
assertNull(selectionWrong2.selection());
|
assertNull(selectionWrong2.selection());
|
||||||
assertNull(selectionWrong2.selectionArgs());
|
assertNull(selectionWrong2.selectionArgs());
|
||||||
|
|
||||||
assertEquals("starttime BETWEEN ? AND ?", selectionOk.selection());
|
assertEquals("time_start BETWEEN ? AND ?", selectionOk.selection());
|
||||||
assertEquals(2, selectionOk.selectionArgs().length);
|
assertEquals(List.of(Long.toString(instant.toEpochMilli()), Long.toString(instant.toEpochMilli() + oneDay)) , selectionOk.selectionArgs());
|
||||||
assertEquals(selectionOk.selectionArgs()[0], Long.toString(instant.toEpochMilli()));
|
|
||||||
assertEquals(selectionOk.selectionArgs()[1], Long.toString(instant.toEpochMilli() + oneDay));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -140,16 +130,11 @@ public class TrackSelectionTest extends TestCase {
|
|||||||
.addActivityType("road biking");
|
.addActivityType("road biking");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SelectionData selection = filter.buildSelection();
|
ContentProviderUtils.SelectionData selection = filter.buildSelection();
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
assertEquals("_id IN (?,?,?) AND category IN (?,?)", selection.selection());
|
assertEquals("_id IN (?,?,?) AND activity_type_localized IN (?,?)", selection.selection());
|
||||||
assertEquals(5, selection.selectionArgs().length);
|
assertEquals(List.of("1", "2", "3", "running", "road biking"), selection.selectionArgs());
|
||||||
assertEquals("1", selection.selectionArgs()[0]);
|
|
||||||
assertEquals("2", selection.selectionArgs()[1]);
|
|
||||||
assertEquals("3", selection.selectionArgs()[2]);
|
|
||||||
assertEquals("running", selection.selectionArgs()[3]);
|
|
||||||
assertEquals("road biking", selection.selectionArgs()[4]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -169,16 +154,11 @@ public class TrackSelectionTest extends TestCase {
|
|||||||
.addDateRange(instant, instant.plusMillis(oneDay));
|
.addDateRange(instant, instant.plusMillis(oneDay));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SelectionData selection = filter.buildSelection();
|
ContentProviderUtils.SelectionData selection = filter.buildSelection();
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
assertEquals("_id IN (?,?,?) AND starttime BETWEEN ? AND ?", selection.selection());
|
assertEquals("_id IN (?,?,?) AND time_start BETWEEN ? AND ?", selection.selection());
|
||||||
assertEquals(5, selection.selectionArgs().length);
|
assertEquals(List.of("1", "2", "3", Long.toString(instant.toEpochMilli()), Long.toString(instant.toEpochMilli() + oneDay)), selection.selectionArgs());
|
||||||
assertEquals("1", selection.selectionArgs()[0]);
|
|
||||||
assertEquals("2", selection.selectionArgs()[1]);
|
|
||||||
assertEquals("3", selection.selectionArgs()[2]);
|
|
||||||
assertEquals(selection.selectionArgs()[3], Long.toString(instant.toEpochMilli()));
|
|
||||||
assertEquals(selection.selectionArgs()[4], Long.toString(instant.toEpochMilli() + oneDay));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -193,14 +173,10 @@ public class TrackSelectionTest extends TestCase {
|
|||||||
.addDateRange(instant, instant.plusMillis(oneDay));
|
.addDateRange(instant, instant.plusMillis(oneDay));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SelectionData selection = filter.buildSelection();
|
ContentProviderUtils.SelectionData selection = filter.buildSelection();
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
assertEquals("category IN (?,?) AND starttime BETWEEN ? AND ?", selection.selection());
|
assertEquals("activity_type_localized IN (?,?) AND time_start BETWEEN ? AND ?", selection.selection());
|
||||||
assertEquals(4, selection.selectionArgs().length);
|
assertEquals(List.of("running", "road biking", Long.toString(instant.toEpochMilli()), Long.toString(instant.toEpochMilli() + oneDay)), selection.selectionArgs());
|
||||||
assertEquals("running", selection.selectionArgs()[0]);
|
|
||||||
assertEquals("road biking", selection.selectionArgs()[1]);
|
|
||||||
assertEquals(selection.selectionArgs()[2], Long.toString(instant.toEpochMilli()));
|
|
||||||
assertEquals(selection.selectionArgs()[3], Long.toString(instant.toEpochMilli() + oneDay));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import de.dennisguse.opentracks.data.models.TrackPoint;
|
|||||||
public class TrackPointTest {
|
public class TrackPointTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void distanceToPrevious() {
|
public void distanceToPrevious_gps() {
|
||||||
TrackPoint tp1 = new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
TrackPoint tp1 = new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.ofEpochMilli(0),
|
Instant.ofEpochMilli(0),
|
||||||
@@ -38,20 +38,123 @@ public class TrackPointTest {
|
|||||||
|
|
||||||
// without sensor distance
|
// without sensor distance
|
||||||
assertEquals(11.13, tp2.distanceToPrevious(tp1).toM(), 0.01);
|
assertEquals(11.13, tp2.distanceToPrevious(tp1).toM(), 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void distanceToPrevious_sensor_distance_first() {
|
||||||
|
TrackPoint tp1 = new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
|
new Position(
|
||||||
|
Instant.ofEpochMilli(0),
|
||||||
|
0d,
|
||||||
|
0.0001,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null),
|
||||||
|
Distance.of(5),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
TrackPoint tp2 = new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
||||||
|
new Position(
|
||||||
|
Instant.ofEpochMilli(1),
|
||||||
|
0d,
|
||||||
|
0.0002,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null));
|
||||||
|
|
||||||
// tp1 has sensor distance
|
// tp1 has sensor distance
|
||||||
tp1.setSensorDistance(Distance.of(5));
|
|
||||||
tp1.setSensorDistance(null);
|
|
||||||
assertEquals(11.13, tp2.distanceToPrevious(tp1).toM(), 0.01);
|
assertEquals(11.13, tp2.distanceToPrevious(tp1).toM(), 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void distanceToPrevious_sensor_distance_second() {
|
||||||
|
TrackPoint tp1 = new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
||||||
|
new Position(
|
||||||
|
Instant.ofEpochMilli(0),
|
||||||
|
0d,
|
||||||
|
0.0001,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null));
|
||||||
|
|
||||||
|
TrackPoint tp2 = new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
|
new Position(
|
||||||
|
Instant.ofEpochMilli(1),
|
||||||
|
0d,
|
||||||
|
0.0002,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null),
|
||||||
|
Distance.of(5),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
|
||||||
// tp2 has sensor distance
|
// tp2 has sensor distance
|
||||||
tp1.setSensorDistance(null);
|
|
||||||
tp2.setSensorDistance(Distance.of(5));
|
|
||||||
assertEquals(5, tp2.distanceToPrevious(tp1).toM(), 0.01);
|
assertEquals(5, tp2.distanceToPrevious(tp1).toM(), 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void distanceToPrevious_sensor_distance_both() {
|
||||||
|
TrackPoint tp1 = new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
|
new Position(
|
||||||
|
Instant.ofEpochMilli(0),
|
||||||
|
0d,
|
||||||
|
0.0001,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null),
|
||||||
|
Distance.of(10),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
TrackPoint tp2 = new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
|
new Position(
|
||||||
|
Instant.ofEpochMilli(1),
|
||||||
|
0d,
|
||||||
|
0.0002,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null),
|
||||||
|
Distance.of(5),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
|
||||||
// tp1 and tp2 have sensor distance
|
// tp1 and tp2 have sensor distance
|
||||||
tp1.setSensorDistance(Distance.of(10));
|
|
||||||
tp2.setSensorDistance(Distance.of(5));
|
|
||||||
assertEquals(5, tp2.distanceToPrevious(tp1).toM(), 0.01);
|
assertEquals(5, tp2.distanceToPrevious(tp1).toM(), 0.01);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ public class SpeedFormatterTest {
|
|||||||
assertEquals("4:59", formatter.getSpeedParts(Speed.of(3.34)).first);
|
assertEquals("4:59", formatter.getSpeedParts(Speed.of(3.34)).first);
|
||||||
assertEquals("5:00", formatter.getSpeedParts(Speed.of(3.33)).first);
|
assertEquals("5:00", formatter.getSpeedParts(Speed.of(3.33)).first);
|
||||||
|
|
||||||
assertEquals("min/km", formatter.getSpeedParts(Speed.zero()).second);
|
assertEquals("min/km", formatter.getSpeedParts(Speed.ZERO).second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -39,7 +39,7 @@ public class SpeedFormatterTest {
|
|||||||
.build(context);
|
.build(context);
|
||||||
|
|
||||||
assertEquals("8:02", formatter.getSpeedParts(Speed.of(3.34)).first);
|
assertEquals("8:02", formatter.getSpeedParts(Speed.of(3.34)).first);
|
||||||
assertEquals("min/mi", formatter.getSpeedParts(Speed.zero()).second);
|
assertEquals("min/mi", formatter.getSpeedParts(Speed.ZERO).second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -50,7 +50,7 @@ public class SpeedFormatterTest {
|
|||||||
.build(context);
|
.build(context);
|
||||||
|
|
||||||
assertEquals("9:14", formatter.getSpeedParts(Speed.of(3.34)).first);
|
assertEquals("9:14", formatter.getSpeedParts(Speed.of(3.34)).first);
|
||||||
assertEquals("min/NM", formatter.getSpeedParts(Speed.zero()).second);
|
assertEquals("min/NM", formatter.getSpeedParts(Speed.ZERO).second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -61,7 +61,7 @@ public class SpeedFormatterTest {
|
|||||||
.build(context);
|
.build(context);
|
||||||
|
|
||||||
assertEquals("11.9", formatter.getSpeedParts(Speed.of(3.31)).first);
|
assertEquals("11.9", formatter.getSpeedParts(Speed.of(3.31)).first);
|
||||||
assertEquals("km/h", formatter.getSpeedParts(Speed.zero()).second);
|
assertEquals("km/h", formatter.getSpeedParts(Speed.ZERO).second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -72,7 +72,7 @@ public class SpeedFormatterTest {
|
|||||||
.build(context);
|
.build(context);
|
||||||
|
|
||||||
assertEquals("7.5", formatter.getSpeedParts(Speed.of(3.34)).first);
|
assertEquals("7.5", formatter.getSpeedParts(Speed.of(3.34)).first);
|
||||||
assertEquals("mph", formatter.getSpeedParts(Speed.zero()).second);
|
assertEquals("mph", formatter.getSpeedParts(Speed.ZERO).second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -83,7 +83,7 @@ public class SpeedFormatterTest {
|
|||||||
.build(context);
|
.build(context);
|
||||||
|
|
||||||
assertEquals("6.5", formatter.getSpeedParts(Speed.of(3.34)).first);
|
assertEquals("6.5", formatter.getSpeedParts(Speed.of(3.34)).first);
|
||||||
assertEquals("kn", formatter.getSpeedParts(Speed.zero()).second);
|
assertEquals("kn", formatter.getSpeedParts(Speed.ZERO).second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package de.dennisguse.opentracks.data.models;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class StatisticsTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMerge() {
|
||||||
|
// given
|
||||||
|
Statistics subject = new Statistics(
|
||||||
|
Instant.ofEpochMilli(1000),
|
||||||
|
Instant.ofEpochMilli(2500),
|
||||||
|
Duration.ofMillis(1500),
|
||||||
|
Duration.ofMillis(700),
|
||||||
|
Distance.of(750.0),
|
||||||
|
Speed.of(60.0),
|
||||||
|
new AltitudeExtremities(1200, 1250),
|
||||||
|
new AltitudeGainLoss(50, 0),
|
||||||
|
HeartRate.of(100),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
Statistics append = new Statistics(
|
||||||
|
Instant.ofEpochMilli(3000),
|
||||||
|
Instant.ofEpochMilli(4000),
|
||||||
|
Duration.ofMillis(1000),
|
||||||
|
Duration.ofMillis(600),
|
||||||
|
Distance.of(350.0),
|
||||||
|
Speed.of(30.0),
|
||||||
|
new AltitudeExtremities(2800.0, 3575.0),
|
||||||
|
new AltitudeGainLoss(850, 0),
|
||||||
|
HeartRate.of(200),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
// when
|
||||||
|
Statistics result = subject.merge(append);
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertEquals(
|
||||||
|
new Statistics(
|
||||||
|
Instant.ofEpochMilli(1000),
|
||||||
|
Instant.ofEpochMilli(4000),
|
||||||
|
Duration.ofMillis(2500),
|
||||||
|
Duration.ofMillis(1300),
|
||||||
|
Distance.of(1100),
|
||||||
|
Speed.of(60),
|
||||||
|
new AltitudeExtremities(1200, 3575),
|
||||||
|
new AltitudeGainLoss(900, 0),
|
||||||
|
HeartRate.of(150),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
, result
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
-6
@@ -4,11 +4,13 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.ZoneOffset;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.data.models.ActivityType;
|
||||||
|
import de.dennisguse.opentracks.data.models.Statistics;
|
||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
|
|
||||||
//TODO Merge with TrackFilenameGeneratorTest whenever Junit5 gets available.
|
//TODO Merge with TrackFilenameGeneratorTest whenever Junit5 gets available.
|
||||||
@@ -33,12 +35,18 @@ public class TrackFilenameGenerator2Test {
|
|||||||
@Test(expected = TrackFilenameGenerator.TemplateInvalidException.class)
|
@Test(expected = TrackFilenameGenerator.TemplateInvalidException.class)
|
||||||
public void testFilenameTemplate() {
|
public void testFilenameTemplate() {
|
||||||
// given
|
// given
|
||||||
Track track = new Track();
|
Track track = new Track(
|
||||||
track.setName("Best Track");
|
null,
|
||||||
track.setUuid(UUID.fromString("f81d4fae-7dec-11d0-a765-00a0c91e6bf6"));
|
UUID.fromString("f81d4fae-7dec-11d0-a765-00a0c91e6bf6"),
|
||||||
track.getTrackStatistics().setStartTime(Instant.parse("2020-02-02T02:02:02Z"));
|
"Berlin",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
ActivityType.CYCLING,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
Statistics.DEFAULT
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String filename = subject.format(track, TrackFileFormat.GPX);
|
subject.format(track, TrackFileFormat.GPX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-4
@@ -10,6 +10,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
@@ -17,6 +18,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.TimezoneRule;
|
import de.dennisguse.opentracks.TimezoneRule;
|
||||||
|
import de.dennisguse.opentracks.data.models.Statistics;
|
||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
@@ -47,10 +49,16 @@ public class TrackFilenameGeneratorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testFilenameTemplate() {
|
public void testFilenameTemplate() {
|
||||||
// given
|
// given
|
||||||
Track track = new Track();
|
Track track = new Track(
|
||||||
track.setName("Best Track");
|
null,
|
||||||
track.setUuid(UUID.fromString("0000fee0-0000-1000-8000-00805f9b34fb"));
|
UUID.fromString("0000fee0-0000-1000-8000-00805f9b34fb"),
|
||||||
track.getTrackStatistics().setStartTime(Instant.parse("2020-02-02T02:02:02Z"));
|
"Best Track",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
null,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(Instant.parse("2020-02-02T02:02:02Z"), Instant.parse("2020-02-02T02:02:02Z"), null, null, null, null, null, null, null, null)
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String filename = subject.format(track, TrackFileFormat.GPX);
|
String filename = subject.format(track, TrackFileFormat.GPX);
|
||||||
|
|||||||
+327
-217
@@ -1,7 +1,6 @@
|
|||||||
package de.dennisguse.opentracks.io.file.importer;
|
package de.dennisguse.opentracks.io.file.importer;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
@@ -27,7 +26,6 @@ import org.junit.BeforeClass;
|
|||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mockito;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -52,6 +50,7 @@ import de.dennisguse.opentracks.content.data.TestDataUtil;
|
|||||||
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
||||||
import de.dennisguse.opentracks.data.models.ActivityType;
|
import de.dennisguse.opentracks.data.models.ActivityType;
|
||||||
import de.dennisguse.opentracks.data.models.Altitude;
|
import de.dennisguse.opentracks.data.models.Altitude;
|
||||||
|
import de.dennisguse.opentracks.data.models.AltitudeExtremities;
|
||||||
import de.dennisguse.opentracks.data.models.AltitudeGainLoss;
|
import de.dennisguse.opentracks.data.models.AltitudeGainLoss;
|
||||||
import de.dennisguse.opentracks.data.models.Cadence;
|
import de.dennisguse.opentracks.data.models.Cadence;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
@@ -60,22 +59,25 @@ import de.dennisguse.opentracks.data.models.Marker;
|
|||||||
import de.dennisguse.opentracks.data.models.Position;
|
import de.dennisguse.opentracks.data.models.Position;
|
||||||
import de.dennisguse.opentracks.data.models.Power;
|
import de.dennisguse.opentracks.data.models.Power;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
|
import de.dennisguse.opentracks.data.models.Statistics;
|
||||||
|
import de.dennisguse.opentracks.data.models.Temperature;
|
||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
|
import de.dennisguse.opentracks.data.models.TrackBuilder;
|
||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||||
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
||||||
import de.dennisguse.opentracks.io.file.exporter.TrackExporter;
|
import de.dennisguse.opentracks.io.file.exporter.TrackExporter;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerManagerCyclingPower;
|
import de.dennisguse.opentracks.sensors.SensorManager;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.CyclingPowerBluetooth;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingDistanceSpeed;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingDistanceSpeed;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingPower;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingPower;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Raw;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorTemperature;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorDataSet;
|
|
||||||
import de.dennisguse.opentracks.services.TrackRecordingService;
|
import de.dennisguse.opentracks.services.TrackRecordingService;
|
||||||
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
|
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
|
||||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export a track to {@link TrackFileFormat} and verify that the import is identical.
|
* Export a track to {@link TrackFileFormat} and verify that the import is identical.
|
||||||
@@ -87,7 +89,7 @@ import de.dennisguse.opentracks.stats.TrackStatistics;
|
|||||||
public class ExportImportTest {
|
public class ExportImportTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
|
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(50, TimeUnit.SECONDS); //TODO 5s
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public GrantPermissionRule mGrantPermissionRule = TestUtil.createGrantPermissionRule();
|
public GrantPermissionRule mGrantPermissionRule = TestUtil.createGrantPermissionRule();
|
||||||
@@ -96,13 +98,15 @@ public class ExportImportTest {
|
|||||||
@Rule
|
@Rule
|
||||||
public TimezoneRule timezoneRule = new TimezoneRule(TimeZone.getTimeZone("Europe/Berlin"));
|
public TimezoneRule timezoneRule = new TimezoneRule(TimeZone.getTimeZone("Europe/Berlin"));
|
||||||
|
|
||||||
|
private static final Context context = ApplicationProvider.getApplicationContext();
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void preSetUp() {
|
public static void preSetUp() {
|
||||||
// Prepare looper for Android's message queue
|
// Prepare looper for Android's message queue
|
||||||
if (Looper.myLooper() == null) Looper.prepare();
|
if (Looper.myLooper() == null) Looper.prepare();
|
||||||
}
|
|
||||||
|
|
||||||
private final Context context = ApplicationProvider.getApplicationContext();
|
PreferencesUtils.resetPreferences(context, true);
|
||||||
|
}
|
||||||
|
|
||||||
private final ContentProviderUtils contentProviderUtils = new ContentProviderUtils(context);
|
private final ContentProviderUtils contentProviderUtils = new ContentProviderUtils(context);
|
||||||
|
|
||||||
@@ -122,11 +126,13 @@ public class ExportImportTest {
|
|||||||
private TrackImporter trackImporter;
|
private TrackImporter trackImporter;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void fileSetup() throws IOException {
|
public void fileSetup() throws IOException, TimeoutException {
|
||||||
tmpFile = File.createTempFile("test", "test", context.getFilesDir());
|
tmpFile = File.createTempFile("test", "test", context.getFilesDir());
|
||||||
tmpFileUri = Uri.fromFile(tmpFile);
|
tmpFileUri = Uri.fromFile(tmpFile);
|
||||||
|
|
||||||
trackImporter = new TrackImporter(context, contentProviderUtils, Distance.of(200), true);
|
trackImporter = new TrackImporter(context, contentProviderUtils, Distance.of(200), true);
|
||||||
|
|
||||||
|
setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -150,24 +156,50 @@ public class ExportImportTest {
|
|||||||
Distance sensorDistance = Distance.of(10); // recording distance interval
|
Distance sensorDistance = Distance.of(10); // recording distance interval
|
||||||
|
|
||||||
sendLocation(trackPointCreator, "2020-02-02T02:02:03Z", 3.1234567, 14.0014567, 10, 13, 15, 1020.25, 1f);
|
sendLocation(trackPointCreator, "2020-02-02T02:02:03Z", 3.1234567, 14.0014567, 10, 13, 15, 1020.25, 1f);
|
||||||
contentProviderUtils.insertMarker(new Marker(trackId, service.getLastStoredTrackPointWithLocation(), "Marker 1", "Marker 1 desc", "Marker 1 category", null, null));
|
contentProviderUtils.insertMarker(
|
||||||
|
new Marker(
|
||||||
|
null,
|
||||||
|
trackId,
|
||||||
|
"Marker 1",
|
||||||
|
"Marker 1 desc",
|
||||||
|
"Marker 1 typeLocalized",
|
||||||
|
new Position(
|
||||||
|
Instant.parse("2020-02-02T02:02:03Z"),
|
||||||
|
3.1234567, 14.0014567,
|
||||||
|
Distance.of(10),
|
||||||
|
Altitude.WGS84.of(1020.25),
|
||||||
|
Distance.of(13),
|
||||||
|
null,
|
||||||
|
Speed.of(15)
|
||||||
|
),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
// A sensor-only TrackPoint
|
// A sensor-only TrackPoint
|
||||||
trackPointCreator.setClock("2020-02-02T02:02:04Z");
|
trackPointCreator.setClock("2020-02-02T02:02:04Z");
|
||||||
mockSensorData(trackPointCreator, 15f, sensorDistance, 66f, 3f, 50f, 1f);
|
mockSensorData(trackPointCreator, 15f, sensorDistance, 66f, 3f, 50f, 1f, 27);
|
||||||
|
|
||||||
trackPointCreator.setClock("2020-02-02T02:02:14Z");
|
trackPointCreator.setClock("2020-02-02T02:02:14Z"); //ignored
|
||||||
mockSensorData(trackPointCreator, 15f, null, 67f, 3f, 50f, null);
|
mockSensorData(trackPointCreator, 15f, null, 67f, 3f, 50f, null, 28);
|
||||||
trackPointCreator.setClock("2020-02-02T02:02:15Z");
|
trackPointCreator.setClock("2020-02-02T02:02:15Z");
|
||||||
mockSensorData(trackPointCreator, null, null, 68f, 3f, 50f, null);
|
mockSensorData(trackPointCreator, null, null, 68f, 3f, 50f, null, 29);
|
||||||
trackPointCreator.setClock("2020-02-02T02:02:16Z");
|
trackPointCreator.setClock("2020-02-02T02:02:16Z");
|
||||||
mockSensorData(trackPointCreator, 5f, Distance.of(2), 69f, 3f, 50f, null); // Distance will be added to next TrackPoint
|
mockSensorData(trackPointCreator, 5f, Distance.of(2), 69f, 3f, 50f, null, 30); //Distance will be added to next TrackPoint
|
||||||
|
|
||||||
sendLocation(trackPointCreator, "2020-02-02T02:02:17Z", 3.1234567, 14.0014567, 10, 13, 15, 1020.25, 0f);
|
sendLocation(trackPointCreator, "2020-02-02T02:02:17Z", 3.1234567, 14.0014567, 10, 13, 15, 1020.25, 0f);
|
||||||
contentProviderUtils.insertMarker(new Marker(trackId, service.getLastStoredTrackPointWithLocation(), "Marker 2", "Marker 2 desc", "Marker 2 category", null, null));
|
contentProviderUtils.insertMarker(
|
||||||
|
new Marker(
|
||||||
|
null,
|
||||||
|
trackId,
|
||||||
|
"Marker 2",
|
||||||
|
"Marker 2 desc",
|
||||||
|
"Marker 2 typeLocalized",
|
||||||
|
service.getLastStoredTrackPointWithLocation().position(),
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
trackPointCreator.setClock("2020-02-02T02:02:18Z");
|
trackPointCreator.setClock("2020-02-02T02:02:18Z");
|
||||||
trackPointCreator.getSensorManager().sensorDataSet = new SensorDataSet(trackPointCreator);
|
trackPointCreator.getSensorManager().clear();
|
||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
|
|
||||||
trackPointCreator.setClock("2020-02-02T02:03:20Z");
|
trackPointCreator.setClock("2020-02-02T02:03:20Z");
|
||||||
@@ -182,129 +214,170 @@ public class ExportImportTest {
|
|||||||
|
|
||||||
sendLocation(trackPointCreator, "2020-02-02T02:03:50Z", 3.1234567, 16.001, 10, 27, 15, 999.123, 0f);
|
sendLocation(trackPointCreator, "2020-02-02T02:03:50Z", 3.1234567, 16.001, 10, 27, 15, 999.123, 0f);
|
||||||
|
|
||||||
trackPointCreator.getSensorManager().sensorDataSet = new SensorDataSet(trackPointCreator);
|
trackPointCreator.getSensorManager().clear();
|
||||||
trackPointCreator.setClock("2020-02-02T02:04:00Z");
|
trackPointCreator.setClock("2020-02-02T02:04:00Z");
|
||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
|
|
||||||
Track track = contentProviderUtils.getTrack(trackId);
|
TrackBuilder trackBuilder = new TrackBuilder(contentProviderUtils.getTrack(trackId));
|
||||||
track.setActivityType(TRACK_ACTIVITY_TYPE);
|
trackBuilder.setActivityType(TRACK_ACTIVITY_TYPE);
|
||||||
track.setActivityTypeLocalized(TRACK_ACTIVITY_TYPE_LOCALIZED);
|
trackBuilder.setActivityTypeLocalized(TRACK_ACTIVITY_TYPE_LOCALIZED);
|
||||||
track.setDescription(TRACK_DESCRIPTION);
|
trackBuilder.setDescription(TRACK_DESCRIPTION);
|
||||||
contentProviderUtils.updateTrack(track);
|
contentProviderUtils.updateTrack(trackBuilder.getTrack());
|
||||||
|
|
||||||
track = contentProviderUtils.getTrack(trackId);
|
|
||||||
trackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, trackId);
|
trackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, trackId);
|
||||||
markers = contentProviderUtils.getMarkers(trackId);
|
markers = TestDataUtil.getMarkers(contentProviderUtils, trackId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@LargeTest
|
@LargeTest
|
||||||
@Test
|
@Test
|
||||||
public void track() throws TimeoutException {
|
public void track() throws TimeoutException {
|
||||||
setUp();
|
|
||||||
|
|
||||||
Track track = contentProviderUtils.getTrack(trackId);
|
Track track = contentProviderUtils.getTrack(trackId);
|
||||||
TrackStatistics trackStatistics = track.getTrackStatistics();
|
Statistics trackStatistics = track.statistics();
|
||||||
|
|
||||||
assertEquals(ZoneOffset.of("+01:00"), track.getZoneOffset());
|
assertEquals(ZoneOffset.of("+01:00"), track.zoneOffset());
|
||||||
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(222049.34375, trackStatistics.getTotalDistance().toM(), 0.01); //TODO Too low
|
|
||||||
|
|
||||||
// Speed
|
|
||||||
assertEquals(8540.359, trackStatistics.getMaxSpeed().toMPS(), 0.01);
|
|
||||||
assertEquals(3965.166, trackStatistics.getAverageSpeed().toMPS(), 0.01);
|
|
||||||
assertEquals(8540.359, trackStatistics.getAverageMovingSpeed().toMPS(), 0.01);
|
|
||||||
|
|
||||||
// Altitude
|
|
||||||
assertEquals(999.122, trackStatistics.getMinAltitude(), 0.01);
|
|
||||||
assertEquals(1020.25, trackStatistics.getMaxAltitude(), 0.01);
|
|
||||||
|
|
||||||
assertEquals(2, trackStatistics.getTotalAltitudeGain(), 0.01);
|
|
||||||
assertEquals(2, trackStatistics.getTotalAltitudeLoss(), 0.01);
|
|
||||||
|
|
||||||
List<TrackPoint> actual = TestDataUtil.getTrackPoints(contentProviderUtils, trackId);
|
List<TrackPoint> actual = TestDataUtil.getTrackPoints(contentProviderUtils, trackId);
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse("2020-02-02T02:02:02Z")),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse("2020-02-02T02:02:02Z")),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:02:03Z"),
|
Instant.parse("2020-02-02T02:02:03Z"),
|
||||||
3.123456, 14.001456, Distance.of(10),
|
3.123456, 14.001456, Distance.of(10),
|
||||||
Altitude.WGS84.of(1020.25), null,
|
Altitude.WGS84.of(1020.25), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeLoss(1f)
|
null,
|
||||||
.setAltitudeGain(1f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
null,
|
||||||
Instant.parse("2020-02-02T02:02:04Z"))
|
null,
|
||||||
.setSensorDistance(Distance.of(10))
|
null,
|
||||||
.setSpeed(Speed.of(15))
|
new AltitudeGainLoss(1, 1)
|
||||||
.setHeartRate(HeartRate.of(66))
|
),
|
||||||
.setCadence(3)
|
new TrackPoint(
|
||||||
.setPower(50)
|
null,
|
||||||
.setAltitudeLoss(1f)
|
TrackPoint.Type.TRACKPOINT,
|
||||||
.setAltitudeGain(1f),
|
new Position(
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:02:15Z"))
|
Instant.parse("2020-02-02T02:02:04Z"),
|
||||||
.setHeartRate(HeartRate.of(68))
|
null, null, null,
|
||||||
.setCadence(3)
|
null, null,
|
||||||
.setPower(50),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
Speed.of(15)),
|
||||||
|
Distance.of(10),
|
||||||
|
HeartRate.of(66),
|
||||||
|
Temperature.of(27),
|
||||||
|
Cadence.of(3),
|
||||||
|
Power.of(50),
|
||||||
|
new AltitudeGainLoss(1, 1)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
|
Position.of(Instant.parse("2020-02-02T02:02:15Z")),
|
||||||
|
null,
|
||||||
|
HeartRate.of(68),
|
||||||
|
Temperature.of(29),
|
||||||
|
Cadence.of(3),
|
||||||
|
Power.of(50),
|
||||||
|
null
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:02:17Z"),
|
Instant.parse("2020-02-02T02:02:17Z"),
|
||||||
3.123456, 14.001456, Distance.of(10),
|
3.123456, 14.001456, Distance.of(10),
|
||||||
Altitude.WGS84.of(1020.25), null,
|
Altitude.WGS84.of(1020.25), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(5)))
|
Speed.of(5)),
|
||||||
.setSensorDistance(Distance.of(2))
|
Distance.of(2),
|
||||||
.setAltitudeLoss(0f)
|
HeartRate.of(69),
|
||||||
.setAltitudeGain(0f)
|
Temperature.of(30),
|
||||||
.setHeartRate(HeartRate.of(69))
|
Cadence.of(3),
|
||||||
.setCadence(3)
|
Power.of(50),
|
||||||
.setPower(50),
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse("2020-02-02T02:02:18Z")),
|
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.SEGMENT_START_MANUAL, Instant.parse("2020-02-02T02:03:20Z")),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:03:21Z"),
|
Instant.parse("2020-02-02T02:03:21Z"),
|
||||||
3.123456, 14.002456, Distance.of(10),
|
3.123456, 14.002456, Distance.of(10),
|
||||||
Altitude.WGS84.of(999.1229858398438), null,
|
Altitude.WGS84.of(999.1229858398438), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
.setAltitudeGain(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
||||||
new Position(Instant.parse("2020-02-02T02:03:22Z"),
|
new Position(Instant.parse("2020-02-02T02:03:22Z"),
|
||||||
3.123456, 16d, Distance.of(10),
|
3.123456, 16d, Distance.of(10),
|
||||||
Altitude.WGS84.of(999.1229858398438), null,
|
Altitude.WGS84.of(999.1229858398438), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
.setAltitudeGain(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.IDLE, Instant.parse("2020-02-02T02:03:30Z"))
|
null,
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
.setAltitudeGain(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.IDLE,
|
||||||
|
Position.of(Instant.parse("2020-02-02T02:03:30Z")),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:03:50Z"),
|
Instant.parse("2020-02-02T02:03:50Z"),
|
||||||
3.123456, 16.001, Distance.of(10),
|
3.123456, 16.001, Distance.of(10),
|
||||||
Altitude.WGS84.of(999.1229858398438), null,
|
Altitude.WGS84.of(999.1229858398438), null,
|
||||||
null, Speed.of(15)))
|
null, Speed.of(15)),
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
.setAltitudeGain(0f),
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse("2020-02-02T02:04:00Z"))
|
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse("2020-02-02T02:04:00Z"))
|
||||||
), actual);
|
), actual);
|
||||||
|
|
||||||
|
assertEquals(new Statistics(
|
||||||
|
Instant.parse("2020-02-02T02:02:02Z"),
|
||||||
|
Instant.parse("2020-02-02T02:04:00Z"),
|
||||||
|
Duration.ofSeconds(56),
|
||||||
|
Duration.ofSeconds(26), //TODO Likely too low
|
||||||
|
Distance.of(222049.34375), //TODO Too low
|
||||||
|
Speed.of(22203.734375),
|
||||||
|
new AltitudeExtremities(999.1229858398438, 1020.25),
|
||||||
|
new AltitudeGainLoss(2, 2),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
),
|
||||||
|
trackStatistics);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Does not test marker images
|
//TODO Does not test marker images
|
||||||
@LargeTest
|
@LargeTest
|
||||||
@Test
|
@Test
|
||||||
public void kmz_with_trackdetail_and_sensordata() throws TimeoutException, IOException {
|
public void kmz_with_trackdetail_and_sensordata() throws IOException {
|
||||||
setUp();
|
|
||||||
|
|
||||||
// given
|
// given
|
||||||
Track track = contentProviderUtils.getTrack(trackId);
|
Track track = contentProviderUtils.getTrack(trackId);
|
||||||
|
|
||||||
@@ -323,41 +396,32 @@ public class ExportImportTest {
|
|||||||
// 1. track
|
// 1. track
|
||||||
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
||||||
assertNotNull(importedTrack);
|
assertNotNull(importedTrack);
|
||||||
assertEquals(track.getActivityType(), importedTrack.getActivityType());
|
assertEquals(track.activityType(), importedTrack.activityType());
|
||||||
assertEquals(track.getActivityTypeLocalized(), importedTrack.getActivityTypeLocalized());
|
assertEquals(track.activityTypeLocalized(), importedTrack.activityTypeLocalized());
|
||||||
assertEquals(track.getDescription(), importedTrack.getDescription());
|
assertEquals(track.description(), importedTrack.description());
|
||||||
assertEquals(track.getName(), importedTrack.getName());
|
assertEquals(track.name(), importedTrack.name());
|
||||||
|
|
||||||
// 2. trackpoints
|
// 2. trackpoints
|
||||||
TrackPointAssert a = new TrackPointAssert();
|
|
||||||
List<TrackPoint> actual = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
List<TrackPoint> actual = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
||||||
a.assertEquals(trackPoints, actual);
|
new TrackPointAssert().assertEquals(trackPoints, actual);
|
||||||
|
|
||||||
// 3. trackstatistics
|
// 3. trackstatistics
|
||||||
TrackStatistics importedTrackStatistics = importedTrack.getTrackStatistics();
|
Statistics importedTrackStatistics = importedTrack.statistics();
|
||||||
|
|
||||||
// Time
|
|
||||||
assertEquals(track.getZoneOffset(), importedTrack.getZoneOffset());
|
|
||||||
assertEquals(Instant.parse("2020-02-02T02:02:02Z"), importedTrackStatistics.getStartTime());
|
|
||||||
assertEquals(Instant.parse("2020-02-02T02:04:00Z"), importedTrackStatistics.getStopTime());
|
|
||||||
|
|
||||||
assertEquals(Duration.ofSeconds(56), importedTrackStatistics.getTotalTime());
|
|
||||||
assertEquals(Duration.ofSeconds(26), importedTrackStatistics.getMovingTime());
|
|
||||||
|
|
||||||
// Distance
|
|
||||||
assertEquals(222049.421, importedTrackStatistics.getTotalDistance().toM(), 0.01);
|
|
||||||
|
|
||||||
// Speed
|
|
||||||
assertEquals(8540.362, importedTrackStatistics.getMaxSpeed().toMPS(), 0.01);
|
|
||||||
assertEquals(3965.168, importedTrackStatistics.getAverageSpeed().toMPS(), 0.01);
|
|
||||||
assertEquals(8540.362, importedTrackStatistics.getAverageMovingSpeed().toMPS(), 0.01);
|
|
||||||
|
|
||||||
// Altitude
|
|
||||||
assertEquals(999.122, importedTrackStatistics.getMinAltitude(), 0.01);
|
|
||||||
assertEquals(1020.25, importedTrackStatistics.getMaxAltitude(), 0.01);
|
|
||||||
assertEquals(2, importedTrackStatistics.getTotalAltitudeGain(), 0.01);
|
|
||||||
assertEquals(2, importedTrackStatistics.getTotalAltitudeLoss(), 0.01);
|
|
||||||
|
|
||||||
|
assertEquals(track.zoneOffset(), importedTrack.zoneOffset());
|
||||||
|
assertEquals(new Statistics(
|
||||||
|
Instant.parse("2020-02-02T02:02:02Z"),
|
||||||
|
Instant.parse("2020-02-02T02:04:00Z"),
|
||||||
|
Duration.ofSeconds(56),
|
||||||
|
Duration.ofSeconds(26), //TODO Likely too low
|
||||||
|
Distance.of(222049.421875), //TODO Too low
|
||||||
|
Speed.of(22203.7421875),
|
||||||
|
new AltitudeExtremities(999.1229858398438, 1020.25),
|
||||||
|
new AltitudeGainLoss(2, 2),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
),
|
||||||
|
importedTrackStatistics);
|
||||||
|
|
||||||
// 4. markers
|
// 4. markers
|
||||||
assertMarkers();
|
assertMarkers();
|
||||||
@@ -365,9 +429,7 @@ public class ExportImportTest {
|
|||||||
|
|
||||||
@LargeTest
|
@LargeTest
|
||||||
@Test(expected = ImportAlreadyExistsException.class)
|
@Test(expected = ImportAlreadyExistsException.class)
|
||||||
public void kml_with_trackdetail_and_sensordata_duplicate_trackUUID() throws TimeoutException, IOException {
|
public void kml_with_trackdetail_and_sensordata_duplicate_trackUUID() throws IOException {
|
||||||
setUp();
|
|
||||||
|
|
||||||
// given
|
// given
|
||||||
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
|
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
|
||||||
editor.putBoolean(context.getString(R.string.import_prevent_reimport_key), true);
|
editor.putBoolean(context.getString(R.string.import_prevent_reimport_key), true);
|
||||||
@@ -392,8 +454,6 @@ public class ExportImportTest {
|
|||||||
@LargeTest
|
@LargeTest
|
||||||
@Test
|
@Test
|
||||||
public void gpx() throws TimeoutException, IOException {
|
public void gpx() throws TimeoutException, IOException {
|
||||||
setUp();
|
|
||||||
|
|
||||||
// given
|
// given
|
||||||
Track track = contentProviderUtils.getTrack(trackId);
|
Track track = contentProviderUtils.getTrack(trackId);
|
||||||
|
|
||||||
@@ -413,10 +473,10 @@ public class ExportImportTest {
|
|||||||
// 1. track
|
// 1. track
|
||||||
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
||||||
assertNotNull(importedTrack);
|
assertNotNull(importedTrack);
|
||||||
assertEquals(track.getActivityType(), importedTrack.getActivityType());
|
assertEquals(track.activityType(), importedTrack.activityType());
|
||||||
assertEquals(track.getActivityTypeLocalized(), importedTrack.getActivityTypeLocalized());
|
assertEquals(track.activityTypeLocalized(), importedTrack.activityTypeLocalized());
|
||||||
assertEquals(track.getDescription(), importedTrack.getDescription());
|
assertEquals(track.description(), importedTrack.description());
|
||||||
assertEquals(track.getName(), importedTrack.getName());
|
assertEquals(track.name(), importedTrack.name());
|
||||||
|
|
||||||
// 2. trackpoints
|
// 2. trackpoints
|
||||||
// The GPX exporter does not support exporting TrackPoints without lat/lng.
|
// The GPX exporter does not support exporting TrackPoints without lat/lng.
|
||||||
@@ -426,82 +486,105 @@ public class ExportImportTest {
|
|||||||
.setDelta(0.05); // speed is not fully
|
.setDelta(0.05); // speed is not fully
|
||||||
List<TrackPoint> actual = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
List<TrackPoint> actual = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
||||||
a.assertEquals(List.of(
|
a.assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:02:03Z"),
|
Instant.parse("2020-02-02T02:02:03Z"),
|
||||||
3.123456, 14.001456d, Distance.of(10),
|
3.123456, 14.001456d, Distance.of(10),
|
||||||
Altitude.WGS84.of(1020.2), null,
|
Altitude.WGS84.of(1020.2), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeLoss(1f)
|
null,
|
||||||
.setAltitudeGain(1f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(1, 1)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:02:17Z"),
|
Instant.parse("2020-02-02T02:02:17Z"),
|
||||||
3.123456, 14.001456, Distance.of(10),
|
3.123456, 14.001456, Distance.of(10),
|
||||||
Altitude.WGS84.of(1020.2), null,
|
Altitude.WGS84.of(1020.2), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(5)))
|
Speed.of(5)),
|
||||||
.setAltitudeLoss(1f)
|
Distance.of(12),
|
||||||
.setAltitudeGain(1f)
|
HeartRate.of(69),
|
||||||
.setSensorDistance(Distance.of(12))
|
Temperature.of(30),
|
||||||
.setHeartRate(69)
|
Cadence.of(3),
|
||||||
.setPower(50f)
|
Power.of(50),
|
||||||
.setCadence(3f),
|
new AltitudeGainLoss(1, 1)
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:03:21Z"),
|
Instant.parse("2020-02-02T02:03:21Z"),
|
||||||
3.123456, 14.002456, Distance.of(10),
|
3.123456, 14.002456, Distance.of(10),
|
||||||
Altitude.WGS84.of(999.0999755859375), null,
|
Altitude.WGS84.of(999.0999755859375), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
.setAltitudeGain(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:03:22Z"),
|
Instant.parse("2020-02-02T02:03:22Z"),
|
||||||
3.123456, 16d, Distance.of(10),
|
3.123456, 16d, Distance.of(10),
|
||||||
Altitude.WGS84.of(999.0999755859375), null,
|
Altitude.WGS84.of(999.0999755859375), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
.setAltitudeGain(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:03:50Z"),
|
Instant.parse("2020-02-02T02:03:50Z"),
|
||||||
3.123456, 16.001, Distance.of(10),
|
3.123456, 16.001, Distance.of(10),
|
||||||
Altitude.WGS84.of(999.0999755859375), null,
|
Altitude.WGS84.of(999.0999755859375), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(10)))
|
Speed.of(15)),
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setSpeed(Speed.of(15))
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
)
|
||||||
), actual);
|
), actual);
|
||||||
|
|
||||||
// 3. trackstatistics
|
// 3. trackstatistics
|
||||||
TrackStatistics importedTrackStatistics = importedTrack.getTrackStatistics();
|
assertEquals(track.zoneOffset(), importedTrack.zoneOffset());
|
||||||
|
|
||||||
// Time
|
Statistics importedTrackStatistics = importedTrack.statistics();
|
||||||
assertEquals(track.getZoneOffset(), importedTrack.getZoneOffset());
|
assertEquals(new Statistics(
|
||||||
assertEquals(Instant.parse("2020-02-02T02:02:03Z"), importedTrackStatistics.getStartTime());
|
Instant.parse("2020-02-02T02:02:03Z"),
|
||||||
assertEquals(Instant.parse("2020-02-02T02:03:50Z"), importedTrackStatistics.getStopTime());
|
Instant.parse("2020-02-02T02:03:50Z"),
|
||||||
|
Duration.ofSeconds(107),
|
||||||
assertEquals(Duration.ofSeconds(107), importedTrackStatistics.getTotalTime());
|
Duration.ofSeconds(107),
|
||||||
assertEquals(Duration.ofSeconds(107), importedTrackStatistics.getMovingTime());
|
Distance.of(222271.734375),
|
||||||
|
Speed.of(2077.305908203125),
|
||||||
// Distance
|
new AltitudeExtremities(999.0999755859375, 1020.2000122070312),
|
||||||
assertEquals(222271.734, importedTrackStatistics.getTotalDistance().toM(), 0.01);
|
new AltitudeGainLoss(2, 2),
|
||||||
|
null,
|
||||||
// Speed
|
null
|
||||||
assertEquals(2077.305, importedTrackStatistics.getMaxSpeed().toMPS(), 0.01);
|
),
|
||||||
assertEquals(2077.305, importedTrackStatistics.getAverageSpeed().toMPS(), 0.01);
|
importedTrackStatistics);
|
||||||
assertEquals(2077.305, importedTrackStatistics.getAverageMovingSpeed().toMPS(), 0.01);
|
|
||||||
|
|
||||||
// Altitude
|
|
||||||
assertEquals(999.099, importedTrackStatistics.getMinAltitude(), 0.01);
|
|
||||||
assertEquals(1020.2, importedTrackStatistics.getMaxAltitude(), 0.01);
|
|
||||||
assertEquals(2, importedTrackStatistics.getTotalAltitudeGain(), 0.01);
|
|
||||||
assertEquals(2, importedTrackStatistics.getTotalAltitudeLoss(), 0.01);
|
|
||||||
|
|
||||||
// 4. markers
|
// 4. markers
|
||||||
assertMarkers();
|
assertMarkers();
|
||||||
@@ -509,9 +592,7 @@ public class ExportImportTest {
|
|||||||
|
|
||||||
@LargeTest
|
@LargeTest
|
||||||
@Test(expected = ImportAlreadyExistsException.class)
|
@Test(expected = ImportAlreadyExistsException.class)
|
||||||
public void gpx_duplicate_trackUUID() throws TimeoutException, IOException {
|
public void gpx_duplicate_trackUUID() throws IOException {
|
||||||
setUp();
|
|
||||||
|
|
||||||
// given
|
// given
|
||||||
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
|
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
|
||||||
editor.putBoolean(context.getString(R.string.import_prevent_reimport_key), true);
|
editor.putBoolean(context.getString(R.string.import_prevent_reimport_key), true);
|
||||||
@@ -537,9 +618,7 @@ public class ExportImportTest {
|
|||||||
|
|
||||||
@LargeTest
|
@LargeTest
|
||||||
@Test
|
@Test
|
||||||
public void csv_export_only() throws TimeoutException, IOException {
|
public void csv_export_only() throws IOException {
|
||||||
setUp();
|
|
||||||
|
|
||||||
// given
|
// given
|
||||||
Track track = contentProviderUtils.getTrack(trackId);
|
Track track = contentProviderUtils.getTrack(trackId);
|
||||||
|
|
||||||
@@ -566,35 +645,34 @@ public class ExportImportTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertMarkers() {
|
private void assertMarkers() {
|
||||||
assertEquals(markers.size(), contentProviderUtils.getMarkers(importTrackId).size());
|
List<Marker> importedMarkers = TestDataUtil.getMarkers(contentProviderUtils, importTrackId);
|
||||||
|
assertEquals(markers.size(), importedMarkers.size());
|
||||||
|
|
||||||
List<Marker> importedMarkers = contentProviderUtils.getMarkers(importTrackId);
|
|
||||||
for (int i = 0; i < markers.size(); i++) {
|
for (int i = 0; i < markers.size(); i++) {
|
||||||
Marker marker = markers.get(i);
|
Marker marker = markers.get(i);
|
||||||
Marker importMarker = importedMarkers.get(i);
|
Marker importMarker = importedMarkers.get(i);
|
||||||
assertEquals(marker.getCategory(), importMarker.getCategory());
|
assertEquals(marker.typeLocalized(), importMarker.typeLocalized());
|
||||||
assertEquals(marker.getDescription(), importMarker.getDescription());
|
assertEquals(marker.description(), importMarker.description());
|
||||||
// assertEquals(marker.getIcon(), importMarker.getIcon()); // TODO for KML
|
assertEquals(marker.name(), importMarker.name());
|
||||||
assertEquals(marker.getName(), importMarker.getName());
|
assertNull(importMarker.photoUrl());
|
||||||
assertFalse(importMarker.hasPhoto());
|
|
||||||
|
|
||||||
assertEquals(marker.getPosition().latitude(), importMarker.getPosition().latitude(), 0.001);
|
assertEquals(marker.position().latitude(), importMarker.position().latitude(), 0.001);
|
||||||
assertEquals(marker.getPosition().longitude(), importMarker.getPosition().longitude(), 0.001);
|
assertEquals(marker.position().longitude(), importMarker.position().longitude(), 0.001);
|
||||||
assertEquals(marker.getPosition().altitude().toM(), importMarker.getPosition().altitude().toM(), 0.1);
|
assertEquals(marker.position().altitude().toM(), importMarker.position().altitude().toM(), 0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mockSensorData(TrackPointCreator trackPointCreator, Float speed, Distance distance, float heartRate, float cadence, Float power, Float altitudeGain) {
|
private static void mockSensorData(TrackPointCreator trackPointCreator, Float speed, Distance distance, float heartRate, float cadence, Float power, Float altitudeGain, float temperature) {
|
||||||
SensorDataSet sensorDataSet = trackPointCreator.getSensorManager().sensorDataSet;
|
SensorManager sensorManager = trackPointCreator.getSensorManager();
|
||||||
|
|
||||||
AggregatorCyclingPower cyclingPower = new AggregatorCyclingPower("", "");
|
AggregatorCyclingPower cyclingPower = new AggregatorCyclingPower("", "");
|
||||||
cyclingPower.add(new Raw<>(trackPointCreator.createNow(), new BluetoothHandlerManagerCyclingPower.Data(Power.of(power), null)));
|
cyclingPower.add(trackPointCreator.getNow(), new CyclingPowerBluetooth.Data(Power.of(power), null));
|
||||||
sensorDataSet.add(cyclingPower);
|
sensorManager.setAggregator(cyclingPower);
|
||||||
|
|
||||||
|
|
||||||
AggregatorHeartRate avgHeartRate = new AggregatorHeartRate("", "");
|
AggregatorHeartRate avgHeartRate = new AggregatorHeartRate("", "");
|
||||||
avgHeartRate.add(new Raw<>(trackPointCreator.createNow(), HeartRate.of(heartRate)));
|
avgHeartRate.add(trackPointCreator.getNow(), HeartRate.of(heartRate));
|
||||||
sensorDataSet.add(avgHeartRate);
|
sensorManager.setAggregator(avgHeartRate);
|
||||||
|
|
||||||
AggregatorCyclingCadence cyclingCadence = new AggregatorCyclingCadence("", "") {
|
AggregatorCyclingCadence cyclingCadence = new AggregatorCyclingCadence("", "") {
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -608,33 +686,65 @@ public class ExportImportTest {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
sensorDataSet.add(cyclingCadence);
|
sensorManager.setAggregator(cyclingCadence);
|
||||||
|
|
||||||
if (distance != null && speed != null) {
|
if (distance != null && speed != null) {
|
||||||
AggregatorCyclingDistanceSpeed distanceSpeed = Mockito.mock(AggregatorCyclingDistanceSpeed.class);
|
AggregatorCyclingDistanceSpeed aggregatorCyclingDistanceSpeed = new AggregatorCyclingDistanceSpeed("", "") {
|
||||||
Mockito.when(distanceSpeed.hasReceivedData()).thenReturn(true);
|
@NonNull
|
||||||
Mockito.when(distanceSpeed.getAggregatedValue(Mockito.any())).thenReturn(new AggregatorCyclingDistanceSpeed.Data(null, distance, Speed.of(speed)));
|
@Override
|
||||||
sensorDataSet.add(distanceSpeed);
|
public Data getAggregatedValue(Instant now) {
|
||||||
|
return new AggregatorCyclingDistanceSpeed.Data(null, distance, Speed.of(speed));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasReceivedData() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sensorManager.setAggregator(aggregatorCyclingDistanceSpeed);
|
||||||
} else {
|
} else {
|
||||||
sensorDataSet.add(new AggregatorCyclingDistanceSpeed("", ""));
|
sensorManager.setAggregator(new AggregatorCyclingDistanceSpeed("", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
mockAltitudeChange(trackPointCreator, altitudeGain);
|
mockAltitudeChange(trackPointCreator, altitudeGain);
|
||||||
|
|
||||||
trackPointCreator.onChange(sensorDataSet);
|
sensorManager.setAggregator(new AggregatorTemperature("", "'") {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Temperature getAggregatedValue(Instant now) {
|
||||||
|
return Temperature.of(temperature);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasReceivedData() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
trackPointCreator.onChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mockAltitudeChange(TrackPointCreator trackPointCreator, Float altitudeGain) {
|
private static void mockAltitudeChange(TrackPointCreator trackPointCreator, Float altitudeGain) {
|
||||||
SensorDataSet sensorDataSet = trackPointCreator.getSensorManager().sensorDataSet;
|
SensorManager sensorManager = trackPointCreator.getSensorManager();
|
||||||
|
|
||||||
if (altitudeGain != null) {
|
if (altitudeGain == null) {
|
||||||
AggregatorBarometer barometer = Mockito.mock(AggregatorBarometer.class);
|
sensorManager.getAltitudeChangeHandler().setAggregator(new AggregatorBarometer("test", null));
|
||||||
Mockito.when(barometer.hasReceivedData()).thenReturn(true);
|
return;
|
||||||
Mockito.when(barometer.getAggregatedValue(Mockito.any())).thenReturn(new AltitudeGainLoss(altitudeGain, altitudeGain));
|
|
||||||
sensorDataSet.add(barometer);
|
|
||||||
} else {
|
|
||||||
sensorDataSet.add(new AggregatorBarometer("test", null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AggregatorBarometer aggregatorBarometer = new AggregatorBarometer("", "") {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public AltitudeGainLoss getAggregatedValue(Instant now) {
|
||||||
|
return new AltitudeGainLoss(altitudeGain, altitudeGain);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasReceivedData() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sensorManager.getAltitudeChangeHandler().setAggregator(aggregatorBarometer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendLocation(TrackPointCreator trackPointCreator, String time, double latitude, double longitude, float accuracy, float verticalAccuracy, float speed, double altitude, Float altitudeGain) {
|
private void sendLocation(TrackPointCreator trackPointCreator, String time, double latitude, double longitude, float accuracy, float verticalAccuracy, float speed, double altitude, Float altitudeGain) {
|
||||||
@@ -649,6 +759,6 @@ public class ExportImportTest {
|
|||||||
mockAltitudeChange(trackPointCreator, altitudeGain);
|
mockAltitudeChange(trackPointCreator, altitudeGain);
|
||||||
|
|
||||||
trackPointCreator.setClock(time);
|
trackPointCreator.setClock(time);
|
||||||
trackPointCreator.getSensorManager().getGpsManager().onLocationChanged(location);
|
trackPointCreator.getSensorManager().getGpsHandler().onDataReceived(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+85
-118
@@ -27,14 +27,18 @@ import de.dennisguse.opentracks.content.data.TestDataUtil;
|
|||||||
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
||||||
import de.dennisguse.opentracks.data.models.ActivityType;
|
import de.dennisguse.opentracks.data.models.ActivityType;
|
||||||
import de.dennisguse.opentracks.data.models.Altitude;
|
import de.dennisguse.opentracks.data.models.Altitude;
|
||||||
|
import de.dennisguse.opentracks.data.models.AltitudeGainLoss;
|
||||||
|
import de.dennisguse.opentracks.data.models.Cadence;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
|
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||||
import de.dennisguse.opentracks.data.models.Position;
|
import de.dennisguse.opentracks.data.models.Position;
|
||||||
|
import de.dennisguse.opentracks.data.models.Power;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
|
import de.dennisguse.opentracks.data.models.Statistics;
|
||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||||
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
||||||
import de.dennisguse.opentracks.io.file.exporter.TrackExporter;
|
import de.dennisguse.opentracks.io.file.exporter.TrackExporter;
|
||||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that legacy KML/GPX formats can still be imported.
|
* Test that legacy KML/GPX formats can still be imported.
|
||||||
@@ -61,73 +65,6 @@ public class GPXTrackImporterTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check that data that contains pause (lat=100, lng=0) and resume (lat=200, lng=0) locations are restored to a segment break.
|
|
||||||
*/
|
|
||||||
@LargeTest
|
|
||||||
@Test
|
|
||||||
public void gpx_with_pause_resume() throws IOException {
|
|
||||||
// given
|
|
||||||
XMLImporter importer = new XMLImporter(new GPXTrackImporter(context, trackImporter));
|
|
||||||
InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.test.R.raw.legacy_gpx_pause_resume);
|
|
||||||
|
|
||||||
// when
|
|
||||||
// 1. import
|
|
||||||
importTrackId = importer.importFile(inputStream).get(0);
|
|
||||||
|
|
||||||
// then
|
|
||||||
// 2. track
|
|
||||||
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
|
||||||
assertNotNull(importedTrack);
|
|
||||||
assertEquals(ActivityType.UNKNOWN, importedTrack.getActivityType());
|
|
||||||
assertEquals("the category", importedTrack.getActivityTypeLocalized());
|
|
||||||
assertEquals("the description", importedTrack.getDescription());
|
|
||||||
assertEquals("2021-01-07 22:51", importedTrack.getName());
|
|
||||||
assertEquals(ActivityType.UNKNOWN, importedTrack.getActivityType());
|
|
||||||
|
|
||||||
//TODO Check trackstatistics
|
|
||||||
|
|
||||||
// 3. trackpoints
|
|
||||||
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
|
||||||
assertEquals(6, importedTrackPoints.size());
|
|
||||||
|
|
||||||
// first segment
|
|
||||||
TrackPointAssert a = new TrackPointAssert();
|
|
||||||
a.assertEquals(List.of(
|
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
|
||||||
new Position(
|
|
||||||
Instant.parse("2021-01-07T21:51:59.179Z"),
|
|
||||||
3d, 14d, null,
|
|
||||||
Altitude.WGS84.of(10), null,
|
|
||||||
null,
|
|
||||||
null)),
|
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
|
||||||
new Position(
|
|
||||||
Instant.parse("2021-01-07T21:52:00.653Z"),
|
|
||||||
3d, 14.001, null,
|
|
||||||
Altitude.WGS84.of(10), null,
|
|
||||||
null,
|
|
||||||
Speed.of(75.4192))),
|
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
|
||||||
new Position(
|
|
||||||
Instant.parse("2021-01-07T21:52:01.010Z"),
|
|
||||||
3d, 14.002, null,
|
|
||||||
Altitude.WGS84.of(10), null,
|
|
||||||
null, Speed.of(311.3948))),
|
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse("2021-01-07T21:52:02.658Z")),
|
|
||||||
|
|
||||||
// created resume trackpoint with time of next valid trackpoint
|
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse("2021-01-07T21:52:03.873Z")),
|
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
|
||||||
new Position(
|
|
||||||
Instant.parse("2021-01-07T21:52:04.103Z"),
|
|
||||||
3d, 14.003, null,
|
|
||||||
Altitude.WGS84.of(10), null,
|
|
||||||
null,
|
|
||||||
null))
|
|
||||||
), importedTrackPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
@LargeTest
|
@LargeTest
|
||||||
@Test
|
@Test
|
||||||
public void gpx_without_speed() throws IOException {
|
public void gpx_without_speed() throws IOException {
|
||||||
@@ -143,15 +80,15 @@ public class GPXTrackImporterTest {
|
|||||||
// 2. track
|
// 2. track
|
||||||
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
||||||
assertNotNull(importedTrack);
|
assertNotNull(importedTrack);
|
||||||
assertEquals("", importedTrack.getActivityTypeLocalized());
|
assertEquals("", importedTrack.activityTypeLocalized());
|
||||||
assertEquals("", importedTrack.getDescription());
|
assertEquals("", importedTrack.description());
|
||||||
assertEquals("20210907_213924.gpx", importedTrack.getName());
|
assertEquals("20210907_213924.gpx", importedTrack.name());
|
||||||
assertEquals(ActivityType.UNKNOWN, importedTrack.getActivityType());
|
assertEquals(ActivityType.UNKNOWN, importedTrack.activityType());
|
||||||
|
|
||||||
// 3. trackstatistics
|
// 3. trackstatistics
|
||||||
TrackStatistics trackStatistics = importedTrack.getTrackStatistics();
|
Statistics trackStatistics = importedTrack.statistics();
|
||||||
assertEquals(0.75, trackStatistics.getMaxSpeed().toMPS(), 0.01);
|
assertEquals(0.75, trackStatistics.maxSpeed().toMPS(), 0.01);
|
||||||
assertEquals(Duration.ofSeconds(101), trackStatistics.getMovingTime());
|
assertEquals(Duration.ofSeconds(101), trackStatistics.movingDuration());
|
||||||
|
|
||||||
// 4. trackpoints
|
// 4. trackpoints
|
||||||
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
||||||
@@ -198,15 +135,15 @@ public class GPXTrackImporterTest {
|
|||||||
// 2. track
|
// 2. track
|
||||||
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
||||||
assertNotNull(importedTrack);
|
assertNotNull(importedTrack);
|
||||||
assertEquals("", importedTrack.getActivityTypeLocalized());
|
assertEquals("", importedTrack.activityTypeLocalized());
|
||||||
assertEquals("", importedTrack.getDescription());
|
assertEquals("", importedTrack.description());
|
||||||
assertEquals("20210907_213924.gpx", importedTrack.getName());
|
assertEquals("20210907_213924.gpx", importedTrack.name());
|
||||||
assertEquals(ActivityType.UNKNOWN, importedTrack.getActivityType());
|
assertEquals(ActivityType.UNKNOWN, importedTrack.activityType());
|
||||||
|
|
||||||
// 3. trackstatistics
|
// 3. trackstatistics
|
||||||
TrackStatistics trackStatistics = importedTrack.getTrackStatistics();
|
Statistics trackStatistics = importedTrack.statistics();
|
||||||
assertEquals(5.0, trackStatistics.getMaxSpeed().toMPS(), 0.01);
|
assertEquals(5.0, trackStatistics.maxSpeed().toMPS(), 0.01);
|
||||||
assertEquals(Duration.ofSeconds(101), trackStatistics.getMovingTime());
|
assertEquals(Duration.ofSeconds(101), trackStatistics.movingDuration());
|
||||||
|
|
||||||
// 4. trackpoints
|
// 4. trackpoints
|
||||||
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
||||||
@@ -260,56 +197,86 @@ public class GPXTrackImporterTest {
|
|||||||
TrackPointAssert a = new TrackPointAssert()
|
TrackPointAssert a = new TrackPointAssert()
|
||||||
.setDelta(0.05); // speed is not fully
|
.setDelta(0.05); // speed is not fully
|
||||||
a.assertEquals(List.of(
|
a.assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:02:03Z"),
|
Instant.parse("2020-02-02T02:02:03Z"),
|
||||||
3d, 14d, Distance.of(10),
|
3d, 14d, Distance.of(10),
|
||||||
Altitude.WGS84.of(10), null,
|
Altitude.WGS84.of(10), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeLoss(1f)
|
null,
|
||||||
.setAltitudeGain(1f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(1, 1)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:02:17Z"),
|
Instant.parse("2020-02-02T02:02:17Z"),
|
||||||
3d, 14.001, Distance.of(10),
|
3d, 14.001, Distance.of(10),
|
||||||
Altitude.WGS84.of(10), null,
|
Altitude.WGS84.of(10), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(5)))
|
Speed.of(5)),
|
||||||
.setAltitudeLoss(1f)
|
Distance.of(12),
|
||||||
.setAltitudeGain(1f)
|
HeartRate.of(69),
|
||||||
.setSensorDistance(Distance.of(12))
|
null,
|
||||||
.setHeartRate(69)
|
Cadence.of(3),
|
||||||
.setPower(50f)
|
Power.of(50),
|
||||||
.setCadence(3f),
|
new AltitudeGainLoss(1, 1)
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:03:21Z"),
|
Instant.parse("2020-02-02T02:03:21Z"),
|
||||||
3d, 14.002, Distance.of(10),
|
3d, 14.002, Distance.of(10),
|
||||||
Altitude.WGS84.of(10), null,
|
Altitude.WGS84.of(10), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
.setAltitudeGain(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:03:22Z"),
|
Instant.parse("2020-02-02T02:03:22Z"),
|
||||||
3d, 16d, Distance.of(10),
|
3d, 16d, Distance.of(10),
|
||||||
Altitude.WGS84.of(10), null,
|
Altitude.WGS84.of(10), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
.setAltitudeGain(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-02-02T02:03:50Z"),
|
Instant.parse("2020-02-02T02:03:50Z"),
|
||||||
3d, 16.001, Distance.of(10),
|
3d, 16.001, Distance.of(10),
|
||||||
Altitude.WGS84.of(10), null,
|
Altitude.WGS84.of(10), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(10)))
|
Speed.of(15)),
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setSpeed(Speed.of(15))
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
)
|
||||||
), actual);
|
), actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,19 +286,19 @@ public class GPXTrackImporterTest {
|
|||||||
// given
|
// given
|
||||||
XMLImporter importer = new XMLImporter(new GPXTrackImporter(context, trackImporter));
|
XMLImporter importer = new XMLImporter(new GPXTrackImporter(context, trackImporter));
|
||||||
InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.test.R.raw.gpx_timezone);
|
InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.test.R.raw.gpx_timezone);
|
||||||
InputStream inputStreamExpected = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.test.R.raw.gpx_timezone);
|
try (InputStream inputStreamExpected = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.test.R.raw.gpx_timezone)) {
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
// when
|
||||||
|
// 1. import
|
||||||
|
importTrackId = importer.importFile(inputStream).get(0);
|
||||||
|
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
||||||
|
|
||||||
// when
|
TrackExporter trackExporter = TrackFileFormat.GPX.createTrackExporter(context, contentProviderUtils);
|
||||||
// 1. import
|
trackExporter.writeTrack(List.of(importedTrack), outputStream);
|
||||||
importTrackId = importer.importFile(inputStream).get(0);
|
|
||||||
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
|
||||||
|
|
||||||
TrackExporter trackExporter = TrackFileFormat.GPX.createTrackExporter(context, contentProviderUtils);
|
// then
|
||||||
trackExporter.writeTrack(List.of(importedTrack), outputStream);
|
assertEquals(new String(inputStreamExpected.readAllBytes(), StandardCharsets.UTF_8), outputStream.toString());
|
||||||
|
}
|
||||||
// then
|
|
||||||
assertEquals(new String(inputStreamExpected.readAllBytes(), StandardCharsets.UTF_8), outputStream.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+22
-27
@@ -73,13 +73,13 @@ public class KMLTrackImporterTest {
|
|||||||
// 1. track
|
// 1. track
|
||||||
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
||||||
assertNotNull(importedTrack);
|
assertNotNull(importedTrack);
|
||||||
assertEquals("", importedTrack.getActivityTypeLocalized());
|
assertEquals("", importedTrack.activityTypeLocalized());
|
||||||
assertEquals("", importedTrack.getDescription());
|
assertEquals("", importedTrack.description());
|
||||||
assertEquals("", importedTrack.getName());
|
assertEquals("", importedTrack.name());
|
||||||
assertEquals(ActivityType.UNKNOWN, importedTrack.getActivityType());
|
assertEquals(ActivityType.UNKNOWN, importedTrack.activityType());
|
||||||
|
|
||||||
// 2. markers
|
// 2. markers
|
||||||
assertEquals(0, contentProviderUtils.getMarkers(importTrackId).size());
|
assertEquals(0, TestDataUtil.getMarkers(contentProviderUtils, importTrackId).size());
|
||||||
|
|
||||||
// 3. trackpoints
|
// 3. trackpoints
|
||||||
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
||||||
@@ -129,13 +129,13 @@ public class KMLTrackImporterTest {
|
|||||||
// 1. track
|
// 1. track
|
||||||
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
||||||
assertNotNull(importedTrack);
|
assertNotNull(importedTrack);
|
||||||
assertEquals("", importedTrack.getActivityTypeLocalized());
|
assertEquals("", importedTrack.activityTypeLocalized());
|
||||||
assertEquals("", importedTrack.getDescription());
|
assertEquals("", importedTrack.description());
|
||||||
assertEquals("", importedTrack.getName());
|
assertEquals("", importedTrack.name());
|
||||||
assertEquals(ActivityType.UNKNOWN, importedTrack.getActivityType());
|
assertEquals(ActivityType.UNKNOWN, importedTrack.activityType());
|
||||||
|
|
||||||
// 2. markers
|
// 2. markers
|
||||||
assertEquals(0, contentProviderUtils.getMarkers(importTrackId).size());
|
assertEquals(0, TestDataUtil.getMarkers(contentProviderUtils, importTrackId).size());
|
||||||
|
|
||||||
// 3. trackpoints
|
// 3. trackpoints
|
||||||
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
||||||
@@ -170,13 +170,14 @@ public class KMLTrackImporterTest {
|
|||||||
// 1. track
|
// 1. track
|
||||||
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
||||||
assertNotNull(importedTrack);
|
assertNotNull(importedTrack);
|
||||||
assertEquals("unknown", importedTrack.getActivityTypeLocalized());
|
assertEquals("unknown", importedTrack.activityTypeLocalized());
|
||||||
assertEquals("Test Track", importedTrack.getDescription());
|
assertEquals("Test Track", importedTrack.description());
|
||||||
assertEquals("2020-11-28 18:06", importedTrack.getName());
|
assertEquals("2020-11-28 18:06", importedTrack.name());
|
||||||
assertEquals(ActivityType.UNKNOWN, importedTrack.getActivityType());
|
assertEquals(ActivityType.UNKNOWN, importedTrack.activityType());
|
||||||
|
|
||||||
// 2. markers
|
// 2. markers
|
||||||
assertEquals(1, contentProviderUtils.getMarkers(importTrackId).size());
|
//TODO Check actual content (Marker should be record for this)
|
||||||
|
assertEquals(1, TestDataUtil.getMarkers(contentProviderUtils, importTrackId).size());
|
||||||
|
|
||||||
// 3. trackpoints
|
// 3. trackpoints
|
||||||
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
|
||||||
@@ -189,24 +190,21 @@ public class KMLTrackImporterTest {
|
|||||||
12.340097, 1.234156, null,
|
12.340097, 1.234156, null,
|
||||||
Altitude.WGS84.of(469.286376953125), null,
|
Altitude.WGS84.of(469.286376953125), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(0.539)))
|
Speed.of(0.539))),
|
||||||
.setAltitudeGain(0f),
|
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-11-28T17:06:25.448Z"),
|
Instant.parse("2020-11-28T17:06:25.448Z"),
|
||||||
12.340036, 1.23415, null,
|
12.340036, 1.23415, null,
|
||||||
Altitude.WGS84.of(439.1626281738281), null,
|
Altitude.WGS84.of(439.1626281738281), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(0.1577)))
|
Speed.of(0.1577))),
|
||||||
.setAltitudeGain(0f),
|
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-11-28T17:06:47.888Z"),
|
Instant.parse("2020-11-28T17:06:47.888Z"),
|
||||||
12.340057, 1.23405, null,
|
12.340057, 1.23405, null,
|
||||||
Altitude.WGS84.of(421.8070983886719), null,
|
Altitude.WGS84.of(421.8070983886719), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(0)))
|
Speed.ZERO)),
|
||||||
.setAltitudeGain(0f),
|
|
||||||
// created resume trackpoint with time of next valid trackpoint
|
// created resume trackpoint with time of next valid trackpoint
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
||||||
new Position(
|
new Position(
|
||||||
@@ -214,24 +212,21 @@ public class KMLTrackImporterTest {
|
|||||||
12.340057, 1.23405, null,
|
12.340057, 1.23405, null,
|
||||||
Altitude.WGS84.of(419.93902587890625), null,
|
Altitude.WGS84.of(419.93902587890625), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(0)))
|
Speed.ZERO)),
|
||||||
.setAltitudeGain(0f),
|
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-11-28T17:06:56.905Z"),
|
Instant.parse("2020-11-28T17:06:56.905Z"),
|
||||||
12.340057, 1.23405, null,
|
12.340057, 1.23405, null,
|
||||||
Altitude.WGS84.of(419.9036560058594), null,
|
Altitude.WGS84.of(419.9036560058594), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(0)))
|
Speed.ZERO)),
|
||||||
.setAltitudeGain(0f),
|
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse("2020-11-28T17:07:20.870Z"),
|
Instant.parse("2020-11-28T17:07:20.870Z"),
|
||||||
12.340082, 1.234046, null,
|
12.340082, 1.234046, null,
|
||||||
Altitude.WGS84.of(417.99432373046875), null,
|
Altitude.WGS84.of(417.99432373046875), null,
|
||||||
null,
|
null,
|
||||||
Speed.of(0)))
|
Speed.ZERO))
|
||||||
.setAltitudeGain(0f)
|
|
||||||
), importedTrackPoints);
|
), importedTrackPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+27
-41
@@ -16,61 +16,47 @@ public class TrackPointAssert {
|
|||||||
public void assertEquals(TrackPoint expected, TrackPoint actual) {
|
public void assertEquals(TrackPoint expected, TrackPoint actual) {
|
||||||
Assert.assertEquals("time", expected.getTime(), actual.getTime());
|
Assert.assertEquals("time", expected.getTime(), actual.getTime());
|
||||||
|
|
||||||
Assert.assertEquals("type", expected.getType(), actual.getType());
|
Assert.assertEquals("type", expected.type(), actual.type());
|
||||||
|
|
||||||
Assert.assertEquals("has location,", expected.hasLocation(), actual.hasLocation());
|
Assert.assertEquals("has location,", expected.position().hasLocation(), actual.position().hasLocation());
|
||||||
if (expected.hasLocation()) {
|
if (expected.position().hasLocation()) {
|
||||||
Assert.assertEquals("latitude", expected.getPosition().latitude(), actual.getPosition().latitude(), 0.001);
|
Assert.assertEquals("latitude", expected.position().latitude(), actual.position().latitude(), 0.001);
|
||||||
Assert.assertEquals("longitude", expected.getPosition().longitude(), actual.getPosition().longitude(), 0.001);
|
Assert.assertEquals("longitude", expected.position().longitude(), actual.position().longitude(), 0.001);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals("has altitude", expected.hasAltitude(), actual.hasAltitude());
|
Assert.assertEquals("has altitude", expected.position().hasAltitude(), actual.position().hasAltitude());
|
||||||
if (expected.hasAltitude()) {
|
if (expected.position().hasAltitude()) {
|
||||||
Assert.assertEquals("altitude", expected.getAltitude().toM(), actual.getAltitude().toM(), delta);
|
Assert.assertEquals("altitude", expected.position().altitude().toM(), actual.position().altitude().toM(), delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals("has altitudeGain", expected.hasAltitudeGain(), actual.hasAltitudeGain());
|
Assert.assertEquals("altitudeGainLoss", expected.altitudeGainLoss(), actual.altitudeGainLoss());
|
||||||
if (expected.hasAltitudeGain()) {
|
|
||||||
Assert.assertEquals("altitudeGain", expected.getAltitudeGain(), actual.getAltitudeGain(), delta);
|
Assert.assertEquals("has speed", expected.position().hasSpeed(), actual.position().hasSpeed());
|
||||||
}
|
if (expected.position().hasSpeed()) {
|
||||||
Assert.assertEquals("has altitudeLoss", expected.hasAltitudeLoss(), actual.hasAltitudeLoss());
|
Assert.assertEquals("speed", expected.position().speed().toMPS(), actual.position().speed().toMPS(), delta);
|
||||||
if (expected.hasAltitudeLoss()) {
|
|
||||||
Assert.assertEquals("altitudeLoss", expected.getAltitudeLoss(), actual.getAltitudeLoss(), delta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals("has speed", expected.hasSpeed(), actual.hasSpeed());
|
Assert.assertEquals("has horizontalAccuracy", expected.position().hasHorizontalAccuracy(), actual.position().hasHorizontalAccuracy());
|
||||||
if (expected.hasSpeed()) {
|
if (expected.position().hasHorizontalAccuracy()) {
|
||||||
Assert.assertEquals("speed", expected.getSpeed().toMPS(), actual.getSpeed().toMPS(), delta);
|
Assert.assertEquals("horizontalAccuracy", expected.position().horizontalAccuracy().toM(), actual.position().horizontalAccuracy().toM(), delta);
|
||||||
|
}
|
||||||
|
Assert.assertEquals("has verticalAccuracy", expected.position().hasVerticalAccuracy(), actual.position().hasVerticalAccuracy());
|
||||||
|
if (expected.position().hasVerticalAccuracy()) {
|
||||||
|
Assert.assertEquals("verticalAccuracy", expected.position().verticalAccuracy().toM(), actual.position().verticalAccuracy().toM(), delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals("has horizontalAccuracy", expected.hasHorizontalAccuracy(), actual.hasHorizontalAccuracy());
|
Assert.assertEquals("has sensorDistance", expected.sensorDistance() != null, actual.sensorDistance() != null);
|
||||||
if (expected.hasHorizontalAccuracy()) {
|
if (expected.sensorDistance() != null) {
|
||||||
Assert.assertEquals("horizontalAccuracy", expected.getHorizontalAccuracy().toM(), actual.getHorizontalAccuracy().toM(), delta);
|
Assert.assertEquals("sensorDistance", expected.sensorDistance().toM(), actual.sensorDistance().toM(), delta);
|
||||||
}
|
|
||||||
Assert.assertEquals("has verticalAccuracy", expected.hasVerticalAccuracy(), actual.hasVerticalAccuracy());
|
|
||||||
if (expected.hasVerticalAccuracy()) {
|
|
||||||
Assert.assertEquals("verticalAccuracy", expected.getVerticalAccuracy().toM(), actual.getVerticalAccuracy().toM(), delta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals("has sensorDistance", expected.hasSensorDistance(), actual.hasSensorDistance());
|
Assert.assertEquals("heartRate", expected.heartRate(), actual.heartRate());
|
||||||
if (expected.hasSensorDistance()) {
|
|
||||||
Assert.assertEquals("sensorDistance", expected.getSensorDistance().toM(), actual.getSensorDistance().toM(), delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertEquals("has heartrate", expected.hasHeartRate(), actual.hasHeartRate());
|
Assert.assertEquals("temperature", expected.temperature(), actual.temperature());
|
||||||
if (expected.hasHeartRate()) {
|
|
||||||
Assert.assertEquals("heartrate", expected.getHeartRate(), actual.getHeartRate());
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertEquals("has power", expected.hasPower(), actual.hasPower());
|
Assert.assertEquals("power", expected.power(), actual.power());
|
||||||
if (expected.hasPower()) {
|
|
||||||
Assert.assertEquals("power", expected.getPower(), actual.getPower());
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertEquals("has cadence", expected.hasCadence(), actual.hasCadence());
|
Assert.assertEquals("cadence", expected.cadence(), actual.cadence());
|
||||||
if (expected.hasCadence()) {
|
|
||||||
Assert.assertEquals("cadence", expected.getCadence(), actual.getCadence());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assertEquals(List<TrackPoint> expected, List<TrackPoint> actual) {
|
public void assertEquals(List<TrackPoint> expected, List<TrackPoint> actual) {
|
||||||
|
|||||||
@@ -0,0 +1,224 @@
|
|||||||
|
package de.dennisguse.opentracks.publicapi;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class DataProviderTest {
|
||||||
|
|
||||||
|
private final ContentResolver resolver = ApplicationProvider.getApplicationContext().getContentResolver();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void supportsVersion2_tracks() {
|
||||||
|
// given
|
||||||
|
Uri uri = Uri.parse(ContentProviderUtils.CONTENT_BASE_URI + "/dashboard/tracks/1");
|
||||||
|
String[] expectedTracksColumns = new String[]{
|
||||||
|
"_id",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"category",
|
||||||
|
"activity_type_localized",
|
||||||
|
"starttime",
|
||||||
|
"stoptime",
|
||||||
|
"totaltime",
|
||||||
|
"movingtime",
|
||||||
|
"totaldistance",
|
||||||
|
"maxspeed",
|
||||||
|
"avgspeed",
|
||||||
|
"avgmovingspeed",
|
||||||
|
"minelevation",
|
||||||
|
"maxelevation",
|
||||||
|
"elevationgain",
|
||||||
|
"elevationloss"
|
||||||
|
};
|
||||||
|
|
||||||
|
// when
|
||||||
|
try (Cursor cursor = resolver.query(
|
||||||
|
uri,
|
||||||
|
expectedTracksColumns,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)) {
|
||||||
|
// then
|
||||||
|
assertEquals("vnd.android.cursor.dir/vnd.de.dennisguse.track", resolver.getType(uri));
|
||||||
|
|
||||||
|
assertNotNull(cursor);
|
||||||
|
assertArrayEquals(expectedTracksColumns, cursor.getColumnNames());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void supportsVersion2_trackpoints() {
|
||||||
|
// given
|
||||||
|
Uri uri = Uri.parse(ContentProviderUtils.CONTENT_BASE_URI + "/dashboard/trackpoints/1");
|
||||||
|
String[] expectedTrackpointsColumns = {
|
||||||
|
"_id",
|
||||||
|
"trackid",
|
||||||
|
"latitude",
|
||||||
|
"longitude",
|
||||||
|
"time",
|
||||||
|
"type",
|
||||||
|
"speed"
|
||||||
|
};
|
||||||
|
|
||||||
|
// when
|
||||||
|
try (Cursor cursor = resolver.query(
|
||||||
|
uri,
|
||||||
|
expectedTrackpointsColumns,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)) {
|
||||||
|
// then
|
||||||
|
assertEquals("vnd.android.cursor.dir/vnd.de.dennisguse.trackpoint", resolver.getType(uri));
|
||||||
|
|
||||||
|
assertNotNull(cursor);
|
||||||
|
assertArrayEquals(expectedTrackpointsColumns, cursor.getColumnNames());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void supportsVersion2_markers() {
|
||||||
|
// given
|
||||||
|
Uri uri = Uri.parse(ContentProviderUtils.CONTENT_BASE_URI + "/dashboard/markers/1");
|
||||||
|
String[] expectedMarkersColumns = {
|
||||||
|
"_id",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"category",
|
||||||
|
"trackid",
|
||||||
|
"longitude",
|
||||||
|
"latitude",
|
||||||
|
"photoUrl",
|
||||||
|
"icon"
|
||||||
|
};
|
||||||
|
|
||||||
|
// when
|
||||||
|
try (Cursor cursor = resolver.query(
|
||||||
|
uri,
|
||||||
|
expectedMarkersColumns,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)) {
|
||||||
|
// then
|
||||||
|
assertEquals("vnd.android.cursor.dir/vnd.de.dennisguse.waypoint", resolver.getType(uri));
|
||||||
|
|
||||||
|
assertNotNull(cursor);
|
||||||
|
assertArrayEquals(expectedMarkersColumns, cursor.getColumnNames());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void supportsVersion3_tracks() {
|
||||||
|
// given
|
||||||
|
Uri uri = Uri.parse(ContentProviderUtils.CONTENT_BASE_URI + "/dashboard/tracks/1");
|
||||||
|
String[] expectedTracksColumns = {
|
||||||
|
"_id",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"activity_type",
|
||||||
|
"activity_type_localized",
|
||||||
|
"time_start",
|
||||||
|
"time_stop",
|
||||||
|
"duration_total",
|
||||||
|
"duration_moving",
|
||||||
|
"distance",
|
||||||
|
"speed_max",
|
||||||
|
"altitude_min",
|
||||||
|
"altitude_max",
|
||||||
|
"altitude_gain",
|
||||||
|
"altitude_loss"
|
||||||
|
};
|
||||||
|
|
||||||
|
// when
|
||||||
|
try (Cursor cursor = resolver.query(
|
||||||
|
uri,
|
||||||
|
expectedTracksColumns,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)) {
|
||||||
|
// then
|
||||||
|
assertEquals("vnd.android.cursor.dir/vnd.de.dennisguse.track", resolver.getType(uri));
|
||||||
|
|
||||||
|
assertNotNull(cursor);
|
||||||
|
assertArrayEquals(expectedTracksColumns, cursor.getColumnNames());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void supportsVersion3_trackpoints() {
|
||||||
|
//given
|
||||||
|
Uri uri = Uri.parse(ContentProviderUtils.CONTENT_BASE_URI + "/dashboard/trackpoints/1");
|
||||||
|
String[] expectedTrackpointsColumns = {
|
||||||
|
"_id",
|
||||||
|
"trackid",
|
||||||
|
"latitude",
|
||||||
|
"longitude",
|
||||||
|
"time",
|
||||||
|
"type",
|
||||||
|
"speed"
|
||||||
|
};
|
||||||
|
|
||||||
|
// when
|
||||||
|
try (Cursor cursor = resolver.query(
|
||||||
|
uri,
|
||||||
|
expectedTrackpointsColumns,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)) {
|
||||||
|
//then
|
||||||
|
assertEquals("vnd.android.cursor.dir/vnd.de.dennisguse.trackpoint", resolver.getType(uri));
|
||||||
|
|
||||||
|
assertNotNull(cursor);
|
||||||
|
assertArrayEquals(expectedTrackpointsColumns, cursor.getColumnNames());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void supportsVersion3_markers() {
|
||||||
|
// given
|
||||||
|
Uri uri = Uri.parse(ContentProviderUtils.CONTENT_BASE_URI + "/dashboard/markers/1");
|
||||||
|
String[] expectedMarkersColumns = {
|
||||||
|
"_id",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"marker_type_localized",
|
||||||
|
"trackid",
|
||||||
|
"latitude",
|
||||||
|
"longitude",
|
||||||
|
"photoUrl"
|
||||||
|
};
|
||||||
|
|
||||||
|
// when
|
||||||
|
try (Cursor cursor = resolver.query(
|
||||||
|
uri,
|
||||||
|
expectedMarkersColumns,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)) {
|
||||||
|
// then
|
||||||
|
assertEquals("vnd.android.cursor.dir/vnd.de.dennisguse.waypoint", resolver.getType(uri));
|
||||||
|
|
||||||
|
assertNotNull(cursor);
|
||||||
|
assertArrayEquals(expectedMarkersColumns, cursor.getColumnNames());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,9 +49,9 @@ public class PublicApiTest {
|
|||||||
List<Track> tracks = new ContentProviderUtils(context).getTracks();
|
List<Track> tracks = new ContentProviderUtils(context).getTracks();
|
||||||
Assert.assertEquals(1, tracks.size());
|
Assert.assertEquals(1, tracks.size());
|
||||||
Track track = tracks.get(0);
|
Track track = tracks.get(0);
|
||||||
Assert.assertEquals("trackName", track.getName());
|
Assert.assertEquals("trackName", track.name());
|
||||||
Assert.assertEquals("activityTypeLocalized", track.getActivityTypeLocalized());
|
Assert.assertEquals("activityTypeLocalized", track.activityTypeLocalized());
|
||||||
Assert.assertEquals("airplane", track.getActivityType().getId());
|
Assert.assertEquals("airplane", track.activityType().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
import de.dennisguse.opentracks.data.models.Position;
|
import de.dennisguse.opentracks.data.models.Position;
|
||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class GpsStatusTest {
|
public class GpsStatusTest {
|
||||||
@@ -82,16 +81,16 @@ public class GpsStatusTest {
|
|||||||
|
|
||||||
// when / then
|
// when / then
|
||||||
subject.start();
|
subject.start();
|
||||||
subject.onNewTrackPoint(new TrackPoint(TrackPoint.Type.TRACKPOINT, Position.of(badFix, Instant.now())));
|
subject.onNewTrackPoint(Position.of(badFix, Instant.now()));
|
||||||
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_BAD), statusList);
|
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_BAD), statusList);
|
||||||
|
|
||||||
subject.onNewTrackPoint(new TrackPoint(TrackPoint.Type.TRACKPOINT, Position.of(ok, Instant.now())));
|
subject.onNewTrackPoint(Position.of(ok, Instant.now()));
|
||||||
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_BAD, GPS_SIGNAL_FIX), statusList);
|
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_BAD, GPS_SIGNAL_FIX), statusList);
|
||||||
|
|
||||||
subject.onNewTrackPoint(new TrackPoint(TrackPoint.Type.TRACKPOINT, Position.of(ok, Instant.now())));
|
subject.onNewTrackPoint(Position.of(ok, Instant.now()));
|
||||||
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_BAD, GPS_SIGNAL_FIX), statusList);
|
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_BAD, GPS_SIGNAL_FIX), statusList);
|
||||||
|
|
||||||
subject.onNewTrackPoint(new TrackPoint(TrackPoint.Type.TRACKPOINT, Position.of(badFix, Instant.now())));
|
subject.onNewTrackPoint(Position.of(badFix, Instant.now()));
|
||||||
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_BAD, GPS_SIGNAL_FIX, GPS_SIGNAL_BAD), statusList);
|
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_BAD, GPS_SIGNAL_FIX, GPS_SIGNAL_BAD), statusList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,13 +105,13 @@ public class GpsStatusTest {
|
|||||||
|
|
||||||
// when / then
|
// when / then
|
||||||
subject.start();
|
subject.start();
|
||||||
subject.onNewTrackPoint(new TrackPoint(TrackPoint.Type.TRACKPOINT, Position.of(ok, Instant.now().minusMillis(1000))));
|
subject.onNewTrackPoint(Position.of(ok, Instant.now().minusMillis(1000)));
|
||||||
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX), statusList);
|
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX), statusList);
|
||||||
|
|
||||||
subject.determineGpsStatusByTime(Instant.now());
|
subject.determineGpsStatusByTime(Instant.now());
|
||||||
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX, GPS_SIGNAL_LOST), statusList);
|
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX, GPS_SIGNAL_LOST), statusList);
|
||||||
|
|
||||||
subject.onNewTrackPoint(new TrackPoint(TrackPoint.Type.TRACKPOINT, Position.of(ok, Instant.now())));
|
subject.onNewTrackPoint(Position.of(ok, Instant.now()));
|
||||||
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX, GPS_SIGNAL_LOST, GPS_SIGNAL_FIX), statusList);
|
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX, GPS_SIGNAL_LOST, GPS_SIGNAL_FIX), statusList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,13 +132,13 @@ public class GpsStatusTest {
|
|||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
assertEquals(List.of(GPS_ENABLED), statusList);
|
assertEquals(List.of(GPS_ENABLED), statusList);
|
||||||
|
|
||||||
subject.onNewTrackPoint(new TrackPoint(TrackPoint.Type.TRACKPOINT, Position.of(ok, Instant.now())));
|
subject.onNewTrackPoint(Position.of(ok, Instant.now()));
|
||||||
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX), statusList);
|
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX), statusList);
|
||||||
|
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX, GPS_SIGNAL_LOST), statusList);
|
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX, GPS_SIGNAL_LOST), statusList);
|
||||||
|
|
||||||
subject.onNewTrackPoint(new TrackPoint(TrackPoint.Type.TRACKPOINT, Position.of(badFix, Instant.now())));
|
subject.onNewTrackPoint(Position.of(badFix, Instant.now()));
|
||||||
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX, GPS_SIGNAL_LOST, GPS_SIGNAL_BAD), statusList);
|
assertEquals(List.of(GPS_ENABLED, GPS_SIGNAL_FIX, GPS_SIGNAL_LOST, GPS_SIGNAL_BAD), statusList);
|
||||||
|
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@@ -13,11 +13,11 @@ public class BluetoothHandlerBarometricPressureTest {
|
|||||||
@Test
|
@Test
|
||||||
public void parseEnvironmentalSensing_Pa() {
|
public void parseEnvironmentalSensing_Pa() {
|
||||||
// given
|
// given
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerBarometricPressure.BAROMETRIC_PRESSURE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BarometerBluetooth.BAROMETRIC_PRESSURE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{(byte) 0xB2, (byte) 0x48, (byte) 0x0F, (byte) 0x00});
|
characteristic.setValue(new byte[]{(byte) 0xB2, (byte) 0x48, (byte) 0x0F, (byte) 0x00});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
AtmosphericPressure pressure = BluetoothHandlerBarometricPressure.parseEnvironmentalSensing(characteristic);
|
AtmosphericPressure pressure = BarometerBluetooth.parseEnvironmentalSensing(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(AtmosphericPressure.ofHPA(1001.65f), pressure);
|
assertEquals(AtmosphericPressure.ofHPA(1001.65f), pressure);
|
||||||
+6
-6
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@@ -8,16 +8,16 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.HeartRate;
|
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||||
|
|
||||||
public class BluetoothHandlerManagerHeartRateTest {
|
public class BluetoothHandlerHeartRateTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseHeartRate_uint8() {
|
public void parseHeartRate_uint8() {
|
||||||
// given
|
// given
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerManagerHeartRate.HEARTRATE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(HeartRateBluetooth.HEARTRATE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x02, 0x3C});
|
characteristic.setValue(new byte[]{0x02, 0x3C});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
HeartRate heartRate = BluetoothHandlerManagerHeartRate.parseHeartRate(characteristic);
|
HeartRate heartRate = HeartRateBluetooth.parseHeartRate(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(HeartRate.of(60), heartRate);
|
assertEquals(HeartRate.of(60), heartRate);
|
||||||
@@ -26,11 +26,11 @@ public class BluetoothHandlerManagerHeartRateTest {
|
|||||||
@Test
|
@Test
|
||||||
public void parseHeartRate_uint16() {
|
public void parseHeartRate_uint16() {
|
||||||
// given
|
// given
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerManagerHeartRate.HEARTRATE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(HeartRateBluetooth.HEARTRATE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x01, 0x01, 0x01});
|
characteristic.setValue(new byte[]{0x01, 0x01, 0x01});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
HeartRate heartRate = BluetoothHandlerManagerHeartRate.parseHeartRate(characteristic);
|
HeartRate heartRate = HeartRateBluetooth.parseHeartRate(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(HeartRate.of(257), heartRate);
|
assertEquals(HeartRate.of(257), heartRate);
|
||||||
+8
-8
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
@@ -8,14 +8,14 @@ import android.util.Pair;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BluetoothHandlerCyclingDistanceSpeedTest {
|
public class CyclingDistanceSpeedBluetoothTest {
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingSpeedCadence_crankOnly() {
|
public void parseCyclingSpeedCadence_crankOnly() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerCyclingDistanceSpeed.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(CyclingDistanceSpeedBluetooth.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x02, (byte) 0xC8, 0x00, 0x00, 0x00, 0x06, (byte) 0x99});
|
characteristic.setValue(new byte[]{0x02, (byte) 0xC8, 0x00, 0x00, 0x00, 0x06, (byte) 0x99});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Pair<BluetoothHandlerCyclingDistanceSpeed.WheelData, BluetoothHandlerCyclingCadence.CrankData> sensor = BluetoothHandlerCyclingDistanceSpeed.parseCyclingCrankAndWheel("address", "sensorName", characteristic);
|
Pair<CyclingDistanceSpeedBluetooth.WheelData, CyclingCadenceBluetooth.CrankData> sensor = CyclingDistanceSpeedBluetooth.parseCyclingCrankAndWheel(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertNull(sensor.first);
|
assertNull(sensor.first);
|
||||||
@@ -24,11 +24,11 @@ public class BluetoothHandlerCyclingDistanceSpeedTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingSpeedCadence_wheelOnly() {
|
public void parseCyclingSpeedCadence_wheelOnly() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerCyclingDistanceSpeed.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(CyclingDistanceSpeedBluetooth.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x01, (byte) 0xFF, (byte) 0xFF, 0, 1, 0x45, (byte) 0x99});
|
characteristic.setValue(new byte[]{0x01, (byte) 0xFF, (byte) 0xFF, 0, 1, 0x45, (byte) 0x99});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Pair<BluetoothHandlerCyclingDistanceSpeed.WheelData, BluetoothHandlerCyclingCadence.CrankData> sensor = BluetoothHandlerCyclingDistanceSpeed.parseCyclingCrankAndWheel("address", "sensorName", characteristic);
|
Pair<CyclingDistanceSpeedBluetooth.WheelData, CyclingCadenceBluetooth.CrankData> sensor = CyclingDistanceSpeedBluetooth.parseCyclingCrankAndWheel(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(65535 + 16777216, sensor.first.wheelRevolutionsCount());
|
assertEquals(65535 + 16777216, sensor.first.wheelRevolutionsCount());
|
||||||
@@ -37,11 +37,11 @@ public class BluetoothHandlerCyclingDistanceSpeedTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingSpeedCadence_crankWheel() {
|
public void parseCyclingSpeedCadence_crankWheel() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerCyclingDistanceSpeed.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(CyclingDistanceSpeedBluetooth.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x03, (byte) 0xC8, 0x00, 0x00, 0x01, 0x06, (byte) 0x99, (byte) 0xE1, 0x00, 0x45, (byte) 0x99});
|
characteristic.setValue(new byte[]{0x03, (byte) 0xC8, 0x00, 0x00, 0x01, 0x06, (byte) 0x99, (byte) 0xE1, 0x00, 0x45, (byte) 0x99});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Pair<BluetoothHandlerCyclingDistanceSpeed.WheelData, BluetoothHandlerCyclingCadence.CrankData> sensor = BluetoothHandlerCyclingDistanceSpeed.parseCyclingCrankAndWheel("address", "sensorName", characteristic);
|
Pair<CyclingDistanceSpeedBluetooth.WheelData, CyclingCadenceBluetooth.CrankData> sensor = CyclingDistanceSpeedBluetooth.parseCyclingCrankAndWheel(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(200 + 16777216, sensor.first.wheelRevolutionsCount());
|
assertEquals(200 + 16777216, sensor.first.wheelRevolutionsCount());
|
||||||
+6
-6
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@@ -6,15 +6,15 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BluetoothHandlerCyclingPowerTest {
|
public class CyclingPowerBluetoothTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingPower_power() {
|
public void parseCyclingPower_power() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerManagerCyclingPower.CYCLING_POWER.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(CyclingPowerBluetooth.CYCLING_POWER.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0, 0, 40, 0});
|
characteristic.setValue(new byte[]{0, 0, 40, 0});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
BluetoothHandlerManagerCyclingPower.Data powerCadence = BluetoothHandlerManagerCyclingPower.parseCyclingPower(characteristic);
|
CyclingPowerBluetooth.Data powerCadence = CyclingPowerBluetooth.parseCyclingPower(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(40, powerCadence.power().getW(), 0.01);
|
assertEquals(40, powerCadence.power().getW(), 0.01);
|
||||||
@@ -22,11 +22,11 @@ public class BluetoothHandlerCyclingPowerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingPower_power_with_cadence() {
|
public void parseCyclingPower_power_with_cadence() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerManagerCyclingPower.CYCLING_POWER.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(CyclingPowerBluetooth.CYCLING_POWER.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x2C, 0x00, 0x00, 0x00, (byte) 0x9F, 0x00, 0x0C, 0x00, (byte) 0xE5, 0x42});
|
characteristic.setValue(new byte[]{0x2C, 0x00, 0x00, 0x00, (byte) 0x9F, 0x00, 0x0C, 0x00, (byte) 0xE5, 0x42});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
BluetoothHandlerManagerCyclingPower.Data powerCadence = BluetoothHandlerManagerCyclingPower.parseCyclingPower(characteristic);
|
CyclingPowerBluetooth.Data powerCadence = CyclingPowerBluetooth.parseCyclingPower(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(0, powerCadence.power().getW(), 0.01);
|
assertEquals(0, powerCadence.power().getW(), 0.01);
|
||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@@ -10,15 +10,15 @@ import de.dennisguse.opentracks.data.models.Cadence;
|
|||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
|
|
||||||
public class BluetoothHandlerRunningSpeedAndCadenceTest {
|
public class RunningSpeedAndCadenceBluetoothTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseRunningSpeedAndCadence_with_distance() {
|
public void parseRunningSpeedAndCadence_with_distance() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerRunningSpeedAndCadence.RUNNING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(RunningSpeedAndCadenceBluetooth.RUNNING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{2, 0, 5, 80, (byte) 0xFF, (byte) 0xFF, 0, 1});
|
characteristic.setValue(new byte[]{2, 0, 5, 80, (byte) 0xFF, (byte) 0xFF, 0, 1});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
BluetoothHandlerRunningSpeedAndCadence.Data sensor = BluetoothHandlerRunningSpeedAndCadence.parseRunningSpeedAndCadence("sensorName", characteristic);
|
RunningSpeedAndCadenceBluetooth.Data sensor = RunningSpeedAndCadenceBluetooth.parseRunningSpeedAndCadence("sensorName", characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(Speed.of(5), sensor.speed());
|
assertEquals(Speed.of(5), sensor.speed());
|
||||||
+3
-3
@@ -11,7 +11,7 @@ public class AggregatorBarometerTest {
|
|||||||
|
|
||||||
private static void addSensorValue(AggregatorBarometer aggregatorBarometer, float[] values) {
|
private static void addSensorValue(AggregatorBarometer aggregatorBarometer, float[] values) {
|
||||||
for (float f : values) {
|
for (float f : values) {
|
||||||
aggregatorBarometer.add(new Raw<>(Instant.MIN, AtmosphericPressure.ofHPA(f)));
|
aggregatorBarometer.add(Instant.MIN, AtmosphericPressure.ofHPA(f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ public class AggregatorBarometerTest {
|
|||||||
addSensorValue(subject, new float[]{1015f, 1015.01f, 1015.02f, 1015.03f, 1015.04f, 1015.05f, 1015.06f, 1015.07f, 1015.08f, 1015.09f, 1015.10f, 1015.11f, 1015.12f, 1015.13f, 1018f, 1018.1f, 1018.1f, 1018.1f, 1018.1f});
|
addSensorValue(subject, new float[]{1015f, 1015.01f, 1015.02f, 1015.03f, 1015.04f, 1015.05f, 1015.06f, 1015.07f, 1015.08f, 1015.09f, 1015.10f, 1015.11f, 1015.12f, 1015.13f, 1018f, 1018.1f, 1018.1f, 1018.1f, 1018.1f});
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Assert.assertEquals(0f, subject.aggregatedValue.gain_m(), 0.01);
|
Assert.assertEquals(0f, subject.output.gain_m(), 0.01);
|
||||||
Assert.assertEquals(15f, subject.aggregatedValue.loss_m(), 0.01);
|
Assert.assertEquals(15f, subject.output.loss_m(), 0.01);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+21
-22
@@ -2,6 +2,7 @@ package de.dennisguse.opentracks.sensors.sensorData;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
@@ -12,10 +13,9 @@ import java.time.Instant;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Cadence;
|
import de.dennisguse.opentracks.data.models.Cadence;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingCadence;
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingDistanceSpeed;
|
|
||||||
import de.dennisguse.opentracks.sensors.UintUtils;
|
import de.dennisguse.opentracks.sensors.UintUtils;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.CyclingCadenceBluetooth;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.CyclingDistanceSpeedBluetooth;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class SensorDataCyclingTest {
|
public class SensorDataCyclingTest {
|
||||||
@@ -25,8 +25,8 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, 1024));
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 2048)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(2, 2048));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(60, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
assertEquals(60, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
||||||
@@ -37,8 +37,8 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 6184)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, 6184));
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 8016)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(2, 8016));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(33.53, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
assertEquals(33.53, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
||||||
@@ -49,8 +49,8 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, 1024));
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 2048)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, 2048));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(Cadence.of(0), current.getAggregatedValue(Instant.MIN));
|
assertEquals(Cadence.of(0), current.getAggregatedValue(Instant.MIN));
|
||||||
@@ -62,8 +62,8 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, 1024));
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 1024)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(2, 1024));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertFalse(current.hasReceivedData()); //TODO Cadence should be 0?
|
assertFalse(current.hasReceivedData()); //TODO Cadence should be 0?
|
||||||
@@ -74,8 +74,8 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, UintUtils.UINT16_MAX - 1024)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, UintUtils.UINT16_MAX - 1024));
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 0)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(2, 0));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(60, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
assertEquals(60, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
||||||
@@ -87,13 +87,13 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(UintUtils.UINT32_MAX - 1, 1024)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(UintUtils.UINT32_MAX - 1, 1024));
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(0, 2048)));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(0, 2048));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
// TODO See #953
|
// TODO See #953
|
||||||
// assertEquals(60, current.getValue().getRPM(), 0.01);
|
// assertEquals(60, current.getValue().getRPM(), 0.01);
|
||||||
assertEquals(Cadence.of(0), current.getAggregatedValue(Instant.MIN));
|
assertNull(current.getAggregatedValue(Instant.MIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -102,8 +102,8 @@ public class SensorDataCyclingTest {
|
|||||||
current.setWheelCircumference(Distance.ofMM(2150));
|
current.setWheelCircumference(Distance.ofMM(2150));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(1, 6184)));
|
current.add(Instant.MIN, new CyclingDistanceSpeedBluetooth.WheelData(1, 6184));
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(2, 8016)));
|
current.add(Instant.MIN, new CyclingDistanceSpeedBluetooth.WheelData(2, 8016));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(2.15, current.getAggregatedValue(Instant.MIN).distance().toM(), 0.01);
|
assertEquals(2.15, current.getAggregatedValue(Instant.MIN).distance().toM(), 0.01);
|
||||||
@@ -117,14 +117,13 @@ public class SensorDataCyclingTest {
|
|||||||
current.setWheelCircumference(Distance.ofMM(2000));
|
current.setWheelCircumference(Distance.ofMM(2000));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(UintUtils.UINT32_MAX - 1, 1024)));
|
current.add(Instant.MIN, new CyclingDistanceSpeedBluetooth.WheelData(UintUtils.UINT32_MAX - 1, 1024));
|
||||||
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(0, 2048)));
|
current.add(Instant.MIN, new CyclingDistanceSpeedBluetooth.WheelData(0, 2048));
|
||||||
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
// TODO See #953
|
// TODO See #953
|
||||||
// assertEquals(2, current.getValue().getDistance().toM(), 0.01);
|
// assertEquals(2, current.getValue().getDistance().toM(), 0.01);
|
||||||
// assertEquals(2, current.getValue().getSpeed().toMPS(), 0.01);
|
// assertEquals(2, current.getValue().getSpeed().toMPS(), 0.01);
|
||||||
assertEquals(new AggregatorCyclingDistanceSpeed.Data(Distance.of(0), Distance.of(0), Speed.of(0)), current.getAggregatedValue(Instant.MIN));
|
assertNull(current.getAggregatedValue(Instant.MIN));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+27
-13
@@ -16,24 +16,24 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
|
import java.time.ZoneOffset;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.data.models.ActivityType;
|
||||||
|
import de.dennisguse.opentracks.data.models.Altitude;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
|
import de.dennisguse.opentracks.data.models.Position;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
|
import de.dennisguse.opentracks.data.models.Statistics;
|
||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||||
import de.dennisguse.opentracks.settings.UnitSystem;
|
import de.dennisguse.opentracks.settings.UnitSystem;
|
||||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class TrackRecordingServiceNotificationManagerTest {
|
public class TrackRecordingServiceNotificationManagerTest {
|
||||||
|
|
||||||
private final Context context = ApplicationProvider.getApplicationContext();
|
private final Context context = ApplicationProvider.getApplicationContext();
|
||||||
|
|
||||||
@Mock
|
|
||||||
private TrackPoint trackPointMock;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private TrackStatistics trackStatisticsMock;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NotificationCompat.Builder notificationCompatBuilder;
|
private NotificationCompat.Builder notificationCompatBuilder;
|
||||||
|
|
||||||
@@ -42,18 +42,32 @@ public class TrackRecordingServiceNotificationManagerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateLocation_triggersAlertOnlyOnFirstInaccurateLocation() {
|
public void updateLocation_triggersAlertOnlyOnFirstInaccurateLocation() {
|
||||||
when(trackPointMock.hasHorizontalAccuracy()).thenReturn(true);
|
TrackPoint trackPointMock = new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
||||||
when(trackPointMock.getHorizontalAccuracy()).thenReturn(Distance.of(999f));
|
new Position(
|
||||||
when(trackPointMock.getSpeed()).thenReturn(Speed.of(0));
|
null,
|
||||||
when(trackStatisticsMock.getTotalDistance()).thenReturn(Distance.of(0));
|
null, null, Distance.of(999f),
|
||||||
|
Altitude.WGS84.of(10), null,
|
||||||
|
null,
|
||||||
|
Speed.ZERO)
|
||||||
|
);
|
||||||
|
|
||||||
when(notificationCompatBuilder.setOnlyAlertOnce(anyBoolean()))
|
when(notificationCompatBuilder.setOnlyAlertOnce(anyBoolean()))
|
||||||
.thenReturn(notificationCompatBuilder);
|
.thenReturn(notificationCompatBuilder);
|
||||||
|
|
||||||
TrackRecordingServiceNotificationManager subject = new TrackRecordingServiceNotificationManager(notificationManager, notificationCompatBuilder);
|
TrackRecordingServiceNotificationManager subject = new TrackRecordingServiceNotificationManager(notificationManager, notificationCompatBuilder);
|
||||||
subject.setUnitSystem(UnitSystem.METRIC);
|
subject.setUnitSystem(UnitSystem.METRIC);
|
||||||
|
|
||||||
Track track = new Track();
|
Track track = new Track(
|
||||||
track.setTrackStatistics(trackStatisticsMock);
|
null,
|
||||||
|
UUID.fromString("f81d4fae-7dec-11d0-a765-00a0c91e6bf6"),
|
||||||
|
"Berlin",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
ActivityType.CYCLING,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
Statistics.DEFAULT
|
||||||
|
);
|
||||||
|
|
||||||
RecordingData data = new RecordingData(track, trackPointMock, null, null);
|
RecordingData data = new RecordingData(track, trackPointMock, null, null);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
|||||||
+402
-163
@@ -5,8 +5,11 @@ import static org.junit.Assert.assertFalse;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.location.Location;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.location.LocationManagerCompat;
|
||||||
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;
|
||||||
@@ -31,26 +34,24 @@ import de.dennisguse.opentracks.TestUtil;
|
|||||||
import de.dennisguse.opentracks.content.data.TestDataUtil;
|
import de.dennisguse.opentracks.content.data.TestDataUtil;
|
||||||
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
||||||
import de.dennisguse.opentracks.data.models.AltitudeGainLoss;
|
import de.dennisguse.opentracks.data.models.AltitudeGainLoss;
|
||||||
|
import de.dennisguse.opentracks.data.models.Cadence;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
import de.dennisguse.opentracks.data.models.HeartRate;
|
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||||
import de.dennisguse.opentracks.data.models.Position;
|
import de.dennisguse.opentracks.data.models.Position;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
|
import de.dennisguse.opentracks.data.models.Statistics;
|
||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||||
import de.dennisguse.opentracks.io.file.importer.TrackPointAssert;
|
import de.dennisguse.opentracks.io.file.importer.TrackPointAssert;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerRunningSpeedAndCadence;
|
|
||||||
import de.dennisguse.opentracks.sensors.SensorManager;
|
import de.dennisguse.opentracks.sensors.SensorManager;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.GpsInternal;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.RunningSpeedAndCadenceBluetooth;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorRunning;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorRunning;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Raw;
|
|
||||||
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
|
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
|
||||||
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
||||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests insert location.
|
|
||||||
*/
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class TrackRecordingServiceRecordingTest {
|
public class TrackRecordingServiceRecordingTest {
|
||||||
|
|
||||||
@@ -106,8 +107,8 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, startTime, 0, 0, 0, 0, null, null)
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(startTime), Duration.ZERO, Duration.ZERO, Distance.ZERO, Speed.ZERO, null, null, null, null)
|
||||||
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime))
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime))
|
||||||
@@ -120,14 +121,21 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, stopTime, 0, 1, 1, 0, 0f, 0f)
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(stopTime), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.ZERO, Speed.ZERO, null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(stopTime))
|
new TrackPoint(
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f)
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
|
Position.of(Instant.parse(stopTime)),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0))
|
||||||
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,10 +151,15 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
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();
|
||||||
|
|
||||||
|
//We do not want the real GPS to interfere.
|
||||||
|
GpsInternal gpsInternal = (GpsInternal)trackPointCreator.getSensorManager().getGpsHandler().driver;
|
||||||
|
LocationManagerCompat.removeUpdates(gpsInternal.locationManager, gpsInternal.locationListenerCompat);
|
||||||
|
|
||||||
String gps1 = "2020-02-02T02:02:03Z";
|
String gps1 = "2020-02-02T02:02:03Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
||||||
String gps2 = "2020-02-02T02:02:04Z";
|
String gps2 = "2020-02-02T02:02:04Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.0, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps2, 45.0, 35.0, 1, 15);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String idleTime = "2020-02-02T02:02:17Z";
|
String idleTime = "2020-02-02T02:02:17Z";
|
||||||
@@ -192,14 +205,21 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, pauseTime, 0, 1, 1, 0, 0f, 0f)
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(pauseTime), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.ZERO, Speed.ZERO, null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(pauseTime))
|
new TrackPoint(
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f)
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
|
Position.of(Instant.parse(pauseTime)),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0))
|
||||||
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
||||||
|
|
||||||
//when
|
//when
|
||||||
@@ -208,14 +228,22 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
service.resumeTrack(trackId);
|
service.resumeTrack(trackId);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, resumeTime, 0, 1, 1, 0, 0f, 0f)
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(resumeTime), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.ZERO, Speed.ZERO, null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(pauseTime))
|
new TrackPoint(
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f),
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
|
Position.of(Instant.parse(pauseTime)),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(resumeTime))
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(resumeTime))
|
||||||
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
||||||
}
|
}
|
||||||
@@ -247,9 +275,16 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
List<TrackPoint> trackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, trackId);
|
List<TrackPoint> trackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, trackId);
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(starTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(starTime)),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(pauseTime))
|
new TrackPoint(
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f)
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
|
Position.of(Instant.parse(pauseTime)),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0))
|
||||||
), trackPoints);
|
), trackPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,9 +312,17 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
// then
|
// then
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(stopTime))
|
new TrackPoint(
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f),
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
|
Position.of(Instant.parse(stopTime)),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(resumeTime))
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(resumeTime))
|
||||||
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
||||||
}
|
}
|
||||||
@@ -296,16 +339,21 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
mockAltitudeChange(trackPointCreator, 0);
|
mockAltitudeChange(trackPointCreator, 0);
|
||||||
|
|
||||||
SensorManager sensorManager = trackPointCreator.getSensorManager();
|
SensorManager sensorManager = trackPointCreator.getSensorManager();
|
||||||
sensorManager.sensorDataSet.add(new AggregatorHeartRate("", ""));
|
|
||||||
// when
|
// when
|
||||||
String sensor1 = "2020-02-02T02:02:03Z";
|
String sensor1 = "2020-02-02T02:02:03Z";
|
||||||
trackPointCreator.setClock(sensor1);
|
trackPointCreator.setClock(sensor1);
|
||||||
|
|
||||||
sensorManager.onChanged(new Raw<>(sensor1, HeartRate.of(5))); //Should be ignored
|
AggregatorHeartRate avgHeartRate = new AggregatorHeartRate("", "");
|
||||||
|
sensorManager.setAggregator(avgHeartRate);
|
||||||
|
|
||||||
|
//Should be ignored
|
||||||
|
avgHeartRate.add(trackPointCreator.getNow(), HeartRate.of(5));
|
||||||
|
sensorManager.onChange();
|
||||||
|
|
||||||
String sensor3 = "2020-02-02T02:02:13Z";
|
String sensor3 = "2020-02-02T02:02:13Z";
|
||||||
trackPointCreator.setClock(sensor3);
|
trackPointCreator.setClock(sensor3);
|
||||||
sensorManager.onChanged(new Raw<>(sensor3, HeartRate.of(7)));
|
avgHeartRate.add(trackPointCreator.getNow(), HeartRate.of(7));
|
||||||
|
sensorManager.onChange();
|
||||||
|
|
||||||
String stopTime = "2020-02-02T02:02:15Z";
|
String stopTime = "2020-02-02T02:02:15Z";
|
||||||
trackPointCreator.setClock(stopTime);
|
trackPointCreator.setClock(stopTime);
|
||||||
@@ -314,14 +362,28 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
// then
|
// then
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse(sensor3))
|
new TrackPoint(
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f)
|
TrackPoint.Type.TRACKPOINT,
|
||||||
.setHeartRate(HeartRate.of(7)),
|
Position.of(Instant.parse(sensor3)),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(stopTime))
|
null,
|
||||||
.setAltitudeGain(0f)
|
HeartRate.of(7),
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
.setHeartRate(HeartRate.of(7))
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
|
Position.of(Instant.parse(stopTime)),
|
||||||
|
null,
|
||||||
|
HeartRate.of(7),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
)
|
||||||
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,28 +400,27 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
String gps1 = "2020-02-02T02:02:03Z";
|
String gps1 = "2020-02-02T02:02:03Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, gps1, 0, 1, 1, 15, 0f, 0f)
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(gps1), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.ZERO, Speed.of(15), null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String gps2 = "2020-02-02T02:02:06Z";
|
String gps2 = "2020-02-02T02:02:06Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.0001, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps2, 45.0001, 35.0, 1, 15);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, gps2, 11.113178253173828f, 4, 4, 15, 0f, 0f)
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(gps2), Duration.ofSeconds(4), Duration.ofSeconds(4), Distance.of(11.113178253173828), Speed.of(15), null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String gps3 = "2020-02-02T02:02:08Z";
|
String gps3 = "2020-02-02T02:02:08Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps3, 45.0002, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps3, 45.0002, 35.0, 1, 15);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, gps3, 22.226356506347656, 6, 6, 15, 0f, 0f)
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(gps3), Duration.ofSeconds(6), Duration.ofSeconds(6), Distance.of(22.226356506347656), Speed.of(15), null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String stopTime = "2020-02-02T02:02:12Z";
|
String stopTime = "2020-02-02T02:02:12Z";
|
||||||
@@ -367,41 +428,70 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, stopTime, 22.226356506347656, 10, 10, 15, 0f, 0f)
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(stopTime), Duration.ofSeconds(10), Duration.ofSeconds(10), Distance.of(22.226356506347656), Speed.of(15), null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps1),
|
Instant.parse(gps1),
|
||||||
45d, 35d, Distance.of(1),
|
45d, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps2),
|
Instant.parse(gps2),
|
||||||
45.001, 35d, Distance.of(1),
|
45.001, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps3),
|
Instant.parse(gps3),
|
||||||
45.001, 35d, Distance.of(1),
|
45.001, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(stopTime))
|
null,
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
|
Position.of(Instant.parse(stopTime)),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
)
|
||||||
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,25 +507,25 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
String gps1 = "2020-02-02T02:02:03Z";
|
String gps1 = "2020-02-02T02:02:03Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
TrackStatistics gps1Statistics = new TrackStatistics(startTime, gps1, 0, 1, 1, 15, 0f, 0f);
|
Statistics gps1Statistics = new Statistics(Instant.parse(startTime), Instant.parse(gps1), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.ZERO, Speed.of(15), null, new AltitudeGainLoss(0, 0), null, null);
|
||||||
assertEquals(gps1Statistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
assertEquals(gps1Statistics, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String gps2 = "2020-02-02T02:02:06Z";
|
String gps2 = "2020-02-02T02:02:06Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.00001, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps2, 45.00001, 35.0, 1, 15);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(gps1Statistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
assertEquals(gps1Statistics, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String gps3 = "2020-02-02T02:02:08Z";
|
String gps3 = "2020-02-02T02:02:08Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps3, 45.00002, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps3, 45.00002, 35.0, 1, 15);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(gps1Statistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
assertEquals(gps1Statistics, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String stopTime = "2020-02-02T02:02:12Z";
|
String stopTime = "2020-02-02T02:02:12Z";
|
||||||
@@ -443,38 +533,59 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, stopTime, 2.222635507583618, 10, 10, 15, 0f, 0f)
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(stopTime), Duration.ofSeconds(10), Duration.ofSeconds(10), Distance.of(2.222635507583618), Speed.of(15), null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps1),
|
Instant.parse(gps1),
|
||||||
45d, 35d, Distance.of(1),
|
45d, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps3),
|
Instant.parse(gps3),
|
||||||
45.00002, 35d, Distance.of(1),
|
45.00002, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(stopTime),
|
Instant.parse(stopTime),
|
||||||
45.00002, 35d, Distance.of(1),
|
45.00002, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
)
|
||||||
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,15 +602,15 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
String gps1 = "2020-02-02T02:02:03Z";
|
String gps1 = "2020-02-02T02:02:03Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
||||||
|
|
||||||
// when - will be ignored
|
// when - will be ignored
|
||||||
String gps2 = "2020-02-02T02:02:04Z";
|
String gps2 = "2020-02-02T02:02:04Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.0, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps2, 45.0, 35.0, 1, 15);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String gps3 = "2020-02-02T02:02:05Z";
|
String gps3 = "2020-02-02T02:02:05Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps3, 45.0001, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps3, 45.0001, 35.0, 1, 15);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String stopTime = "2020-02-02T02:02:12Z";
|
String stopTime = "2020-02-02T02:02:12Z";
|
||||||
@@ -509,27 +620,47 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
// then
|
// then
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps1),
|
Instant.parse(gps1),
|
||||||
45d, 35d, Distance.of(1),
|
45d, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps3),
|
Instant.parse(gps3),
|
||||||
45d, 35d, Distance.of(1),
|
45d, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(stopTime))
|
null,
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
|
Position.of(Instant.parse(stopTime)),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0))
|
||||||
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,19 +676,19 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
String gps1 = "2020-02-02T02:02:03Z";
|
String gps1 = "2020-02-02T02:02:03Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 100, 15);
|
sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 100, 15);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
TrackStatistics startStatistics = new TrackStatistics(startTime, startTime, 0, 0, 0, 0, null, null);
|
Statistics startStatistics = new Statistics(Instant.parse(startTime), Instant.parse(startTime), Duration.ZERO, Duration.ZERO, Distance.ZERO, Speed.ZERO, null, null, null, null);
|
||||||
assertEquals(startStatistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
assertEquals(startStatistics, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String gps2 = "2020-02-02T02:02:06Z";
|
String gps2 = "2020-02-02T02:02:06Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.1, 35.0, 100, 15);
|
sendGPSLocation(trackPointCreator, gps2, 45.1, 35.0, 100, 15);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(startStatistics, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
assertEquals(startStatistics, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@@ -566,16 +697,22 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, stopTime, 0, 10, 10, 0, 0f, 0f)
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(stopTime), Duration.ofSeconds(10), Duration.ofSeconds(10), Distance.ZERO, Speed.ZERO, null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
, contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(stopTime))
|
new TrackPoint(
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f)
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
|
Position.of(Instant.parse(stopTime)),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0))
|
||||||
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -591,18 +728,19 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
String gps1 = "2020-02-02T02:02:03Z";
|
String gps1 = "2020-02-02T02:02:03Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, gps1, 0, 1, 1, 15, 0f, 0f), contentProviderUtils.getTrack(trackId).getTrackStatistics());
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(gps1), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.ZERO, Speed.of(15), null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String gps2 = "2020-02-02T02:02:06Z";
|
String gps2 = "2020-02-02T02:02:06Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.1, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps2, 45.1, 35.0, 1, 15);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, gps2, 11113.275390625, 4, 4, 2778.31884765625f, 0f, 0f).toString(), contentProviderUtils.getTrack(trackId).getTrackStatistics().toString());
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(gps2), Duration.ofSeconds(4), Duration.ofSeconds(4), Distance.of(11113.275390625), Speed.of(2778.31884765625f), null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String stopTime = "2020-02-02T02:02:12Z";
|
String stopTime = "2020-02-02T02:02:12Z";
|
||||||
@@ -610,33 +748,55 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(new TrackStatistics(startTime, stopTime, 11113.275390625, 10, 10, 1111.3275390625f, 0f, 0f).toString(), contentProviderUtils.getTrack(trackId).getTrackStatistics().toString());
|
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(stopTime), Duration.ofSeconds(10), Duration.ofSeconds(10), Distance.of(11113.275390625), Speed.of(1111.3275146484375), null, new AltitudeGainLoss(0, 0), null, null)
|
||||||
|
, contentProviderUtils.getTrack(trackId).statistics());
|
||||||
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps1),
|
Instant.parse(gps1),
|
||||||
45d, 35d, Distance.of(1),
|
45d, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_START_AUTOMATIC,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps2),
|
Instant.parse(gps2),
|
||||||
45.1, 35d, Distance.of(1),
|
45.1, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(15)))
|
Speed.of(15)),
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f),
|
null,
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse(stopTime))
|
null,
|
||||||
.setAltitudeGain(0f)
|
null,
|
||||||
.setAltitudeLoss(0f)
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0)
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
|
Position.of(Instant.parse(stopTime)),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(0, 0))
|
||||||
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,50 +813,58 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
trackPointCreator.setClock(startTime);
|
trackPointCreator.setClock(startTime);
|
||||||
Track.Id trackId = service.startNewTrack();
|
Track.Id trackId = service.startNewTrack();
|
||||||
|
|
||||||
|
AggregatorRunning aggregatorRunning = new AggregatorRunning("", "");
|
||||||
SensorManager sensorManager = trackPointCreator.getSensorManager();
|
SensorManager sensorManager = trackPointCreator.getSensorManager();
|
||||||
sensorManager.sensorDataSet.add(new AggregatorRunning("", ""));
|
sensorManager.setAggregator(aggregatorRunning);
|
||||||
sensorManager.sensorDataSet.barometer = null;
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String sensor1 = "2020-02-02T02:02:03Z";
|
String sensor1 = "2020-02-02T02:02:03Z";
|
||||||
trackPointCreator.setClock(sensor1);
|
trackPointCreator.setClock(sensor1);
|
||||||
sensorManager.onChanged(new Raw<>(sensor1, new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), null, Distance.of(0)))); //Should be ignored
|
//Should be ignored
|
||||||
|
aggregatorRunning.add(trackPointCreator.getNow(), new RunningSpeedAndCadenceBluetooth.Data(Speed.of(5), Cadence.of(1), Distance.ZERO));
|
||||||
|
sensorManager.onChange();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String sensor2 = "2020-02-02T02:02:04Z";
|
String sensor2 = "2020-02-02T02:02:04Z";
|
||||||
trackPointCreator.setClock(sensor2);
|
trackPointCreator.setClock(sensor2);
|
||||||
sensorManager.onChanged(new Raw<>(sensor2, new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), null, Distance.of(2))));
|
aggregatorRunning.add(trackPointCreator.getNow(), new RunningSpeedAndCadenceBluetooth.Data(Speed.of(5), Cadence.of(2), Distance.of(2)));
|
||||||
|
sensorManager.onChange();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String gps1 = "2020-02-02T02:02:05Z";
|
String gps1 = "2020-02-02T02:02:05Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 1, 15);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String sensor3 = "2020-02-02T02:02:06Z";
|
String sensor3 = "2020-02-02T02:02:06Z";
|
||||||
trackPointCreator.setClock(sensor3);
|
trackPointCreator.setClock(sensor3);
|
||||||
sensorManager.onChanged(new Raw<>(sensor3, new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), null, Distance.of(12))));
|
aggregatorRunning.add(trackPointCreator.getNow(), new RunningSpeedAndCadenceBluetooth.Data(Speed.of(5), Cadence.of(3), Distance.of(12)));
|
||||||
|
sensorManager.onChange();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String sensor4 = "2020-02-02T02:02:07Z";
|
String sensor4 = "2020-02-02T02:02:07Z";
|
||||||
trackPointCreator.setClock(sensor4);
|
trackPointCreator.setClock(sensor4);
|
||||||
sensorManager.onChanged(new Raw<>(sensor4, new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), null, Distance.of(14)))); //Should be ignored
|
//Should be ignored
|
||||||
|
aggregatorRunning.add(trackPointCreator.getNow(), new RunningSpeedAndCadenceBluetooth.Data(Speed.of(5), Cadence.of(4), Distance.of(14)));
|
||||||
|
sensorManager.onChange();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String gps2 = "2020-02-02T02:02:08Z";
|
String gps2 = "2020-02-02T02:02:08Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps2, 45.0, 35.0, 4, 15); //Should be ignored
|
sendGPSLocation(trackPointCreator, gps2, 45.0, 35.0, 4, 15); //Should be ignored
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String sensor5 = "2020-02-02T02:02:10Z";
|
String sensor5 = "2020-02-02T02:02:10Z";
|
||||||
trackPointCreator.setClock(sensor5);
|
trackPointCreator.setClock(sensor5);
|
||||||
sensorManager.onChanged(new Raw<>(sensor5, new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), null, Distance.of(16)))); //Should be ignored
|
//Should be ignored
|
||||||
|
aggregatorRunning.add(trackPointCreator.getNow(), new RunningSpeedAndCadenceBluetooth.Data(Speed.of(5), Cadence.of(5), Distance.of(16)));
|
||||||
|
sensorManager.onChange();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String gps3 = "2020-02-02T02:02:12Z";
|
String gps3 = "2020-02-02T02:02:12Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps3, 45.001, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps3, 45.001, 35.0, 1, 15);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String gps4 = "2020-02-02T02:02:14Z";
|
String gps4 = "2020-02-02T02:02:14Z";
|
||||||
TrackRecordingServiceTestUtils.sendGPSLocation(trackPointCreator, gps4, 45.001, 35.0, 1, 15);
|
sendGPSLocation(trackPointCreator, gps4, 45.001, 35.0, 1, 15);
|
||||||
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@@ -707,58 +875,129 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
// then
|
// then
|
||||||
new TrackPointAssert().assertEquals(List.of(
|
new TrackPointAssert().assertEquals(List.of(
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse(startTime)),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse(sensor2)) //First moving TrackPoint: store as the time might be interesting.
|
new TrackPoint( //First moving TrackPoint: stored as the time might be interesting.
|
||||||
.setSpeed(Speed.of(5))
|
null,
|
||||||
.setSensorDistance(Distance.of(2)),
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
new Position(
|
||||||
|
Instant.parse(sensor2),
|
||||||
|
null, null, null,
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
Speed.of(5)),
|
||||||
|
Distance.of(2),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
Cadence.of(2),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps1),
|
Instant.parse(gps1),
|
||||||
45d, 35d, Distance.of(1),
|
45d, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(5)))
|
Speed.of(5)),
|
||||||
.setSensorDistance(Distance.of(0)),
|
Distance.ZERO,
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse(sensor3))
|
null,
|
||||||
.setSpeed(Speed.of(5))
|
null,
|
||||||
.setSensorDistance(Distance.of(10)),
|
Cadence.of(2),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
null,
|
||||||
|
null
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
|
new Position(
|
||||||
|
Instant.parse(sensor3),
|
||||||
|
null, null, null,
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
Speed.of(5)),
|
||||||
|
Distance.of(10),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
Cadence.of(3),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps3),
|
Instant.parse(gps3),
|
||||||
45.001, 35d, Distance.of(1),
|
45.001, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(5)))
|
Speed.of(5)),
|
||||||
.setSensorDistance(Distance.of(4.0)),
|
Distance.of(4.0),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT,
|
null,
|
||||||
|
null,
|
||||||
|
Cadence.of(5),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.TRACKPOINT,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(gps4),
|
Instant.parse(gps4),
|
||||||
45.001, 35d, Distance.of(1),
|
45.001, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(5)))
|
Speed.of(5)),
|
||||||
.setSensorDistance(Distance.of(0)),
|
Distance.ZERO,
|
||||||
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL,
|
null,
|
||||||
|
null,
|
||||||
|
Cadence.of(5),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
),
|
||||||
|
new TrackPoint(
|
||||||
|
null,
|
||||||
|
TrackPoint.Type.SEGMENT_END_MANUAL,
|
||||||
new Position(
|
new Position(
|
||||||
Instant.parse(stopTime),
|
Instant.parse(stopTime),
|
||||||
45.001, 35d, Distance.of(1),
|
45.001, 35d, Distance.of(1),
|
||||||
null, null,
|
null, null,
|
||||||
null,
|
null,
|
||||||
Speed.of(0))) //Sensor data is now outdated, but we do not fall back to GPS.
|
Speed.ZERO), //Sensor data is now outdated, but we do not fall back to GPS.
|
||||||
.setSensorDistance(Distance.of(0))
|
Distance.ZERO,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
Cadence.of(0), //TODO This could be null, right?
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
)
|
||||||
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mockAltitudeChange(TrackPointCreator trackPointCreator, float altitudeGain) {
|
private void mockAltitudeChange(TrackPointCreator trackPointCreator, float altitudeGain) {
|
||||||
trackPointCreator.getSensorManager().sensorDataSet.barometer = new AggregatorBarometer("", "") {
|
trackPointCreator.getSensorManager().getAltitudeChangeHandler().setAggregator(new AggregatorBarometer("", "") {
|
||||||
@Override
|
@Override
|
||||||
public boolean hasReceivedData() {
|
public boolean hasReceivedData() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public AltitudeGainLoss getAggregatedValue(Instant now) {
|
public AltitudeGainLoss getAggregatedValue(Instant now) {
|
||||||
return new AltitudeGainLoss(altitudeGain, altitudeGain);
|
return new AltitudeGainLoss(altitudeGain, altitudeGain);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private 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.
|
||||||
|
location.setLatitude(latitude);
|
||||||
|
location.setLongitude(longitude);
|
||||||
|
location.setAccuracy(accuracy);
|
||||||
|
location.setSpeed(speed);
|
||||||
|
|
||||||
|
trackPointCreator.setClock(time);
|
||||||
|
trackPointCreator.getSensorManager().getGpsHandler().onDataReceived(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-30
@@ -45,13 +45,13 @@ import java.util.List;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.TestUtil;
|
||||||
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
import de.dennisguse.opentracks.sensors.GpsStatusValue;
|
import de.dennisguse.opentracks.sensors.GpsStatusValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Testing the states of TrackRecordingService.
|
* Testing the states of TrackRecordingService.
|
||||||
* As states are checked against MutableLiveData that are updated via `postValue()` (is asynchronous to be inform other Threads), Thread.sleep() is required.
|
|
||||||
*/
|
*/
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class TrackRecordingServiceStateMachineTest {
|
public class TrackRecordingServiceStateMachineTest {
|
||||||
@@ -60,7 +60,7 @@ public class TrackRecordingServiceStateMachineTest {
|
|||||||
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
|
public final ServiceTestRule mServiceRule = ServiceTestRule.withTimeout(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public GrantPermissionRule mRuntimePermissionRule = GrantPermissionRule.grant(android.Manifest.permission.ACCESS_FINE_LOCATION);
|
public GrantPermissionRule mRuntimePermissionRule = TestUtil.createGrantPermissionRule();
|
||||||
|
|
||||||
private final Context context = ApplicationProvider.getApplicationContext();
|
private final Context context = ApplicationProvider.getApplicationContext();
|
||||||
private ContentProviderUtils contentProviderUtils;
|
private ContentProviderUtils contentProviderUtils;
|
||||||
@@ -111,84 +111,77 @@ public class TrackRecordingServiceStateMachineTest {
|
|||||||
// then
|
// then
|
||||||
assertFalse(service.isRecording());
|
assertFalse(service.isRecording());
|
||||||
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
||||||
assertEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
assertEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@MediumTest
|
@MediumTest
|
||||||
@Test
|
@Test
|
||||||
public void gps_startStop() throws InterruptedException {
|
public void gps_startStop() {
|
||||||
// given
|
// given
|
||||||
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
service.tryStartSensors();
|
service.tryStartSensors();
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
||||||
assertEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
assertEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
service.stopSensors();
|
service.stopSensors();
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
||||||
assertEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
assertEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
// assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue()); TODO BUG: GPS can only be stopped if a service is recording.
|
// assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue()); TODO BUG: GPS can only be stopped if a service is recording.
|
||||||
}
|
}
|
||||||
|
|
||||||
@MediumTest
|
@MediumTest
|
||||||
@Test
|
@Test
|
||||||
public void recording_startStopResume_no_data() throws InterruptedException {
|
public void recording_startStopResume_no_data() {
|
||||||
// given
|
// given
|
||||||
assertFalse(service.isRecording());
|
assertFalse(service.isRecording());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Track.Id trackId = service.startNewTrack();
|
Track.Id trackId = service.startNewTrack();
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertTrue(service.isRecording());
|
assertTrue(service.isRecording());
|
||||||
assertEquals(new RecordingStatus(trackId), service.getRecordingStatusObservable().getValue());
|
assertEquals(new RecordingStatus(trackId), service.getRecordingStatusObservable().getValue());
|
||||||
assertNotEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
assertNotEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
||||||
|
|
||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
service.resumeTrack(trackId);
|
service.resumeTrack(trackId);
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertTrue(service.isRecording());
|
assertTrue(service.isRecording());
|
||||||
assertEquals(new RecordingStatus(trackId), service.getRecordingStatusObservable().getValue());
|
assertEquals(new RecordingStatus(trackId), service.getRecordingStatusObservable().getValue());
|
||||||
assertNotEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
assertNotEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
||||||
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertFalse(service.isRecording());
|
assertFalse(service.isRecording());
|
||||||
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
||||||
assertNotEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
assertNotEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
||||||
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
service.resumeTrack(trackId);
|
service.resumeTrack(trackId);
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertTrue(service.isRecording());
|
assertTrue(service.isRecording());
|
||||||
assertEquals(new RecordingStatus(trackId), service.getRecordingStatusObservable().getValue());
|
assertEquals(new RecordingStatus(trackId), service.getRecordingStatusObservable().getValue());
|
||||||
Thread.sleep(1000); //TODO Figure out why we need to wait here until the update is happening
|
assertNotEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
assertNotEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
|
||||||
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +191,7 @@ public class TrackRecordingServiceStateMachineTest {
|
|||||||
// given
|
// given
|
||||||
assertFalse(service.isRecording());
|
assertFalse(service.isRecording());
|
||||||
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
||||||
assertEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
assertEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@@ -207,59 +200,55 @@ public class TrackRecordingServiceStateMachineTest {
|
|||||||
// then
|
// then
|
||||||
assertFalse(service.isRecording());
|
assertFalse(service.isRecording());
|
||||||
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
||||||
assertEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
assertEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@MediumTest
|
@MediumTest
|
||||||
@Test
|
@Test
|
||||||
public void cannotEnd_without_starting() throws InterruptedException {
|
public void cannotEnd_without_starting() {
|
||||||
// given
|
// given
|
||||||
assertFalse(service.isRecording());
|
assertFalse(service.isRecording());
|
||||||
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
||||||
assertEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
assertEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
assertEquals(TrackRecordingService.STATUS_DEFAULT, service.getRecordingStatusObservable().getValue());
|
||||||
assertEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
assertEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_NONE, service.getGpsStatusObservable().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("TODO Bug: GPS can be stopped although the current track is recording")
|
@Ignore("TODO Bug: GPS can be stopped although the current track is recording")
|
||||||
@MediumTest
|
@MediumTest
|
||||||
@Test
|
@Test
|
||||||
public void recording_stopGPS_noop() throws InterruptedException {
|
public void recording_stopGPS_noop() {
|
||||||
// given
|
// given
|
||||||
Track.Id trackId = service.startNewTrack();
|
Track.Id trackId = service.startNewTrack();
|
||||||
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
service.stopSensors(); //TODO Should be ignored as service is recording
|
service.stopSensors(); //TODO Should be ignored as service is recording
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertTrue(service.isRecording());
|
assertTrue(service.isRecording());
|
||||||
assertEquals(new RecordingStatus(trackId), service.getRecordingStatusObservable().getValue());
|
assertEquals(new RecordingStatus(trackId), service.getRecordingStatusObservable().getValue());
|
||||||
Thread.sleep(1000); //TODO Figure out why we need to wait here until the update is happening
|
assertNotEquals(RecordingData.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
||||||
assertNotEquals(TrackRecordingService.NOT_RECORDING, service.getRecordingDataObservable().getValue());
|
|
||||||
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
assertEquals(GpsStatusValue.GPS_ENABLED, service.getGpsStatusObservable().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@MediumTest
|
@MediumTest
|
||||||
@Test
|
@Test
|
||||||
public void recording_startRecording_alreadyRecording() throws InterruptedException {
|
public void recording_startRecording_alreadyRecording() {
|
||||||
// given
|
// given
|
||||||
Track.Id trackId = service.startNewTrack();
|
Track.Id trackId = service.startNewTrack();
|
||||||
assertTrue(service.isRecording());
|
assertTrue(service.isRecording());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Track.Id newTrackId = service.startNewTrack();
|
Track.Id newTrackId = service.startNewTrack();
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertNotNull(trackId);
|
assertNotNull(trackId);
|
||||||
|
|||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
package de.dennisguse.opentracks.services;
|
|
||||||
|
|
||||||
import android.location.Location;
|
|
||||||
|
|
||||||
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
|
|
||||||
|
|
||||||
public class TrackRecordingServiceTestUtils {
|
|
||||||
|
|
||||||
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.
|
|
||||||
location.setLatitude(latitude);
|
|
||||||
location.setLongitude(longitude);
|
|
||||||
location.setAccuracy(accuracy);
|
|
||||||
location.setSpeed(speed);
|
|
||||||
|
|
||||||
trackPointCreator.setClock(time);
|
|
||||||
trackPointCreator.getSensorManager().getGpsManager().onLocationChanged(location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+53
-11
@@ -21,8 +21,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
|
import de.dennisguse.opentracks.data.models.Statistics;
|
||||||
import de.dennisguse.opentracks.services.TrackRecordingService;
|
import de.dennisguse.opentracks.services.TrackRecordingService;
|
||||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class VoiceAnnouncementManagerTest {
|
public class VoiceAnnouncementManagerTest {
|
||||||
@@ -54,13 +54,32 @@ public class VoiceAnnouncementManagerTest {
|
|||||||
voiceAnnouncementManager.setFrequency(Distance.ofKilometer(5));
|
voiceAnnouncementManager.setFrequency(Distance.ofKilometer(5));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
TrackStatistics statistics = new TrackStatistics();
|
voiceAnnouncementManager.start(new Statistics(
|
||||||
statistics.setTotalDistance(Distance.ofKilometer(13));
|
null,
|
||||||
voiceAnnouncementManager.start(statistics);
|
null,
|
||||||
|
Duration.ofSeconds(91),
|
||||||
|
Duration.ZERO,
|
||||||
|
Distance.ofKilometer(13),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
assertEquals(Distance.of(15000), voiceAnnouncementManager.getNextTotalDistance());
|
assertEquals(Distance.of(15000), voiceAnnouncementManager.getNextTotalDistance());
|
||||||
|
|
||||||
statistics.setTotalDistance(Distance.of(15100));
|
voiceAnnouncementManager.start(new Statistics(
|
||||||
voiceAnnouncementManager.start(statistics);
|
null,
|
||||||
|
null,
|
||||||
|
Duration.ofSeconds(91),
|
||||||
|
Duration.ZERO,
|
||||||
|
Distance.of(15000),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
assertEquals(Distance.of(20000), voiceAnnouncementManager.getNextTotalDistance());
|
assertEquals(Distance.of(20000), voiceAnnouncementManager.getNextTotalDistance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,14 +92,37 @@ public class VoiceAnnouncementManagerTest {
|
|||||||
VoiceAnnouncementManager voiceAnnouncementManager = new VoiceAnnouncementManager(service);
|
VoiceAnnouncementManager voiceAnnouncementManager = new VoiceAnnouncementManager(service);
|
||||||
voiceAnnouncementManager.setFrequency(Duration.ofSeconds(5));
|
voiceAnnouncementManager.setFrequency(Duration.ofSeconds(5));
|
||||||
|
|
||||||
|
Statistics first = new Statistics(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
Duration.ofSeconds(91),
|
||||||
|
Duration.ZERO,
|
||||||
|
Distance.ZERO,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
Statistics second = new Statistics(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
Duration.ofSeconds(95),
|
||||||
|
Duration.ZERO,
|
||||||
|
Distance.ZERO,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
TrackStatistics statistics = new TrackStatistics();
|
voiceAnnouncementManager.start(first);
|
||||||
statistics.setTotalTime(Duration.ofSeconds(91));
|
|
||||||
voiceAnnouncementManager.start(statistics);
|
|
||||||
assertEquals(Duration.ofSeconds(95), voiceAnnouncementManager.getNextTotalTime());
|
assertEquals(Duration.ofSeconds(95), voiceAnnouncementManager.getNextTotalTime());
|
||||||
|
|
||||||
statistics.setTotalTime(Duration.ofSeconds(95));
|
voiceAnnouncementManager.start(second);
|
||||||
voiceAnnouncementManager.start(statistics);
|
|
||||||
assertEquals(Duration.ofSeconds(100), voiceAnnouncementManager.getNextTotalTime());
|
assertEquals(Duration.ofSeconds(100), voiceAnnouncementManager.getNextTotalTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+406
-231
@@ -1,7 +1,6 @@
|
|||||||
package de.dennisguse.opentracks.services.announcement;
|
package de.dennisguse.opentracks.services.announcement;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.icu.text.MessageFormat;
|
import android.icu.text.MessageFormat;
|
||||||
@@ -10,33 +9,39 @@ import android.util.Pair;
|
|||||||
|
|
||||||
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.SdkSuppress;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mockito;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.LocaleRule;
|
import de.dennisguse.opentracks.LocaleRule;
|
||||||
import de.dennisguse.opentracks.content.data.TestDataUtil;
|
import de.dennisguse.opentracks.content.data.TestDataUtil;
|
||||||
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
import de.dennisguse.opentracks.data.models.ActivityType;
|
||||||
import de.dennisguse.opentracks.data.TrackPointIterator;
|
import de.dennisguse.opentracks.data.models.AltitudeGainLoss;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
import de.dennisguse.opentracks.data.models.HeartRate;
|
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
|
import de.dennisguse.opentracks.data.models.Statistics;
|
||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
|
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||||
|
import de.dennisguse.opentracks.data.statistics.SensorStatistics;
|
||||||
|
import de.dennisguse.opentracks.sensors.sensorData.SensorData;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorDataSet;
|
import de.dennisguse.opentracks.sensors.sensorData.SensorDataSet;
|
||||||
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
||||||
import de.dennisguse.opentracks.settings.UnitSystem;
|
import de.dennisguse.opentracks.settings.UnitSystem;
|
||||||
import de.dennisguse.opentracks.stats.SensorStatistics;
|
import de.dennisguse.opentracks.ui.intervals.IntervalStatisticsUpdater;
|
||||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
|
||||||
import de.dennisguse.opentracks.ui.intervals.IntervalStatistics;
|
|
||||||
|
|
||||||
|
//Due to DateTimeFormatter using NBSP, these tests only work in SDK34+
|
||||||
|
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class VoiceAnnouncementUtilsTest {
|
public class VoiceAnnouncementUtilsTest {
|
||||||
|
|
||||||
@@ -44,12 +49,9 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
public final LocaleRule mLocaleRule = new LocaleRule(Locale.ENGLISH);
|
public final LocaleRule mLocaleRule = new LocaleRule(Locale.ENGLISH);
|
||||||
|
|
||||||
private final Context context = ApplicationProvider.getApplicationContext();
|
private final Context context = ApplicationProvider.getApplicationContext();
|
||||||
private ContentProviderUtils contentProviderUtils;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
contentProviderUtils = new ContentProviderUtils(context);
|
|
||||||
|
|
||||||
PreferencesUtils.setVoiceAnnounceHeartRateCurrent(false);
|
PreferencesUtils.setVoiceAnnounceHeartRateCurrent(false);
|
||||||
PreferencesUtils.setVoiceAnnounceLapHeartRate(false);
|
PreferencesUtils.setVoiceAnnounceLapHeartRate(false);
|
||||||
PreferencesUtils.setVoiceAnnounceAverageHeartRate(false);
|
PreferencesUtils.setVoiceAnnounceAverageHeartRate(false);
|
||||||
@@ -59,26 +61,38 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
PreferencesUtils.setVoiceAnnounceLapSpeedPace(true);
|
PreferencesUtils.setVoiceAnnounceLapSpeedPace(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void sdkRequirement() {
|
|
||||||
assertFalse("Due to DateTimeFormatter using NBSP, these tests only work in SDK34+", Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_metric_speed() {
|
public void getAnnouncement_metric_speed() {
|
||||||
TrackStatistics stats = new TrackStatistics();
|
Track track = new Track(
|
||||||
stats.setStartTime(Instant.EPOCH);
|
null,
|
||||||
stats.setTotalDistance(Distance.of(20000));
|
null,
|
||||||
stats.setTotalTime(Duration.ofHours(2).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMovingTime(Duration.ofHours(1).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMaxSpeed(Speed.of(100));
|
"",
|
||||||
stats.setTotalAltitudeGain(6000f);
|
ActivityType.AIRPLANE,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(
|
||||||
|
Instant.EPOCH,
|
||||||
|
Instant.EPOCH,
|
||||||
|
Duration.ofHours(2).plusMinutes(5).plusSeconds(10),
|
||||||
|
Duration.ofHours(1).plusMinutes(5).plusSeconds(10),
|
||||||
|
Distance.of(20000),
|
||||||
|
Speed.of(100),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, null, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, null, null).toString();
|
||||||
@@ -89,19 +103,36 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_metric_speed_rounding_check() {
|
public void getAnnouncement_metric_speed_rounding_check() {
|
||||||
TrackStatistics stats = new TrackStatistics();
|
Track track = new Track(
|
||||||
stats.setStartTime(Instant.EPOCH);
|
null,
|
||||||
stats.setTotalDistance(Distance.of(20000));
|
null,
|
||||||
stats.setTotalTime(Duration.ofHours(1).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMovingTime(Duration.ofHours(1).plusSeconds(1));
|
"",
|
||||||
stats.setMaxSpeed(Speed.of(100));
|
"",
|
||||||
stats.setTotalAltitudeGain(6000f);
|
ActivityType.AIRPLANE,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(
|
||||||
|
Instant.EPOCH,
|
||||||
|
Instant.EPOCH,
|
||||||
|
Duration.ofHours(2).plusMinutes(5).plusSeconds(10),
|
||||||
|
Duration.ofHours(1).plusSeconds(1),
|
||||||
|
Distance.of(20000),
|
||||||
|
Speed.of(100),
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(6000, 6000),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, null, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, null, null).toString();
|
||||||
@@ -112,19 +143,36 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_metric_distance_rounding_check() {
|
public void getAnnouncement_metric_distance_rounding_check() {
|
||||||
TrackStatistics stats = new TrackStatistics();
|
Track track = new Track(
|
||||||
stats.setStartTime(Instant.EPOCH);
|
null,
|
||||||
stats.setTotalDistance(Distance.of(19999));
|
null,
|
||||||
stats.setTotalTime(Duration.ofHours(1).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMovingTime(Duration.ofHours(1));
|
"",
|
||||||
stats.setMaxSpeed(Speed.of(100));
|
"",
|
||||||
stats.setTotalAltitudeGain(6000f);
|
ActivityType.AIRPLANE,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(
|
||||||
|
Instant.EPOCH,
|
||||||
|
Instant.EPOCH,
|
||||||
|
Duration.ofHours(2).plusMinutes(5).plusSeconds(10),
|
||||||
|
Duration.ofHours(1),
|
||||||
|
Distance.of(19999),
|
||||||
|
Speed.of(100),
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(6000, 6000),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, null, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, null, null).toString();
|
||||||
@@ -135,19 +183,36 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_metric_distance_rounding_check_two() {
|
public void getAnnouncement_metric_distance_rounding_check_two() {
|
||||||
TrackStatistics stats = new TrackStatistics();
|
Track track = new Track(
|
||||||
stats.setStartTime(Instant.EPOCH);
|
null,
|
||||||
stats.setTotalDistance(Distance.of(19900));
|
null,
|
||||||
stats.setTotalTime(Duration.ofHours(1).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMovingTime(Duration.ofHours(1));
|
"",
|
||||||
stats.setMaxSpeed(Speed.of(100));
|
"",
|
||||||
stats.setTotalAltitudeGain(6000f);
|
ActivityType.AIRPLANE,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(
|
||||||
|
Instant.EPOCH,
|
||||||
|
Instant.EPOCH,
|
||||||
|
Duration.ofHours(2).plusMinutes(5).plusSeconds(10),
|
||||||
|
Duration.ofHours(1),
|
||||||
|
Distance.of(19900),
|
||||||
|
Speed.of(100),
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(6000, 6000),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, null, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, null, null).toString();
|
||||||
@@ -159,26 +224,20 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_withInterval_metric_speed() {
|
public void getAnnouncement_withInterval_metric_speed() {
|
||||||
// given
|
// given
|
||||||
int numberOfPoints = 1000;
|
Pair<Track, Statistics> data = buildTrackWithTrackPoints();
|
||||||
Pair<Track.Id, TrackStatistics> trackWithStats = TestDataUtil.buildTrackWithTrackPoints(contentProviderUtils, numberOfPoints);
|
|
||||||
Track.Id trackId = trackWithStats.first;
|
|
||||||
TrackStatistics stats = trackWithStats.second;
|
|
||||||
IntervalStatistics.Interval lastInterval;
|
|
||||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
|
||||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
|
||||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
|
||||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
|
||||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
null,
|
||||||
|
null,
|
||||||
Track track = new Track();
|
null,
|
||||||
track.setTrackStatistics(stats);
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, lastInterval, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, data.first, dataSet, UnitSystem.METRIC, true, data.second, null).toString();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals("12:16 AM. 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);
|
assertEquals("12:16 AM. 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);
|
||||||
@@ -186,19 +245,36 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_metric_pace() {
|
public void getAnnouncement_metric_pace() {
|
||||||
TrackStatistics stats = new TrackStatistics();
|
Track track = new Track(
|
||||||
stats.setStartTime(Instant.EPOCH);
|
null,
|
||||||
stats.setTotalDistance(Distance.of(20000));
|
null,
|
||||||
stats.setTotalTime(Duration.ofHours(2).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMovingTime(Duration.ofHours(1).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMaxSpeed(Speed.of(100));
|
"",
|
||||||
stats.setTotalAltitudeGain(6000f);
|
ActivityType.AIRPLANE,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(
|
||||||
|
Instant.EPOCH,
|
||||||
|
Instant.EPOCH,
|
||||||
|
Duration.ofHours(2).plusMinutes(5).plusSeconds(10),
|
||||||
|
Duration.ofHours(1).plusMinutes(5).plusSeconds(10),
|
||||||
|
Distance.of(20000),
|
||||||
|
Speed.of(100),
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(6000, 6000),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, false, null, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, false, null, null).toString();
|
||||||
@@ -210,26 +286,20 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_withInterval_metric_pace() {
|
public void getAnnouncement_withInterval_metric_pace() {
|
||||||
// given
|
// given
|
||||||
int numberOfPoints = 1000;
|
Pair<Track, Statistics> data = buildTrackWithTrackPoints();
|
||||||
Pair<Track.Id, TrackStatistics> trackWithStats = TestDataUtil.buildTrackWithTrackPoints(contentProviderUtils, numberOfPoints);
|
|
||||||
Track.Id trackId = trackWithStats.first;
|
|
||||||
TrackStatistics stats = trackWithStats.second;
|
|
||||||
IntervalStatistics.Interval lastInterval;
|
|
||||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
|
||||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
|
||||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
|
||||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
|
||||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, false, lastInterval, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, data.first, dataSet, UnitSystem.METRIC, false, data.second, null).toString();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals("12:16 AM. 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);
|
assertEquals("12:16 AM. 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);
|
||||||
@@ -237,19 +307,36 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_imperial_speed() {
|
public void getAnnouncement_imperial_speed() {
|
||||||
TrackStatistics stats = new TrackStatistics();
|
Track track = new Track(
|
||||||
stats.setStartTime(Instant.EPOCH);
|
null,
|
||||||
stats.setTotalDistance(Distance.of(20000));
|
null,
|
||||||
stats.setTotalTime(Duration.ofHours(2).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMovingTime(Duration.ofHours(1).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMaxSpeed(Speed.of(100));
|
"",
|
||||||
stats.setTotalAltitudeGain(6000f);
|
ActivityType.AIRPLANE,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(
|
||||||
|
Instant.EPOCH,
|
||||||
|
Instant.EPOCH,
|
||||||
|
Duration.ofHours(2).plusMinutes(5).plusSeconds(10),
|
||||||
|
Duration.ofHours(1).plusMinutes(5).plusSeconds(10),
|
||||||
|
Distance.of(20000),
|
||||||
|
Speed.of(100),
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(6000, 6000),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.IMPERIAL_FEET, true, null, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.IMPERIAL_FEET, true, null, null).toString();
|
||||||
@@ -260,17 +347,36 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_imperial_speed_1() {
|
public void getAnnouncement_imperial_speed_1() {
|
||||||
TrackStatistics stats = new TrackStatistics();
|
Track track = new Track(
|
||||||
stats.setStartTime(Instant.EPOCH);
|
null,
|
||||||
stats.setTotalDistance(Distance.ofMile(1.1));
|
null,
|
||||||
stats.setTotalTime(Duration.ofHours(2).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMovingTime(Duration.ofHours(1));
|
"",
|
||||||
|
"",
|
||||||
|
ActivityType.AIRPLANE,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(
|
||||||
|
Instant.EPOCH,
|
||||||
|
Instant.EPOCH,
|
||||||
|
Duration.ofHours(2).plusMinutes(5).plusSeconds(10),
|
||||||
|
Duration.ofHours(1),
|
||||||
|
Distance.ofMile(1.1),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.IMPERIAL_FEET, true, null, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.IMPERIAL_FEET, true, null, null).toString();
|
||||||
@@ -281,17 +387,36 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_imperial_meter_speed_1() {
|
public void getAnnouncement_imperial_meter_speed_1() {
|
||||||
TrackStatistics stats = new TrackStatistics();
|
Track track = new Track(
|
||||||
stats.setStartTime(Instant.EPOCH);
|
null,
|
||||||
stats.setTotalDistance(Distance.ofMile(1.1));
|
null,
|
||||||
stats.setTotalTime(Duration.ofHours(2).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMovingTime(Duration.ofHours(1));
|
"",
|
||||||
|
"",
|
||||||
|
ActivityType.AIRPLANE,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(
|
||||||
|
Instant.EPOCH,
|
||||||
|
Instant.EPOCH,
|
||||||
|
Duration.ofHours(2).plusMinutes(5).plusSeconds(10),
|
||||||
|
Duration.ofHours(1),
|
||||||
|
Distance.ofMile(1.1),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.IMPERIAL_METER, true, null, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.IMPERIAL_METER, true, null, null).toString();
|
||||||
@@ -302,17 +427,36 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_metric_speed_1() {
|
public void getAnnouncement_metric_speed_1() {
|
||||||
TrackStatistics stats = new TrackStatistics();
|
Track track = new Track(
|
||||||
stats.setStartTime(Instant.EPOCH);
|
null,
|
||||||
stats.setTotalDistance(Distance.ofKilometer(1.1));
|
null,
|
||||||
stats.setTotalTime(Duration.ofHours(2).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMovingTime(Duration.ofHours(1));
|
"",
|
||||||
|
"",
|
||||||
|
ActivityType.AIRPLANE,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(
|
||||||
|
Instant.EPOCH,
|
||||||
|
Instant.EPOCH,
|
||||||
|
Duration.ofHours(2).plusMinutes(5).plusSeconds(10),
|
||||||
|
Duration.ofHours(1),
|
||||||
|
Distance.ofKilometer(1.1),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, null, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, null, null).toString();
|
||||||
@@ -324,26 +468,20 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_withInterval_imperial_speed() {
|
public void getAnnouncement_withInterval_imperial_speed() {
|
||||||
// given
|
// given
|
||||||
int numberOfPoints = 1000;
|
Pair<Track, Statistics> data = buildTrackWithTrackPoints();
|
||||||
Pair<Track.Id, TrackStatistics> trackWithStats = TestDataUtil.buildTrackWithTrackPoints(contentProviderUtils, numberOfPoints);
|
|
||||||
Track.Id trackId = trackWithStats.first;
|
|
||||||
TrackStatistics stats = trackWithStats.second;
|
|
||||||
IntervalStatistics.Interval lastInterval;
|
|
||||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
|
||||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
|
||||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
|
||||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
|
||||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.IMPERIAL_FEET, true, lastInterval, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, data.first, dataSet, UnitSystem.IMPERIAL_FEET, true, data.second, null).toString();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals("12:16 AM. 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);
|
assertEquals("12:16 AM. 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);
|
||||||
@@ -351,19 +489,36 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_imperial_pace() {
|
public void getAnnouncement_imperial_pace() {
|
||||||
TrackStatistics stats = new TrackStatistics();
|
Track track = new Track(
|
||||||
stats.setStartTime(Instant.EPOCH);
|
null,
|
||||||
stats.setTotalDistance(Distance.of(20000));
|
null,
|
||||||
stats.setTotalTime(Duration.ofHours(2).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMovingTime(Duration.ofHours(1).plusMinutes(5).plusSeconds(10));
|
"",
|
||||||
stats.setMaxSpeed(Speed.of(100));
|
"",
|
||||||
stats.setTotalAltitudeGain(6000f);
|
ActivityType.AIRPLANE,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(
|
||||||
|
Instant.EPOCH,
|
||||||
|
Instant.EPOCH,
|
||||||
|
Duration.ofHours(2).plusMinutes(5).plusSeconds(10),
|
||||||
|
Duration.ofHours(1).plusMinutes(5).plusSeconds(10),
|
||||||
|
Distance.of(20000),
|
||||||
|
Speed.of(100),
|
||||||
|
null,
|
||||||
|
new AltitudeGainLoss(6000, 6000),
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.IMPERIAL_FEET, false, null, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.IMPERIAL_FEET, false, null, null).toString();
|
||||||
@@ -375,26 +530,20 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_withInterval_imperial_pace() {
|
public void getAnnouncement_withInterval_imperial_pace() {
|
||||||
// given
|
// given
|
||||||
int numberOfPoints = 1000;
|
Pair<Track, Statistics> data = buildTrackWithTrackPoints();
|
||||||
Pair<Track.Id, TrackStatistics> trackWithStats = TestDataUtil.buildTrackWithTrackPoints(contentProviderUtils, numberOfPoints);
|
|
||||||
Track.Id trackId = trackWithStats.first;
|
|
||||||
TrackStatistics stats = trackWithStats.second;
|
|
||||||
IntervalStatistics.Interval lastInterval;
|
|
||||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
|
||||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
|
||||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
|
||||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
|
||||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.IMPERIAL_FEET, false, lastInterval, null).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, data.first, dataSet, UnitSystem.IMPERIAL_FEET, false, data.second, null).toString();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals("12:16 AM. 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);
|
assertEquals("12:16 AM. 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);
|
||||||
@@ -402,31 +551,26 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_heart_rate_and_sensor_statistics() {
|
public void getAnnouncement_heart_rate_and_sensor_statistics() {
|
||||||
|
// given
|
||||||
PreferencesUtils.setVoiceAnnounceAverageHeartRate(true);
|
PreferencesUtils.setVoiceAnnounceAverageHeartRate(true);
|
||||||
PreferencesUtils.setVoiceAnnounceLapHeartRate(true);
|
PreferencesUtils.setVoiceAnnounceLapHeartRate(true);
|
||||||
|
|
||||||
int numberOfPoints = 1000;
|
Pair<Track, Statistics> data = buildTrackWithTrackPoints();
|
||||||
Pair<Track.Id, TrackStatistics> trackWithStats = TestDataUtil.buildTrackWithTrackPoints(contentProviderUtils, numberOfPoints);
|
|
||||||
Track.Id trackId = trackWithStats.first;
|
|
||||||
TrackStatistics stats = trackWithStats.second;
|
|
||||||
IntervalStatistics.Interval lastInterval;
|
|
||||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
|
||||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
|
||||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
|
||||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
|
||||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null);
|
SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null);
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, data.first, dataSet, UnitSystem.METRIC, true, data.second, sensorStatistics).toString();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals("12:16 AM. 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. Lap heart rate 133 bpm.", announcement);
|
assertEquals("12:16 AM. 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. Lap heart rate 133 bpm.", announcement);
|
||||||
@@ -434,6 +578,7 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAnnouncement_heart_rate() {
|
public void getAnnouncement_heart_rate() {
|
||||||
|
// given
|
||||||
PreferencesUtils.setVoiceAnnounceHeartRateCurrent(true);
|
PreferencesUtils.setVoiceAnnounceHeartRateCurrent(true);
|
||||||
PreferencesUtils.setVoiceAnnounceLapHeartRate(true);
|
PreferencesUtils.setVoiceAnnounceLapHeartRate(true);
|
||||||
PreferencesUtils.setVoiceAnnounceAverageHeartRate(true);
|
PreferencesUtils.setVoiceAnnounceAverageHeartRate(true);
|
||||||
@@ -443,28 +588,22 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
PreferencesUtils.setVoiceAnnounceAverageSpeedPace(false);
|
PreferencesUtils.setVoiceAnnounceAverageSpeedPace(false);
|
||||||
PreferencesUtils.setVoiceAnnounceLapSpeedPace(false);
|
PreferencesUtils.setVoiceAnnounceLapSpeedPace(false);
|
||||||
|
|
||||||
int numberOfPoints = 1000;
|
Pair<Track, Statistics> data = buildTrackWithTrackPoints();
|
||||||
Pair<Track.Id, TrackStatistics> trackWithStats = TestDataUtil.buildTrackWithTrackPoints(contentProviderUtils, numberOfPoints);
|
|
||||||
Track.Id trackId = trackWithStats.first;
|
|
||||||
TrackStatistics stats = trackWithStats.second;
|
|
||||||
IntervalStatistics.Interval lastInterval;
|
|
||||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
|
||||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
|
||||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
|
||||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
|
||||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null);
|
SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null);
|
||||||
|
|
||||||
Track track = new Track();
|
SensorDataSet dataSet = new SensorDataSet(
|
||||||
track.setTrackStatistics(stats);
|
null,
|
||||||
|
null,
|
||||||
SensorDataSet dataSet = Mockito.mock(SensorDataSet.class);
|
null,
|
||||||
Mockito.when(dataSet.getHeartRate()).thenReturn(new Pair<>(HeartRate.of(60), "unused"));
|
new SensorData<>(HeartRate.of(60), "unused"),
|
||||||
|
null, null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String announcement = VoiceAnnouncementUtils.createStatistics(context, track, dataSet, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString();
|
String announcement = VoiceAnnouncementUtils.createStatistics(context, data.first, dataSet, UnitSystem.METRIC, true, data.second, sensorStatistics).toString();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals("12:16 AM. Current heart rate 60 bpm. Average heart rate 180 bpm. Lap heart rate 133 bpm.", announcement);
|
assertEquals("12:16 AM. Current heart rate 60 bpm. Average heart rate 180 bpm. Lap heart rate 133 bpm.", announcement);
|
||||||
@@ -484,4 +623,40 @@ public class VoiceAnnouncementUtilsTest {
|
|||||||
assertEquals("1.1 miles", MessageFormat.format(template, Map.of("n", 1.11)));
|
assertEquals("1.1 miles", MessageFormat.format(template, Map.of("n", 1.11)));
|
||||||
assertEquals("1.2 miles", MessageFormat.format(template, Map.of("n", 1.18)));
|
assertEquals("1.2 miles", MessageFormat.format(template, Map.of("n", 1.18)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Pair<Track, Statistics> buildTrackWithTrackPoints() {
|
||||||
|
int numberOfPoints = 1000;
|
||||||
|
|
||||||
|
ArrayList<TrackPoint> trackPoints = new ArrayList<>();
|
||||||
|
for (int i = 0; i < numberOfPoints; i++) {
|
||||||
|
trackPoints.add(TestDataUtil.createTrackPoint(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
IntervalStatisticsUpdater intervalStatistics = new IntervalStatisticsUpdater(Distance.of(1000));
|
||||||
|
intervalStatistics.addTrackPoints(trackPoints.iterator());
|
||||||
|
Statistics lastInterval = intervalStatistics.getLastInterval();
|
||||||
|
|
||||||
|
Track track = new Track(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
ActivityType.AIRPLANE,
|
||||||
|
ZoneOffset.UTC,
|
||||||
|
new Statistics(
|
||||||
|
Instant.EPOCH,
|
||||||
|
Instant.EPOCH.plusSeconds(999),
|
||||||
|
Duration.ofMinutes(16).plusSeconds(39),
|
||||||
|
Duration.ofMinutes(16).plusSeconds(39),
|
||||||
|
Distance.of(14208),
|
||||||
|
Speed.of(104),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
|
return new Pair<>(track, lastInterval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -60,8 +60,7 @@ public class PreferencesOpenHelperTest {
|
|||||||
// when update to version 2
|
// when update to version 2
|
||||||
PreferencesOpenHelper.newInstance(2).check();
|
PreferencesOpenHelper.newInstance(2).check();
|
||||||
|
|
||||||
String updatedOldCustomLayoutCsv = context.getString(R.string.activity_type_unknown) + ";"
|
String updatedOldCustomLayoutCsv = context.getString(R.string.activity_type_unknown) + ";2;distance,1,1,0;speed,1,1,0;";
|
||||||
+ PreferencesUtils.getLayoutColumnsByDefault() + ";distance,1,1,0;speed,1,1,0;";
|
|
||||||
|
|
||||||
// then there should be one layout with old custom layout that has the new CSV value.
|
// then there should be one layout with old custom layout that has the new CSV value.
|
||||||
List<RecordingLayout> recordingLayouts = PreferencesUtils.getAllCustomLayouts();
|
List<RecordingLayout> recordingLayouts = PreferencesUtils.getAllCustomLayouts();
|
||||||
@@ -110,7 +109,7 @@ public class PreferencesOpenHelperTest {
|
|||||||
PreferencesOpenHelper.newInstance(1).check();
|
PreferencesOpenHelper.newInstance(1).check();
|
||||||
|
|
||||||
// then custom layout should be equals to default layout.
|
// then custom layout should be equals to default layout.
|
||||||
RecordingLayout defaultRecordingLayout = RecordingLayoutIO.fromCsv(PreferencesUtils.buildDefaultLayout(), resources);
|
RecordingLayout defaultRecordingLayout = RecordingLayoutIO.fromCsvLine(PreferencesUtils.buildDefaultLayout(), resources);
|
||||||
List<RecordingLayout> customRecordingLayout = PreferencesUtils.getAllCustomLayouts();
|
List<RecordingLayout> customRecordingLayout = PreferencesUtils.getAllCustomLayouts();
|
||||||
|
|
||||||
assertEquals(1, customRecordingLayout.size());
|
assertEquals(1, customRecordingLayout.size());
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user