mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-11 13:33:07 +02:00
Merge heads
This commit is contained in:
+1
-1
@@ -2,8 +2,8 @@
|
|||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||||
|
<classpathentry kind="con" path="com.google.gdt.eclipse.managedapis.MANAGED_API_CONTAINER/drive-v2r30lv1.12.0-beta"/>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="gen"/>
|
<classpathentry kind="src" path="gen"/>
|
||||||
<classpathentry kind="con" path="com.google.gdt.eclipse.managedapis.MANAGED_API_CONTAINER/drive-v2r30lv1.12.0-beta"/>
|
|
||||||
<classpathentry kind="output" path="bin/classes"/>
|
<classpathentry kind="output" path="bin/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -565,7 +565,7 @@ public class TrackDataHub implements DataSourceListener {
|
|||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
cursor = myTracksProviderUtils.getWaypointCursor(
|
cursor = myTracksProviderUtils.getWaypointCursor(
|
||||||
selectedTrackId, 0L, MAX_DISPLAYED_WAYPOINTS_POINTS);
|
selectedTrackId, -1L, MAX_DISPLAYED_WAYPOINTS_POINTS);
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
Waypoint waypoint = myTracksProviderUtils.createWaypoint(cursor);
|
Waypoint waypoint = myTracksProviderUtils.createWaypoint(cursor);
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ class TrackWriterImpl implements TrackWriter {
|
|||||||
// problem because we don't try to load them into objects all at the
|
// problem because we don't try to load them into objects all at the
|
||||||
// same time.
|
// same time.
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
cursor = providerUtils.getWaypointCursor(trackId, 0,
|
cursor = providerUtils.getWaypointCursor(trackId, -1L,
|
||||||
Constants.MAX_LOADED_WAYPOINTS_POINTS);
|
Constants.MAX_LOADED_WAYPOINTS_POINTS);
|
||||||
boolean hasWaypoints = false;
|
boolean hasWaypoints = false;
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
@@ -311,7 +311,7 @@ class TrackWriterImpl implements TrackWriter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TrackWriterLocationFactory locationFactory = new TrackWriterLocationFactory();
|
TrackWriterLocationFactory locationFactory = new TrackWriterLocationFactory();
|
||||||
LocationIterator it = providerUtils.getTrackPointLocationIterator(track.getId(), 0, false,
|
LocationIterator it = providerUtils.getTrackPointLocationIterator(track.getId(), -1L, false,
|
||||||
locationFactory);
|
locationFactory);
|
||||||
try {
|
try {
|
||||||
int pointNumber = 0;
|
int pointNumber = 0;
|
||||||
|
|||||||
+2
-2
@@ -210,7 +210,7 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
|||||||
private boolean uploadAllTrackPoints(Track track) {
|
private boolean uploadAllTrackPoints(Track track) {
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
cursor = myTracksProviderUtils.getTrackPointCursor(trackId, 0, -1, false);
|
cursor = myTracksProviderUtils.getTrackPointCursor(trackId, -1L, -1, false);
|
||||||
if (cursor == null) {
|
if (cursor == null) {
|
||||||
Log.d(TAG, "Location cursor is null");
|
Log.d(TAG, "Location cursor is null");
|
||||||
return false;
|
return false;
|
||||||
@@ -329,7 +329,7 @@ public class SendFusionTablesAsyncTask extends AbstractSendAsyncTask {
|
|||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
cursor = myTracksProviderUtils.getWaypointCursor(
|
cursor = myTracksProviderUtils.getWaypointCursor(
|
||||||
trackId, 0, Constants.MAX_LOADED_WAYPOINTS_POINTS);
|
trackId, -1L, Constants.MAX_LOADED_WAYPOINTS_POINTS);
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
// This will skip the first waypoint (it carries the stats for the
|
// This will skip the first waypoint (it carries the stats for the
|
||||||
// track).
|
// track).
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
|
|||||||
boolean uploadAllTrackPoints(Track track) {
|
boolean uploadAllTrackPoints(Track track) {
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
cursor = myTracksProviderUtils.getTrackPointCursor(trackId, 0, -1, false);
|
cursor = myTracksProviderUtils.getTrackPointCursor(trackId, -1L, -1, false);
|
||||||
if (cursor == null) {
|
if (cursor == null) {
|
||||||
Log.d(TAG, "Location cursor is null");
|
Log.d(TAG, "Location cursor is null");
|
||||||
return false;
|
return false;
|
||||||
@@ -437,7 +437,7 @@ public class SendMapsAsyncTask extends AbstractSendAsyncTask {
|
|||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
cursor = myTracksProviderUtils.getWaypointCursor(
|
cursor = myTracksProviderUtils.getWaypointCursor(
|
||||||
trackId, 0, Constants.MAX_LOADED_WAYPOINTS_POINTS);
|
trackId, -1L, Constants.MAX_LOADED_WAYPOINTS_POINTS);
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
// This will skip the first waypoint (it carries the stats for the
|
// This will skip the first waypoint (it carries the stats for the
|
||||||
// track).
|
// track).
|
||||||
|
|||||||
@@ -604,7 +604,7 @@ public class TrackRecordingService extends Service {
|
|||||||
try {
|
try {
|
||||||
// TODO: how to handle very long track.
|
// TODO: how to handle very long track.
|
||||||
cursor = myTracksProviderUtils.getTrackPointCursor(
|
cursor = myTracksProviderUtils.getTrackPointCursor(
|
||||||
recordingTrackId, -1, Constants.MAX_LOADED_TRACK_POINTS, true);
|
recordingTrackId, -1L, Constants.MAX_LOADED_TRACK_POINTS, true);
|
||||||
if (cursor == null) {
|
if (cursor == null) {
|
||||||
Log.e(TAG, "Cursor is null.");
|
Log.e(TAG, "Cursor is null.");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import java.text.ParsePosition;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -96,7 +97,31 @@ public class StringUtils {
|
|||||||
* @param time the time in milliseconds
|
* @param time the time in milliseconds
|
||||||
*/
|
*/
|
||||||
public static String formatElapsedTime(long time) {
|
public static String formatElapsedTime(long time) {
|
||||||
return DateUtils.formatElapsedTime(time / 1000);
|
/*
|
||||||
|
* Temporary workaround for DateUtils.formatElapsedTime(time / 1000). In API
|
||||||
|
* level 17, it returns strings like "1:0:00" instead of "1:00:00", which
|
||||||
|
* breaks several unit tests.
|
||||||
|
*/
|
||||||
|
long elapsedSeconds = time / 1000;
|
||||||
|
long hours = 0;
|
||||||
|
long minutes = 0;
|
||||||
|
long seconds = 0;
|
||||||
|
|
||||||
|
if (elapsedSeconds >= 3600) {
|
||||||
|
hours = elapsedSeconds / 3600;
|
||||||
|
elapsedSeconds -= hours * 3600;
|
||||||
|
}
|
||||||
|
if (elapsedSeconds >= 60) {
|
||||||
|
minutes = elapsedSeconds / 60;
|
||||||
|
elapsedSeconds -= minutes * 60;
|
||||||
|
}
|
||||||
|
seconds = elapsedSeconds;
|
||||||
|
|
||||||
|
if (hours > 0) {
|
||||||
|
return String.format(Locale.US, "%d:%02d:%02d", hours, minutes, seconds);
|
||||||
|
} else {
|
||||||
|
return String.format(Locale.US, "%02d:%02d", minutes, seconds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+13
-14
@@ -82,9 +82,9 @@ public interface MyTracksProviderUtils {
|
|||||||
* Gets a track cursor. The caller owns the returned cursor and is responsible
|
* Gets a track cursor. The caller owns the returned cursor and is responsible
|
||||||
* for closing it.
|
* for closing it.
|
||||||
*
|
*
|
||||||
* @param selection the selection
|
* @param selection the selection. Can be null
|
||||||
* @param selectionArgs the selection arguments
|
* @param selectionArgs the selection arguments. Can be null
|
||||||
* @param sortOrder the sort order
|
* @param sortOrder the sort order. Can be null
|
||||||
*/
|
*/
|
||||||
public Cursor getTrackCursor(String selection, String[] selectionArgs, String sortOrder);
|
public Cursor getTrackCursor(String selection, String[] selectionArgs, String sortOrder);
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ public interface MyTracksProviderUtils {
|
|||||||
* deletion. The generator is used to update the next statistics waypoint.
|
* deletion. The generator is used to update the next statistics waypoint.
|
||||||
*
|
*
|
||||||
* @param waypointId the waypoint id
|
* @param waypointId the waypoint id
|
||||||
* @param descriptionGenerator the description generator
|
* @param descriptionGenerator the description generator. Can be null for waypoint marker
|
||||||
*/
|
*/
|
||||||
public void deleteWaypoint(long waypointId, DescriptionGenerator descriptionGenerator);
|
public void deleteWaypoint(long waypointId, DescriptionGenerator descriptionGenerator);
|
||||||
|
|
||||||
@@ -160,10 +160,10 @@ public interface MyTracksProviderUtils {
|
|||||||
* 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.
|
||||||
*
|
*
|
||||||
* @param selection the selection
|
* @param selection the selection. Can be null
|
||||||
* @param selectionArgs the selection arguments
|
* @param selectionArgs the selection arguments. Can be null
|
||||||
* @param sortOrder the sort order
|
* @param sortOrder the sort order. Can be null
|
||||||
* @param maxWaypoints the maximum number of waypoints to return
|
* @param maxWaypoints the maximum number of waypoints to return. -1 for no limit
|
||||||
*/
|
*/
|
||||||
public Cursor getWaypointCursor(
|
public Cursor getWaypointCursor(
|
||||||
String selection, String[] selectionArgs, String sortOrder, int maxWaypoints);
|
String selection, String[] selectionArgs, String sortOrder, int maxWaypoints);
|
||||||
@@ -173,8 +173,8 @@ public interface MyTracksProviderUtils {
|
|||||||
* is responsible for closing it.
|
* is responsible for closing it.
|
||||||
*
|
*
|
||||||
* @param trackId the track id
|
* @param trackId the track id
|
||||||
* @param minWaypointId the minimum waypoint id
|
* @param minWaypointId the minimum waypoint id. -1L to ignore
|
||||||
* @param maxWaypoints the maximum number of waypoints to return
|
* @param maxWaypoints the maximum number of waypoints to return. -1 for no limit
|
||||||
*/
|
*/
|
||||||
public Cursor getWaypointCursor(long trackId, long minWaypointId, int maxWaypoints);
|
public Cursor getWaypointCursor(long trackId, long minWaypointId, int maxWaypoints);
|
||||||
|
|
||||||
@@ -242,8 +242,8 @@ public interface MyTracksProviderUtils {
|
|||||||
* responsible for closing it.
|
* responsible for closing it.
|
||||||
*
|
*
|
||||||
* @param trackId the track id
|
* @param trackId the track id
|
||||||
* @param startTrackPointId the starting track point id
|
* @param startTrackPointId the starting track point id. -1L to ignore
|
||||||
* @param maxLocations maximum number of locations to return
|
* @param maxLocations maximum number of locations to return. -1 for no limit
|
||||||
* @param descending true to sort the result in descending order (latest
|
* @param descending true to sort the result in descending order (latest
|
||||||
* location first)
|
* location first)
|
||||||
*/
|
*/
|
||||||
@@ -262,8 +262,7 @@ public interface MyTracksProviderUtils {
|
|||||||
* iteration, {@link LocationIterator#close()} must be called.
|
* iteration, {@link LocationIterator#close()} must be called.
|
||||||
*
|
*
|
||||||
* @param trackId the track id
|
* @param trackId the track id
|
||||||
* @param startTrackPointId the start track point id or -1L to start from the
|
* @param startTrackPointId the starting track point id. -1L to ignore
|
||||||
* first point
|
|
||||||
* @param descending true to sort the result in descending order (latest
|
* @param descending true to sort the result in descending order (latest
|
||||||
* location first)
|
* location first)
|
||||||
* @param locationFactory the location factory
|
* @param locationFactory the location factory
|
||||||
|
|||||||
+6
-5
@@ -439,7 +439,8 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
@Override
|
@Override
|
||||||
public void deleteWaypoint(long waypointId, DescriptionGenerator descriptionGenerator) {
|
public void deleteWaypoint(long waypointId, DescriptionGenerator descriptionGenerator) {
|
||||||
final Waypoint waypoint = getWaypoint(waypointId);
|
final Waypoint waypoint = getWaypoint(waypointId);
|
||||||
if (waypoint != null && waypoint.getType() == Waypoint.TYPE_STATISTICS) {
|
if (waypoint != null && waypoint.getType() == Waypoint.TYPE_STATISTICS
|
||||||
|
&& descriptionGenerator != null) {
|
||||||
final Waypoint nextWaypoint = getNextStatisticsWaypointAfter(waypoint);
|
final Waypoint nextWaypoint = getNextStatisticsWaypointAfter(waypoint);
|
||||||
if (nextWaypoint == null) {
|
if (nextWaypoint == null) {
|
||||||
Log.d(TAG, "Unable to find the next statistics marker after deleting one.");
|
Log.d(TAG, "Unable to find the next statistics marker after deleting one.");
|
||||||
@@ -510,7 +511,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
|
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
|
||||||
int type = statistics ? Waypoint.TYPE_STATISTICS : Waypoint.TYPE_WAYPOINT;
|
int type = statistics ? Waypoint.TYPE_STATISTICS : Waypoint.TYPE_WAYPOINT;
|
||||||
String[] selectionArgs = new String[] { Long.toString(trackId), Integer.toString(type) };
|
String[] selectionArgs = new String[] { Long.toString(trackId), Integer.toString(type) };
|
||||||
cursor = getWaypointCursor(projection, selection, selectionArgs, WaypointsColumns._ID, 0);
|
cursor = getWaypointCursor(projection, selection, selectionArgs, WaypointsColumns._ID, -1);
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
int count = cursor.getCount();
|
int count = cursor.getCount();
|
||||||
/*
|
/*
|
||||||
@@ -535,7 +536,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
cursor = getWaypointCursor(null, WaypointsColumns._ID + "=?",
|
cursor = getWaypointCursor(null, WaypointsColumns._ID + "=?",
|
||||||
new String[] { Long.toString(waypointId) }, WaypointsColumns._ID, 0);
|
new String[] { Long.toString(waypointId) }, WaypointsColumns._ID, 1);
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
return createWaypoint(cursor);
|
return createWaypoint(cursor);
|
||||||
}
|
}
|
||||||
@@ -672,7 +673,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
if (sortOrder == null) {
|
if (sortOrder == null) {
|
||||||
sortOrder = WaypointsColumns._ID;
|
sortOrder = WaypointsColumns._ID;
|
||||||
}
|
}
|
||||||
if (maxWaypoints > 0) {
|
if (maxWaypoints >= 0) {
|
||||||
sortOrder += " LIMIT " + maxWaypoints;
|
sortOrder += " LIMIT " + maxWaypoints;
|
||||||
}
|
}
|
||||||
return contentResolver.query(
|
return contentResolver.query(
|
||||||
@@ -789,7 +790,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
if (descending) {
|
if (descending) {
|
||||||
sortOrder += " DESC";
|
sortOrder += " DESC";
|
||||||
}
|
}
|
||||||
if (maxLocations > 0) {
|
if (maxLocations >= 0) {
|
||||||
sortOrder += " LIMIT " + maxLocations;
|
sortOrder += " LIMIT " + maxLocations;
|
||||||
}
|
}
|
||||||
return getTrackPointCursor(null, selection, selectionArgs, sortOrder);
|
return getTrackPointCursor(null, selection, selectionArgs, sortOrder);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#Tue Jul 17 10:23:26 PDT 2012
|
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ limitations under the License.
|
|||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="8"
|
android:minSdkVersion="8"
|
||||||
android:targetSdkVersion="16" />
|
android:targetSdkVersion="17" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="My Tracks Tests" >
|
android:label="My Tracks Tests" >
|
||||||
|
|||||||
+5
-5
@@ -128,7 +128,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
((MyTracksProviderUtilsImpl) providerUtils).setDefaultCursorBatchSize(batchSize);
|
((MyTracksProviderUtilsImpl) providerUtils).setDefaultCursorBatchSize(batchSize);
|
||||||
List<Location> locations = new ArrayList<Location>(numPoints);
|
List<Location> locations = new ArrayList<Location>(numPoints);
|
||||||
LocationIterator it = providerUtils.getTrackPointLocationIterator(
|
LocationIterator it = providerUtils.getTrackPointLocationIterator(
|
||||||
trackId, -1, descending, locationFactory);
|
trackId, -1L, descending, locationFactory);
|
||||||
try {
|
try {
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Location loc = it.next();
|
Location loc = it.next();
|
||||||
@@ -168,7 +168,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
// Load all inserted locations.
|
// Load all inserted locations.
|
||||||
long lastPointId = -1;
|
long lastPointId = -1;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
LocationIterator it = providerUtils.getTrackPointLocationIterator(id, -1, false,
|
LocationIterator it = providerUtils.getTrackPointLocationIterator(id, -1L, false,
|
||||||
MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
||||||
try {
|
try {
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@@ -645,9 +645,9 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
insertTrackWithLocations(track);
|
insertTrackWithLocations(track);
|
||||||
|
|
||||||
providerUtils.bulkInsertTrackPoint(track.getLocations().toArray(new Location[0]), -1, trackId);
|
providerUtils.bulkInsertTrackPoint(track.getLocations().toArray(new Location[0]), -1, trackId);
|
||||||
assertEquals(20, providerUtils.getTrackPointCursor(trackId, 0, 1000, false).getCount());
|
assertEquals(20, providerUtils.getTrackPointCursor(trackId, -1L, 1000, false).getCount());
|
||||||
providerUtils.bulkInsertTrackPoint(track.getLocations().toArray(new Location[0]), 8, trackId);
|
providerUtils.bulkInsertTrackPoint(track.getLocations().toArray(new Location[0]), 8, trackId);
|
||||||
assertEquals(28, providerUtils.getTrackPointCursor(trackId, 0, 1000, false).getCount());
|
assertEquals(28, providerUtils.getTrackPointCursor(trackId, -1L, 1000, false).getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -728,7 +728,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
insertTrackWithLocations(track);
|
insertTrackWithLocations(track);
|
||||||
|
|
||||||
providerUtils.insertTrackPoint(createLocation(22), trackId);
|
providerUtils.insertTrackPoint(createLocation(22), trackId);
|
||||||
assertEquals(11, providerUtils.getTrackPointCursor(trackId, 0, 1000, false).getCount());
|
assertEquals(11, providerUtils.getTrackPointCursor(trackId, -1L, 1000, false).getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
// Register two listeners
|
// Register two listeners
|
||||||
Capture<ContentObserver> contentObserverCapture = new Capture<ContentObserver>();
|
Capture<ContentObserver> contentObserverCapture = new Capture<ContentObserver>();
|
||||||
expect(myTracksProviderUtils.getWaypointCursor(
|
expect(myTracksProviderUtils.getWaypointCursor(
|
||||||
eq(TRACK_ID), AndroidMock.leq(0L), eq(Constants.MAX_DISPLAYED_WAYPOINTS_POINTS)))
|
eq(TRACK_ID), AndroidMock.leq(-1L), eq(Constants.MAX_DISPLAYED_WAYPOINTS_POINTS)))
|
||||||
.andStubAnswer(new FixedSizeCursorAnswer(2));
|
.andStubAnswer(new FixedSizeCursorAnswer(2));
|
||||||
expect(myTracksProviderUtils.createWaypoint(isA(Cursor.class)))
|
expect(myTracksProviderUtils.createWaypoint(isA(Cursor.class)))
|
||||||
.andReturn(waypoint1).andReturn(waypoint2).andReturn(waypoint1).andReturn(waypoint2);
|
.andReturn(waypoint1).andReturn(waypoint2).andReturn(waypoint1).andReturn(waypoint2);
|
||||||
@@ -231,7 +231,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
// Cause waypoints table update
|
// Cause waypoints table update
|
||||||
ContentObserver contentObserver = contentObserverCapture.getValue();
|
ContentObserver contentObserver = contentObserverCapture.getValue();
|
||||||
expect(myTracksProviderUtils.getWaypointCursor(
|
expect(myTracksProviderUtils.getWaypointCursor(
|
||||||
eq(TRACK_ID), AndroidMock.leq(0L), eq(Constants.MAX_DISPLAYED_WAYPOINTS_POINTS)))
|
eq(TRACK_ID), AndroidMock.leq(-1L), eq(Constants.MAX_DISPLAYED_WAYPOINTS_POINTS)))
|
||||||
.andStubAnswer(new FixedSizeCursorAnswer(3));
|
.andStubAnswer(new FixedSizeCursorAnswer(3));
|
||||||
expect(myTracksProviderUtils.createWaypoint(isA(Cursor.class)))
|
expect(myTracksProviderUtils.createWaypoint(isA(Cursor.class)))
|
||||||
.andReturn(waypoint1).andReturn(waypoint2).andReturn(waypoint3);
|
.andReturn(waypoint1).andReturn(waypoint2).andReturn(waypoint3);
|
||||||
@@ -252,7 +252,7 @@ public class TrackDataHubTest extends AndroidTestCase {
|
|||||||
|
|
||||||
// Unregister one listener
|
// Unregister one listener
|
||||||
expect(myTracksProviderUtils.getWaypointCursor(
|
expect(myTracksProviderUtils.getWaypointCursor(
|
||||||
eq(TRACK_ID), AndroidMock.leq(0L), eq(Constants.MAX_DISPLAYED_WAYPOINTS_POINTS)))
|
eq(TRACK_ID), AndroidMock.leq(-1L), eq(Constants.MAX_DISPLAYED_WAYPOINTS_POINTS)))
|
||||||
.andStubAnswer(new FixedSizeCursorAnswer(4));
|
.andStubAnswer(new FixedSizeCursorAnswer(4));
|
||||||
expect(myTracksProviderUtils.createWaypoint(isA(Cursor.class)))
|
expect(myTracksProviderUtils.createWaypoint(isA(Cursor.class)))
|
||||||
.andReturn(waypoint1).andReturn(waypoint2).andReturn(waypoint3).andReturn(waypoint4);
|
.andReturn(waypoint1).andReturn(waypoint2).andReturn(waypoint3).andReturn(waypoint4);
|
||||||
|
|||||||
+8
-8
@@ -144,7 +144,7 @@ public class SendMapsAsyncTaskTest extends AndroidTestCase {
|
|||||||
*/
|
*/
|
||||||
public void testUploadAllTrackPoints_nullCursor() {
|
public void testUploadAllTrackPoints_nullCursor() {
|
||||||
Track track = TrackStubUtils.createTrack(1);
|
Track track = TrackStubUtils.createTrack(1);
|
||||||
AndroidMock.expect(myTracksProviderUtilsMock.getTrackPointCursor(TRACK_ID, 0, -1, false))
|
AndroidMock.expect(myTracksProviderUtilsMock.getTrackPointCursor(TRACK_ID, -1L, -1, false))
|
||||||
.andReturn(null);
|
.andReturn(null);
|
||||||
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock);
|
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock);
|
||||||
SendMapsAsyncTask sendMapsAsyncTask = new SendMapsAsyncTask(sendMapsActivityMock,
|
SendMapsAsyncTask sendMapsAsyncTask = new SendMapsAsyncTask(sendMapsActivityMock,
|
||||||
@@ -166,7 +166,7 @@ public class SendMapsAsyncTaskTest extends AndroidTestCase {
|
|||||||
cursorMock.close();
|
cursorMock.close();
|
||||||
AndroidMock.expect(myTracksProviderUtilsMock.createTrackPoint(cursorMock)).andReturn(
|
AndroidMock.expect(myTracksProviderUtilsMock.createTrackPoint(cursorMock)).andReturn(
|
||||||
new Location("1"));
|
new Location("1"));
|
||||||
AndroidMock.expect(myTracksProviderUtilsMock.getTrackPointCursor(TRACK_ID, 0, -1, false))
|
AndroidMock.expect(myTracksProviderUtilsMock.getTrackPointCursor(TRACK_ID, -1L, -1, false))
|
||||||
.andReturn(cursorMock);
|
.andReturn(cursorMock);
|
||||||
|
|
||||||
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock, cursorMock);
|
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock, cursorMock);
|
||||||
@@ -193,7 +193,7 @@ public class SendMapsAsyncTaskTest extends AndroidTestCase {
|
|||||||
cursorMock.close();
|
cursorMock.close();
|
||||||
AndroidMock.expect(myTracksProviderUtilsMock.createTrackPoint(cursorMock))
|
AndroidMock.expect(myTracksProviderUtilsMock.createTrackPoint(cursorMock))
|
||||||
.andReturn(new Location("1")).times(2);
|
.andReturn(new Location("1")).times(2);
|
||||||
AndroidMock.expect(myTracksProviderUtilsMock.getTrackPointCursor(TRACK_ID, 0, -1, false))
|
AndroidMock.expect(myTracksProviderUtilsMock.getTrackPointCursor(TRACK_ID, -1L, -1, false))
|
||||||
.andReturn(cursorMock);
|
.andReturn(cursorMock);
|
||||||
|
|
||||||
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock, cursorMock);
|
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock, cursorMock);
|
||||||
@@ -223,7 +223,7 @@ public class SendMapsAsyncTaskTest extends AndroidTestCase {
|
|||||||
cursorMock.close();
|
cursorMock.close();
|
||||||
AndroidMock.expect(myTracksProviderUtilsMock.createTrackPoint(cursorMock))
|
AndroidMock.expect(myTracksProviderUtilsMock.createTrackPoint(cursorMock))
|
||||||
.andReturn(new Location("1")).times(2);
|
.andReturn(new Location("1")).times(2);
|
||||||
AndroidMock.expect(myTracksProviderUtilsMock.getTrackPointCursor(TRACK_ID, 0, -1, false))
|
AndroidMock.expect(myTracksProviderUtilsMock.getTrackPointCursor(TRACK_ID, -1L, -1, false))
|
||||||
.andReturn(cursorMock);
|
.andReturn(cursorMock);
|
||||||
|
|
||||||
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock, cursorMock);
|
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock, cursorMock);
|
||||||
@@ -252,7 +252,7 @@ public class SendMapsAsyncTaskTest extends AndroidTestCase {
|
|||||||
cursorMock.close();
|
cursorMock.close();
|
||||||
AndroidMock.expect(myTracksProviderUtilsMock.createTrackPoint(cursorMock))
|
AndroidMock.expect(myTracksProviderUtilsMock.createTrackPoint(cursorMock))
|
||||||
.andReturn(new Location("1")).times(2);
|
.andReturn(new Location("1")).times(2);
|
||||||
AndroidMock.expect(myTracksProviderUtilsMock.getTrackPointCursor(TRACK_ID, 0, -1, false))
|
AndroidMock.expect(myTracksProviderUtilsMock.getTrackPointCursor(TRACK_ID, -1L, -1, false))
|
||||||
.andReturn(cursorMock);
|
.andReturn(cursorMock);
|
||||||
|
|
||||||
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock, cursorMock);
|
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock, cursorMock);
|
||||||
@@ -274,7 +274,7 @@ public class SendMapsAsyncTaskTest extends AndroidTestCase {
|
|||||||
@UsesMocks(Cursor.class)
|
@UsesMocks(Cursor.class)
|
||||||
public void testUploadWaypoints_nullCursor() {
|
public void testUploadWaypoints_nullCursor() {
|
||||||
AndroidMock.expect(
|
AndroidMock.expect(
|
||||||
myTracksProviderUtilsMock.getWaypointCursor(TRACK_ID, 0,
|
myTracksProviderUtilsMock.getWaypointCursor(TRACK_ID, -1L,
|
||||||
Constants.MAX_LOADED_WAYPOINTS_POINTS)).andReturn(null);
|
Constants.MAX_LOADED_WAYPOINTS_POINTS)).andReturn(null);
|
||||||
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock);
|
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock);
|
||||||
SendMapsAsyncTask sendMapsAsyncTask = new SendMapsAsyncTask(sendMapsActivityMock,
|
SendMapsAsyncTask sendMapsAsyncTask = new SendMapsAsyncTask(sendMapsActivityMock,
|
||||||
@@ -296,7 +296,7 @@ public class SendMapsAsyncTaskTest extends AndroidTestCase {
|
|||||||
cursorMock.close();
|
cursorMock.close();
|
||||||
|
|
||||||
AndroidMock.expect(
|
AndroidMock.expect(
|
||||||
myTracksProviderUtilsMock.getWaypointCursor(TRACK_ID, 0,
|
myTracksProviderUtilsMock.getWaypointCursor(TRACK_ID, -1L,
|
||||||
Constants.MAX_LOADED_WAYPOINTS_POINTS)).andReturn(cursorMock);
|
Constants.MAX_LOADED_WAYPOINTS_POINTS)).andReturn(cursorMock);
|
||||||
|
|
||||||
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock, cursorMock);
|
AndroidMock.replay(sendMapsActivityMock, myTracksProviderUtilsMock, cursorMock);
|
||||||
@@ -323,7 +323,7 @@ public class SendMapsAsyncTaskTest extends AndroidTestCase {
|
|||||||
cursorMock.close();
|
cursorMock.close();
|
||||||
|
|
||||||
AndroidMock.expect(
|
AndroidMock.expect(
|
||||||
myTracksProviderUtilsMock.getWaypointCursor(TRACK_ID, 0,
|
myTracksProviderUtilsMock.getWaypointCursor(TRACK_ID, -1L,
|
||||||
Constants.MAX_LOADED_WAYPOINTS_POINTS)).andReturn(cursorMock);
|
Constants.MAX_LOADED_WAYPOINTS_POINTS)).andReturn(cursorMock);
|
||||||
Waypoint waypoint = new Waypoint();
|
Waypoint waypoint = new Waypoint();
|
||||||
waypoint.setLocation(TrackStubUtils.createMyTracksLocation());
|
waypoint.setLocation(TrackStubUtils.createMyTracksLocation());
|
||||||
|
|||||||
+1
-1
@@ -787,6 +787,6 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
|
|||||||
location.setTime(System.currentTimeMillis());
|
location.setTime(System.currentTimeMillis());
|
||||||
location.setBearing(3.0f);
|
location.setBearing(3.0f);
|
||||||
trackRecordingService.insertTrackPoint(location);
|
trackRecordingService.insertTrackPoint(location);
|
||||||
Thread.sleep(100);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user