diff options
| author | Portree-Kid <keith.paterson@gmx.de> | 2013-03-08 15:51:14 +0100 |
|---|---|---|
| committer | Portree-Kid <keith.paterson@gmx.de> | 2013-03-08 15:51:14 +0100 |
| commit | c80b90edad7c3721e349b4db3d6c5aa21a6c7a12 (patch) | |
| tree | 7af952f09a1e4d00c7f77cb1936a86bc81b6ef52 /tests | |
| parent | a0932683fdf840fd97464e93a4597fac5c93a731 (diff) | |
| parent | ea4e5bbbe197384fe276f85ae11856b0344af02c (diff) | |
| download | cgeo-c80b90edad7c3721e349b4db3d6c5aa21a6c7a12.zip cgeo-c80b90edad7c3721e349b4db3d6c5aa21a6c7a12.tar.gz cgeo-c80b90edad7c3721e349b4db3d6c5aa21a6c7a12.tar.bz2 | |
Merge remote-tracking branch 'upstream/master' into master-master
Conflicts:
main/src/cgeo/geocaching/cgeocaches.java
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/src/cgeo/CGeoTestCase.java | 7 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/cgeoApplicationTest.java | 5 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java (renamed from tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java) | 44 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java (renamed from tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java) | 2 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/test/mock/GC1ZXX2.html | 7 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/test/mock/GC2CJPF.html | 7 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/test/mock/GC2JVEH.html | 7 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/test/mock/GC3XX5J.html | 7 |
8 files changed, 58 insertions, 28 deletions
diff --git a/tests/src/cgeo/CGeoTestCase.java b/tests/src/cgeo/CGeoTestCase.java index 31fde34..6a63cbc 100644 --- a/tests/src/cgeo/CGeoTestCase.java +++ b/tests/src/cgeo/CGeoTestCase.java @@ -1,6 +1,8 @@ package cgeo; +import cgeo.geocaching.cgData; import cgeo.geocaching.cgeoapplication; +import cgeo.geocaching.enumerations.LoadFlags; import android.test.ApplicationTestCase; @@ -16,4 +18,9 @@ public abstract class CGeoTestCase extends ApplicationTestCase<cgeoapplication> createApplication(); } + /** Remove cache from DB and cache to ensure that the cache is not loaded from the database */ + protected static void deleteCacheFromDB(String geocode) { + cgData.removeCache(geocode, LoadFlags.REMOVE_ALL); + } + } diff --git a/tests/src/cgeo/geocaching/cgeoApplicationTest.java b/tests/src/cgeo/geocaching/cgeoApplicationTest.java index 73591ed..a877660 100644 --- a/tests/src/cgeo/geocaching/cgeoApplicationTest.java +++ b/tests/src/cgeo/geocaching/cgeoApplicationTest.java @@ -405,11 +405,6 @@ public class cgeoApplicationTest extends CGeoTestCase { } /** Remove cache from DB and cache to ensure that the cache is not loaded from the database */ - private static void deleteCacheFromDB(String geocode) { - cgData.removeCache(geocode, LoadFlags.REMOVE_ALL); - } - - /** Remove cache from DB and cache to ensure that the cache is not loaded from the database */ private static void deleteCacheFromDBAndLogout(String geocode) { deleteCacheFromDB(geocode); diff --git a/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java b/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java index ca2e302..b12823a 100644 --- a/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java +++ b/tests/src/cgeo/geocaching/connector/oc/OCXMLTest.java @@ -1,9 +1,8 @@ -package cgeo.geocaching.connector.opencaching; +package cgeo.geocaching.connector.oc; import cgeo.CGeoTestCase; import cgeo.geocaching.Geocache; import cgeo.geocaching.Settings; -import cgeo.geocaching.connector.oc.OCXMLClient; import cgeo.geocaching.enumerations.CacheType; import java.util.Collection; @@ -80,4 +79,45 @@ public class OCXMLTest extends CGeoTestCase { 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()); + assertEquals(description, cache.getDescription()); + cache.store(null); + + // reload, make sure description is not duplicated + cache = OCXMLClient.getCache(geoCode); + assertNotNull(cache); + assertEquals(description, cache.getDescription()); + } finally { + deleteCacheFromDB(geoCode); + } + } + + public static void testRemoveMarkupCache() { + 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."; + + Geocache cache = OCXMLClient.getCache(geoCode); + assertNotNull(cache); + assertEquals(description, cache.getDescription()); + } + + 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/opencaching/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java index 9173c6a..690cd4c 100644 --- a/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java +++ b/tests/src/cgeo/geocaching/connector/oc/OkapiClientTest.java @@ -1,4 +1,4 @@ -package cgeo.geocaching.connector.opencaching; +package cgeo.geocaching.connector.oc; import cgeo.CGeoTestCase; import cgeo.geocaching.Geocache; diff --git a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.html b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.html index 33364ef..69eb0a1 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.html +++ b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.html @@ -1050,11 +1050,8 @@ Man weiß hier Bescheid. Dieser Cache ist rund um die Uhr zu finden, ohne ein Ge </p>
<ul class="NoPrint">
<li>
- ...other caches
- <a id="ctl00_ContentBody_uxFindLinksHiddenByThisUser" href="/seek/nearest.aspx?u=daniel354">hidden</a>
- or
- <a id="ctl00_ContentBody_uxFindLinksFoundByThisUser" href="/seek/nearest.aspx?ul=daniel354">found</a>
- by this user
+
+ ...other caches <a href="/seek/nearest.aspx?u=daniel354">hidden</a> or <a href="/seek/nearest.aspx?ul=daniel354">found</a> by this user
</li>
<li>
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html index b06215d..bfa932f 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html +++ b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.html @@ -1394,11 +1394,8 @@ P.S. An warmen Tagen Badesachen und Handtuch mitnehmen.</span> </p>
<ul class="NoPrint">
<li>
- ...other caches
- <a id="ctl00_ContentBody_uxFindLinksHiddenByThisUser" href="/seek/nearest.aspx?u=Tom03">hidden</a>
- or
- <a id="ctl00_ContentBody_uxFindLinksFoundByThisUser" href="/seek/nearest.aspx?ul=Tom03">found</a>
- by this user
+
+ ...other caches <a href="/seek/nearest.aspx?u=Tom03">hidden</a> or <a href="/seek/nearest.aspx?ul=Tom03">found</a> by this user
</li>
<li>
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.html b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.html index 9e1a44f..8b974b5 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.html +++ b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.html @@ -1062,11 +1062,8 @@ Sys.WebForms.PageRequestManager._initialize('ctl00$uxMainScriptManager', 'aspnet </p>
<ul class="NoPrint">
<li>
- ...other caches
- <a id="ctl00_ContentBody_uxFindLinksHiddenByThisUser" href="/seek/nearest.aspx?u=indianerjones">hidden</a>
- or
- <a id="ctl00_ContentBody_uxFindLinksFoundByThisUser" href="/seek/nearest.aspx?ul=indianerjones">found</a>
- by this user
+
+ ...other caches <a href="/seek/nearest.aspx?u=indianerjones">hidden</a> or <a href="/seek/nearest.aspx?ul=indianerjones">found</a> by this user
</li>
<li>
diff --git a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html index c4740f0..30bb9ac 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html +++ b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.html @@ -943,11 +943,8 @@ PRINESI SVOJE PISALO / BRING YOUR OWN PEN<br /></span> </p> <ul class="NoPrint"> <li> - ...other caches - <a id="ctl00_ContentBody_uxFindLinksHiddenByThisUser" href="/seek/nearest.aspx?u=David+%26+Ajda">hidden</a> - or - <a id="ctl00_ContentBody_uxFindLinksFoundByThisUser" href="/seek/nearest.aspx?ul=David+%26+Ajda">found</a> - by this user + + ...other caches <a href="/seek/nearest.aspx?u=David+%26+Ajda">hidden</a> or <a href="/seek/nearest.aspx?ul=David+%26+Ajda">found</a> by this user </li> <li> |
