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:
Jimmy Shih
2011-10-10 16:47:59 -07:00
parent c39ab2fda2
commit 21e47d8ce0
8 changed files with 57 additions and 28 deletions
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}