diff options
| author | rsudev <rasch@munin-soft.de> | 2013-07-28 12:19:55 +0200 |
|---|---|---|
| committer | rsudev <rasch@munin-soft.de> | 2013-07-28 13:18:53 +0200 |
| commit | 45e1a1e7a5d4e2964a4ebd229980d2b40cbe4ddd (patch) | |
| tree | 8f94cb07c616be5b30f6dafc06f0abcfa4458b0f /tests/src/cgeo/geocaching/GeocacheTest.java | |
| parent | f86fa7a33393cd4ce2c7eff72479775b37dfeff3 (diff) | |
| download | cgeo-45e1a1e7a5d4e2964a4ebd229980d2b40cbe4ddd.zip cgeo-45e1a1e7a5d4e2964a4ebd229980d2b40cbe4ddd.tar.gz cgeo-45e1a1e7a5d4e2964a4ebd229980d2b40cbe4ddd.tar.bz2 | |
Create cache merging tests
Diffstat (limited to 'tests/src/cgeo/geocaching/GeocacheTest.java')
| -rw-r--r-- | tests/src/cgeo/geocaching/GeocacheTest.java | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/GeocacheTest.java b/tests/src/cgeo/geocaching/GeocacheTest.java index 5431835..aa0a581 100644 --- a/tests/src/cgeo/geocaching/GeocacheTest.java +++ b/tests/src/cgeo/geocaching/GeocacheTest.java @@ -78,4 +78,139 @@ public class GeocacheTest extends AndroidTestCase { } cache.drop(new Handler()); } + + public static void testMergeDownloadedStored() { + + Geocache stored = new Geocache(); + stored.setGeocode("GC12345"); + stored.setDetailed(true); + stored.setDisabled(true); + stored.setType(CacheType.TRADITIONAL); + stored.setCoords(new Geopoint(40.0, 8.0)); + stored.setDescription("Test1"); + + Geocache download = new Geocache(); + download.setGeocode("GC12345"); + download.setDetailed(true); + download.setDisabled(false); + download.setType(CacheType.MULTI); + download.setCoords(new Geopoint(41.0, 9.0)); + download.setDescription("Test2"); + + download.gatherMissingFrom(stored); + + assertTrue("Detailed not merged correctly", download.isDetailed()); + assertFalse("Disabled not merged correctly", download.isDisabled()); + assertEquals("Type not merged correctly", CacheType.MULTI, download.getType()); + assertEquals("Longitude not merged correctly", 9.0, download.getCoords().getLongitude(), 0.1); + assertEquals("Latitude not merged correctly", 41.0, download.getCoords().getLatitude(), 0.1); + assertEquals("Description not merged correctly", "Test2", download.getDescription()); + } + + public static void testMergeLivemapStored() { + + Geocache stored = new Geocache(); + stored.setGeocode("GC12345"); + stored.setDetailed(true); + stored.setDisabled(true); + stored.setType(CacheType.TRADITIONAL); + stored.setCoords(new Geopoint(40.0, 8.0)); + + Geocache livemap = new Geocache(); + livemap.setGeocode("GC12345"); + livemap.setType(CacheType.MULTI); + livemap.setCoords(new Geopoint(41.0, 9.0)); + livemap.setZoomlevel(12); + + livemap.gatherMissingFrom(stored); + + assertTrue("Detailed not merged correctly", livemap.isDetailed()); + assertTrue("Disabled not merged correctly", livemap.isDisabled()); + assertEquals("Type not merged correctly", CacheType.TRADITIONAL, livemap.getType()); + assertEquals("Longitude not merged correctly", 8.0, livemap.getCoords().getLongitude(), 0.1); + assertEquals("Latitude not merged correctly", 40.0, livemap.getCoords().getLatitude(), 0.1); + assertEquals("Zoomlevel not merged correctly", stored.getZoomLevel(), livemap.getZoomLevel()); + } + + public static void testMergeLivemapZoomin() { + + Geocache livemapFirst = new Geocache(); + livemapFirst.setGeocode("GC12345"); + livemapFirst.setType(CacheType.TRADITIONAL); + livemapFirst.setCoords(new Geopoint(40.0, 8.0)); + livemapFirst.setZoomlevel(11); + + Geocache livemapSecond = new Geocache(); + livemapSecond.setGeocode("GC12345"); + livemapSecond.setType(CacheType.MULTI); + livemapSecond.setCoords(new Geopoint(41.0, 9.0)); + livemapSecond.setZoomlevel(12); + + livemapSecond.gatherMissingFrom(livemapFirst); + + assertEquals("Type not merged correctly", CacheType.MULTI, livemapSecond.getType()); + assertEquals("Longitude not merged correctly", 9.0, livemapSecond.getCoords().getLongitude(), 0.1); + assertEquals("Latitude not merged correctly", 41.0, livemapSecond.getCoords().getLatitude(), 0.1); + assertEquals("Zoomlevel not merged correctly", 12, livemapSecond.getZoomLevel()); + } + + public static void testMergeLivemapZoomout() { + + Geocache livemapFirst = new Geocache(); + livemapFirst.setGeocode("GC12345"); + livemapFirst.setType(CacheType.TRADITIONAL); + livemapFirst.setCoords(new Geopoint(40.0, 8.0)); + livemapFirst.setZoomlevel(12); + + Geocache livemapSecond = new Geocache(); + livemapSecond.setGeocode("GC12345"); + livemapSecond.setType(CacheType.MULTI); + livemapSecond.setCoords(new Geopoint(41.0, 9.0)); + livemapSecond.setZoomlevel(11); + + livemapSecond.gatherMissingFrom(livemapFirst); + + assertEquals("Type not merged correctly", CacheType.TRADITIONAL, livemapSecond.getType()); + assertEquals("Longitude not merged correctly", 8.0, livemapSecond.getCoords().getLongitude(), 0.1); + assertEquals("Latitude not merged correctly", 40.0, livemapSecond.getCoords().getLatitude(), 0.1); + assertEquals("Zoomlevel not merged correctly", 12, livemapSecond.getZoomLevel()); + } + + public static void testMergePopupLivemap() { + + Geocache livemap = new Geocache(); + livemap.setGeocode("GC12345"); + livemap.setCoords(new Geopoint(40.0, 8.0)); + livemap.setFound(true); + livemap.setZoomlevel(12); + + Geocache popup = new Geocache(); + popup.setGeocode("GC12345"); + popup.setType(CacheType.MULTI); + + popup.gatherMissingFrom(livemap); + + assertEquals("Type not merged correctly", CacheType.MULTI, popup.getType()); + assertEquals("Longitude not merged correctly", 8.0, popup.getCoords().getLongitude(), 0.1); + assertEquals("Latitude not merged correctly", 40.0, popup.getCoords().getLatitude(), 0.1); + assertTrue("Found not merged correctly", popup.isFound()); + assertEquals("Zoomlevel not merged correctly", 12, popup.getZoomLevel()); + } + + public static void testMergeLivemapBMSearched() { + + Geocache bmsearched = new Geocache(); + bmsearched.setGeocode("GC12345"); + + Geocache livemap = new Geocache(); + livemap.setGeocode("GC12345"); + livemap.setCoords(new Geopoint(40.0, 8.0)); + livemap.setZoomlevel(12); + + livemap.gatherMissingFrom(bmsearched); + + assertEquals("Longitude not merged correctly", 8.0, livemap.getCoords().getLongitude(), 0.1); + assertEquals("Latitude not merged correctly", 40.0, livemap.getCoords().getLatitude(), 0.1); + assertEquals("Zoomlevel not merged correctly", 12, livemap.getZoomLevel()); + } } |
