forked from upstream-mirrors/OpenTracks
Change the code style and fix few invisible warnings in javadoc of MyTracksProviderUtilsImplTest.
This commit is contained in:
+25
-21
@@ -50,6 +50,9 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
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!";
|
||||||
|
private double INITIAL_LATITUDE = 37.0;
|
||||||
|
private double INITIAL_LONGITUDE = -57.0;
|
||||||
|
private double ALTITUDE_INTERVAL = 2.5;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
@@ -272,13 +275,13 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
// Check whether all have been deleted.
|
// Check whether all have been deleted.
|
||||||
tracksCursor = contentResolver.query(TracksColumns.CONTENT_URI, null, null, null,
|
tracksCursor = contentResolver.query(TracksColumns.CONTENT_URI, null, null, null,
|
||||||
TracksColumns._ID);
|
TracksColumns._ID);
|
||||||
assertTrue(tracksCursor.getCount() == 0);
|
assertEquals(0, tracksCursor.getCount());
|
||||||
tracksPointsCursor = contentResolver.query(TrackPointsColumns.CONTENT_URI, null, null,
|
tracksPointsCursor = contentResolver.query(TrackPointsColumns.CONTENT_URI, null, null,
|
||||||
null, TrackPointsColumns._ID);
|
null, TrackPointsColumns._ID);
|
||||||
assertTrue(tracksPointsCursor.getCount() == 0);
|
assertEquals(0, tracksPointsCursor.getCount());
|
||||||
waypointCursor = contentResolver.query(WaypointsColumns.CONTENT_URI, null, null,
|
waypointCursor = contentResolver.query(WaypointsColumns.CONTENT_URI, null, null,
|
||||||
null, WaypointsColumns._ID);
|
null, WaypointsColumns._ID);
|
||||||
assertTrue(waypointCursor.getCount() == 0);
|
assertEquals(0, waypointCursor.getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,9 +330,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
@UsesMocks(Cursor.class)
|
@UsesMocks(Cursor.class)
|
||||||
public void testCreateTrack() {
|
public void testCreateTrack() {
|
||||||
Cursor cursorMock = AndroidMock.createNiceMock(Cursor.class);
|
Cursor cursorMock = AndroidMock.createNiceMock(Cursor.class);
|
||||||
// The startColumnIndex can be any value, just make it to 2 in case it's
|
int startColumnIndex = 1;
|
||||||
// hard coded to 0 or 1 in some where.
|
|
||||||
int startColumnIndex = 2;
|
|
||||||
int columnIndex = startColumnIndex;
|
int columnIndex = startColumnIndex;
|
||||||
AndroidMock.expect(cursorMock.getColumnIndexOrThrow(TracksColumns._ID))
|
AndroidMock.expect(cursorMock.getColumnIndexOrThrow(TracksColumns._ID))
|
||||||
.andReturn(columnIndex++);
|
.andReturn(columnIndex++);
|
||||||
@@ -358,7 +359,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
* Tests the method {@link MyTracksProviderUtilsImpl#createContentValues(Track)}.
|
* Tests the method {@link MyTracksProviderUtilsImpl#createContentValues(Track)}.
|
||||||
*/
|
*/
|
||||||
@UsesMocks(TripStatistics.class)
|
@UsesMocks(TripStatistics.class)
|
||||||
public void testCreateContentValues_Track() {
|
public void testCreateContentValues_track() {
|
||||||
// ID
|
// ID
|
||||||
long trackId = System.currentTimeMillis();
|
long trackId = System.currentTimeMillis();
|
||||||
// Name
|
// Name
|
||||||
@@ -644,9 +645,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
@UsesMocks(Cursor.class)
|
@UsesMocks(Cursor.class)
|
||||||
public void testCreateWaypoint() {
|
public void testCreateWaypoint() {
|
||||||
Cursor cursorMock = AndroidMock.createNiceMock(Cursor.class);
|
Cursor cursorMock = AndroidMock.createNiceMock(Cursor.class);
|
||||||
// The startColumnIndex can be any value, just make it to 2 in case it's
|
int startColumnIndex = 1;
|
||||||
// hard coded to 0 or 1 in some where.
|
|
||||||
int startColumnIndex = 2;
|
|
||||||
int columnIndex = startColumnIndex;
|
int columnIndex = startColumnIndex;
|
||||||
AndroidMock.expect(cursorMock.getColumnIndexOrThrow(WaypointsColumns._ID))
|
AndroidMock.expect(cursorMock.getColumnIndexOrThrow(WaypointsColumns._ID))
|
||||||
.andReturn(columnIndex++);
|
.andReturn(columnIndex++);
|
||||||
@@ -682,7 +681,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
/**
|
/**
|
||||||
* Tests the method {@link MyTracksProviderUtilsImpl#createContentValues(Waypoint)}.
|
* Tests the method {@link MyTracksProviderUtilsImpl#createContentValues(Waypoint)}.
|
||||||
*/
|
*/
|
||||||
public void testCreateContentValues_Waypoint() {
|
public void testCreateContentValues_waypoint() {
|
||||||
long trackId = System.currentTimeMillis();
|
long trackId = System.currentTimeMillis();
|
||||||
Track track = getTrack(trackId, 10);
|
Track track = getTrack(trackId, 10);
|
||||||
providerUtils.insertTrack(track);
|
providerUtils.insertTrack(track);
|
||||||
@@ -818,10 +817,10 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
|
|
||||||
LocationIterator locationIterator = providerUtils.getLocationIterator(trackId,
|
LocationIterator locationIterator = providerUtils.getLocationIterator(trackId,
|
||||||
startTrackPointId, true, MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
startTrackPointId, true, MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
||||||
assertEquals(startTrackPointId, locationIterator.getLocationId());
|
|
||||||
for (int i = 1; i >= 0; i--) {
|
for (int i = 1; i >= 0; i--) {
|
||||||
assertTrue(locationIterator.hasNext());
|
assertTrue(locationIterator.hasNext());
|
||||||
Location location = locationIterator.next();
|
Location location = locationIterator.next();
|
||||||
|
assertEquals(2 + (i - 1), locationIterator.getLocationId());
|
||||||
checkLocation(i, location);
|
checkLocation(i, location);
|
||||||
}
|
}
|
||||||
assertFalse(locationIterator.hasNext());
|
assertFalse(locationIterator.hasNext());
|
||||||
@@ -842,10 +841,11 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
|
|
||||||
LocationIterator locationIterator = providerUtils.getLocationIterator(trackId,
|
LocationIterator locationIterator = providerUtils.getLocationIterator(trackId,
|
||||||
startTrackPointId, false, MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
startTrackPointId, false, MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
||||||
assertEquals(startTrackPointId, locationIterator.getLocationId());
|
|
||||||
for (int i = 1; i < 10; i++) {
|
for (int i = 1; i < 10; i++) {
|
||||||
assertTrue(locationIterator.hasNext());
|
assertTrue(locationIterator.hasNext());
|
||||||
Location location = locationIterator.next();
|
Location location = locationIterator.next();
|
||||||
|
assertEquals(2 + (i - 1), locationIterator.getLocationId());
|
||||||
checkLocation(i, location);
|
checkLocation(i, location);
|
||||||
}
|
}
|
||||||
assertFalse(locationIterator.hasNext());
|
assertFalse(locationIterator.hasNext());
|
||||||
@@ -870,6 +870,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
* test also covers the method
|
* test also covers the method
|
||||||
* {@link MyTracksProviderUtilsImpl#createContentValues(Location, long)}.
|
* {@link MyTracksProviderUtilsImpl#createContentValues(Location, long)}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
public void testInsertTrackPoint() {
|
public void testInsertTrackPoint() {
|
||||||
// Insert track, point at first.
|
// Insert track, point at first.
|
||||||
long trackId = System.currentTimeMillis();
|
long trackId = System.currentTimeMillis();
|
||||||
@@ -887,6 +888,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
* {@link MyTracksProviderUtilsImpl#createContentValues(Location, long)} and
|
* {@link MyTracksProviderUtilsImpl#createContentValues(Location, long)} and
|
||||||
* the inner class {@link MyTracksProviderUtilsImpl.CachedTrackPointsIndexes}.
|
* the inner class {@link MyTracksProviderUtilsImpl.CachedTrackPointsIndexes}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
public void testBulkInsertTrackPoints() {
|
public void testBulkInsertTrackPoints() {
|
||||||
// Insert track, point at first.
|
// Insert track, point at first.
|
||||||
long trackId = System.currentTimeMillis();
|
long trackId = System.currentTimeMillis();
|
||||||
@@ -907,6 +909,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
* and the inner class
|
* and the inner class
|
||||||
* {@link MyTracksProviderUtilsImpl.CachedTrackPointsIndexes}.
|
* {@link MyTracksProviderUtilsImpl.CachedTrackPointsIndexes}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
@UsesMocks(Cursor.class)
|
@UsesMocks(Cursor.class)
|
||||||
public void testCreateLocation() {
|
public void testCreateLocation() {
|
||||||
Cursor cursorMock = AndroidMock.createNiceMock(Cursor.class);
|
Cursor cursorMock = AndroidMock.createNiceMock(Cursor.class);
|
||||||
@@ -983,7 +986,7 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
track.setId(id);
|
track.setId(id);
|
||||||
track.setName("Test: " + id);
|
track.setName("Test: " + id);
|
||||||
track.setNumberOfPoints(numPoints);
|
track.setNumberOfPoints(numPoints);
|
||||||
for(int i=0; i < numPoints; i++) {
|
for(int i = 0; i < numPoints; i++) {
|
||||||
track.addLocation(createLocation(i));
|
track.addLocation(createLocation(i));
|
||||||
}
|
}
|
||||||
return track;
|
return track;
|
||||||
@@ -995,9 +998,10 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
* @return created location
|
* @return created location
|
||||||
*/
|
*/
|
||||||
private Location createLocation(int i) {
|
private Location createLocation(int i) {
|
||||||
|
|
||||||
Location loc = new Location("test");
|
Location loc = new Location("test");
|
||||||
loc.setLatitude(37.0 + (double) i / 10000.0);
|
loc.setLatitude(INITIAL_LATITUDE + (double) i / 10000.0);
|
||||||
loc.setLongitude(57.0 - (double) i / 10000.0);
|
loc.setLongitude(INITIAL_LONGITUDE - (double) i / 10000.0);
|
||||||
loc.setAccuracy((float) i / 100.0f);
|
loc.setAccuracy((float) i / 100.0f);
|
||||||
loc.setAltitude(i * 2.5);
|
loc.setAltitude(i * 2.5);
|
||||||
return loc;
|
return loc;
|
||||||
@@ -1006,15 +1010,15 @@ public class MyTracksProviderUtilsImplTest extends AndroidTestCase {
|
|||||||
/**
|
/**
|
||||||
* Checks the value of a location.
|
* Checks the value of a location.
|
||||||
*
|
*
|
||||||
* @param i the index of this location which created in the method {@link
|
* @param i the index of this location which created in the method
|
||||||
* this#getTrack(long, int)}
|
* {@link MyTracksProviderUtilsImplTest#getTrack(long, int)}
|
||||||
* @param location the location to be checked
|
* @param location the location to be checked
|
||||||
*/
|
*/
|
||||||
private void checkLocation(int i, Location location) {
|
private void checkLocation(int i, Location location) {
|
||||||
assertEquals(37.0 + (double) i / 10000.0, location.getLatitude());
|
assertEquals(INITIAL_LATITUDE + (double) i / 10000.0, location.getLatitude());
|
||||||
assertEquals(57.0 - (double) i / 10000.0, location.getLongitude());
|
assertEquals(INITIAL_LONGITUDE - (double) i / 10000.0, location.getLongitude());
|
||||||
assertEquals((float) i / 100.0f, location.getAccuracy());
|
assertEquals((float) i / 100.0f, location.getAccuracy());
|
||||||
assertEquals(i * 2.5, location.getAltitude());
|
assertEquals(i * ALTITUDE_INTERVAL, location.getAltitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user