aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/connector
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/cgeo/geocaching/connector')
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java1
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java2
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCParserTest.java20
-rw-r--r--tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java123
-rw-r--r--tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java7
5 files changed, 26 insertions, 127 deletions
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
index a001f1d..94cc067 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
@@ -82,4 +82,3 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/GC12ABC"));
}
}
-
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
index 8298ad7..4458789 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java
@@ -10,7 +10,7 @@ public class GCConstantsTest extends AndroidTestCase {
// adapt the following after downloading new mock html files
public static final String MOCK_LOGIN_NAME = "JoSaMaJa";
- public static final int MOCK_CACHES_FOUND = 419;
+ public static final int MOCK_CACHES_FOUND = 426;
public static void testLocation() {
// GC37GFJ
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
index cf1df46..db064b8 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 {
@@ -94,7 +96,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
/**
* Test {@link cgBase#parseCacheFromText(String, int, CancellableHandler)} with "mocked" data
- *
+ *
*/
@MediumTest
public static void testParseCacheFromTextWithMockedData() {
@@ -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
deleted file mode 100644
index 2e4855f..0000000
--- a/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package cgeo.geocaching.connector.oc;
-
-import cgeo.CGeoTestCase;
-import cgeo.geocaching.Geocache;
-import cgeo.geocaching.Settings;
-import cgeo.geocaching.enumerations.CacheType;
-
-import org.apache.commons.lang3.StringUtils;
-
-import android.text.Html;
-
-import java.util.Collection;
-
-public class OCXMLTest extends CGeoTestCase {
-
- public static void testOCGetCache() {
- final String geoCode = "OCDE76";
-
- final Geocache cache = OCXMLClient.getCache(geoCode);
- assertNotNull(cache);
- assertEquals(geoCode, cache.getGeocode());
- assertEquals("Gitarrenspielplatz", cache.getName());
- assertEquals(CacheType.TRADITIONAL, cache.getType());
- assertEquals(2.0, cache.getDifficulty(), 0.1);
- assertEquals(2.0, cache.getTerrain(), 0.1);
- }
-
- public static void testOCLogAttendedAsFound() {
-
- final String oldOCName = Settings.getOCConnectorUserName();
- try {
- Settings.setOCConnectorUserName("ra_sch");
- final String geoCode = "OCD541";
- final Geocache cache = OCXMLClient.getCache(geoCode);
- assertNotNull(cache);
-
- assertTrue(cache.isFound());
- } finally {
- Settings.setOCConnectorUserName(oldOCName);
- }
- }
-
- public static void testOCOwner() {
- final String oldOCName = Settings.getOCConnectorUserName();
- try {
- Settings.setOCConnectorUserName("andi12.2");
- final String geoCode = "OCC9BE";
- final Geocache cache = OCXMLClient.getCache(geoCode);
- assertNotNull(cache);
-
- assertTrue(cache.isOwner());
- assertEquals("180571", cache.getOwnerUserId());
- } finally {
- Settings.setOCConnectorUserName(oldOCName);
- }
- }
-
- public static void testOC0537Description() {
- final String geoCode = "OC0537";
- final Geocache cache = OCXMLClient.getCache(geoCode);
- assertNotNull(cache);
-
- assertFalse(cache.getDescription().length() < 100);
- }
-
- public static void testNoArchivedInNearby() {
-
- final boolean oldExcludeDisabled = Settings.isExcludeDisabledCaches();
- final boolean oldExcludeMine = Settings.isExcludeMyCaches();
- try {
- Settings.setExcludeDisabledCaches(false);
- Settings.setExcludeMine(false);
- // get an archived cache
- final Geocache cache = OCXMLClient.getCache("OCD541");
- assertNotNull(cache);
- assertTrue(cache.isArchived());
- // Get nearby for this cache
- final Collection<Geocache> caches = OCXMLClient.getCachesAround(cache.getCoords(), 0.5);
- // Should not be in the result!
- assertFalse(caches.contains(cache));
- } finally {
- Settings.setExcludeDisabledCaches(oldExcludeDisabled);
- Settings.setExcludeMine(oldExcludeMine);
- }
- }
-
- public static void testFetchTwiceDuplicatesDescription() {
- final String geoCode = "OCEFBA";
- final String description = "Bei dem Cache kannst du einen kleinen Schatz bergen. Bitte lege aber einen ander Schatz in das Döschen. Achtung vor Automuggels.";
-
- deleteCacheFromDB(geoCode);
- Geocache cache = OCXMLClient.getCache(geoCode);
- assertNotNull(cache);
- try {
- assertEquals(geoCode, cache.getGeocode());
- // ignore copyright as the date part will change all the time
- assertEquals(description, removeCopyrightAndTags(cache.getDescription()));
- cache.store(null);
-
- // reload, make sure description is not duplicated
- cache = OCXMLClient.getCache(geoCode);
- assertNotNull(cache);
- assertEquals(description, removeCopyrightAndTags(cache.getDescription()));
- } finally {
- deleteCacheFromDB(geoCode);
- }
- }
-
- private static String removeCopyrightAndTags(String input) {
- return Html.fromHtml(StringUtils.substringBefore(input, "&copy")).toString().trim();
- }
-
- 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>"));
- }
-}
diff --git a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java
index 690cd4c..50bf22a 100644
--- a/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java
+++ b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java
@@ -3,7 +3,6 @@ package cgeo.geocaching.connector.oc;
import cgeo.CGeoTestCase;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.cgData;
-import cgeo.geocaching.connector.oc.OkapiClient;
import cgeo.geocaching.enumerations.LoadFlags;
public class OkapiClientTest extends CGeoTestCase {
@@ -23,4 +22,10 @@ public class OkapiClientTest extends CGeoTestCase {
assertTrue(cache.isDetailed());
}
+ public static void testOCSearchMustWorkWithoutOAuthAccessTokens() {
+ final String geoCode = "OC1234";
+ Geocache cache = OkapiClient.getCache(geoCode);
+ assertNotNull(cache);
+ assertEquals("Wupper-Schein", cache.getName());
+ }
}