diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2011-11-01 22:02:31 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2011-11-01 22:02:31 +0100 |
| commit | e2be3a453815fd8519be5f12914656dd1fc29112 (patch) | |
| tree | 6b4ab398674b12e6203f52cd9ee4a1138cd4dbef /tests | |
| parent | 8579c883dbc8c1aea42483b943a1bc79b4d645d8 (diff) | |
| download | cgeo-e2be3a453815fd8519be5f12914656dd1fc29112.zip cgeo-e2be3a453815fd8519be5f12914656dd1fc29112.tar.gz cgeo-e2be3a453815fd8519be5f12914656dd1fc29112.tar.bz2 | |
new: import caches from unknown source, fixes #720
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/res/raw/no_connector.gpx | 168 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/files/GPXParserTest.java | 26 |
2 files changed, 188 insertions, 6 deletions
diff --git a/tests/res/raw/no_connector.gpx b/tests/res/raw/no_connector.gpx new file mode 100644 index 0000000..76799e3 --- /dev/null +++ b/tests/res/raw/no_connector.gpx @@ -0,0 +1,168 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="EasyGPS 4.29" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.topografix.com/GPX/gpx_overlay/0/3 http://www.topografix.com/GPX/gpx_overlay/0/3/gpx_overlay.xsd http://www.topografix.com/GPX/gpx_modified/0/1 http://www.topografix.com/GPX/gpx_modified/0/1/gpx_modified.xsd">
+<metadata>
+<bounds minlat="33.23580184" minlon="-83.95870466" maxlat="33.24745160" maxlon="-83.94473756"/>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:25:07.006Z</time>
+</extensions>
+</metadata>
+<wpt lat="33.24308329" lon="-83.94859994">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>12</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:23:30.512Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>12</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.24391662" lon="-83.94701660">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>14</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:23:45.154Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>14</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.23580184" lon="-83.95303782">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>22</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:23:45.154Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>22</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.23861850" lon="-83.94748766">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>24</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:23:45.154Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>24</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.24745160" lon="-83.95662125">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>32</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:23:45.154Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>32</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.24496662" lon="-83.95683331">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>34</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:24:25.797Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>34</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.24423328" lon="-83.94773333">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>42</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:23:45.154Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>42</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.24543332" lon="-83.94983333">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>44</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:23:45.154Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>44</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.24029999" lon="-83.94995001">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>MAIN</name>
+<cmt>10TH ANNUAL GGA GEO-CHALLENGE</cmt>
+<sym>Campground</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:25:07.006Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>MAIN</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.23896844" lon="-83.94473756">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>WILD-1</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:23:45.154Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>WILD-1</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.23768517" lon="-83.94800432">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>WILD-2</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:23:45.154Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>WILD-2</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.24701825" lon="-83.95870466">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>WILD-3</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:23:45.154Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>WILD-3</label_text>
+</label>
+</extensions>
+</wpt>
+<wpt lat="33.24601829" lon="-83.94810431">
+<time>2011-10-09T14:22:22.212Z</time>
+<name>WILD-4</name>
+<sym>Geocache</sym>
+<type>Geocache Found</type>
+<extensions>
+<time xmlns="http://www.topografix.com/GPX/gpx_modified/0/1">2011-10-09T14:24:25.797Z</time>
+<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3">
+<label_text>WILD-4</label_text>
+</label>
+</extensions>
+</wpt>
+<extensions>
+</extensions>
+</gpx>
diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java index c3e253a..d063dee 100644 --- a/tests/src/cgeo/geocaching/files/GPXParserTest.java +++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java @@ -30,7 +30,7 @@ public class GPXParserTest extends InstrumentationTestCase { } private cgCache testGPXVersion(final int resourceId) throws IOException, ParserException { - final List<cgCache> caches = readGPX(resourceId); + final List<cgCache> caches = readGPX10(resourceId); assertNotNull(caches); assertEquals(1, caches.size()); final cgCache cache = caches.get(0); @@ -57,7 +57,7 @@ public class GPXParserTest extends InstrumentationTestCase { } public void testOC() throws IOException, ParserException { - final List<cgCache> caches = readGPX(R.raw.oc5952_gpx); + final List<cgCache> caches = readGPX10(R.raw.oc5952_gpx); final cgCache cache = caches.get(0); assertEquals("OC5952", cache.getGeocode()); assertEquals(CacheType.TRADITIONAL.id, cache.getType()); @@ -74,7 +74,7 @@ public class GPXParserTest extends InstrumentationTestCase { } public void testGc31j2h() throws IOException, ParserException { - final List<cgCache> caches = readGPX(R.raw.gc31j2h); + final List<cgCache> caches = readGPX10(R.raw.gc31j2h); assertEquals(1, caches.size()); final cgCache cache = caches.get(0); @@ -86,7 +86,7 @@ public class GPXParserTest extends InstrumentationTestCase { } public void testGc31j2hWpts() throws IOException, ParserException { - List<cgCache> caches = readGPX(R.raw.gc31j2h, R.raw.gc31j2h_wpts); + List<cgCache> caches = readGPX10(R.raw.gc31j2h, R.raw.gc31j2h_wpts); assertEquals(1, caches.size()); cgCache cache = caches.get(0); assertGc31j2h(cache); @@ -94,7 +94,7 @@ public class GPXParserTest extends InstrumentationTestCase { } public void testGc31j2hWptsWithoutCache() throws IOException, ParserException { - final List<cgCache> caches = readGPX(R.raw.gc31j2h_wpts); + final List<cgCache> caches = readGPX10(R.raw.gc31j2h_wpts); assertEquals(0, caches.size()); } @@ -174,8 +174,17 @@ public class GPXParserTest extends InstrumentationTestCase { assertEquals(8.545100, wp.getCoords().getLongitude(), 0.000001); } - private List<cgCache> readGPX(int... resourceIds) throws IOException, ParserException { + private List<cgCache> readGPX10(int... resourceIds) throws IOException, ParserException { final GPX10Parser parser = new GPX10Parser(1); + return readVersionedGPX(parser, resourceIds); + } + + private List<cgCache> readGPX11(int... resourceIds) throws IOException, ParserException { + final GPX11Parser parser = new GPX11Parser(1); + return readVersionedGPX(parser, resourceIds); + } + + private List<cgCache> readVersionedGPX(final GPXParser parser, int... resourceIds) throws IOException, ParserException { Collection<cgCache> caches = null; for (int resourceId : resourceIds) { final Resources res = getInstrumentation().getContext().getResources(); @@ -203,4 +212,9 @@ public class GPXParserTest extends InstrumentationTestCase { e.printStackTrace(); } } + + public void testSelfmadeGPXWithoutGeocodes() throws Exception { + final List<cgCache> caches = readGPX11(R.raw.no_connector); + assertEquals(13, caches.size()); + } } |
