diff options
| author | Marco Jacob <mjacob@union06.de> | 2013-03-09 20:07:33 +0100 |
|---|---|---|
| committer | Marco Jacob <mjacob@union06.de> | 2013-03-09 20:07:33 +0100 |
| commit | 950921d1c15efbcb7e5e87d3944c237cae8938ab (patch) | |
| tree | 166f229d37b67497a537319aae9a861c5fd462cb /tests/src/cgeo/geocaching/StaticMapsProviderTest.java | |
| parent | 42150c02e5da6461fa5bd10386b2bbca6868c558 (diff) | |
| download | cgeo-950921d1c15efbcb7e5e87d3944c237cae8938ab.zip cgeo-950921d1c15efbcb7e5e87d3944c237cae8938ab.tar.gz cgeo-950921d1c15efbcb7e5e87d3944c237cae8938ab.tar.bz2 | |
adding StaticMapsProviderTest
Diffstat (limited to 'tests/src/cgeo/geocaching/StaticMapsProviderTest.java')
| -rw-r--r-- | tests/src/cgeo/geocaching/StaticMapsProviderTest.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/StaticMapsProviderTest.java b/tests/src/cgeo/geocaching/StaticMapsProviderTest.java new file mode 100644 index 0000000..be3520d --- /dev/null +++ b/tests/src/cgeo/geocaching/StaticMapsProviderTest.java @@ -0,0 +1,62 @@ +package cgeo.geocaching; + +import cgeo.geocaching.enumerations.WaypointType; +import cgeo.geocaching.files.LocalStorage; +import cgeo.geocaching.geopoint.Geopoint; + +import java.io.File; + +import junit.framework.TestCase; + +public class StaticMapsProviderTest extends TestCase { + + public static void testDownloadStaticMaps() { + final double lat = 52.354176d; + final double lon = 9.745685d; + String geocode = "GCTEST1"; + + boolean backupStoreWP = Settings.isStoreOfflineWpMaps(); + Settings.setStoreOfflineMaps(true); + try { + Geopoint gp = new Geopoint(lat + 0.25d, lon + 0.25d); + Geocache cache = new Geocache(); + cache.setGeocode(geocode); + cache.setCoords(gp); + cache.setCacheId(String.valueOf(1)); + + Waypoint theFinal = new Waypoint("Final", WaypointType.FINAL, false); + Geopoint finalGp = new Geopoint(lat + 0.25d + 1, lon + 0.25d + 1); + theFinal.setCoords(finalGp); + theFinal.setId(1); + cache.addOrChangeWaypoint(theFinal, false); + + Waypoint trailhead = new Waypoint("Trail head", WaypointType.TRAILHEAD, false); + Geopoint trailheadGp = new Geopoint(lat + 0.25d + 2, lon + 0.25d + 2); + trailhead.setCoords(trailheadGp); + trailhead.setId(2); + cache.addOrChangeWaypoint(trailhead, false); + + StaticMapsProvider.downloadMaps(cache); + + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + fail(); + } + assertTrue(StaticMapsProvider.hasStaticMap(cache)); + assertTrue(StaticMapsProvider.hasStaticMapForWaypoint(geocode, theFinal)); + assertTrue(StaticMapsProvider.hasStaticMapForWaypoint(geocode, trailhead)); + + // waypoint static maps hashcode dependent + trailhead.setCoords(new Geopoint(lat + 0.24d + 2, lon + 0.25d + 2)); + assertFalse(StaticMapsProvider.hasStaticMapForWaypoint(geocode, trailhead)); + } finally { + Settings.setStoreOfflineWpMaps(backupStoreWP); + File cacheDir = LocalStorage.getStorageDir(geocode); + if (!cacheDir.delete()) { + cacheDir.deleteOnExit(); + } + } + } + +} |
