mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-03 18:03:06 +02:00
Merge heads
This commit is contained in:
+4
-2
@@ -35,19 +35,21 @@ public class WaypointCreationRequestTest extends AndroidTestCase {
|
||||
p.setDataPosition(0);
|
||||
WaypointCreationRequest copy = WaypointCreationRequest.CREATOR.createFromParcel(p);
|
||||
assertEquals(original.getType(), copy.getType());
|
||||
assertFalse(copy.isTrackStatistics());
|
||||
assertNull(copy.getName());
|
||||
assertNull(copy.getDescription());
|
||||
assertNull(copy.getIconUrl());
|
||||
}
|
||||
|
||||
public void testAllAttributesParceling() {
|
||||
WaypointCreationRequest original =
|
||||
new WaypointCreationRequest(WaypointType.WAYPOINT, "name", "category", "description", "img.png");
|
||||
WaypointCreationRequest original = new WaypointCreationRequest(
|
||||
WaypointType.WAYPOINT, false, "name", "category", "description", "img.png");
|
||||
Parcel p = Parcel.obtain();
|
||||
original.writeToParcel(p, 0);
|
||||
p.setDataPosition(0);
|
||||
WaypointCreationRequest copy = WaypointCreationRequest.CREATOR.createFromParcel(p);
|
||||
assertEquals(original.getType(), copy.getType());
|
||||
assertFalse(copy.isTrackStatistics());
|
||||
assertEquals("name", copy.getName());
|
||||
assertEquals("category", copy.getCategory());
|
||||
assertEquals("description", copy.getDescription());
|
||||
|
||||
+22
-1
@@ -39,6 +39,7 @@ import android.location.Location;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.Settings;
|
||||
import android.test.RenamingDelegatingContext;
|
||||
import android.test.ServiceTestCase;
|
||||
@@ -494,6 +495,7 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
|
||||
|
||||
ITrackRecordingService service = bindAndGetService(createStartIntent());
|
||||
assertTrue(service.isRecording());
|
||||
insertLocation(service);
|
||||
|
||||
assertEquals(1, service.insertWaypoint(WaypointCreationRequest.DEFAULT_STATISTICS));
|
||||
assertEquals(2, service.insertWaypoint(WaypointCreationRequest.DEFAULT_STATISTICS));
|
||||
@@ -530,12 +532,13 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
|
||||
|
||||
ITrackRecordingService service = bindAndGetService(createStartIntent());
|
||||
assertTrue(service.isRecording());
|
||||
insertLocation(service);
|
||||
|
||||
assertEquals(1, service.insertWaypoint(WaypointCreationRequest.DEFAULT_WAYPOINT));
|
||||
Waypoint wpt = providerUtils.getWaypoint(1);
|
||||
assertEquals(getContext().getString(R.string.marker_waypoint_icon_url),
|
||||
wpt.getIcon());
|
||||
assertEquals(getContext().getString(R.string.marker_waypoint_name_format, 1), wpt.getName());
|
||||
assertEquals(getContext().getString(R.string.marker_name_format, 1), wpt.getName());
|
||||
assertEquals(Waypoint.TYPE_WAYPOINT, wpt.getType());
|
||||
assertEquals(123L, wpt.getTrackId());
|
||||
assertEquals(0.0, wpt.getLength());
|
||||
@@ -742,4 +745,22 @@ public class TrackRecordingServiceTest extends ServiceTestCase<TestRecordingServ
|
||||
assertTrue(tripStatistics.getStartTime() > 0);
|
||||
assertTrue(tripStatistics.getStopTime() >= tripStatistics.getStartTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a location and waits for 100ms.
|
||||
*
|
||||
* @param trackRecordingService the track recording service
|
||||
*/
|
||||
private void insertLocation(ITrackRecordingService trackRecordingService)
|
||||
throws RemoteException, InterruptedException {
|
||||
Location location = new Location("gps");
|
||||
location.setLongitude(35.0f);
|
||||
location.setLatitude(45.0f);
|
||||
location.setAccuracy(5);
|
||||
location.setSpeed(10);
|
||||
location.setTime(System.currentTimeMillis());
|
||||
location.setBearing(3.0f);
|
||||
trackRecordingService.recordLocation(location);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.google.android.apps.mytracks.util;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
import android.text.format.DateFormat;
|
||||
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
@@ -29,23 +28,6 @@ import java.util.TimeZone;
|
||||
*/
|
||||
public class StringUtilsTest extends AndroidTestCase {
|
||||
|
||||
/**
|
||||
* Tests {@link StringUtils#formatDateTime(android.content.Context, long)}.
|
||||
*/
|
||||
public void testFormatTime() {
|
||||
assertEquals(DateFormat.getTimeFormat(getContext()).format(0L),
|
||||
StringUtils.formatTime(getContext(), 0L));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link StringUtils#formatDateTime(android.content.Context, long)}.
|
||||
*/
|
||||
public void testFormatDateTime() {
|
||||
String expected = DateFormat.getDateFormat(getContext()).format(0L) + " "
|
||||
+ DateFormat.getTimeFormat(getContext()).format(0L);
|
||||
assertEquals(expected, StringUtils.formatDateTime(getContext(), 0L));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link StringUtils#formatDateTimeIso8601(long)}.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user