Fix unit tests

This commit is contained in:
Jimmy Shih
2011-10-09 13:42:02 -07:00
parent b1af2089a4
commit 36f7ba71f9
6 changed files with 10 additions and 36 deletions
@@ -63,7 +63,6 @@ public class MapOverlayTest extends AndroidTestCase {
assertEquals(2, myTracksOverlay.getNumLocations()); assertEquals(2, myTracksOverlay.getNumLocations());
assertEquals(0, myTracksOverlay.getNumWaypoints()); assertEquals(0, myTracksOverlay.getNumWaypoints());
assertNotNull(myTracksOverlay.getLastPath()); assertNotNull(myTracksOverlay.getLastPath());
assertEquals(2, ((MockPath)myTracksOverlay.getLastPath()).totalPoints);
myTracksOverlay.draw(canvas, mockView, true); myTracksOverlay.draw(canvas, mockView, true);
assertEquals(2, myTracksOverlay.getNumLocations()); assertEquals(2, myTracksOverlay.getNumLocations());
@@ -152,11 +151,8 @@ public class MapOverlayTest extends AndroidTestCase {
// No shadow. // No shadow.
myTracksOverlay.draw(canvas, mockView, false); myTracksOverlay.draw(canvas, mockView, false);
assertNotNull(myTracksOverlay.getLastPath()); assertNotNull(myTracksOverlay.getLastPath());
assertTrue(myTracksOverlay.getLastPath() instanceof MockPath);
MockPath path = (MockPath) myTracksOverlay.getLastPath();
assertEquals(40, myTracksOverlay.getNumWaypoints()); assertEquals(40, myTracksOverlay.getNumWaypoints());
assertEquals(100, myTracksOverlay.getNumLocations()); assertEquals(100, myTracksOverlay.getNumLocations());
assertEquals(100, path.totalPoints);
// TODO: Check the points from the path (and the segments). // TODO: Check the points from the path (and the segments).
} }
} }
@@ -15,8 +15,6 @@
*/ */
package com.google.android.apps.mytracks.maps; package com.google.android.apps.mytracks.maps;
import com.google.android.apps.mytracks.MockPath;
import android.location.Location; import android.location.Location;
/** /**
@@ -45,9 +43,6 @@ public class TrackPathDescriptorDynamicSpeedTest extends TrackPathPainterTestCas
painter.updatePath(myTracksOverlay.getMapProjection(mockView), painter.updatePath(myTracksOverlay.getMapProjection(mockView),
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible, myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
myTracksOverlay.getPoints()); myTracksOverlay.getPoints());
assertNotNull(myTracksOverlay.getLastPath());
assertTrue(myTracksOverlay.getLastPath() instanceof MockPath);
painter.drawTrack(canvas); painter.drawTrack(canvas);
} }
} }
@@ -15,8 +15,6 @@
*/ */
package com.google.android.apps.mytracks.maps; package com.google.android.apps.mytracks.maps;
import com.google.android.apps.mytracks.MockPath;
import android.location.Location; import android.location.Location;
/** /**
@@ -45,8 +43,6 @@ public class TrackPathDescriptorFixedSpeedTest extends TrackPathPainterTestCase
painter.updatePath(myTracksOverlay.getMapProjection(mockView), painter.updatePath(myTracksOverlay.getMapProjection(mockView),
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible, myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
myTracksOverlay.getPoints()); myTracksOverlay.getPoints());
assertNotNull(myTracksOverlay.getLastPath());
assertTrue(myTracksOverlay.getLastPath() instanceof MockPath);
painter.drawTrack(canvas); painter.drawTrack(canvas);
} }
} }
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.maps; package com.google.android.apps.mytracks.maps;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MockPath;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.content.Context; import android.content.Context;
@@ -57,8 +56,8 @@ public class TrackPathPainterFactoryTest extends TrackPathPainterTestCase {
private <T> void testTrackPathPainterFactorySpecific(Context context, SharedPreferences prefs, private <T> void testTrackPathPainterFactorySpecific(Context context, SharedPreferences prefs,
int track_color_mode, Class <?> c) { int track_color_mode, Class <?> c) {
prefs.edit().putString(context.getString(track_color_mode), prefs.edit().putString(context.getString(R.string.track_color_mode_key),
context.getString(R.string.track_color_mode_key)).commit(); context.getString(track_color_mode)).commit();
int startLocationIdx = 0; int startLocationIdx = 0;
Boolean alwaysVisible = true; Boolean alwaysVisible = true;
@@ -71,8 +70,6 @@ public class TrackPathPainterFactoryTest extends TrackPathPainterTestCase {
painter.updatePath(myTracksOverlay.getMapProjection(mockView), painter.updatePath(myTracksOverlay.getMapProjection(mockView),
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible, myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
myTracksOverlay.getPoints()); myTracksOverlay.getPoints());
assertNotNull(myTracksOverlay.getLastPath());
assertTrue(myTracksOverlay.getLastPath() instanceof MockPath);
painter.drawTrack(canvas); painter.drawTrack(canvas);
} }
} }
@@ -15,8 +15,6 @@
*/ */
package com.google.android.apps.mytracks.maps; package com.google.android.apps.mytracks.maps;
import com.google.android.apps.mytracks.MockPath;
import android.location.Location; import android.location.Location;
/** /**
@@ -45,8 +43,6 @@ public class TrackPathPainterSingleColorTest extends TrackPathPainterTestCase {
painter.updatePath(myTracksOverlay.getMapProjection(mockView), painter.updatePath(myTracksOverlay.getMapProjection(mockView),
myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible, myTracksOverlay.getMapViewRect(mockView), startLocationIdx, alwaysVisible,
myTracksOverlay.getPoints()); myTracksOverlay.getPoints());
assertNotNull(myTracksOverlay.getLastPath());
assertTrue(myTracksOverlay.getLastPath() instanceof MockPath);
painter.drawTrack(canvas); painter.drawTrack(canvas);
} }
} }
@@ -405,12 +405,10 @@ public class TrackRecordingServiceTest
ITrackRecordingService service = bindAndGetService(createStartIntent()); ITrackRecordingService service = bindAndGetService(createStartIntent());
assertTrue(service.isRecording()); assertTrue(service.isRecording());
try { // Starting a new track when there is a recording should just return -1L.
service.startNewTrack(); long newTrack = service.startNewTrack();
fail("Expecting IllegalStateException"); assertEquals(-1L, newTrack);
} catch (IllegalStateException e) {
// Expected.
}
assertEquals(123, sharedPreferences.getLong( assertEquals(123, sharedPreferences.getLong(
context.getString(R.string.recording_track_key), 0)); context.getString(R.string.recording_track_key), 0));
assertEquals(123, service.getRecordingTrackId()); assertEquals(123, service.getRecordingTrackId());
@@ -452,13 +450,9 @@ public class TrackRecordingServiceTest
ITrackRecordingService service = bindAndGetService(createStartIntent()); ITrackRecordingService service = bindAndGetService(createStartIntent());
assertFalse(service.isRecording()); assertFalse(service.isRecording());
// End the current track. // Ending the current track when there is no recording should not result in any error.
try { service.endCurrentTrack();
service.endCurrentTrack();
fail("Expecting IllegalStateException");
} catch (IllegalStateException e) {
// Expected.
}
assertEquals(-1, sharedPreferences.getLong( assertEquals(-1, sharedPreferences.getLong(
context.getString(R.string.recording_track_key), 0)); context.getString(R.string.recording_track_key), 0));
assertEquals(-1, service.getRecordingTrackId()); assertEquals(-1, service.getRecordingTrackId());