diff --git a/MyTracks/src/com/google/android/apps/mytracks/BootReceiver.java b/MyTracks/src/com/google/android/apps/mytracks/BootReceiver.java index 248735b7f..5b227c6a0 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/BootReceiver.java +++ b/MyTracks/src/com/google/android/apps/mytracks/BootReceiver.java @@ -16,7 +16,6 @@ package com.google.android.apps.mytracks; import static android.content.Intent.ACTION_BOOT_COMPLETED; -import static com.google.android.apps.mytracks.Constants.RESUME_TRACK_EXTRA_NAME; import static com.google.android.apps.mytracks.Constants.TAG; import com.google.android.apps.mytracks.services.RemoveTempFilesService; @@ -49,7 +48,7 @@ public class BootReceiver extends BroadcastReceiver { Log.d(TAG, "BootReceiver.onReceive: " + intent.getAction()); if (ACTION_BOOT_COMPLETED.equals(intent.getAction())) { Intent startIntent = new Intent(context, TrackRecordingService.class) - .putExtra(RESUME_TRACK_EXTRA_NAME, true); + .putExtra(TrackRecordingService.RESUME_TRACK_EXTRA_NAME, true); context.startService(startIntent); Intent removeTempFilesIntent = new Intent(context, RemoveTempFilesService.class); diff --git a/MyTracks/src/com/google/android/apps/mytracks/Constants.java b/MyTracks/src/com/google/android/apps/mytracks/Constants.java index b6e1066f2..ee5e9cf38 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/Constants.java +++ b/MyTracks/src/com/google/android/apps/mytracks/Constants.java @@ -13,118 +13,58 @@ * License for the specific language governing permissions and limitations under * the License. */ + package com.google.android.apps.mytracks; /** - * Constants used by the MyTracks application. - * + * Common constants. + * * @author Leif Hendrik Wilden */ -public abstract class Constants { +public class Constants { + + private Constants() {} /** - * Should be used by all log statements - */ - public static final String TAG = "MyTracks"; - - /** - * Name of the top-level directory inside the SD card where our files will - * be read from/written to. - */ - public static final String SDCARD_TOP_DIR = "MyTracks"; - - /** - * The number of distance readings to smooth to get a stable signal. - */ - public static final int DISTANCE_SMOOTHING_FACTOR = 25; - - /** - * The number of elevation readings to smooth to get a somewhat accurate - * signal. - */ - public static final int ELEVATION_SMOOTHING_FACTOR = 25; - - /** - * The number of grade readings to smooth to get a somewhat accurate signal. - */ - public static final int GRADE_SMOOTHING_FACTOR = 5; - - /** - * The number of speed reading to smooth to get a somewhat accurate signal. - */ - public static final int SPEED_SMOOTHING_FACTOR = 25; - - /** - * Maximum number of track points displayed by the map overlay. - */ - public static final int MAX_DISPLAYED_TRACK_POINTS = 10000; - - /** - * Target number of track points displayed by the map overlay. - * We may display more than this number of points. - */ - public static final int TARGET_DISPLAYED_TRACK_POINTS = 5000; - - /** - * Maximum number of track points ever loaded at once from the provider into - * memory. - * With a recording frequency of 2 seconds, 15000 corresponds to 8.3 hours. - */ - public static final int MAX_LOADED_TRACK_POINTS = 20000; - - /** - * Maximum number of track points ever loaded at once from the provider into - * memory in a single call to read points. - */ - public static final int MAX_LOADED_TRACK_POINTS_PER_BATCH = 1000; - - /** - * Maximum number of way points displayed by the map overlay. - */ - public static final int MAX_DISPLAYED_WAYPOINTS_POINTS = 128; - - /** - * Maximum number of way points that will be loaded at one time. - */ - public static final int MAX_LOADED_WAYPOINTS_POINTS = 10000; - - /** - * Any time segment where the distance traveled is less than this value will - * not be considered moving. - */ - public static final double MAX_NO_MOVEMENT_DISTANCE = 2; - - /** - * Anything faster than that (in meters per second) will be considered moving. - */ - public static final double MAX_NO_MOVEMENT_SPEED = 0.224; - - /** - * Ignore any acceleration faster than this. - * Will ignore any speeds that imply accelaration greater than 2g's - * 2g = 19.6 m/s^2 = 0.0002 m/ms^2 = 0.02 m/(m*ms) - */ - public static final double MAX_ACCELERATION = 0.02; - - /** Maximum age of a GPS location to be considered current. */ - public static final long MAX_LOCATION_AGE_MS = 60 * 1000; // 1 minute - - /** - * The type of account that we can use for gdata uploads. + * The google account type. */ public static final String ACCOUNT_TYPE = "com.google"; /** - * The name of extra intent property to indicate whether we want to resume - * a previously recorded track. + * Maximum number of track points displayed by the map overlay. Set to 2X of + * {@link Constants#TARGET_DISPLAYED_TRACK_POINTS} */ - public static final String - RESUME_TRACK_EXTRA_NAME = "com.google.android.apps.mytracks.RESUME_TRACK"; + public static final int MAX_DISPLAYED_TRACK_POINTS = 10000; + /** + * Maximum number of waypoints displayed by the map overlay. + */ + public static final int MAX_DISPLAYED_WAYPOINTS_POINTS = 128; + + /** + * Maximum number of track points that will be loaded at one time. With + * recording frequency of 2 seconds, 20000 corresponds to 11.1 hours. + */ + public static final int MAX_LOADED_TRACK_POINTS = 20000; + + /** + * Maximum number of waypoints that will be loaded at one time. + */ + public static final int MAX_LOADED_WAYPOINTS_POINTS = 10000; + + /** + * The settings file name. + */ public static final String SETTINGS_NAME = "SettingsActivity"; /** - * This is an abstract utility class. + * The log tag. */ - protected Constants() { } + public static final String TAG = "MyTracks"; + + /** + * Target number of track points displayed by the map overlay. We may display + * more than this number of points. + */ + public static final int TARGET_DISPLAYED_TRACK_POINTS = 5000; } diff --git a/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java b/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java index 65189d67d..1a7d929c3 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java +++ b/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java @@ -17,7 +17,6 @@ package com.google.android.apps.mytracks.content; import static com.google.android.apps.mytracks.Constants.MAX_DISPLAYED_WAYPOINTS_POINTS; -import static com.google.android.apps.mytracks.Constants.MAX_LOCATION_AGE_MS; import static com.google.android.apps.mytracks.Constants.TARGET_DISPLAYED_TRACK_POINTS; import com.google.android.apps.mytracks.Constants; @@ -53,6 +52,11 @@ public class TrackDataHub implements DataSourceListener { private static final String TAG = TrackDataHub.class.getSimpleName(); + /** + * Maximum age of a location to be considered current. + */ + private static final long MAX_LOCATION_AGE_MS = 60 * 1000; // 1 minute + private final Context context; private final TrackDataManager trackDataManager; private final MyTracksProviderUtils myTracksProviderUtils; diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java b/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java index beb95ea1c..56423f5c1 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java +++ b/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java @@ -16,8 +16,6 @@ package com.google.android.apps.mytracks.services; -import static com.google.android.apps.mytracks.Constants.RESUME_TRACK_EXTRA_NAME; - import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.TrackDetailActivity; import com.google.android.apps.mytracks.content.DescriptionGeneratorImpl; @@ -82,6 +80,14 @@ import java.util.concurrent.Executors; public class TrackRecordingService extends Service { private static final String TAG = TrackRecordingService.class.getSimpleName(); + + /** + * The name of extra intent property to indicate whether we want to resume a + * previously recorded track. + */ + public static final String + RESUME_TRACK_EXTRA_NAME = "com.google.android.apps.mytracks.RESUME_TRACK"; + public static final double PAUSE_LATITUDE = 100.0; public static final double RESUME_LATITUDE = 200.0; diff --git a/MyTracks/src/com/google/android/apps/mytracks/stats/TripStatisticsUpdater.java b/MyTracks/src/com/google/android/apps/mytracks/stats/TripStatisticsUpdater.java index 9b18f8ced..f58ea4993 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/stats/TripStatisticsUpdater.java +++ b/MyTracks/src/com/google/android/apps/mytracks/stats/TripStatisticsUpdater.java @@ -18,7 +18,6 @@ package com.google.android.apps.mytracks.stats; import static com.google.android.apps.mytracks.Constants.TAG; -import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.services.TrackRecordingService; import com.google.android.apps.mytracks.util.LocationUtils; import com.google.common.annotations.VisibleForTesting; @@ -36,6 +35,43 @@ import android.util.Log; */ public class TripStatisticsUpdater { + /** + * The number of distance readings to smooth to get a stable signal. + */ + @VisibleForTesting + static final int DISTANCE_SMOOTHING_FACTOR = 25; + + /** + * The number of elevation readings to smooth to get a somewhat accurate + * signal. + */ + @VisibleForTesting + static final int ELEVATION_SMOOTHING_FACTOR = 25; + + /** + * The number of grade readings to smooth to get a somewhat accurate signal. + */ + @VisibleForTesting + static final int GRADE_SMOOTHING_FACTOR = 5; + + /** + * The number of speed reading to smooth to get a somewhat accurate signal. + */ + @VisibleForTesting + static final int SPEED_SMOOTHING_FACTOR = 25; + + /** + * Anything faster than that (in meters per second) will be considered moving. + */ + private static final double MAX_NO_MOVEMENT_SPEED = 0.224; + + /** + * Ignore any acceleration faster than this. Will ignore any speeds that imply + * accelaration greater than 2g's 2g = 19.6 m/s^2 = 0.0002 m/ms^2 = 0.02 + * m/(m*ms) + */ + private static final double MAX_ACCELERATION = 0.02; + // The track's trip statistics private final TripStatistics tripStatistics; @@ -49,17 +85,16 @@ public class TripStatisticsUpdater { private Location lastMovingLocation; // A buffer of the recent speed readings (m/s) for calculating max speed - private final DoubleBuffer speedBuffer = new DoubleBuffer(Constants.SPEED_SMOOTHING_FACTOR); + private final DoubleBuffer speedBuffer = new DoubleBuffer(SPEED_SMOOTHING_FACTOR); // A buffer of the recent elevation readings (m) - private final DoubleBuffer elevationBuffer = new DoubleBuffer( - Constants.ELEVATION_SMOOTHING_FACTOR); + private final DoubleBuffer elevationBuffer = new DoubleBuffer(ELEVATION_SMOOTHING_FACTOR); // A buffer of the recent distance readings (m) for calculating grade - private final DoubleBuffer distanceBuffer = new DoubleBuffer(Constants.DISTANCE_SMOOTHING_FACTOR); + private final DoubleBuffer distanceBuffer = new DoubleBuffer(DISTANCE_SMOOTHING_FACTOR); // A buffer of the recent grade calculations (%) - private final DoubleBuffer gradeBuffer = new DoubleBuffer(Constants.GRADE_SMOOTHING_FACTOR); + private final DoubleBuffer gradeBuffer = new DoubleBuffer(GRADE_SMOOTHING_FACTOR); /** * Creates a new trip statistics updater. @@ -122,8 +157,7 @@ public class TripStatisticsUpdater { return; } double movingDistance = lastMovingLocation.distanceTo(location); - if (movingDistance < minRecordingDistance - && location.getSpeed() < Constants.MAX_NO_MOVEMENT_SPEED) { + if (movingDistance < minRecordingDistance && location.getSpeed() < MAX_NO_MOVEMENT_SPEED) { updateTime(location.getTime()); lastLocation = location; return; @@ -258,7 +292,7 @@ public class TripStatisticsUpdater { */ long timeDifference = time - lastLocationTime; double speedDifference = Math.abs(lastLocationSpeed - speed); - if (speedDifference > Constants.MAX_ACCELERATION * timeDifference) { + if (speedDifference > MAX_ACCELERATION * timeDifference) { return false; } @@ -272,6 +306,6 @@ public class TripStatisticsUpdater { } double average = speedBuffer.getAverage(); double diff = Math.abs(average - speed); - return (speed < average * 10) && (diff < Constants.MAX_ACCELERATION * timeDifference); + return (speed < average * 10) && (diff < MAX_ACCELERATION * timeDifference); } } diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/FileUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/FileUtils.java index 659552e65..f0ebbabd9 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/FileUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/FileUtils.java @@ -15,7 +15,6 @@ */ package com.google.android.apps.mytracks.util; -import com.google.android.apps.mytracks.Constants; import com.google.common.annotations.VisibleForTesting; import android.os.Environment; @@ -31,6 +30,13 @@ public class FileUtils { private FileUtils() {} + /** + * Name of the top-level directory inside the SD card where our files will be + * read from/written to. + */ + @VisibleForTesting + static final String SDCARD_TOP_DIR = "MyTracks"; + /** * The maximum FAT32 path length. See the FAT32 spec at * http://msdn.microsoft.com/en-us/windows/hardware/gg463080 @@ -88,7 +94,7 @@ public class FileUtils { StringBuilder dirNameBuilder = new StringBuilder(); dirNameBuilder.append(Environment.getExternalStorageDirectory()); dirNameBuilder.append(File.separatorChar); - dirNameBuilder.append(Constants.SDCARD_TOP_DIR); + dirNameBuilder.append(SDCARD_TOP_DIR); for (String component : components) { dirNameBuilder.append(File.separatorChar); dirNameBuilder.append(component); diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/services/TrackRecordingServiceTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/services/TrackRecordingServiceTest.java index 0195fc5b0..a2431ad6a 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/services/TrackRecordingServiceTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/services/TrackRecordingServiceTest.java @@ -15,8 +15,6 @@ */ package com.google.android.apps.mytracks.services; -import static com.google.android.apps.mytracks.Constants.RESUME_TRACK_EXTRA_NAME; - import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.content.MyTracksProvider; import com.google.android.apps.mytracks.content.MyTracksProviderUtils; @@ -57,13 +55,13 @@ import java.util.List; /** * Tests for the MyTracks track recording service. - * + *

+ * TODO: The original class, ServiceTestCase, has a few limitations, e.g. it's + * not possible to properly shutdown the service, unless tearDown() is called, + * which prevents from testing multiple scenarios in a single test (see + * runFunctionTest for more details). + * * @author Bartlomiej Niechwiej - * - * TODO: The original class, ServiceTestCase, has a few limitations, e.g. - * it's not possible to properly shutdown the service, unless tearDown() - * is called, which prevents from testing multiple scenarios in a single - * test (see runFunctionTest for more details). */ public class TrackRecordingServiceTest extends ServiceTestCase { @@ -71,9 +69,9 @@ public class TrackRecordingServiceTest extends ServiceTestCase= 0); providerUtils.insertTrack(track); assertEquals(track.getId(), providerUtils.getTrack(track.getId()).getId()); - PreferencesUtils.setLong(context, R.string.recording_track_id_key, isRecording ? track.getId() - : PreferencesUtils.RECORDING_TRACK_ID_DEFAULT); + PreferencesUtils.setLong(context, R.string.recording_track_id_key, + isRecording ? track.getId() : PreferencesUtils.RECORDING_TRACK_ID_DEFAULT); PreferencesUtils.setBoolean(context, R.string.recording_track_paused_key, !isRecording); } @@ -760,7 +763,7 @@ public class TrackRecordingServiceTest extends ServiceTestCase 0); assertTrue(tripStatistics.getStopTime() >= tripStatistics.getStartTime()); } - + /** * Inserts a location and waits for 100ms. * diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/stats/TripStatisticsUpdaterTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/stats/TripStatisticsUpdaterTest.java index 8c6d65c21..900bb4812 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/stats/TripStatisticsUpdaterTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/stats/TripStatisticsUpdaterTest.java @@ -2,7 +2,6 @@ package com.google.android.apps.mytracks.stats; -import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.util.PreferencesUtils; import android.location.Location; @@ -103,21 +102,22 @@ public class TripStatisticsUpdaterTest extends TestCase { public void testElevationGain() throws Exception { for (double i = 0; i < 1000; i++) { double expectedGain; - if (i < Constants.ELEVATION_SMOOTHING_FACTOR - 1) { + if (i < TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR - 1) { expectedGain = 0; - } else if (i < Constants.ELEVATION_SMOOTHING_FACTOR) { + } else if (i < TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR) { expectedGain = 0.5; } else { expectedGain = 1.0; } assertEquals(expectedGain, tripStatisticsUpdater.updateElevation(i)); assertEquals(i, tripStatisticsUpdater.getSmoothedElevation(), - Constants.ELEVATION_SMOOTHING_FACTOR / 2); + TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR / 2); TripStatistics data = tripStatisticsUpdater.getTripStatistics(); assertEquals(0.0, data.getMinElevation()); - assertEquals(i, data.getMaxElevation(), Constants.ELEVATION_SMOOTHING_FACTOR / 2); - assertEquals(i, data.getTotalElevationGain(), Constants.ELEVATION_SMOOTHING_FACTOR); + assertEquals(i, data.getMaxElevation(), TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR / 2); + assertEquals( + i, data.getTotalElevationGain(), TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR); } } @@ -133,7 +133,8 @@ public class TripStatisticsUpdaterTest extends TestCase { */ tripStatisticsUpdater.updateElevation(i); tripStatisticsUpdater.updateGrade(100, 100); - if (i >= Constants.GRADE_SMOOTHING_FACTOR && i >= Constants.ELEVATION_SMOOTHING_FACTOR) { + if (i >= TripStatisticsUpdater.GRADE_SMOOTHING_FACTOR + && i >= TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR) { assertEquals(1.0, tripStatisticsUpdater.getTripStatistics().getMaxGrade()); assertEquals(1.0, tripStatisticsUpdater.getTripStatistics().getMinGrade()); } @@ -145,7 +146,8 @@ public class TripStatisticsUpdaterTest extends TestCase { */ tripStatisticsUpdater.updateElevation(i); tripStatisticsUpdater.updateGrade(100, -100); - if (i >= Constants.GRADE_SMOOTHING_FACTOR && i >= Constants.ELEVATION_SMOOTHING_FACTOR) { + if (i >= TripStatisticsUpdater.GRADE_SMOOTHING_FACTOR + && i >= TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR) { assertEquals(1.0, tripStatisticsUpdater.getTripStatistics().getMaxGrade()); assertEquals(-1.0, tripStatisticsUpdater.getTripStatistics().getMinGrade()); } @@ -164,10 +166,10 @@ public class TripStatisticsUpdaterTest extends TestCase { */ tripStatisticsUpdater.updateElevation(i); tripStatisticsUpdater.updateGrade(1, 100); - assertEquals(Double.NEGATIVE_INFINITY, tripStatisticsUpdater.getTripStatistics() - .getMaxGrade()); - assertEquals(Double.POSITIVE_INFINITY, tripStatisticsUpdater.getTripStatistics() - .getMinGrade()); + assertEquals( + Double.NEGATIVE_INFINITY, tripStatisticsUpdater.getTripStatistics().getMaxGrade()); + assertEquals( + Double.POSITIVE_INFINITY, tripStatisticsUpdater.getTripStatistics().getMinGrade()); } } @@ -210,7 +212,7 @@ public class TripStatisticsUpdaterTest extends TestCase { double speed = 4.0; for (int i = 0; i < 1000; i++) { tripStatisticsUpdater.updateSpeed(i + ONE_SECOND, speed, i, speed); - if (i >= Constants.SPEED_SMOOTHING_FACTOR) { + if (i >= TripStatisticsUpdater.SPEED_SMOOTHING_FACTOR) { assertEquals(speed, tripStatisticsUpdater.getTripStatistics().getMaxSpeed()); } } @@ -231,28 +233,29 @@ public class TripStatisticsUpdaterTest extends TestCase { // Going up by 1 meter each time. // Moving by .001 degree latitude (111 meters). // Each time slice is 10 seconds. - Location location = getLocation(i + locationOffset, (i + locationOffset) * .001, - MOVING_SPEED, startTime + (timeOffset + i) * TEN_SECONDS); + Location location = getLocation(i + locationOffset, (i + locationOffset) * .001, MOVING_SPEED, + startTime + (timeOffset + i) * TEN_SECONDS); tripStatisticsUpdater.addLocation(location, PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT); tripStatistics = tripStatisticsUpdater.getTripStatistics(); assertEquals((timeOffset + i) * TEN_SECONDS, tripStatistics.getTotalTime()); assertEquals((locationOffset + i) * TEN_SECONDS, tripStatistics.getMovingTime()); assertEquals(i + locationOffset, tripStatisticsUpdater.getSmoothedElevation(), - Constants.ELEVATION_SMOOTHING_FACTOR / 2); + TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR / 2); assertEquals(0.0, tripStatistics.getMinElevation()); assertEquals(i + locationOffset, tripStatistics.getMaxElevation(), - Constants.ELEVATION_SMOOTHING_FACTOR / 2); + TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR / 2); assertEquals(i + locationOffset, tripStatistics.getTotalElevationGain(), - Constants.ELEVATION_SMOOTHING_FACTOR); + TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR); - if (i + locationOffset >= Constants.SPEED_SMOOTHING_FACTOR) { + if (i + locationOffset >= TripStatisticsUpdater.SPEED_SMOOTHING_FACTOR) { assertEquals(MOVING_SPEED, tripStatistics.getMaxSpeed(), 0.1); } // If there are only moving locations in the track. - if (locationOffset == 0 && (i + locationOffset) >= Constants.DISTANCE_SMOOTHING_FACTOR - && (i + locationOffset) >= Constants.ELEVATION_SMOOTHING_FACTOR) { + if (locationOffset == 0 + && (i + locationOffset) >= TripStatisticsUpdater.DISTANCE_SMOOTHING_FACTOR + && (i + locationOffset) >= TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR) { // 1 m / 111 m = .009 assertEquals(0.009, tripStatistics.getMinGrade(), 0.0001); assertEquals(0.009, tripStatistics.getMaxGrade(), 0.0001); @@ -274,26 +277,26 @@ public class TripStatisticsUpdaterTest extends TestCase { private void addWaitLocations(int points, long startTime, TripStatistics tripStatistics, int timeOffset, int locationOffset) { for (int i = 0; i < points; i++) { - Location location = getLocation(locationOffset, locationOffset * .001, 0, startTime - + (i + timeOffset) * TEN_SECONDS); + Location location = getLocation( + locationOffset, locationOffset * .001, 0, startTime + (i + timeOffset) * TEN_SECONDS); tripStatisticsUpdater.addLocation(location, PreferencesUtils.MIN_RECORDING_DISTANCE_DEFAULT); tripStatistics = tripStatisticsUpdater.getTripStatistics(); assertEquals((i + timeOffset) * TEN_SECONDS, tripStatistics.getTotalTime()); assertEquals((locationOffset) * TEN_SECONDS, tripStatistics.getMovingTime()); assertEquals(locationOffset, tripStatisticsUpdater.getSmoothedElevation(), - Constants.ELEVATION_SMOOTHING_FACTOR / 2); + TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR / 2); assertEquals(0.0, tripStatistics.getMinElevation()); assertEquals(locationOffset, tripStatistics.getMaxElevation(), - Constants.ELEVATION_SMOOTHING_FACTOR / 2); + TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR / 2); assertEquals(locationOffset, tripStatistics.getTotalElevationGain(), - Constants.ELEVATION_SMOOTHING_FACTOR); - if (locationOffset >= Constants.SPEED_SMOOTHING_FACTOR) { + TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR); + if (locationOffset >= TripStatisticsUpdater.SPEED_SMOOTHING_FACTOR) { assertEquals(MOVING_SPEED, tripStatistics.getMaxSpeed(), 0.1); } assertEquals(MOVING_SPEED, tripStatistics.getMaxSpeed(), 0.1); - assertEquals(locationOffset * 111.0, tripStatistics.getTotalDistance(), - locationOffset * 111.0 * 0.01); + assertEquals( + locationOffset * 111.0, tripStatistics.getTotalDistance(), locationOffset * 111.0 * 0.01); } } diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/util/FileUtilsTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/util/FileUtilsTest.java index 12152c3c7..8897f0bba 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/util/FileUtilsTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/util/FileUtilsTest.java @@ -15,8 +15,6 @@ */ package com.google.android.apps.mytracks.util; -import com.google.android.apps.mytracks.Constants; - import android.os.Environment; import java.io.File; @@ -25,7 +23,7 @@ import junit.framework.TestCase; /** * Tests for {@link FileUtils}. - * + * * @author Rodrigo Damazio */ public class FileUtilsTest extends TestCase { @@ -35,7 +33,7 @@ public class FileUtilsTest extends TestCase { */ public void testBuildExternalDirectoryPath() { String expectedName = Environment.getExternalStorageDirectory() + File.separator - + Constants.SDCARD_TOP_DIR + File.separator + "a" + File.separator + "b" + File.separator + + FileUtils.SDCARD_TOP_DIR + File.separator + "a" + File.separator + "b" + File.separator + "c"; String dirName = FileUtils.buildExternalDirectoryPath("a", "b", "c"); assertEquals(expectedName, dirName);