forked from upstream-mirrors/OpenTracks
Remove unused methods in MyTracksProviderUtils
Change getLastValidLocation to getLastValidTrackLocation, thus all location related api takes trackId as an argument.
This commit is contained in:
@@ -125,7 +125,7 @@ public class TrackEditActivity extends AbstractMyTracksActivity {
|
|||||||
Button cancel = (Button) findViewById(R.id.track_edit_cancel);
|
Button cancel = (Button) findViewById(R.id.track_edit_cancel);
|
||||||
if (getIntent().getBooleanExtra(EXTRA_NEW_TRACK, false)) {
|
if (getIntent().getBooleanExtra(EXTRA_NEW_TRACK, false)) {
|
||||||
String trackName = TrackNameUtils.getTrackName(
|
String trackName = TrackNameUtils.getTrackName(
|
||||||
this, -1L, -1L, myTracksProviderUtils.getLastValidLocation());
|
this, -1L, -1L, myTracksProviderUtils.getLastValidTrackLocation(trackId));
|
||||||
if (trackName != null) {
|
if (trackName != null) {
|
||||||
name.setText(trackName);
|
name.setText(trackName);
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-70
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.google.android.apps.mytracks.content;
|
package com.google.android.apps.mytracks.content;
|
||||||
|
|
||||||
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.location.Location;
|
||||||
@@ -70,18 +69,6 @@ public interface MyTracksProviderUtils {
|
|||||||
*/
|
*/
|
||||||
public Track getLastTrack();
|
public Track getLastTrack();
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the last track id. Returns -1L if doesn't exist.
|
|
||||||
*/
|
|
||||||
public long getLastTrackId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if a track exists.
|
|
||||||
*
|
|
||||||
* @param trackId the track id
|
|
||||||
*/
|
|
||||||
public boolean trackExists(long trackId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a track.
|
* Inserts a track.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -120,13 +107,6 @@ public interface MyTracksProviderUtils {
|
|||||||
*/
|
*/
|
||||||
public Track createTrack(Cursor cursor);
|
public Track createTrack(Cursor cursor);
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a {@link ContentValues} from a track.
|
|
||||||
*
|
|
||||||
* @param track the track
|
|
||||||
*/
|
|
||||||
public ContentValues createContentValues(Track track);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a waypoint cursor. The caller owns the returned cursor and is
|
* Gets a waypoint cursor. The caller owns the returned cursor and is
|
||||||
* responsible for closing it.
|
* responsible for closing it.
|
||||||
@@ -149,15 +129,6 @@ public interface MyTracksProviderUtils {
|
|||||||
*/
|
*/
|
||||||
public Cursor getWaypointsCursor(long trackId, long minWaypointId, int maxWaypoints);
|
public Cursor getWaypointsCursor(long trackId, long minWaypointId, int maxWaypoints);
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the first recorded waypoint for a track. The first waypoint is special
|
|
||||||
* as it contains the stats for the current segment. Returns null if it
|
|
||||||
* doesn't exist.
|
|
||||||
*
|
|
||||||
* @param trackId the track id
|
|
||||||
*/
|
|
||||||
public Waypoint getFirstWaypoint(long trackId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the first waypoint id for a track. The first waypoint is special as it
|
* Gets the first waypoint id for a track. The first waypoint is special as it
|
||||||
* contains the stats for the current segment. Returns -1L if it doesn't
|
* contains the stats for the current segment. Returns -1L if it doesn't
|
||||||
@@ -167,13 +138,6 @@ public interface MyTracksProviderUtils {
|
|||||||
*/
|
*/
|
||||||
public long getFirstWaypointId(long trackId);
|
public long getFirstWaypointId(long trackId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the last waypoint id for a track. Returns -1L if it doesn't exist.
|
|
||||||
*
|
|
||||||
* @param trackId the track id
|
|
||||||
*/
|
|
||||||
public long getLastWaypointId(long trackId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the last statistics waypoint for a track. Returns null if it doesn't exist.
|
* Gets the last statistics waypoint for a track. Returns null if it doesn't exist.
|
||||||
*
|
*
|
||||||
@@ -190,14 +154,6 @@ public interface MyTracksProviderUtils {
|
|||||||
*/
|
*/
|
||||||
public int getNextMarkerNumber(long trackId, boolean statistics);
|
public int getNextMarkerNumber(long trackId, boolean statistics);
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the next statistics waypoint after the given waypoint. Returns null if
|
|
||||||
* it doesn't exists.
|
|
||||||
*
|
|
||||||
* @param waypoint the given waypoint
|
|
||||||
*/
|
|
||||||
public Waypoint getNextStatisticsWaypointAfter(Waypoint waypoint);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a waypoint from a waypoint id. Returns null if not found.
|
* Gets a waypoint from a waypoint id. Returns null if not found.
|
||||||
*
|
*
|
||||||
@@ -237,23 +193,6 @@ public interface MyTracksProviderUtils {
|
|||||||
*/
|
*/
|
||||||
public Waypoint createWaypoint(Cursor cursor);
|
public Waypoint createWaypoint(Cursor cursor);
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the first recorded location. Returns null if it doesn't exist.
|
|
||||||
*/
|
|
||||||
public Location getFirstLocation();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the last valid recorded location. Returns null if it doesn't exist.
|
|
||||||
*/
|
|
||||||
public Location getLastValidLocation();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a location by track point id. Returns null if not found.
|
|
||||||
*
|
|
||||||
* @param trackPointId the track point id
|
|
||||||
*/
|
|
||||||
public Location getLocation(long trackPointId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a location cursor. The caller owns the returned cursor and is
|
* Creates a location cursor. The caller owns the returned cursor and is
|
||||||
* responsible for closing it.
|
* responsible for closing it.
|
||||||
@@ -296,12 +235,19 @@ public interface MyTracksProviderUtils {
|
|||||||
public long getLastTrackLocationId(long trackId);
|
public long getLastTrackLocationId(long trackId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the last location for a track. Returns -1L if it doesn't exist.
|
* Gets the last location for a track. Returns null if it doesn't exist.
|
||||||
*
|
*
|
||||||
* @param trackId the track id
|
* @param trackId the track id
|
||||||
*/
|
*/
|
||||||
public Location getLastTrackLocation(long trackId);
|
public Location getLastTrackLocation(long trackId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the last valid location for a track. Returns null if it doesn't exist.
|
||||||
|
*
|
||||||
|
* @param trackId the track id
|
||||||
|
*/
|
||||||
|
public Location getLastValidTrackLocation(long trackId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a track point.
|
* Inserts a track point.
|
||||||
*
|
*
|
||||||
@@ -322,14 +268,6 @@ public interface MyTracksProviderUtils {
|
|||||||
*/
|
*/
|
||||||
public int bulkInsertTrackPoints(Location[] locations, int length, long trackId);
|
public int bulkInsertTrackPoints(Location[] locations, int length, long trackId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Fills a location from a cursor.
|
|
||||||
*
|
|
||||||
* @param cursor the cursor pointing to the location
|
|
||||||
* @param location the location to be overwritten
|
|
||||||
*/
|
|
||||||
public void fillLocation(Cursor cursor, Location location);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a location object from a cursor.
|
* Creates a location object from a cursor.
|
||||||
*
|
*
|
||||||
|
|||||||
+18
-117
@@ -120,45 +120,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getLastTrackId() {
|
|
||||||
Cursor cursor = null;
|
|
||||||
try {
|
|
||||||
String selection = TracksColumns._ID + "=(select max(" + TracksColumns._ID + ") from "
|
|
||||||
+ TracksColumns.TABLE_NAME + ")";
|
|
||||||
cursor = getTracksCursor(
|
|
||||||
new String[] { TracksColumns._ID }, selection, null, TracksColumns._ID);
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
|
||||||
return cursor.getLong(cursor.getColumnIndexOrThrow(TracksColumns._ID));
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (cursor != null) {
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1L;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean trackExists(long trackId) {
|
|
||||||
if (trackId < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Cursor cursor = null;
|
|
||||||
try {
|
|
||||||
cursor = getTracksCursor(new String[] { TracksColumns._ID }, TracksColumns._ID + "=?",
|
|
||||||
new String[] { Long.toString(trackId) }, TracksColumns._ID);
|
|
||||||
if (cursor != null && cursor.moveToNext()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (cursor != null) {
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Uri insertTrack(Track track) {
|
public Uri insertTrack(Track track) {
|
||||||
return contentResolver.insert(TracksColumns.CONTENT_URI, createContentValues(track));
|
return contentResolver.insert(TracksColumns.CONTENT_URI, createContentValues(track));
|
||||||
@@ -298,8 +259,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private ContentValues createContentValues(Track track) {
|
||||||
public ContentValues createContentValues(Track track) {
|
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
TripStatistics tripStatistics = track.getTripStatistics();
|
TripStatistics tripStatistics = track.getTripStatistics();
|
||||||
|
|
||||||
@@ -381,26 +341,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
return getWaypointsCursor(null, selection, selectionArgs, WaypointsColumns._ID, maxWaypoints);
|
return getWaypointsCursor(null, selection, selectionArgs, WaypointsColumns._ID, maxWaypoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Waypoint getFirstWaypoint(long trackId) {
|
|
||||||
if (trackId < 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Cursor cursor = null;
|
|
||||||
try {
|
|
||||||
cursor = getWaypointsCursor(null, WaypointsColumns.TRACKID + "=?", new String[] {
|
|
||||||
Long.toString(trackId) }, WaypointsColumns._ID, 1);
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
|
||||||
return createWaypoint(cursor);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (cursor != null) {
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getFirstWaypointId(long trackId) {
|
public long getFirstWaypointId(long trackId) {
|
||||||
if (trackId < 0) {
|
if (trackId < 0) {
|
||||||
@@ -422,27 +362,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
return -1L;
|
return -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getLastWaypointId(long trackId) {
|
|
||||||
if (trackId < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
Cursor cursor = null;
|
|
||||||
try {
|
|
||||||
cursor = getWaypointsCursor(new String[] { WaypointsColumns._ID },
|
|
||||||
WaypointsColumns.TRACKID + "=?", new String[] { Long.toString(trackId) },
|
|
||||||
WaypointsColumns._ID + " DESC", 1);
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
|
||||||
return cursor.getLong(cursor.getColumnIndexOrThrow(WaypointsColumns._ID));
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (cursor != null) {
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1L;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Waypoint getLastStatisticsWaypoint(long trackId) {
|
public Waypoint getLastStatisticsWaypoint(long trackId) {
|
||||||
if (trackId < 0) {
|
if (trackId < 0) {
|
||||||
@@ -494,8 +413,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private Waypoint getNextStatisticsWaypointAfter(Waypoint waypoint) {
|
||||||
public Waypoint getNextStatisticsWaypointAfter(Waypoint waypoint) {
|
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
String selection = WaypointsColumns._ID + ">? AND " + WaypointsColumns.TRACKID + "=? AND "
|
String selection = WaypointsColumns._ID + ">? AND " + WaypointsColumns.TRACKID + "=? AND "
|
||||||
@@ -789,29 +707,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Location getFirstLocation() {
|
|
||||||
String selection = TrackPointsColumns._ID + "=(select min(" + TrackPointsColumns._ID + ") from "
|
|
||||||
+ TrackPointsColumns.TABLE_NAME + ")";
|
|
||||||
return findLocationBy(selection, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Location getLastValidLocation() {
|
|
||||||
String selection = TrackPointsColumns._ID + "=(select max(" + TrackPointsColumns._ID + ") from "
|
|
||||||
+ TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.LATITUDE + "<=90)";
|
|
||||||
return findLocationBy(selection, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Location getLocation(long trackPointId) {
|
|
||||||
if (trackPointId < 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return findLocationBy(
|
|
||||||
TrackPointsColumns._ID + "=?", new String[] { Long.toString(trackPointId) });
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor getLocationsCursor(
|
public Cursor getLocationsCursor(
|
||||||
long trackId, long startTrackPointId, int maxLocations, boolean descending) {
|
long trackId, long startTrackPointId, int maxLocations, boolean descending) {
|
||||||
@@ -951,15 +846,26 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
}
|
}
|
||||||
return -1L;
|
return -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLastTrackLocation(long trackId) {
|
public Location getLastTrackLocation(long trackId) {
|
||||||
if (trackId < 0) {
|
if (trackId < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String selection = TrackPointsColumns._ID + "=(select max(" + TrackPointsColumns._ID
|
String selection = TrackPointsColumns._ID + "=(select max(" + TrackPointsColumns._ID + ") from "
|
||||||
+ ") from " + TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.TRACKID
|
+ TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.TRACKID + "=?)";
|
||||||
+ "=?)";
|
String[] selectionArgs = new String[] { Long.toString(trackId) };
|
||||||
|
return findLocationBy(selection, selectionArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location getLastValidTrackLocation(long trackId) {
|
||||||
|
if (trackId < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String selection = TrackPointsColumns._ID + "=(select max(" + TrackPointsColumns._ID + ") from "
|
||||||
|
+ TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.TRACKID + "=? AND "
|
||||||
|
+ TrackPointsColumns.LATITUDE + "<=90000000)";
|
||||||
String[] selectionArgs = new String[] { Long.toString(trackId) };
|
String[] selectionArgs = new String[] { Long.toString(trackId) };
|
||||||
return findLocationBy(selection, selectionArgs);
|
return findLocationBy(selection, selectionArgs);
|
||||||
}
|
}
|
||||||
@@ -1024,15 +930,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fillLocation(Cursor cursor, Location location) {
|
|
||||||
fillLocation(cursor, new CachedTrackPointsIndexes(cursor), location);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location createLocation(Cursor cursor) {
|
public Location createLocation(Cursor cursor) {
|
||||||
Location location = new MyTracksLocation("");
|
Location location = new MyTracksLocation("");
|
||||||
fillLocation(cursor, location);
|
fillLocation(cursor, new CachedTrackPointsIndexes(cursor), location);
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-158
@@ -47,7 +47,6 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
private MyTracksProviderUtils providerUtils;
|
private MyTracksProviderUtils providerUtils;
|
||||||
|
|
||||||
private static final String NAME_PREFIX = "test name";
|
private static final String NAME_PREFIX = "test name";
|
||||||
private static final String TRACK_CATEGORY = "test category";
|
|
||||||
private static final String MOCK_DESC = "Mock Next Waypoint Desc!";
|
private static final String MOCK_DESC = "Mock Next Waypoint Desc!";
|
||||||
private static final String TEST_DESC = "Test Desc!";
|
private static final String TEST_DESC = "Test Desc!";
|
||||||
private static final String TEST_DESC_NEW = "Test Desc new!";
|
private static final String TEST_DESC_NEW = "Test Desc new!";
|
||||||
@@ -216,24 +215,6 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
providerUtils.insertTrack(getTrack(trackId, 0));
|
providerUtils.insertTrack(getTrack(trackId, 0));
|
||||||
assertEquals(trackId, providerUtils.getLastTrack().getId());
|
assertEquals(trackId, providerUtils.getLastTrack().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#getLastTrackId()}
|
|
||||||
*/
|
|
||||||
public void testGetLastTrackId() {
|
|
||||||
long trackId = System.currentTimeMillis();
|
|
||||||
providerUtils.insertTrack(getTrack(trackId, 0));
|
|
||||||
assertEquals(trackId, providerUtils.getLastTrackId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#trackExists(long)}
|
|
||||||
*/
|
|
||||||
public void testTrackExists() {
|
|
||||||
long trackId = System.currentTimeMillis();
|
|
||||||
providerUtils.insertTrack(getTrack(trackId, 0));
|
|
||||||
assertTrue(providerUtils.trackExists(trackId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#updateTrack(Track)}
|
* Tests the method {@link MyTracksProviderUtilsImpl#updateTrack(Track)}
|
||||||
@@ -355,59 +336,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
assertEquals(name, track.getName());
|
assertEquals(name, track.getName());
|
||||||
AndroidMock.verify(cursorMock);
|
AndroidMock.verify(cursorMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#createContentValues(Track)}.
|
|
||||||
*/
|
|
||||||
@UsesMocks(TripStatistics.class)
|
|
||||||
public void testCreateContentValues_track() {
|
|
||||||
// ID
|
|
||||||
long trackId = System.currentTimeMillis();
|
|
||||||
// Name
|
|
||||||
String name = NAME_PREFIX + Long.toString(trackId);
|
|
||||||
Track track = getTrack(trackId, 10);
|
|
||||||
track.setName(name);
|
|
||||||
track.setCategory(TRACK_CATEGORY);
|
|
||||||
TripStatistics tripStatistics = AndroidMock.createNiceMock(TripStatistics.class);
|
|
||||||
// Bottom
|
|
||||||
int bottom = 22;
|
|
||||||
// AverageSpeed
|
|
||||||
double averageSpeed = 1.11;
|
|
||||||
AndroidMock.expect(tripStatistics.getBottom()).andReturn(bottom);
|
|
||||||
AndroidMock.expect(tripStatistics.getAverageSpeed()).andReturn(averageSpeed);
|
|
||||||
track.setTripStatistics(tripStatistics);
|
|
||||||
AndroidMock.replay(tripStatistics);
|
|
||||||
|
|
||||||
ContentValues contentValues = providerUtils.createContentValues(track);
|
|
||||||
assertEquals(trackId, contentValues.get(TracksColumns._ID));
|
|
||||||
assertEquals(name, contentValues.get(TracksColumns.NAME));
|
|
||||||
assertEquals(bottom, contentValues.get(TracksColumns.MINLAT));
|
|
||||||
assertEquals(averageSpeed, contentValues.get(TracksColumns.AVGSPEED));
|
|
||||||
AndroidMock.verify(tripStatistics);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#getFirstWaypoint(long)}.
|
|
||||||
*/
|
|
||||||
public void testGetFirstWaypoint() {
|
|
||||||
long trackId = System.currentTimeMillis();
|
|
||||||
Track track = getTrack(trackId, 10);
|
|
||||||
providerUtils.insertTrack(track);
|
|
||||||
|
|
||||||
Waypoint waypoint1 = new Waypoint();
|
|
||||||
waypoint1.setDescription("Desc1");
|
|
||||||
waypoint1.setTrackId(trackId);
|
|
||||||
Waypoint waypoint2 = new Waypoint();
|
|
||||||
waypoint2.setDescription("Desc2");
|
|
||||||
waypoint2.setTrackId(trackId);
|
|
||||||
providerUtils.insertWaypoint(waypoint1);
|
|
||||||
providerUtils.insertWaypoint(waypoint2);
|
|
||||||
|
|
||||||
assertNull(providerUtils.getFirstWaypoint(-1));
|
|
||||||
Waypoint wayPoint = providerUtils.getFirstWaypoint(trackId);
|
|
||||||
assertEquals("Desc1", wayPoint.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#getFirstWaypointId(long)}.
|
* Tests the method {@link MyTracksProviderUtilsImpl#getFirstWaypointId(long)}.
|
||||||
*/
|
*/
|
||||||
@@ -426,28 +355,6 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
assertEquals(-1L, providerUtils.getFirstWaypointId(-1));
|
assertEquals(-1L, providerUtils.getFirstWaypointId(-1));
|
||||||
assertEquals(1L, providerUtils.getFirstWaypointId(trackId));
|
assertEquals(1L, providerUtils.getFirstWaypointId(trackId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#getLastWaypointId(long)}.
|
|
||||||
*/
|
|
||||||
public void testGetLastWaypointId() {
|
|
||||||
long trackId = System.currentTimeMillis();
|
|
||||||
Track track = getTrack(trackId, 10);
|
|
||||||
providerUtils.insertTrack(track);
|
|
||||||
|
|
||||||
Waypoint waypoint1 = new Waypoint();
|
|
||||||
waypoint1.setTrackId(trackId);
|
|
||||||
Waypoint waypoint2 = new Waypoint();
|
|
||||||
waypoint2.setTrackId(trackId);
|
|
||||||
Waypoint waypoint3 = new Waypoint();
|
|
||||||
waypoint3.setTrackId(trackId);
|
|
||||||
providerUtils.insertWaypoint(waypoint1);
|
|
||||||
providerUtils.insertWaypoint(waypoint2);
|
|
||||||
providerUtils.insertWaypoint(waypoint3);
|
|
||||||
|
|
||||||
assertEquals(-1L, providerUtils.getLastWaypointId(-1));
|
|
||||||
assertEquals(3L, providerUtils.getLastWaypointId(trackId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the method
|
* Tests the method
|
||||||
@@ -505,37 +412,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
assertEquals(2, providerUtils.getNextMarkerNumber(trackId, true));
|
assertEquals(2, providerUtils.getNextMarkerNumber(trackId, true));
|
||||||
assertEquals(3, providerUtils.getNextMarkerNumber(trackId, false));
|
assertEquals(3, providerUtils.getNextMarkerNumber(trackId, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#getNextStatisticsWaypointAfter(Waypoint)}.
|
|
||||||
*/
|
|
||||||
public void testGetNextStatisticsWaypointAfter() {
|
|
||||||
long trackId = System.currentTimeMillis();
|
|
||||||
Track track = getTrack(trackId, 10);
|
|
||||||
providerUtils.insertTrack(track);
|
|
||||||
|
|
||||||
Waypoint waypoint1 = new Waypoint();
|
|
||||||
waypoint1.setType(Waypoint.TYPE_STATISTICS);
|
|
||||||
waypoint1.setTrackId(trackId);
|
|
||||||
Waypoint waypoint2 = new Waypoint();
|
|
||||||
waypoint2.setType(Waypoint.TYPE_WAYPOINT);
|
|
||||||
waypoint2.setTrackId(trackId);
|
|
||||||
Waypoint waypoint3 = new Waypoint();
|
|
||||||
waypoint3.setType(Waypoint.TYPE_STATISTICS);
|
|
||||||
waypoint3.setTrackId(trackId);
|
|
||||||
waypoint3.setDescription("Desc3");
|
|
||||||
Waypoint waypoint4 = new Waypoint();
|
|
||||||
waypoint4.setType(Waypoint.TYPE_STATISTICS);
|
|
||||||
waypoint4.setTrackId(trackId);
|
|
||||||
waypoint4.setDescription("Desc4");
|
|
||||||
providerUtils.insertWaypoint(waypoint1);
|
|
||||||
providerUtils.insertWaypoint(waypoint2);
|
|
||||||
providerUtils.insertWaypoint(waypoint3);
|
|
||||||
providerUtils.insertWaypoint(waypoint4);
|
|
||||||
|
|
||||||
assertEquals("Desc3", providerUtils.getNextStatisticsWaypointAfter(providerUtils.getFirstWaypoint(trackId)).getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#insertWaypoint(Waypoint)} and
|
* Tests the method {@link MyTracksProviderUtilsImpl#insertWaypoint(Waypoint)} and
|
||||||
* {@link MyTracksProviderUtilsImpl#getWaypoint(long)}.
|
* {@link MyTracksProviderUtilsImpl#getWaypoint(long)}.
|
||||||
@@ -757,50 +634,20 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
assertEquals(startTime, contentValues.get(WaypointsColumns.STARTTIME));
|
assertEquals(startTime, contentValues.get(WaypointsColumns.STARTTIME));
|
||||||
assertEquals(minGrade, contentValues.get(WaypointsColumns.MINGRADE));
|
assertEquals(minGrade, contentValues.get(WaypointsColumns.MINGRADE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#getFirstLocation()}.
|
* Tests the method {@link MyTracksProviderUtilsImpl#getLastValidTrackLocation(long)}.
|
||||||
*/
|
*/
|
||||||
public void testGetFirstLocation() {
|
public void testGetLastValidTrackLocation() {
|
||||||
// Insert track, points at first.
|
// Insert track, points at first.
|
||||||
long trackId = System.currentTimeMillis();
|
long trackId = System.currentTimeMillis();
|
||||||
Track track = getTrack(trackId, 10);
|
Track track = getTrack(trackId, 10);
|
||||||
insertTrackWithLocations(track);
|
insertTrackWithLocations(track);
|
||||||
|
|
||||||
Location firstLocation = providerUtils.getFirstLocation();
|
Location lastLocation = providerUtils.getLastValidTrackLocation(trackId);
|
||||||
checkLocation(0, firstLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#getLastValidLocation()}.
|
|
||||||
*/
|
|
||||||
public void testGetLastLocation() {
|
|
||||||
// Insert track, points at first.
|
|
||||||
long trackId = System.currentTimeMillis();
|
|
||||||
Track track = getTrack(trackId, 10);
|
|
||||||
insertTrackWithLocations(track);
|
|
||||||
|
|
||||||
Location lastLocation = providerUtils.getLastValidLocation();
|
|
||||||
checkLocation(9, lastLocation);
|
checkLocation(9, lastLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#getLocation(long)}.
|
|
||||||
*/
|
|
||||||
public void testGetLocation() {
|
|
||||||
// Insert track, points at first.
|
|
||||||
long trackId = System.currentTimeMillis();
|
|
||||||
Track track = getTrack(trackId, 10);
|
|
||||||
insertTrackWithLocations(track);
|
|
||||||
|
|
||||||
Location location1 = providerUtils.getLocation(1L);
|
|
||||||
checkLocation(0, location1);
|
|
||||||
Location location5 = providerUtils.getLocation(5L);
|
|
||||||
checkLocation(4, location5);
|
|
||||||
Location location10 = providerUtils.getLocation(10L);
|
|
||||||
checkLocation(9, location10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the method
|
* Tests the method
|
||||||
* {@link MyTracksProviderUtilsImpl#getLocationsCursor(long, long, int, boolean)}
|
* {@link MyTracksProviderUtilsImpl#getLocationsCursor(long, long, int, boolean)}
|
||||||
|
|||||||
Reference in New Issue
Block a user