diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/content/DescriptionGeneratorImplTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/content/DescriptionGeneratorImplTest.java
index a44519b0c..019ac51e1 100644
--- a/MyTracksTest/src/com/google/android/apps/mytracks/content/DescriptionGeneratorImplTest.java
+++ b/MyTracksTest/src/com/google/android/apps/mytracks/content/DescriptionGeneratorImplTest.java
@@ -17,6 +17,7 @@
package com.google.android.apps.mytracks.content;
import com.google.android.apps.mytracks.stats.TripStatistics;
+import com.google.android.apps.mytracks.util.StringUtils;
import com.google.android.maps.mytracks.R;
import android.test.AndroidTestCase;
@@ -29,6 +30,7 @@ import android.util.Pair;
*/
public class DescriptionGeneratorImplTest extends AndroidTestCase {
+ private static final long START_TIME = 1288721514000L;
private DescriptionGeneratorImpl descriptionGenerator;
@Override
@@ -52,7 +54,7 @@ public class DescriptionGeneratorImplTest extends AndroidTestCase {
stats.setTotalElevationGain(6000);
stats.setMaxGrade(0.42);
stats.setMinGrade(0.11);
- stats.setStartTime(1288721514000L);
+ stats.setStartTime(START_TIME);
track.setStatistics(stats);
track.setCategory("hiking");
String expected = "Created by"
@@ -71,7 +73,7 @@ public class DescriptionGeneratorImplTest extends AndroidTestCase {
+ "Elevation gain: 6000 m (19685 ft)
"
+ "Max grade: 42 %
"
+ "Min grade: 11 %
"
- + "Recorded: 11/2/2010 11:11 AM
"
+ + "Recorded: " + StringUtils.formatDateTime(getContext(), START_TIME) + "
"
+ "Activity type: hiking
";
assertEquals(expected, descriptionGenerator.generateTrackDescription(track, null, null));
}
@@ -91,7 +93,7 @@ public class DescriptionGeneratorImplTest extends AndroidTestCase {
stats.setTotalElevationGain(6000);
stats.setMaxGrade(0.42);
stats.setMinGrade(0.11);
- stats.setStartTime(1288721514000L);
+ stats.setStartTime(START_TIME);
waypoint.setStatistics(stats);
String expected = "Total distance: 20.00 km (12.4 mi)\n"
+ "Total time: 10:00\n"
@@ -107,7 +109,7 @@ public class DescriptionGeneratorImplTest extends AndroidTestCase {
+ "Elevation gain: 6000 m (19685 ft)\n"
+ "Max grade: 42 %\n"
+ "Min grade: 11 %\n"
- + "Recorded: 11/2/2010 11:11 AM\n";
+ + "Recorded: " + StringUtils.formatDateTime(getContext(), START_TIME) + "\n";
assertEquals(expected, descriptionGenerator.generateWaypointDescription(waypoint));
}
diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/util/StringUtilsTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/util/StringUtilsTest.java
index cb698913c..074a4ca01 100644
--- a/MyTracksTest/src/com/google/android/apps/mytracks/util/StringUtilsTest.java
+++ b/MyTracksTest/src/com/google/android/apps/mytracks/util/StringUtilsTest.java
@@ -13,9 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
+
package com.google.android.apps.mytracks.util;
import android.test.AndroidTestCase;
+import android.text.format.DateFormat;
import java.util.GregorianCalendar;
import java.util.TimeZone;
@@ -31,22 +33,19 @@ public class StringUtilsTest extends AndroidTestCase {
* Tests {@link StringUtils#formatDateTime(android.content.Context, long)}.
*/
public void testFormatTime() {
- // Unix time 0 in UTC is "4:00 PM" in Pacific Standard time zone.
- // This test can break if run on a different time zone or with a different
- // time format preference.
- assertEquals("4:00 PM", StringUtils.formatTime(getContext(), 0L));
+ assertEquals(DateFormat.getTimeFormat(getContext()).format(0L),
+ StringUtils.formatTime(getContext(), 0L));
}
/**
* Tests {@link StringUtils#formatDateTime(android.content.Context, long)}.
*/
public void testFormatDateTime() {
- // Unix time 0 in UTC is "12/31/1969 4:00 PM" in Pacific Standard time zone.
- // This test can break if run on a different time zone or with a different
- // date/time format preference.
- assertEquals("12/31/1969 4:00 PM", StringUtils.formatDateTime(getContext(), 0L));
+ String expected = DateFormat.getDateFormat(getContext()).format(0L) + " "
+ + DateFormat.getTimeFormat(getContext()).format(0L);
+ assertEquals(expected, StringUtils.formatDateTime(getContext(), 0L));
}
-
+
/**
* Tests {@link StringUtils#formatDateTimeIso8601(long)}.
*/