diff options
Diffstat (limited to 'tests/src')
8 files changed, 78 insertions, 12 deletions
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java index cf1df46..ff7ddff 100644 --- a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java @@ -7,6 +7,7 @@ import cgeo.geocaching.Settings; import cgeo.geocaching.Waypoint; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.enumerations.StatusCode; +import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase; import cgeo.geocaching.test.R; @@ -22,6 +23,7 @@ import android.os.Handler; import android.test.suitebuilder.annotation.MediumTest; import java.util.ArrayList; +import java.util.List; public class GCParserTest extends AbstractResourceInstrumentationTestCase { @@ -187,6 +189,22 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { assertEquals(13, cache.getWaypoints().size()); } + public static void testNoteParsingWaypointTypes() { + final Geocache cache = new Geocache(); + cache.setWaypoints(new ArrayList<Waypoint>(), false); + cache.setPersonalNote("\"Parking area at PARKING=N 50° 40.666E 006° 58.222\n" + + "My calculated final coordinates: FINAL=N 50° 40.777E 006° 58.111\n" + + "Get some ice cream at N 50° 40.555E 006° 58.000\""); + + cache.parseWaypointsFromNote(); + final List<Waypoint> waypoints = cache.getWaypoints(); + + assertEquals(3, waypoints.size()); + assertEquals(WaypointType.PARKING, waypoints.get(0).getWaypointType()); + assertEquals(WaypointType.FINAL, waypoints.get(1).getWaypointType()); + assertEquals(WaypointType.WAYPOINT, waypoints.get(2).getWaypointType()); + } + private Geocache parseCache(int resourceId) { final String page = getFileContent(resourceId); final SearchResult result = GCParser.parseCacheFromText(page, null); diff --git a/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java b/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java index b12823a..3563991 100644 --- a/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java +++ b/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java @@ -111,13 +111,13 @@ public class OCXMLTest extends CGeoTestCase { } public static void testRemoveMarkup() { - assertEquals("", OC11XMLParser.stripMarkup("")); - assertEquals("Test", OC11XMLParser.stripMarkup("Test")); - assertEquals("<b>bold and others not removed</b>", OC11XMLParser.stripMarkup("<b>bold and others not removed</b>")); - assertEquals("unnecessary paragraph", OC11XMLParser.stripMarkup("<p>unnecessary paragraph</p>")); - assertEquals("unnecessary span", OC11XMLParser.stripMarkup("<span>unnecessary span</span>")); - assertEquals("nested", OC11XMLParser.stripMarkup("<span><span>nested</span></span>")); - assertEquals("mixed", OC11XMLParser.stripMarkup("<span> <p> mixed </p> </span>")); - assertEquals("<p>not</p><p>removable</p>", OC11XMLParser.stripMarkup("<p>not</p><p>removable</p>")); + assertEquals("", OC11XMLParser.stripEmptyText("")); + assertEquals("Test", OC11XMLParser.stripEmptyText("Test")); + assertEquals("<b>bold and others not removed</b>", OC11XMLParser.stripEmptyText("<b>bold and others not removed</b>")); + assertEquals("unnecessary paragraph", OC11XMLParser.stripEmptyText("<p>unnecessary paragraph</p>")); + assertEquals("unnecessary span", OC11XMLParser.stripEmptyText("<span>unnecessary span</span>")); + assertEquals("nested", OC11XMLParser.stripEmptyText("<span><span>nested</span></span>")); + assertEquals("mixed", OC11XMLParser.stripEmptyText("<span> <p> mixed </p> </span>")); + assertEquals("<p>not</p><p>removable</p>", OC11XMLParser.stripEmptyText("<p>not</p><p>removable</p>")); } } diff --git a/tests/src/cgeo/geocaching/filter/DifficultyFilterTest.java b/tests/src/cgeo/geocaching/filter/DifficultyFilterTest.java index b3ff056..ebe4cf6 100644 --- a/tests/src/cgeo/geocaching/filter/DifficultyFilterTest.java +++ b/tests/src/cgeo/geocaching/filter/DifficultyFilterTest.java @@ -19,6 +19,6 @@ public class DifficultyFilterTest extends CGeoTestCase { } public static void testAllFilters() { - assertTrue(new DifficultyFilter.Factory().getFilters().length == 5); // difficulty ranges from 1 to 5 + assertTrue(new DifficultyFilter.Factory().getFilters().size() == 5); // difficulty ranges from 1 to 5 } } diff --git a/tests/src/cgeo/geocaching/filter/SizeFilterTest.java b/tests/src/cgeo/geocaching/filter/SizeFilterTest.java index 2c6552b..8b909f3 100644 --- a/tests/src/cgeo/geocaching/filter/SizeFilterTest.java +++ b/tests/src/cgeo/geocaching/filter/SizeFilterTest.java @@ -33,7 +33,7 @@ public class SizeFilterTest extends CGeoTestCase { public static void testGetAllFilters() { final int expectedSizes = CacheSize.values().length - 1; // hide "UNKNOWN" - assertEquals(expectedSizes, new SizeFilter.Factory().getFilters().length); + assertEquals(expectedSizes, new SizeFilter.Factory().getFilters().size()); } public void testFilter() { diff --git a/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java b/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java index d64f4d9..234af7e 100644 --- a/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java +++ b/tests/src/cgeo/geocaching/filter/TerrainFilterTest.java @@ -19,6 +19,6 @@ public class TerrainFilterTest extends CGeoTestCase { } public static void testAllFilters() { - assertTrue(new TerrainFilter.Factory().getFilters().length == 5); // terrain ranges from 1 to 5 + assertTrue(new TerrainFilter.Factory().getFilters().size() == 5); // terrain ranges from 1 to 5 } } diff --git a/tests/src/cgeo/geocaching/filter/TypeFilterTest.java b/tests/src/cgeo/geocaching/filter/TypeFilterTest.java index 3a43b33..e813052 100644 --- a/tests/src/cgeo/geocaching/filter/TypeFilterTest.java +++ b/tests/src/cgeo/geocaching/filter/TypeFilterTest.java @@ -46,7 +46,7 @@ public class TypeFilterTest extends CGeoTestCase { public static void testGetAllFilters() { final int expectedEntries = CacheType.values().length - 1; // hide "all" - assertEquals(expectedEntries, new TypeFilter.Factory().getFilters().length); + assertEquals(expectedEntries, new TypeFilter.Factory().getFilters().size()); } } diff --git a/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java b/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java index c0cea01..a1be25d 100644 --- a/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java +++ b/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java @@ -6,6 +6,17 @@ import android.test.AndroidTestCase; public class GeoPointFormatterTest extends AndroidTestCase { + public static void testConfluence() { + // From issue #2624: coordinate is wrong near to a confluence point + final Geopoint point = new Geopoint(49.9999999999999, 5.0); + final String format = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECDEGREE_COMMA, point); + assertEquals("50.000000,5.000000", format); + final String formatMinute = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECMINUTE_RAW, point); + assertEquals("N 50° 00.000 E 005° 00.000", formatMinute); + final String formatSecond = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECSECOND, point).replaceAll(",", "."); + assertEquals(formatSecond, "N 50° 00' 00.000\"" + Formatter.SEPARATOR + "E 005° 00' 00.000\"", formatSecond); + } + public static void testFormat() { // taken from GC30R6G final Geopoint point = new Geopoint("N 51° 21.104 E 010° 15.369"); diff --git a/tests/src/cgeo/geocaching/twitter/TwitterTest.java b/tests/src/cgeo/geocaching/twitter/TwitterTest.java new file mode 100644 index 0000000..a27e57a --- /dev/null +++ b/tests/src/cgeo/geocaching/twitter/TwitterTest.java @@ -0,0 +1,37 @@ +package cgeo.geocaching.twitter; + +import cgeo.geocaching.Geocache; +import cgeo.geocaching.Settings; +import cgeo.geocaching.Trackable; + +import junit.framework.TestCase; + +public class TwitterTest extends TestCase { + + public static void testTrackableMessage() { + Trackable tb = new Trackable(); + tb.setName("Travel bug"); + tb.setGeocode("TB1234"); + assertEquals("I touched Travel bug (http://www.geocaching.com//track/details.aspx?tracker=TB1234)! #cgeo #geocaching", Twitter.getStatusMessage(tb)); + } + + public static void testCacheMessage() { + Geocache cache = new Geocache(); + cache.setGeocode("GC1234"); + cache.setName("TwitterTest"); + assertEquals("I found TwitterTest (http://coord.info/GC1234) #cgeo #geocaching", Twitter.getStatusMessage(cache)); + } + + public static void testAvoidDuplicateTags() { + String oldMessage = Settings.getCacheTwitterMessage(); + try { + Geocache cache = new Geocache(); + cache.setGeocode("GC1234"); + cache.setName("TwitterTest"); + Settings.setCacheTwitterMessage("[NAME] #cgeo"); + assertEquals("TwitterTest #cgeo #geocaching", Twitter.getStatusMessage(cache)); + } finally { + Settings.setCacheTwitterMessage(oldMessage); + } + } +} |
