aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/test
diff options
context:
space:
mode:
authorBananeweizen <Bananeweizen@gmx.de>2011-10-03 09:17:22 -0700
committerBananeweizen <Bananeweizen@gmx.de>2011-10-03 09:17:22 -0700
commitb8ba64294a8fb27cf7beecf46a47110f07646460 (patch)
treedaa67127501c061d18da1412e9b879da90694aae /tests/src/cgeo/geocaching/test
parentd4da5dc7e89350574821b324c468ed97af230ee5 (diff)
parent4d84217c53f5c5fb414ec8550e14307e89a5b0fd (diff)
downloadcgeo-b8ba64294a8fb27cf7beecf46a47110f07646460.zip
cgeo-b8ba64294a8fb27cf7beecf46a47110f07646460.tar.gz
cgeo-b8ba64294a8fb27cf7beecf46a47110f07646460.tar.bz2
Merge pull request #597 from stephanme/unittests
fix #587: put tests into same java package as tested class
Diffstat (limited to 'tests/src/cgeo/geocaching/test')
-rw-r--r--tests/src/cgeo/geocaching/test/CgeoTestSuite.java (renamed from tests/src/cgeo/geocaching/test/cgeoTestSuite.java)7
-rw-r--r--tests/src/cgeo/geocaching/test/CompatibilityTest.java35
-rw-r--r--tests/src/cgeo/geocaching/test/CryptUtilsTest.java15
-rw-r--r--tests/src/cgeo/geocaching/test/DistanceParserTest.java35
-rw-r--r--tests/src/cgeo/geocaching/test/GPXParserTest.java210
-rw-r--r--tests/src/cgeo/geocaching/test/GeoPointParserTest.java48
-rw-r--r--tests/src/cgeo/geocaching/test/GeopointTest.java84
-rw-r--r--tests/src/cgeo/geocaching/test/LocParserTest.java64
-rw-r--r--tests/src/cgeo/geocaching/test/SettingsTest.java27
-rw-r--r--tests/src/cgeo/geocaching/test/cgBaseTest.java16
-rw-r--r--tests/src/cgeo/geocaching/test/cgDestinationTest.java26
-rw-r--r--tests/src/cgeo/geocaching/test/cgWaypointTest.java36
-rw-r--r--tests/src/cgeo/geocaching/test/cgeoApplicationTest.java109
-rw-r--r--tests/src/cgeo/geocaching/test/cgeogpxesTest.java25
14 files changed, 4 insertions, 733 deletions
diff --git a/tests/src/cgeo/geocaching/test/cgeoTestSuite.java b/tests/src/cgeo/geocaching/test/CgeoTestSuite.java
index 31a469e..ee4ab43 100644
--- a/tests/src/cgeo/geocaching/test/cgeoTestSuite.java
+++ b/tests/src/cgeo/geocaching/test/CgeoTestSuite.java
@@ -1,8 +1,9 @@
package cgeo.geocaching.test;
+import android.test.suitebuilder.TestSuiteBuilder;
+
import junit.framework.Test;
import junit.framework.TestSuite;
-import android.test.suitebuilder.TestSuiteBuilder;
/**
* The c:geo unit test suite. Based on http://marakana.com/tutorials/android/junit-test-example.html
@@ -11,9 +12,9 @@ import android.test.suitebuilder.TestSuiteBuilder;
* For further informations have a look at http://developer.android.com/guide/topics/testing/testing_android.html
*/
-public class cgeoTestSuite extends TestSuite {
+public class CgeoTestSuite extends TestSuite {
public static Test suite() {
- return new TestSuiteBuilder(cgeoTestSuite.class).includeAllPackagesUnderHere().build();
+ return new TestSuiteBuilder(CgeoTestSuite.class).includePackages("cgeo.geocaching").build();
}
}
diff --git a/tests/src/cgeo/geocaching/test/CompatibilityTest.java b/tests/src/cgeo/geocaching/test/CompatibilityTest.java
deleted file mode 100644
index 1d5ef5c..0000000
--- a/tests/src/cgeo/geocaching/test/CompatibilityTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.cgeo;
-import cgeo.geocaching.compatibility.Compatibility;
-
-import android.test.ActivityInstrumentationTestCase2;
-
-import junit.framework.Assert;
-
-@SuppressWarnings("static-method")
-public class CompatibilityTest extends ActivityInstrumentationTestCase2<cgeo> {
-
- private cgeo activity;
-
- public CompatibilityTest() {
- super("cgeo.geocaching", cgeo.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- activity = getActivity();
- }
-
- public void testDataChanged() {
- // This should not raise an exception in any Android version
- Compatibility.dataChanged("cgeo.geocaching");
- }
-
- public void testGetDirectionNow() {
- final float angle = Compatibility.getDirectionNow(1.0f, activity);
- Assert.assertTrue(angle == 1.0f || angle == 91.0f || angle == 181.0f || angle == 271.0f);
- }
-
-}
diff --git a/tests/src/cgeo/geocaching/test/CryptUtilsTest.java b/tests/src/cgeo/geocaching/test/CryptUtilsTest.java
deleted file mode 100644
index 7966943..0000000
--- a/tests/src/cgeo/geocaching/test/CryptUtilsTest.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.utils.CryptUtils;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("static-method")
-public class CryptUtilsTest extends TestCase {
- public void testROT13() {
- assertEquals("", CryptUtils.rot13(""));
- assertEquals("", CryptUtils.rot13((String) null));
- assertEquals("Pnpur uvag", CryptUtils.rot13("Cache hint"));
- assertEquals("123", CryptUtils.rot13("123"));
- }
-}
diff --git a/tests/src/cgeo/geocaching/test/DistanceParserTest.java b/tests/src/cgeo/geocaching/test/DistanceParserTest.java
deleted file mode 100644
index 34bef7b..0000000
--- a/tests/src/cgeo/geocaching/test/DistanceParserTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.geopoint.DistanceParser;
-
-import android.test.AndroidTestCase;
-
-import junit.framework.Assert;
-
-@SuppressWarnings("static-method")
-public class DistanceParserTest extends AndroidTestCase {
-
- static private final double MM = 1e-6; // 1mm, in kilometers
-
- public void testFormats() {
- Assert.assertEquals(1.2, DistanceParser.parseDistance("1200 m", true), MM);
- Assert.assertEquals(1.2, DistanceParser.parseDistance("1.2 km", true), MM);
- Assert.assertEquals(0.36576, DistanceParser.parseDistance("1200 ft", true), MM);
- Assert.assertEquals(1.09728, DistanceParser.parseDistance("1200 yd", true), MM);
- Assert.assertEquals(1.9312128, DistanceParser.parseDistance("1.2 mi", true), MM);
- }
-
- public void testImplicit() {
- Assert.assertEquals(1.2, DistanceParser.parseDistance("1200", true), MM);
- Assert.assertEquals(0.36576, DistanceParser.parseDistance("1200", false), MM);
- }
-
- public void testComma() {
- Assert.assertEquals(1.2, DistanceParser.parseDistance("1,2km", true), MM);
- }
-
- public void testCase() {
- Assert.assertEquals(0.36576, DistanceParser.parseDistance("1200 FT", true), MM);
- }
-
-} \ No newline at end of file
diff --git a/tests/src/cgeo/geocaching/test/GPXParserTest.java b/tests/src/cgeo/geocaching/test/GPXParserTest.java
deleted file mode 100644
index c02ba30..0000000
--- a/tests/src/cgeo/geocaching/test/GPXParserTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.cgBase;
-import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgLog;
-import cgeo.geocaching.cgWaypoint;
-import cgeo.geocaching.enumerations.CacheSize;
-import cgeo.geocaching.enumerations.WaypointType;
-import cgeo.geocaching.files.GPX10Parser;
-import cgeo.geocaching.files.GPXParser;
-import cgeo.geocaching.geopoint.Geopoint;
-
-import android.content.res.Resources;
-import android.os.Handler;
-import android.test.InstrumentationTestCase;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-public class GPXParserTest extends InstrumentationTestCase {
- private static final SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); // 2010-04-20T07:00:00Z
-
- public void testGPXVersion100() throws Exception {
- testGPXVersion(R.raw.gc1bkp3_gpx100);
- }
-
- private cgCache testGPXVersion(final int resourceId) throws IOException {
- final List<cgCache> caches = readGPX(resourceId);
- assertNotNull(caches);
- assertEquals(1, caches.size());
- final cgCache cache = caches.get(0);
- assertEquals("GC1BKP3", cache.geocode);
- assertEquals("9946f030-a514-46d8-a050-a60e92fd2e1a", cache.guid);
- assertEquals("traditional", cache.type);
- assertEquals(false, cache.archived);
- assertEquals(false, cache.disabled);
- assertEquals("Die Schatzinsel / treasure island", cache.name);
- assertEquals("Die unbesiegbaren Geo - Geparden", cache.owner);
- assertEquals(CacheSize.MICRO, cache.size);
- assertEquals(1.0f, cache.difficulty.floatValue());
- assertEquals(5.0f, cache.terrain.floatValue());
- assertEquals("Baden-Württemberg, Germany", cache.location);
- assertEquals("Ein alter Kindheitstraum, ein Schatz auf einer unbewohnten Insel.\nA old dream of my childhood, a treasure on a lonely island.", cache.shortdesc);
- assertTrue(new Geopoint(48.859683, 9.1874).isEqualTo(cache.coords));
- return cache;
- }
-
- public void testGPXVersion101() throws IOException {
- final cgCache cache = testGPXVersion(R.raw.gc1bkp3_gpx101);
- assertNotNull(cache.attributes);
- assertEquals(10, cache.attributes.size());
- }
-
- public void testOC() throws IOException {
- final List<cgCache> caches = readGPX(R.raw.oc5952_gpx);
- final cgCache cache = caches.get(0);
- assertEquals("OC5952", cache.geocode);
- assertEquals("traditional", cache.type);
- assertEquals(false, cache.archived);
- assertEquals(false, cache.disabled);
- assertEquals("Die Schatzinsel / treasure island", cache.name);
- assertEquals("Die unbesiegbaren Geo - Geparden", cache.owner);
- assertEquals(CacheSize.SMALL, cache.size);
- assertEquals(1.0f, cache.difficulty.floatValue());
- assertEquals(4.0f, cache.terrain.floatValue());
- assertEquals("Baden-Württemberg, Germany", cache.location);
- assertEquals("Ein alter Kindheitstraum, ein Schatz auf einer unbewohnten Insel. A old dream of my childhood, a treasure on a lonely is", cache.shortdesc);
- assertTrue(new Geopoint(48.85968, 9.18740).isEqualTo(cache.coords));
- }
-
- public void testGc31j2h() throws IOException {
- final List<cgCache> caches = readGPX(R.raw.gc31j2h);
- assertEquals(1, caches.size());
- final cgCache cache = caches.get(0);
-
- assertGc31j2h(cache);
- assertSame(cache, caches.get(0));
-
- // no waypoints without importing waypoint file
- assertNull(cache.waypoints);
- }
-
- public void testGc31j2hWpts() throws IOException {
- List<cgCache> caches = readGPX(R.raw.gc31j2h, R.raw.gc31j2h_wpts);
- assertEquals(1, caches.size());
- cgCache cache = caches.get(0);
- assertGc31j2h(cache);
- assertGc31j2hWaypoints(cache);
- }
-
- public void testGc31j2hWptsWithoutCache() throws IOException {
- final List<cgCache> caches = readGPX(R.raw.gc31j2h_wpts);
- assertEquals(0, caches.size());
- }
-
- public void testConvertWaypointSym2Type() {
- assertEquals(WaypointType.WAYPOINT, GPXParser.convertWaypointSym2Type("unknown sym"));
-
- assertEquals(WaypointType.PKG, GPXParser.convertWaypointSym2Type("Parking area"));
- assertEquals(WaypointType.STAGE, GPXParser.convertWaypointSym2Type("Stages of a multicache"));
- assertEquals(WaypointType.PUZZLE, GPXParser.convertWaypointSym2Type("Question to answer"));
- assertEquals(WaypointType.TRAILHEAD, GPXParser.convertWaypointSym2Type("Trailhead"));
- assertEquals(WaypointType.FLAG, GPXParser.convertWaypointSym2Type("Final location"));
- assertEquals(WaypointType.WAYPOINT, GPXParser.convertWaypointSym2Type("Reference point"));
- }
-
- private void assertGc31j2h(final cgCache cache) {
- assertEquals("GC31J2H", cache.getGeocode());
- assertEquals("Hockenheimer City-Brunnen", cache.getName());
- assertTrue("Hockenheimer City-Brunnen by vptsz, Multi-cache (2/1)", cache.getShortDescription().startsWith("Kurzer informativer Multi entlang der Brunnen"));
- assertTrue(cache.getDescription().startsWith("Cachemobile können kostenfrei am Messplatz geparkt werden."));
- assertTrue(cache.hasTrackables());
- assertEquals(2.0f, cache.getDifficulty().floatValue(), 0.01f);
- assertEquals(1.0f, cache.getTerrain().floatValue(), 0.01f);
- final Geopoint refCoordinates = new Geopoint("N 49° 19.122", "E 008° 32.739");
- assertEquals(cgBase.formatLatitude(refCoordinates.getLatitude(), true), cache.getLatitude());
- assertEquals(cgBase.formatLongitude(refCoordinates.getLongitude(), true), cache.getLongitude());
- assertEquals("vptsz", cache.getOwner());
- assertEquals(CacheSize.SMALL, cache.getSize());
- assertEquals("multi", cache.getType());
- assertFalse(cache.isArchived());
- assertFalse(cache.isDisabled());
- assertFalse(cache.isEventCache());
- assertFalse(cache.isMembersOnly());
- assertFalse(cache.isOwn());
- assertTrue(cache.found);
- assertEquals("Station3: Der zerbrochene Stein zählt doppelt.\nFinal: Oben neben dem Tor", cache.getHint());
- // logs
- assertEquals(6, cache.logs.size());
- final cgLog log = cache.logs.get(5);
- assertEquals("Geoteufel", log.author);
- assertEquals(parseTime("2011-09-11T07:00:00Z"), log.date);
- assertEquals(-1, log.found);
- assertEquals("Sehr schöne Runde und wir haben wieder etwas Neues über Hockenheim gelernt. Super Tarnung.\nTFTC, Geoteufel", log.log);
-
- // following info is not contained in pocket query gpx file
- assertNull(cache.attributes);
- }
-
- private long parseTime(String time) {
- try {
- return LOG_DATE_FORMAT.parse(time).getTime();
- } catch (ParseException e) {
- return 0;
- }
- }
-
- private void assertGc31j2hWaypoints(final cgCache cache) {
- assertNotNull(cache.waypoints);
- assertEquals(2, cache.waypoints.size());
- cgWaypoint wp = cache.waypoints.get(0);
- assertEquals("GC31J2H", wp.geocode);
- assertEquals("00", wp.getPrefix());
- assertEquals("---", wp.lookup);
- assertEquals("Parkplatz", wp.name);
- assertEquals("Kostenfreies Parken (je nach Parkreihe Parkscheibe erforderlich)", wp.note);
- assertEquals(WaypointType.PKG.id, wp.type);
- assertEquals(49.317517, wp.coords.getLatitude(), 0.000001);
- assertEquals(8.545083, wp.coords.getLongitude(), 0.000001);
-
- wp = cache.waypoints.get(1);
- assertEquals("GC31J2H", wp.geocode);
- assertEquals("S1", wp.getPrefix());
- assertEquals("---", wp.lookup);
- assertEquals("Station 1", wp.name);
- assertEquals("Ein zweiter Wegpunkt, der nicht wirklich existiert sondern nur zum Testen gedacht ist.", wp.note);
- assertEquals(WaypointType.STAGE.id, wp.type);
- assertEquals(49.317500, wp.coords.getLatitude(), 0.000001);
- assertEquals(8.545100, wp.coords.getLongitude(), 0.000001);
- }
-
- public void testGetWaypointsFileForGpx() {
- assertEquals(new File("1234567-wpts.gpx"), GPXParser.getWaypointsFileForGpx(new File("1234567.gpx")));
- assertEquals(new File("/mnt/sdcard/1234567-wpts.gpx"), GPXParser.getWaypointsFileForGpx(new File("/mnt/sdcard/1234567.gpx")));
- assertEquals(new File("/mnt/sdcard/1-wpts.gpx"), GPXParser.getWaypointsFileForGpx(new File("/mnt/sdcard/1.gpx")));
- assertEquals(new File("/mnt/sd.card/1-wpts.gpx"), GPXParser.getWaypointsFileForGpx(new File("/mnt/sd.card/1.gpx")));
- assertEquals(new File("1234567.9-wpts.gpx"), GPXParser.getWaypointsFileForGpx(new File("1234567.9.gpx")));
- assertEquals(new File("1234567-wpts.GPX"), GPXParser.getWaypointsFileForGpx(new File("1234567.GPX")));
- assertEquals(new File("gpx.gpx-wpts.gpx"), GPXParser.getWaypointsFileForGpx(new File("gpx.gpx.gpx")));
- assertNull(GPXParser.getWaypointsFileForGpx(new File("123.gpy")));
- assertNull(GPXParser.getWaypointsFileForGpx(new File("gpx")));
- assertNull(GPXParser.getWaypointsFileForGpx(new File(".gpx")));
- assertNull(GPXParser.getWaypointsFileForGpx(new File("/mnt/sdcard/.gpx")));
- }
-
- private List<cgCache> readGPX(int... resourceIds) throws IOException {
- final GPX10Parser parser = new GPX10Parser(1);
- for (int resourceId : resourceIds) {
- final Resources res = getInstrumentation().getContext().getResources();
- final InputStream instream = res.openRawResource(resourceId);
- try {
- assertTrue(parser.parse(instream, new Handler()));
- } finally {
- instream.close();
- }
- }
- Collection<cgCache> caches = parser.getParsedCaches();
- assertNotNull(caches);
- List<cgCache> cacheList = new ArrayList<cgCache>(caches);
- // TODO: may need to sort by geocode when a test imports more than one cache
- return cacheList;
- }
-
-}
diff --git a/tests/src/cgeo/geocaching/test/GeoPointParserTest.java b/tests/src/cgeo/geocaching/test/GeoPointParserTest.java
deleted file mode 100644
index e6eb0e8..0000000
--- a/tests/src/cgeo/geocaching/test/GeoPointParserTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.geopoint.Geopoint;
-import cgeo.geocaching.geopoint.GeopointParser;
-
-import android.test.AndroidTestCase;
-
-import junit.framework.Assert;
-
-@SuppressWarnings("static-method")
-public class GeoPointParserTest extends AndroidTestCase {
-
- private static final double refLongitude = 8.0 + 38.564 / 60.0;
- private static final double refLatitude = 49.0 + 56.031 / 60.0;
-
- public void testParseLatitude() {
-
- Assert.assertEquals(refLatitude, GeopointParser.parseLatitude("N 49° 56.031"), 1e-8);
- }
-
- public void testParseLongitude() {
-
- Assert.assertEquals(refLongitude, GeopointParser.parseLongitude("E 8° 38.564"), 1e-8);
- }
-
- public void testFullCoordinates() {
- final Geopoint goal = new Geopoint(refLatitude, refLongitude);
- Assert.assertTrue(goal.isEqualTo(GeopointParser.parse("N 49° 56.031 | E 8° 38.564"), 1e-6));
- }
-
- public void testSouth() {
- Assert.assertEquals(-refLatitude, GeopointParser.parseLatitude("S 49° 56.031"), 1e-8);
- }
-
- public void testWest() {
- Assert.assertEquals(-refLongitude, GeopointParser.parseLongitude("W 8° 38.564"), 1e-8);
- }
-
- public void testLowerCase() {
- Assert.assertEquals(refLongitude, GeopointParser.parseLongitude("e 8° 38.564"), 1e-8);
- }
-
- public void testVariousFormats() {
- final Geopoint goal1 = GeopointParser.parse("N 49° 43' 57\" | E 2 12' 35");
- final Geopoint goal2 = GeopointParser.parse("N 49 43.95 E2°12.5833333333");
- Assert.assertTrue(goal1.isEqualTo(goal2, 1e-6));
- }
-}
diff --git a/tests/src/cgeo/geocaching/test/GeopointTest.java b/tests/src/cgeo/geocaching/test/GeopointTest.java
deleted file mode 100644
index ad42d73..0000000
--- a/tests/src/cgeo/geocaching/test/GeopointTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.geopoint.Geopoint;
-import cgeo.geocaching.geopoint.Geopoint.GeopointException;
-
-import android.test.AndroidTestCase;
-
-import junit.framework.Assert;
-
-@SuppressWarnings("static-method")
-public class GeopointTest extends AndroidTestCase {
-
- public void testCreation() {
- final Geopoint gp = new Geopoint(48.2, 3.5);
- Assert.assertEquals(48.2, gp.getLatitude(), 1e-8);
- Assert.assertEquals(3.5, gp.getLongitude(), 1e-8);
- }
-
- public void testCreationAtLimit() {
- // No exception should be raised at limits.
- final Geopoint gp1 = new Geopoint(90.0, 10.0);
- Assert.assertEquals(90, gp1.getLatitude(), 1e-8);
-
- final Geopoint gp2 = new Geopoint(-90.0, 10.0);
- Assert.assertEquals(-90, gp2.getLatitude(), 1e-8);
-
- final Geopoint gp3 = new Geopoint(10.0, 180.0);
- Assert.assertEquals(180, gp3.getLongitude(), 1e-8);
-
- // 180 should be preferred to -180
- final Geopoint gp4 = new Geopoint(10.0, -180.0);
- Assert.assertEquals(180, gp4.getLongitude(), 1e-8);
- }
-
- private static void createShouldFail(final double lat, final double lon) {
- try {
- final Geopoint gp = new Geopoint(lat, lon);
- Assert.fail("creation should fail: " + gp);
- } catch (GeopointException e) {
- // Success
- }
- }
-
- public void testCreationFails() {
- createShouldFail(90.1, 0.0);
- createShouldFail(-90.1, 0.0);
- createShouldFail(0.0, 180.1);
- createShouldFail(0.0, -180.1);
- }
-
- public void testEqual() {
- final Geopoint gp1 = new Geopoint(48.2, 2.31);
- Assert.assertTrue(gp1.equals(gp1));
- final Geopoint gp2 = new Geopoint(48.3, 2.31);
- Assert.assertFalse(gp1.equals(gp2));
- }
-
- public void testCreateE6() {
- final Geopoint gp1 = new Geopoint(48.2, 2.34);
- final Geopoint gp2 = new Geopoint(48200000, 2340000);
- Assert.assertTrue(gp1.isEqualTo(gp2, 1e-6));
- }
-
- public void testGetE6() {
- final Geopoint gp = new Geopoint(41.2, -3.4);
- Assert.assertEquals(41200000.0, gp.getLatitudeE6(), 1e-6);
- Assert.assertEquals(-3400000.0, gp.getLongitudeE6(), 1e-6);
- }
-
- public void testBearingDistance() {
- final Geopoint gp1 = new Geopoint(-30.4, -1.2);
- final Geopoint gp2 = new Geopoint(-30.1, -2.3);
-
- final float d12 = gp1.distanceTo(gp2);
- Assert.assertEquals(110.967995, d12, 1e-6);
- Assert.assertEquals(d12, gp2.distanceTo(gp1), 1e-6);
-
- // Bearing in both directions cannot be added, as this is
- // the initial bearing of the path in both cases.
- Assert.assertEquals(287.162, gp1.bearingTo(gp2), 1e-3);
- Assert.assertEquals(107.715, gp2.bearingTo(gp1), 1e-3);
- }
-
-}
diff --git a/tests/src/cgeo/geocaching/test/LocParserTest.java b/tests/src/cgeo/geocaching/test/LocParserTest.java
deleted file mode 100644
index ec6d7e6..0000000
--- a/tests/src/cgeo/geocaching/test/LocParserTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.cgCoord;
-import cgeo.geocaching.enumerations.CacheSize;
-import cgeo.geocaching.files.LocParser;
-import cgeo.geocaching.geopoint.Geopoint;
-
-import android.content.res.Resources;
-import android.test.InstrumentationTestCase;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
-public class LocParserTest extends InstrumentationTestCase {
- private Map<String, cgCoord> readLoc(int resourceId) {
- Map<String, cgCoord> caches = null;
- final Resources res = getInstrumentation().getContext().getResources();
- final InputStream instream = res.openRawResource(resourceId);
- try {
- final StringBuilder buffer = new StringBuilder();
- int ch;
- while ((ch = instream.read()) != -1) {
- buffer.append((char) ch);
- }
- caches = LocParser.parseCoordinates(buffer.toString());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- try {
- instream.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- assertNotNull(caches);
- assertTrue(caches.size() > 0);
- return caches;
- }
-
- public void testOCLoc() {
- final Map<String, cgCoord> coords = readLoc(R.raw.oc5952_loc);
- final cgCoord coord = coords.get("OC5952");
- assertNotNull(coord);
- assertEquals("OC5952", coord.geocode);
- assertEquals("Die Schatzinsel / treasure island", coord.name);
- assertTrue(new Geopoint(48.85968, 9.18740).isEqualTo(coord.coords));
- }
-
- public void testGCLoc() {
- final Map<String, cgCoord> coords = readLoc(R.raw.gc1bkp3_loc);
- final cgCoord coord = coords.get("GC1BKP3");
- assertNotNull(coord);
- assertEquals("GC1BKP3", coord.geocode);
- assertEquals("Die Schatzinsel / treasure island", coord.name);
- assertTrue(new Geopoint(48.859683, 9.1874).isEqualTo(coord.coords));
- assertEquals(1.0f, coord.difficulty.floatValue());
- assertEquals(5.0f, coord.terrain.floatValue());
- assertEquals(CacheSize.MICRO, coord.size);
- }
-
-}
diff --git a/tests/src/cgeo/geocaching/test/SettingsTest.java b/tests/src/cgeo/geocaching/test/SettingsTest.java
deleted file mode 100644
index bb3bee8..0000000
--- a/tests/src/cgeo/geocaching/test/SettingsTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.Settings;
-import cgeo.geocaching.cgeo;
-
-import android.test.ActivityInstrumentationTestCase2;
-
-public class SettingsTest extends ActivityInstrumentationTestCase2<cgeo> {
-
- public SettingsTest() {
- super("cgeo.geocaching", cgeo.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * access settings.
- * this should work fine without an exception (once there was an exception because of the empty map file string)
- */
- public void testSettingsException() {
- // asserts A OR NOT A, because we don't know what the settings are on any device or emulator
- assertTrue(Settings.isValidMapFile() || !Settings.isValidMapFile());
- }
-}
diff --git a/tests/src/cgeo/geocaching/test/cgBaseTest.java b/tests/src/cgeo/geocaching/test/cgBaseTest.java
deleted file mode 100644
index 8c8d7fb..0000000
--- a/tests/src/cgeo/geocaching/test/cgBaseTest.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.cgBase;
-
-import android.test.AndroidTestCase;
-
-import junit.framework.Assert;
-
-@SuppressWarnings("static-method")
-public class cgBaseTest extends AndroidTestCase {
-
- public void testReplaceWhitespaces() {
- Assert.assertEquals("foo bar baz ", cgBase.replaceWhitespace(new String(" foo\n\tbar \r baz ")));
- }
-
-}
diff --git a/tests/src/cgeo/geocaching/test/cgDestinationTest.java b/tests/src/cgeo/geocaching/test/cgDestinationTest.java
deleted file mode 100644
index 883c1ab..0000000
--- a/tests/src/cgeo/geocaching/test/cgDestinationTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.cgDestination;
-import cgeo.geocaching.geopoint.Geopoint;
-
-import android.test.AndroidTestCase;
-
-import junit.framework.Assert;
-
-public class cgDestinationTest extends AndroidTestCase {
-
- private cgDestination dest = null;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- dest = new cgDestination(1, 10000, new Geopoint(52.5, 9.33));
- }
-
- public void testSomething() {
- Assert.assertEquals(1, dest.getId());
- Assert.assertEquals(10000, dest.getDate());
- Assert.assertEquals(52.5, dest.getCoords().getLatitude());
- Assert.assertEquals(9.33, dest.getCoords().getLongitude());
- }
-} \ No newline at end of file
diff --git a/tests/src/cgeo/geocaching/test/cgWaypointTest.java b/tests/src/cgeo/geocaching/test/cgWaypointTest.java
deleted file mode 100644
index 601308c..0000000
--- a/tests/src/cgeo/geocaching/test/cgWaypointTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.cgWaypoint;
-
-import android.test.AndroidTestCase;
-
-import junit.framework.Assert;
-
-public class cgWaypointTest extends AndroidTestCase {
-
- @SuppressWarnings("static-method")
- public void testOrder() {
- final cgWaypoint wp1 = new cgWaypoint();
- final cgWaypoint wp2 = new cgWaypoint();
-
- wp1.setPrefix("PK");
- wp2.setPrefix("X");
- Assert.assertTrue(wp1.compareTo(wp2) < 0);
-
- wp1.setPrefix("S1");
- Assert.assertTrue(wp1.compareTo(wp2) > 0);
-
- wp2.setPrefix("S3");
- Assert.assertTrue(wp1.compareTo(wp2) < 0);
-
- wp1.setPrefix("S10");
- Assert.assertTrue(wp1.compareTo(wp2) > 0);
-
- wp2.setPrefix("FI");
- Assert.assertTrue(wp1.compareTo(wp2) < 0);
-
- wp1.setPrefix("OWN");
- Assert.assertTrue(wp1.compareTo(wp2) > 0);
- }
-
-}
diff --git a/tests/src/cgeo/geocaching/test/cgeoApplicationTest.java b/tests/src/cgeo/geocaching/test/cgeoApplicationTest.java
deleted file mode 100644
index 89eda4d..0000000
--- a/tests/src/cgeo/geocaching/test/cgeoApplicationTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.cgBase;
-import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgCacheWrap;
-import cgeo.geocaching.cgeoapplication;
-import cgeo.geocaching.test.mock.GC1ZXX2;
-import cgeo.geocaching.test.mock.GC2CJPF;
-import cgeo.geocaching.test.mock.MockedCache;
-
-import android.test.ApplicationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.UUID;
-
-import junit.framework.Assert;
-
-/**
- * The c:geo application test. It can be used for tests that require an
- * application and/or context.
- */
-
-public class cgeoApplicationTest extends ApplicationTestCase<cgeoapplication> {
-
- private cgBase base = null;
-
- public cgeoApplicationTest() {
- super(cgeoapplication.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- // init environment
- createApplication();
-
- // create required c:geo objects
- base = new cgBase(this.getApplication());
- }
-
- /**
- * The name 'test preconditions' is a convention to signal that if this test
- * doesn't pass, the test case was not set up properly and it might explain
- * any and all failures in other tests. This is not guaranteed to run before
- * other tests, as junit uses reflection to find the tests.
- */
- @SmallTest
- public void testPreconditions() {
- }
-
- /**
- * Test {@link cgBase#searchByGeocode(HashMap, int, boolean)}
- *
- * @param base
- */
- @MediumTest
- public void testSearchByGeocode() {
- final UUID id = base.searchByGeocode("GC1RMM2", null, 0, true);
- Assert.assertNotNull(id);
- }
-
-/**
-* Test {@link cgBase#parseCache(String, int) with "mocked" data
-* @param base
-*/
- @MediumTest
- public void testParseCache() {
- final List<MockedCache> cachesToTest = new ArrayList<MockedCache>();
- cachesToTest.add(new GC2CJPF());
- cachesToTest.add(new GC1ZXX2());
-
- for (MockedCache cache : cachesToTest) {
- cgCacheWrap caches = base.parseCache(cache.getData(), 0);
- cgCache cacheParsed = caches.cacheList.get(0);
- Assert.assertEquals(cache.getGeocode(), cacheParsed.getGeocode());
- Assert.assertEquals(cache.getType(), cacheParsed.getType());
- Assert.assertEquals(cache.getOwner(), cacheParsed.getOwner());
- Assert.assertEquals(cache.getDifficulty(), cacheParsed.getDifficulty());
- Assert.assertEquals(cache.getTerrain(), cacheParsed.getTerrain());
- Assert.assertEquals(cache.getLatitude(), cacheParsed.getLatitude());
- Assert.assertEquals(cache.getLongitude(), cacheParsed.getLongitude());
- Assert.assertEquals(cache.isDisabled(), cacheParsed.isDisabled());
- Assert.assertEquals(cache.isOwn(), cacheParsed.isOwn());
- Assert.assertEquals(cache.isArchived(), cacheParsed.isArchived());
- Assert.assertEquals(cache.isMembersOnly(), cacheParsed.isMembersOnly());
- Assert.assertEquals(cache.getOwnerReal(), cacheParsed.getOwnerReal());
- Assert.assertEquals(cache.getSize(), cacheParsed.getSize());
- Assert.assertEquals(cache.getHint(), cacheParsed.getHint());
- Assert.assertTrue(cacheParsed.getDescription().startsWith(cache.getDescription()));
- Assert.assertEquals(cache.getShortDescription(), cacheParsed.getShortDescription());
- Assert.assertEquals(cache.getName(), cacheParsed.getName());
- Assert.assertEquals(cache.getCacheId(), cacheParsed.getCacheId());
- Assert.assertEquals(cache.getGuid(), cacheParsed.getGuid());
- Assert.assertEquals(cache.getLocation(), cacheParsed.getLocation());
- Assert.assertEquals(cache.getPersonalNote(), cacheParsed.getPersonalNote());
- }
- }
-
- public void testParseLocationWithLink() {
- cgCacheWrap caches = base.parseCache(MockedCache.readCachePage("GCV2R9"), 0);
- cgCache cache = caches.cacheList.get(0);
- Assert.assertEquals("California, United States", cache.getLocation());
- }
-}
diff --git a/tests/src/cgeo/geocaching/test/cgeogpxesTest.java b/tests/src/cgeo/geocaching/test/cgeogpxesTest.java
deleted file mode 100644
index 9c2d088..0000000
--- a/tests/src/cgeo/geocaching/test/cgeogpxesTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package cgeo.geocaching.test;
-
-import cgeo.geocaching.cgeogpxes;
-
-import android.test.AndroidTestCase;
-
-public class cgeogpxesTest extends AndroidTestCase {
- private cgeogpxes cgeogpxes = new cgeogpxes();
-
- public void testFileNameMatches() {
- assertTrue(cgeogpxes.filenameBelongsToList("1234567.gpx"));
- assertTrue(cgeogpxes.filenameBelongsToList("1234567.GPX"));
- assertTrue(cgeogpxes.filenameBelongsToList(".gpx"));
- assertTrue(cgeogpxes.filenameBelongsToList("1234567.loc"));
- assertTrue(cgeogpxes.filenameBelongsToList("1234567.LOC"));
-
- assertFalse(cgeogpxes.filenameBelongsToList("1234567.gpy"));
- assertFalse(cgeogpxes.filenameBelongsToList("1234567.agpx"));
- assertFalse(cgeogpxes.filenameBelongsToList("1234567"));
- assertFalse(cgeogpxes.filenameBelongsToList(""));
- assertFalse(cgeogpxes.filenameBelongsToList("gpx"));
-
- assertFalse(cgeogpxes.filenameBelongsToList("1234567-wpts.gpx"));
- }
-}