aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <Bananeweizen@gmx.de>2012-12-29 10:20:34 +0100
committerBananeweizen <Bananeweizen@gmx.de>2012-12-29 10:20:34 +0100
commit7d6c8ca06ab9c7833875fdd77bacd2471a9e5a41 (patch)
treecbb7b41a8c5b6fca0613afab43ea96317de3b360
parentf0ca3839442f1702d729e02045d536a35da874dd (diff)
downloadcgeo-7d6c8ca06ab9c7833875fdd77bacd2471a9e5a41.zip
cgeo-7d6c8ca06ab9c7833875fdd77bacd2471a9e5a41.tar.gz
cgeo-7d6c8ca06ab9c7833875fdd77bacd2471a9e5a41.tar.bz2
fix #2300: WP "Original coords" does not have a type
-rw-r--r--main/src/cgeo/geocaching/ui/Formatter.java5
-rw-r--r--tests/src/cgeo/geocaching/ui/FormatterTest.java30
2 files changed, 33 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/ui/Formatter.java b/main/src/cgeo/geocaching/ui/Formatter.java
index e006d57..ea2ecb5 100644
--- a/main/src/cgeo/geocaching/ui/Formatter.java
+++ b/main/src/cgeo/geocaching/ui/Formatter.java
@@ -153,8 +153,9 @@ public abstract class Formatter {
public static String formatWaypointInfo(cgWaypoint waypoint) {
final List<String> infos = new ArrayList<String>(3);
- if (WaypointType.ALL_TYPES_EXCEPT_OWN_AND_ORIGINAL.contains(waypoint.getWaypointType())) {
- infos.add(waypoint.getWaypointType().getL10n());
+ WaypointType waypointType = waypoint.getWaypointType();
+ if (waypointType != WaypointType.OWN && waypointType != null) {
+ infos.add(waypointType.getL10n());
}
if (cgWaypoint.PREFIX_OWN.equalsIgnoreCase(waypoint.getPrefix())) {
infos.add(cgeoapplication.getInstance().getString(R.string.waypoint_custom));
diff --git a/tests/src/cgeo/geocaching/ui/FormatterTest.java b/tests/src/cgeo/geocaching/ui/FormatterTest.java
new file mode 100644
index 0000000..8f48abb
--- /dev/null
+++ b/tests/src/cgeo/geocaching/ui/FormatterTest.java
@@ -0,0 +1,30 @@
+package cgeo.geocaching.ui;
+
+import cgeo.geocaching.R;
+import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.enumerations.WaypointType;
+
+import android.test.AndroidTestCase;
+
+public class FormatterTest extends AndroidTestCase {
+
+ public static void testParkingWaypoint() {
+ assertFormatting(new cgWaypoint("you can park here", WaypointType.PARKING, false), WaypointType.PARKING.getL10n());
+ }
+
+ public static void testOriginalWaypoint() {
+ assertFormatting(new cgWaypoint("an original", WaypointType.ORIGINAL, false), WaypointType.ORIGINAL.getL10n());
+ }
+
+ public static void testOwnWaypoint() {
+ cgWaypoint own = new cgWaypoint("my own", WaypointType.OWN, true);
+ own.setPrefix(cgWaypoint.PREFIX_OWN);
+ assertFormatting(own, cgeoapplication.getInstance().getString(R.string.waypoint_custom));
+ }
+
+ private static void assertFormatting(cgWaypoint waypoint, String expected) {
+ assertEquals(expected, Formatter.formatWaypointInfo(waypoint));
+ }
+
+}