mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-10 05:03:06 +02:00
Fix unit tests with TrackPathDescriptor.
In MapOverlay, for testing, expose a getter and a setter for TrackPathDescriptor instead of newPath and getLastPath. In SingleColorTrackPathPainter, refactor "new Path" to a newPath method so that tests can override the newPath method to provide a mockPath.
This commit is contained in:
+5
-1
@@ -35,7 +35,10 @@ public class TrackPathDescriptorDynamicSpeedTest extends TrackPathPainterTestCas
|
||||
myTracksOverlay.addLocation(location);
|
||||
}
|
||||
|
||||
TrackPathPainter painter = new DynamicSpeedTrackPathPainter(getContext(), new DynamicSpeedTrackPathDescriptor(getContext()));
|
||||
TrackPathPainter painter = new DynamicSpeedTrackPathPainter(
|
||||
getContext(), new DynamicSpeedTrackPathDescriptor(getContext()));
|
||||
myTracksOverlay.setTrackPathPainter(painter);
|
||||
|
||||
int startLocationIdx = 0;
|
||||
Boolean alwaysVisible = true;
|
||||
|
||||
@@ -43,6 +46,7 @@ public class TrackPathDescriptorDynamicSpeedTest extends TrackPathPainterTestCas
|
||||
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
||||
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
||||
myTracksOverlay.getPoints());
|
||||
assertNotNull(myTracksOverlay.getTrackPathPainter().getLastPath());
|
||||
painter.drawTrack(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -35,7 +35,10 @@ public class TrackPathDescriptorFixedSpeedTest extends TrackPathPainterTestCase
|
||||
myTracksOverlay.addLocation(location);
|
||||
}
|
||||
|
||||
TrackPathPainter painter = new DynamicSpeedTrackPathPainter(getContext(), new FixedSpeedTrackPathDescriptor(getContext()));
|
||||
TrackPathPainter painter = new DynamicSpeedTrackPathPainter(
|
||||
getContext(), new FixedSpeedTrackPathDescriptor(getContext()));
|
||||
myTracksOverlay.setTrackPathPainter(painter);
|
||||
|
||||
int startLocationIdx = 0;
|
||||
Boolean alwaysVisible = true;
|
||||
|
||||
@@ -43,6 +46,7 @@ public class TrackPathDescriptorFixedSpeedTest extends TrackPathPainterTestCase
|
||||
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
||||
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
||||
myTracksOverlay.getPoints());
|
||||
assertNotNull(myTracksOverlay.getTrackPathPainter().getLastPath());
|
||||
painter.drawTrack(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -63,6 +63,7 @@ public class TrackPathPainterFactoryTest extends TrackPathPainterTestCase {
|
||||
Boolean alwaysVisible = true;
|
||||
|
||||
TrackPathPainter painter = TrackPathPainterFactory.getTrackPathPainter(context);
|
||||
myTracksOverlay.setTrackPathPainter(painter);
|
||||
|
||||
assertNotNull(painter);
|
||||
assertTrue(c.isInstance(painter));
|
||||
@@ -70,6 +71,7 @@ public class TrackPathPainterFactoryTest extends TrackPathPainterTestCase {
|
||||
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
||||
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
||||
myTracksOverlay.getPoints());
|
||||
assertNotNull(myTracksOverlay.getTrackPathPainter().getLastPath());
|
||||
painter.drawTrack(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -36,6 +36,8 @@ public class TrackPathPainterSingleColorTest extends TrackPathPainterTestCase {
|
||||
}
|
||||
|
||||
TrackPathPainter painter = new SingleColorTrackPathPainter(getContext());
|
||||
myTracksOverlay.setTrackPathPainter(painter);
|
||||
|
||||
int startLocationIdx = 0;
|
||||
Boolean alwaysVisible = true;
|
||||
|
||||
@@ -43,6 +45,7 @@ public class TrackPathPainterSingleColorTest extends TrackPathPainterTestCase {
|
||||
painter.updatePath(myTracksOverlay.getMapProjection(mockView),
|
||||
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
|
||||
myTracksOverlay.getPoints());
|
||||
assertNotNull(myTracksOverlay.getTrackPathPainter().getLastPath());
|
||||
painter.drawTrack(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user