Refactoring to marker: content-package and fragments.

#389
This commit is contained in:
Dennis Guse
2020-09-05 10:37:41 +02:00
parent 19d8563a76
commit 9d6c9676ab
14 changed files with 150 additions and 147 deletions
@@ -278,7 +278,7 @@ public class SearchEngineTest {
private void assertTrackResult(Track.Id trackId, ScoredResult result) {
assertNotNull("Not a track", result.track);
assertNull("Ambiguous result", result.waypoint);
assertNull("Ambiguous result", result.marker);
assertEquals(trackId, result.track.getId());
}
@@ -293,15 +293,15 @@ public class SearchEngineTest {
for (int i = 0; i < results.size(); i++) {
ScoredResult result = results.get(i);
assertNotNull(errMsg, result.track);
assertNull(errMsg, result.waypoint);
assertNull(errMsg, result.marker);
assertEquals(errMsg, trackIds[i], result.track.getId());
}
}
private void assertWaypointResult(Marker.Id waypointId, ScoredResult result) {
assertNotNull("Not a waypoint", result.waypoint);
assertNotNull("Not a waypoint", result.marker);
assertNull("Ambiguous result", result.track);
assertEquals(waypointId, result.waypoint.getId());
assertEquals(waypointId, result.marker.getId());
}
private void assertWaypointResults(List<ScoredResult> results, Marker.Id... waypointIds) {
@@ -314,9 +314,9 @@ public class SearchEngineTest {
assertEquals(results.size(), waypointIds.length);
for (int i = 0; i < results.size(); i++) {
ScoredResult result = results.get(i);
assertNotNull(errMsg, result.waypoint);
assertNotNull(errMsg, result.marker);
assertNull(errMsg, result.track);
assertEquals(errMsg, waypointIds[i], result.waypoint.getId());
assertEquals(errMsg, waypointIds[i], result.marker.getId());
}
}
}
@@ -53,7 +53,7 @@ public class ExportImportTest {
private static final String TRACK_CATEGORY = "the category";
private static final String TRACK_DESCRIPTION = "the description";
private final List<Marker> waypoints = new ArrayList<>();
private final List<Marker> markers = new ArrayList<>();
private final List<TrackPoint> trackPoints = new ArrayList<>();
private Track.Id importTrackId;
@@ -72,19 +72,19 @@ public class ExportImportTest {
trackPoints.addAll(Arrays.asList(track.second));
for (int i = 0; i < 3; i++) {
Marker waypoint = new Marker(track.second[i].getLocation());
waypoint.setName("the waypoint " + i);
waypoint.setDescription("the waypoint description " + i);
waypoint.setCategory("the waypoint category" + i);
waypoint.setIcon("the waypoing icon" + i);
waypoint.setPhotoUrl("the photo url" + i);
waypoint.setTrackId(trackId);
contentProviderUtils.insertMarker(waypoint);
Marker marker = new Marker(track.second[i].getLocation());
marker.setName("the marker " + i);
marker.setDescription("the marker description " + i);
marker.setCategory("the marker category" + i);
marker.setIcon("the waypoing icon" + i);
marker.setPhotoUrl("the photo url" + i);
marker.setTrackId(trackId);
contentProviderUtils.insertMarker(marker);
waypoints.add(waypoint);
markers.add(marker);
}
assertEquals(waypoints.size(), contentProviderUtils.getMarkerCount(trackId));
assertEquals(markers.size(), contentProviderUtils.getMarkerCount(trackId));
}
@After
@@ -129,8 +129,8 @@ public class ExportImportTest {
assertEquals(track.getIcon(), importedTrack.getIcon());
assertEquals(track.getUuid(), importedTrack.getUuid());
// 2. waypoints
assertWaypoints();
// 2. markers
assertMarkers();
// 3. trackpoints
assertTrackpoints(false, false, false);
@@ -164,8 +164,8 @@ public class ExportImportTest {
assertEquals(track.getName(), importedTrack.getName());
assertEquals(track.getIcon(), importedTrack.getIcon());
// 2. waypoints
assertWaypoints();
// 2. markers
assertMarkers();
// 3. trackpoints
assertTrackpoints(true, true, true);
@@ -253,8 +253,8 @@ public class ExportImportTest {
//TODO exporting and importing a track icon is not yet supported by GpxTrackWriter.
//assertEquals(track.getIcon(), trackImported.getIcon());
// 2. waypoints
assertWaypoints();
// 2. markers
assertMarkers();
// 3. trackpoints
assertTrackpoints(false, true, true);
@@ -285,22 +285,22 @@ public class ExportImportTest {
assertNull(trackImported);
}
private void assertWaypoints() {
assertEquals(waypoints.size(), contentProviderUtils.getMarkerCount(importTrackId));
private void assertMarkers() {
assertEquals(markers.size(), contentProviderUtils.getMarkerCount(importTrackId));
List<Marker> importedWaypoints = contentProviderUtils.getMarkers(importTrackId);
for (int i = 0; i < waypoints.size(); i++) {
Marker waypoint = waypoints.get(i);
Marker importedWaypoint = importedWaypoints.get(i);
assertEquals(waypoint.getCategory(), importedWaypoint.getCategory());
assertEquals(waypoint.getDescription(), importedWaypoint.getDescription());
// assertEquals(waypoint.getIcon(), importedWaypoint.getIcon()); // TODO for KML
assertEquals(waypoint.getName(), importedWaypoint.getName());
assertEquals("", importedWaypoint.getPhotoUrl());
List<Marker> importedMarkers = contentProviderUtils.getMarkers(importTrackId);
for (int i = 0; i < markers.size(); i++) {
Marker marker = markers.get(i);
Marker importMarker = importedMarkers.get(i);
assertEquals(marker.getCategory(), importMarker.getCategory());
assertEquals(marker.getDescription(), importMarker.getDescription());
// assertEquals(marker.getIcon(), importMarker.getIcon()); // TODO for KML
assertEquals(marker.getName(), importMarker.getName());
assertEquals("", importMarker.getPhotoUrl());
assertEquals(waypoint.getLocation().getLatitude(), importedWaypoint.getLocation().getLatitude(), 0.001);
assertEquals(waypoint.getLocation().getLongitude(), importedWaypoint.getLocation().getLongitude(), 0.001);
assertEquals(waypoint.getLocation().getAltitude(), importedWaypoint.getLocation().getAltitude(), 0.001);
assertEquals(marker.getLocation().getLatitude(), importMarker.getLocation().getLatitude(), 0.001);
assertEquals(marker.getLocation().getLongitude(), importMarker.getLocation().getLongitude(), 0.001);
assertEquals(marker.getLocation().getAltitude(), importMarker.getLocation().getAltitude(), 0.001);
}
}