aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/cgeo/geocaching/CacheTest.java6
-rw-r--r--tests/src/cgeo/geocaching/SettingsTest.java2
-rw-r--r--tests/src/cgeo/geocaching/StoredListTest.java18
-rw-r--r--tests/src/cgeo/geocaching/TrackableTest.java18
-rw-r--r--tests/src/cgeo/geocaching/WaypointTest.java (renamed from tests/src/cgeo/geocaching/cgWaypointTest.java)19
-rw-r--r--tests/src/cgeo/geocaching/cgDataTest.java70
-rw-r--r--tests/src/cgeo/geocaching/cgeoApplicationTest.java189
-rw-r--r--tests/src/cgeo/geocaching/compatibility/CompatibilityTest.java2
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java49
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java4
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCParserTest.java62
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java352
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java67
-rw-r--r--tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java5
-rw-r--r--tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java7
-rw-r--r--tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java10
-rw-r--r--tests/src/cgeo/geocaching/enumerations/LogTypeTest.java3
-rw-r--r--tests/src/cgeo/geocaching/files/GPXImporterTest.java34
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java42
-rw-r--r--tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java84
-rw-r--r--tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java17
-rw-r--r--tests/src/cgeo/geocaching/sorting/NameComparatorTest.java8
-rw-r--r--tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java4
-rw-r--r--tests/src/cgeo/geocaching/test/RegExPerformanceTest.java8
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC2JVEH.java16
-rw-r--r--tests/src/cgeo/geocaching/test/mock/MockedCache.java10
-rw-r--r--tests/src/cgeo/geocaching/ui/FormatterTest.java30
27 files changed, 886 insertions, 250 deletions
diff --git a/tests/src/cgeo/geocaching/CacheTest.java b/tests/src/cgeo/geocaching/CacheTest.java
index e1d6efb..905cab0 100644
--- a/tests/src/cgeo/geocaching/CacheTest.java
+++ b/tests/src/cgeo/geocaching/CacheTest.java
@@ -41,4 +41,10 @@ public class CacheTest extends AndroidTestCase {
// different objects with same geocode shall be equal
assertTrue(one.equals(two));
}
+
+ public static void testGeocodeUppercase() {
+ cgCache cache = new cgCache();
+ cache.setGeocode("gc1234");
+ assertEquals("GC1234", cache.getGeocode());
+ }
}
diff --git a/tests/src/cgeo/geocaching/SettingsTest.java b/tests/src/cgeo/geocaching/SettingsTest.java
index 0d395f4..f113180 100644
--- a/tests/src/cgeo/geocaching/SettingsTest.java
+++ b/tests/src/cgeo/geocaching/SettingsTest.java
@@ -30,6 +30,6 @@ public class SettingsTest extends ActivityInstrumentationTestCase2<cgeo> {
}
public static void testSettings() {
- assertEquals(Settings.getMemberStatus(), GCConstants.MEMBER_STATUS_PM);
+ assertEquals(GCConstants.MEMBER_STATUS_PM, Settings.getMemberStatus());
}
}
diff --git a/tests/src/cgeo/geocaching/StoredListTest.java b/tests/src/cgeo/geocaching/StoredListTest.java
new file mode 100644
index 0000000..6d8fd64
--- /dev/null
+++ b/tests/src/cgeo/geocaching/StoredListTest.java
@@ -0,0 +1,18 @@
+package cgeo.geocaching;
+
+import junit.framework.TestCase;
+
+public class StoredListTest extends TestCase {
+
+ public static void testStandardListExists() {
+ StoredList list = cgData.getList(StoredList.STANDARD_LIST_ID);
+ assertNotNull(list);
+ }
+
+ public static void testEquals() {
+ StoredList list1 = cgData.getList(StoredList.STANDARD_LIST_ID);
+ StoredList list2 = cgData.getList(StoredList.STANDARD_LIST_ID);
+ assertEquals(list1, list2);
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/TrackableTest.java b/tests/src/cgeo/geocaching/TrackableTest.java
new file mode 100644
index 0000000..c18d1ea
--- /dev/null
+++ b/tests/src/cgeo/geocaching/TrackableTest.java
@@ -0,0 +1,18 @@
+package cgeo.geocaching;
+
+import android.test.AndroidTestCase;
+
+public class TrackableTest extends AndroidTestCase {
+
+ public static void testGetGeocode() {
+ Trackable trackable = new Trackable();
+ trackable.setGeocode("tb1234");
+ assertEquals("TB1234", trackable.getGeocode());
+ }
+
+ public static void testSetLogsNull() {
+ Trackable trackable = new Trackable();
+ trackable.setLogs(null);
+ assertNotNull("Trackable logs must not be null!", trackable.getLogs());
+ }
+}
diff --git a/tests/src/cgeo/geocaching/cgWaypointTest.java b/tests/src/cgeo/geocaching/WaypointTest.java
index 324d562..273a3bf 100644
--- a/tests/src/cgeo/geocaching/cgWaypointTest.java
+++ b/tests/src/cgeo/geocaching/WaypointTest.java
@@ -4,15 +4,15 @@ import cgeo.geocaching.enumerations.WaypointType;
import android.test.AndroidTestCase;
-public class cgWaypointTest extends AndroidTestCase {
+public class WaypointTest extends AndroidTestCase {
public static void testOrder() {
- final cgWaypoint cache = new cgWaypoint("Final", WaypointType.FINAL, false);
- final cgWaypoint trailhead = new cgWaypoint("Trail head", WaypointType.TRAILHEAD, false);
- final cgWaypoint stage = new cgWaypoint("stage", WaypointType.STAGE, false);
- final cgWaypoint puzzle = new cgWaypoint("puzzle", WaypointType.PUZZLE, false);
- final cgWaypoint own = new cgWaypoint("own", WaypointType.OWN, true);
- final cgWaypoint parking = new cgWaypoint("parking", WaypointType.PARKING, false);
+ final Waypoint cache = new Waypoint("Final", WaypointType.FINAL, false);
+ final Waypoint trailhead = new Waypoint("Trail head", WaypointType.TRAILHEAD, false);
+ final Waypoint stage = new Waypoint("stage", WaypointType.STAGE, false);
+ final Waypoint puzzle = new Waypoint("puzzle", WaypointType.PUZZLE, false);
+ final Waypoint own = new Waypoint("own", WaypointType.OWN, true);
+ final Waypoint parking = new Waypoint("parking", WaypointType.PARKING, false);
assertTrue(trailhead.compareTo(puzzle) < 0);
assertTrue(trailhead.compareTo(stage) < 0);
@@ -33,4 +33,9 @@ public class cgWaypointTest extends AndroidTestCase {
assertTrue(parking.compareTo(trailhead) < 0);
}
+ public static void testGeocode() {
+ Waypoint waypoint = new Waypoint("Test waypoint", WaypointType.PARKING, false);
+ waypoint.setGeocode("p1");
+ assertEquals("P1", waypoint.getGeocode());
+ }
}
diff --git a/tests/src/cgeo/geocaching/cgDataTest.java b/tests/src/cgeo/geocaching/cgDataTest.java
index 3cee32f..1c8a0e0 100644
--- a/tests/src/cgeo/geocaching/cgDataTest.java
+++ b/tests/src/cgeo/geocaching/cgDataTest.java
@@ -18,7 +18,6 @@ public class cgDataTest extends CGeoTestCase {
public static void testStoredLists() {
- cgeoapplication app = cgeoapplication.getInstance();
int listId1 = StoredList.STANDARD_LIST_ID;
int listId2 = StoredList.STANDARD_LIST_ID;
@@ -32,11 +31,11 @@ public class cgDataTest extends CGeoTestCase {
try {
// create lists
- listId1 = app.createList("cgData Test");
+ listId1 = cgData.createList("cgData Test");
assertTrue(listId1 > StoredList.STANDARD_LIST_ID);
- listId2 = app.createList("cgDataTest");
+ listId2 = cgData.createList("cgDataTest");
assertTrue(listId2 > StoredList.STANDARD_LIST_ID);
- assertTrue(app.getLists().size() >= 2);
+ assertTrue(cgData.getLists().size() >= 2);
cache1.setDetailed(true);
cache1.setListId(listId1);
@@ -44,33 +43,33 @@ public class cgDataTest extends CGeoTestCase {
cache2.setListId(listId1);
// save caches to DB (cache1=listId1, cache2=listId1)
- app.saveCache(cache1, LoadFlags.SAVE_ALL);
- app.saveCache(cache2, LoadFlags.SAVE_ALL);
- assertTrue(app.getAllStoredCachesCount(false, CacheType.ALL) >= 2);
+ cgData.saveCache(cache1, LoadFlags.SAVE_ALL);
+ cgData.saveCache(cache2, LoadFlags.SAVE_ALL);
+ assertTrue(cgData.getAllCachesCount() >= 2);
// rename list (cache1=listId1, cache2=listId1)
- assertEquals(1, app.renameList(listId1, "cgData Test (renamed)"));
+ assertEquals(1, cgData.renameList(listId1, "cgData Test (renamed)"));
// get list
- StoredList list1 = app.getList(listId1);
+ StoredList list1 = cgData.getList(listId1);
assertEquals("cgData Test (renamed)", list1.title);
// move to list (cache1=listId2, cache2=listId2)
- app.moveToList(Collections.singletonList(cache1), listId2);
- assertEquals(1, app.getAllStoredCachesCount(false, CacheType.ALL, listId2));
+ cgData.moveToList(Collections.singletonList(cache1), listId2);
+ assertEquals(1, cgData.getAllStoredCachesCount(CacheType.ALL, listId2));
// remove list (cache1=listId2, cache2=listId2)
- assertTrue(app.removeList(listId1));
+ assertTrue(cgData.removeList(listId1));
// mark dropped (cache1=1, cache2=0)
- app.markDropped(Collections.singletonList(cache2));
+ cgData.markDropped(Collections.singletonList(cache2));
// mark stored (cache1=1, cache2=listId2)
- app.markStored(Collections.singletonList(cache2), listId2);
- assertEquals(2, app.getAllStoredCachesCount(false, CacheType.ALL, listId2));
+ cgData.moveToList(Collections.singletonList(cache2), listId2);
+ assertEquals(2, cgData.getAllStoredCachesCount(CacheType.ALL, listId2));
// drop stored (cache1=0, cache2=0)
- app.removeList(listId2);
+ cgData.removeList(listId2);
} finally {
@@ -78,61 +77,56 @@ public class cgDataTest extends CGeoTestCase {
Set<String> geocodes = new HashSet<String>();
geocodes.add(cache1.getGeocode());
geocodes.add(cache2.getGeocode());
- app.removeCaches(geocodes, LoadFlags.REMOVE_ALL);
+ cgData.removeCaches(geocodes, LoadFlags.REMOVE_ALL);
// remove list
- app.removeList(listId1);
- app.removeList(listId2);
+ cgData.removeList(listId1);
+ cgData.removeList(listId2);
}
}
// Check that queries don't throw an exception (see issue #1429).
public static void testLoadWaypoints() {
final Viewport viewport = new Viewport(new Geopoint(-1, -2), new Geopoint(3, 4));
- final cgeoapplication app = cgeoapplication.getInstance();
- app.getWaypointsInViewport(viewport, false, false, CacheType.ALL);
- app.getWaypointsInViewport(viewport, false, true, CacheType.ALL);
- app.getWaypointsInViewport(viewport, true, false, CacheType.ALL);
- app.getWaypointsInViewport(viewport, true, true, CacheType.ALL);
- app.getWaypointsInViewport(viewport, false, false, CacheType.TRADITIONAL);
- app.getWaypointsInViewport(viewport, false, true, CacheType.TRADITIONAL);
- app.getWaypointsInViewport(viewport, true, false, CacheType.TRADITIONAL);
- app.getWaypointsInViewport(viewport, true, true, CacheType.TRADITIONAL);
+ cgData.loadWaypoints(viewport, false, false, CacheType.ALL);
+ cgData.loadWaypoints(viewport, false, true, CacheType.ALL);
+ cgData.loadWaypoints(viewport, true, false, CacheType.ALL);
+ cgData.loadWaypoints(viewport, true, true, CacheType.ALL);
+ cgData.loadWaypoints(viewport, false, false, CacheType.TRADITIONAL);
+ cgData.loadWaypoints(viewport, false, true, CacheType.TRADITIONAL);
+ cgData.loadWaypoints(viewport, true, false, CacheType.TRADITIONAL);
+ cgData.loadWaypoints(viewport, true, true, CacheType.TRADITIONAL);
}
// Check that saving a cache and trackable without logs works (see #2199)
public static void testSaveWithoutLogs() {
- cgeoapplication app = cgeoapplication.getInstance();
-
final String GEOCODE_CACHE = "TEST";
// create cache and trackable
final cgCache cache = new cgCache();
cache.setGeocode(GEOCODE_CACHE);
cache.setDetailed(true);
- final cgTrackable trackable = new cgTrackable();
+ final Trackable trackable = new Trackable();
trackable.setLogs(null);
- final List<cgTrackable> inventory = new ArrayList<cgTrackable>();
+ final List<Trackable> inventory = new ArrayList<Trackable>();
inventory.add(trackable);
cache.setInventory(inventory);
try {
- app.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB));
- final cgCache loadedCache = app.loadCache(GEOCODE_CACHE, LoadFlags.LOAD_ALL_DB_ONLY);
+ cgData.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB));
+ final cgCache loadedCache = cgData.loadCache(GEOCODE_CACHE, LoadFlags.LOAD_ALL_DB_ONLY);
assertNotNull("Cache was not saved!", loadedCache);
assertEquals(1, loadedCache.getInventory().size());
} finally {
- app.removeCache(GEOCODE_CACHE, LoadFlags.REMOVE_ALL);
+ cgData.removeCache(GEOCODE_CACHE, LoadFlags.REMOVE_ALL);
}
}
// Loading logs for an empty geocode should return an empty list, not null!
public static void testLoadLogsFromEmptyGeocode() {
- cgeoapplication app = cgeoapplication.getInstance();
-
- List<LogEntry> logs = app.loadLogs("");
+ List<LogEntry> logs = cgData.loadLogs("");
assertNotNull("Logs must not be null", logs);
assertEquals("Logs from empty geocode must be empty", 0, logs.size());
diff --git a/tests/src/cgeo/geocaching/cgeoApplicationTest.java b/tests/src/cgeo/geocaching/cgeoApplicationTest.java
index f7d3158..fbb860c 100644
--- a/tests/src/cgeo/geocaching/cgeoApplicationTest.java
+++ b/tests/src/cgeo/geocaching/cgeoApplicationTest.java
@@ -56,7 +56,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
*/
@MediumTest
public static void testSearchTrackableNotExisting() {
- cgTrackable tb = GCParser.searchTrackable("123456", null, null);
+ Trackable tb = GCParser.searchTrackable("123456", null, null);
assertNull(tb);
}
@@ -65,7 +65,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
*/
@MediumTest
public static void testSearchTrackable() {
- final cgTrackable tb = GCParser.searchTrackable("TB2J1VZ", null, null);
+ final Trackable tb = GCParser.searchTrackable("TB2J1VZ", null, null);
// fix data
assertEquals("aefffb86-099f-444f-b132-605436163aa8", tb.getGuid());
assertEquals("TB2J1VZ", tb.getGeocode());
@@ -82,7 +82,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
// Following data can change over time
assertTrue(tb.getDistance() >= 10617.8f);
assertTrue(tb.getLogs().size() >= 10);
- assertTrue(cgTrackable.SPOTTED_CACHE == tb.getSpottedType() || cgTrackable.SPOTTED_USER == tb.getSpottedType());
+ assertTrue(Trackable.SPOTTED_CACHE == tb.getSpottedType() || Trackable.SPOTTED_USER == tb.getSpottedType());
// no assumption possible: assertEquals("faa2d47d-19ea-422f-bec8-318fc82c8063", tb.getSpottedGuid());
// no assumption possible: assertEquals("Nice place for a break cache", tb.getSpottedName());
@@ -109,7 +109,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
if (Settings.isPremiumMember() || search.getError() == null) {
assertEquals(1, search.getGeocodes().size());
assertTrue(search.getGeocodes().contains(geocode));
- return cgeoapplication.getInstance().loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
+ return cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
}
assertEquals(0, search.getGeocodes().size());
return null;
@@ -191,46 +191,60 @@ public class cgeoApplicationTest extends CGeoTestCase {
}
/**
- * Test {@link cgBase#searchByCoords(AbstractSearchThread, Geopoint, String, int, boolean)}
+ * mock the "exclude disabled caches" and "exclude my caches" options for the execution of the runnable
+ *
+ * @param runnable
*/
- @MediumTest
- public static void testSearchByCoords() {
+ private static void withMockedFilters(Runnable runnable) {
// backup user settings
final boolean excludeMine = Settings.isExcludeMyCaches();
+ final boolean excludeDisabled = Settings.isExcludeDisabledCaches();
try {
// set up settings required for test
Settings.setExcludeMine(false);
+ Settings.setExcludeDisabledCaches(false);
+
+ runnable.run();
- final SearchResult search = GCParser.searchByCoords(new Geopoint("N 52° 24.972 E 009° 35.647"), CacheType.MYSTERY, false);
- assertNotNull(search);
- assertTrue(20 <= search.getGeocodes().size());
- assertTrue(search.getGeocodes().contains("GC1RMM2"));
} finally {
// restore user settings
Settings.setExcludeMine(excludeMine);
+ Settings.setExcludeDisabledCaches(excludeDisabled);
}
}
/**
+ * Test {@link cgBase#searchByCoords(AbstractSearchThread, Geopoint, String, int, boolean)}
+ */
+ @MediumTest
+ public static void testSearchByCoords() {
+ withMockedFilters(new Runnable() {
+
+ @Override
+ public void run() {
+ final SearchResult search = GCParser.searchByCoords(new Geopoint("N 52° 24.972 E 009° 35.647"), CacheType.MYSTERY, false);
+ assertNotNull(search);
+ assertTrue(20 <= search.getGeocodes().size());
+ assertTrue(search.getGeocodes().contains("GC1RMM2"));
+ }
+ });
+ }
+
+ /**
* Test {@link cgBase#searchByOwner(String, String, int, boolean, CancellableHandler)}
*/
@MediumTest
public static void testSearchByOwner() {
- // backup user settings
- final boolean excludeMine = Settings.isExcludeMyCaches();
- try {
- // set up settings required for test
- Settings.setExcludeMine(false);
-
- final SearchResult search = GCParser.searchByOwner("blafoo", CacheType.MYSTERY, false);
- assertNotNull(search);
- assertEquals(3, search.getGeocodes().size());
- assertTrue(search.getGeocodes().contains("GC36RT6"));
-
- } finally {
- // restore user settings
- Settings.setExcludeMine(excludeMine);
- }
+ withMockedFilters(new Runnable() {
+
+ @Override
+ public void run() {
+ final SearchResult search = GCParser.searchByOwner("blafoo", CacheType.MYSTERY, false);
+ assertNotNull(search);
+ assertEquals(3, search.getGeocodes().size());
+ assertTrue(search.getGeocodes().contains("GC36RT6"));
+ }
+ });
}
/**
@@ -238,21 +252,16 @@ public class cgeoApplicationTest extends CGeoTestCase {
*/
@MediumTest
public static void testSearchByUsername() {
- // backup user settings
- final boolean excludeMine = Settings.isExcludeMyCaches();
- try {
- // set up settings required for test
- Settings.setExcludeMine(false);
-
- final SearchResult search = GCParser.searchByUsername("blafoo", CacheType.WEBCAM, false);
- assertNotNull(search);
- assertEquals(3, search.getTotal());
- assertTrue(search.getGeocodes().contains("GCP0A9"));
-
- } finally {
- // restore user settings
- Settings.setExcludeMine(excludeMine);
- }
+ withMockedFilters(new Runnable() {
+
+ @Override
+ public void run() {
+ final SearchResult search = GCParser.searchByUsername("blafoo", CacheType.WEBCAM, false);
+ assertNotNull(search);
+ assertEquals(3, search.getTotal());
+ assertTrue(search.getGeocodes().contains("GCP0A9"));
+ }
+ });
}
/**
@@ -260,49 +269,54 @@ public class cgeoApplicationTest extends CGeoTestCase {
*/
@MediumTest
public static void testSearchByViewport() {
- // backup user settings
- final boolean excludeMine = Settings.isExcludeMyCaches();
- final Strategy strategy = Settings.getLiveMapStrategy();
-
- try {
- // set up settings required for test
- Settings.setExcludeMine(false);
-
- final GC2CJPF mockedCache = new GC2CJPF();
- deleteCacheFromDB(mockedCache.getGeocode());
-
- final String[] tokens = Login.getMapTokens();
- final Viewport viewport = new Viewport(mockedCache, 0.003, 0.003);
-
- // check coords for DETAILED
- Settings.setLiveMapStrategy(Strategy.DETAILED);
- SearchResult search = ConnectorFactory.searchByViewport(viewport, tokens);
- assertNotNull(search);
- assertTrue(search.getGeocodes().contains(mockedCache.getGeocode()));
-
- cgCache parsedCache = cgeoapplication.getInstance().loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
-
- assertEquals(Settings.isPremiumMember(), mockedCache.getCoords().equals(parsedCache.getCoords()));
- assertEquals(Settings.isPremiumMember(), parsedCache.isReliableLatLon());
-
- // check update after switch strategy to FAST
- Settings.setLiveMapStrategy(Strategy.FAST);
- Tile.Cache.removeFromTileCache(mockedCache);
-
- search = ConnectorFactory.searchByViewport(viewport, tokens);
- assertNotNull(search);
- assertTrue(search.getGeocodes().contains(mockedCache.getGeocode()));
-
- parsedCache = cgeoapplication.getInstance().loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
-
- assertEquals(Settings.isPremiumMember(), mockedCache.getCoords().equals(parsedCache.getCoords()));
- assertEquals(Settings.isPremiumMember(), parsedCache.isReliableLatLon());
-
- } finally {
- // restore user settings
- Settings.setExcludeMine(excludeMine);
- Settings.setLiveMapStrategy(strategy);
- }
+ withMockedFilters(new Runnable() {
+
+ @Override
+ public void run() {
+ // backup user settings
+ final Strategy strategy = Settings.getLiveMapStrategy();
+ final CacheType cacheType = Settings.getCacheType();
+
+ try {
+ // set up settings required for test
+ Settings.setExcludeMine(false);
+ Settings.setCacheType(CacheType.ALL);
+
+ final GC2CJPF mockedCache = new GC2CJPF();
+ deleteCacheFromDB(mockedCache.getGeocode());
+
+ final String[] tokens = Login.getMapTokens();
+ final Viewport viewport = new Viewport(mockedCache, 0.003, 0.003);
+
+ // check coords for DETAILED
+ Settings.setLiveMapStrategy(Strategy.DETAILED);
+ SearchResult search = ConnectorFactory.searchByViewport(viewport, tokens);
+ assertNotNull(search);
+ assertTrue(search.getGeocodes().contains(mockedCache.getGeocode()));
+ cgCache parsedCache = cgData.loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
+
+ assertEquals(Settings.isPremiumMember(), mockedCache.getCoords().equals(parsedCache.getCoords()));
+ assertEquals(Settings.isPremiumMember(), parsedCache.isReliableLatLon());
+
+ // check update after switch strategy to FAST
+ Settings.setLiveMapStrategy(Strategy.FAST);
+ Tile.Cache.removeFromTileCache(mockedCache);
+
+ search = ConnectorFactory.searchByViewport(viewport, tokens);
+ assertNotNull(search);
+ assertTrue(search.getGeocodes().contains(mockedCache.getGeocode()));
+ parsedCache = cgData.loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
+
+ assertEquals(Settings.isPremiumMember(), mockedCache.getCoords().equals(parsedCache.getCoords()));
+ assertEquals(Settings.isPremiumMember(), parsedCache.isReliableLatLon());
+
+ } finally {
+ // restore user settings
+ Settings.setLiveMapStrategy(strategy);
+ Settings.setCacheType(cacheType);
+ }
+ }
+ });
}
/**
@@ -316,6 +330,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
Strategy strategy = Settings.getLiveMapStrategy();
Strategy testStrategy = Strategy.FAST; // FASTEST, FAST or DETAILED for tests
Settings.setLiveMapStrategy(testStrategy);
+ final CacheType cacheType = Settings.getCacheType();
try {
@@ -325,6 +340,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
MockedCache cache = new GC2CJPF();
deleteCacheFromDBAndLogout(cache.getGeocode());
Tile.Cache.removeFromTileCache(cache);
+ Settings.setCacheType(CacheType.ALL);
Viewport viewport = new Viewport(cache, 0.003, 0.003);
SearchResult search = ConnectorFactory.searchByViewport(viewport, tokens);
@@ -332,7 +348,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
assertNotNull(search);
assertTrue(search.getGeocodes().contains(cache.getGeocode()));
// coords differ
- cgCache cacheFromViewport = cgeoapplication.getInstance().loadCache(cache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
+ cgCache cacheFromViewport = cgData.loadCache(cache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
Log.d("cgeoApplicationTest.testSearchByViewportNotLoggedIn: Coords expected = " + cache.getCoords());
Log.d("cgeoApplicationTest.testSearchByViewportNotLoggedIn: Coords actual = " + cacheFromViewport.getCoords());
assertFalse(cache.getCoords().isEqualTo(cacheFromViewport.getCoords(), 1e-3));
@@ -356,6 +372,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
Settings.setMemberStatus(memberStatus);
Login.login();
Settings.setLiveMapStrategy(strategy);
+ Settings.setCacheType(cacheType);
}
}
@@ -390,7 +407,7 @@ 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) {
- cgeoapplication.getInstance().removeCache(geocode, LoadFlags.REMOVE_ALL);
+ cgData.removeCache(geocode, LoadFlags.REMOVE_ALL);
}
/** Remove cache from DB and cache to ensure that the cache is not loaded from the database */
diff --git a/tests/src/cgeo/geocaching/compatibility/CompatibilityTest.java b/tests/src/cgeo/geocaching/compatibility/CompatibilityTest.java
index 03034f8..35baa8c 100644
--- a/tests/src/cgeo/geocaching/compatibility/CompatibilityTest.java
+++ b/tests/src/cgeo/geocaching/compatibility/CompatibilityTest.java
@@ -11,7 +11,7 @@ public class CompatibilityTest extends ActivityInstrumentationTestCase2<cgeo> {
private cgeo activity;
public CompatibilityTest() {
- super(cgeo.class);
+ super("cgeo.geocaching", cgeo.class);
}
@Override
diff --git a/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java b/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java
index 234ff26..fb49949 100644
--- a/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java
@@ -1,6 +1,9 @@
package cgeo.geocaching.connector.gc;
import cgeo.geocaching.geopoint.Geopoint;
+import cgeo.geocaching.geopoint.Viewport;
+
+import java.util.Set;
import junit.framework.TestCase;
@@ -10,16 +13,58 @@ public class AutoZoomTest extends TestCase {
Geopoint bottomLeft = new Geopoint(49.3, 8.3);
Geopoint topRight = new Geopoint(49.4, 8.4);
- int zoom = Tile.calcZoomLat(bottomLeft, topRight);
+ int zoom = Tile.calcZoomLat(bottomLeft, topRight, 2);
assertTrue(Math.abs(new Tile(bottomLeft, zoom).getY() - new Tile(topRight, zoom).getY()) == 1);
assertTrue(Math.abs(new Tile(bottomLeft, zoom + 1).getY() - new Tile(topRight, zoom + 1).getY()) > 1);
- zoom = Tile.calcZoomLon(bottomLeft, topRight);
+ zoom = Tile.calcZoomLon(bottomLeft, topRight, 2);
assertTrue(new Tile(bottomLeft, zoom).getX() + 1 == new Tile(topRight, zoom).getX());
assertTrue(new Tile(bottomLeft, zoom + 1).getX() + 1 < new Tile(topRight, zoom + 1).getX());
}
+ public static void testZoom2() {
+ Geopoint bottomLeft = new Geopoint(49.3, 8.3);
+ Geopoint topRight = new Geopoint(49.4, 8.4);
+
+ int zoom = Tile.calcZoomLat(bottomLeft, topRight, 3);
+
+ assertTrue(Math.abs(new Tile(bottomLeft, zoom).getY() - new Tile(topRight, zoom).getY()) >= 2);
+ assertTrue(Math.abs(new Tile(bottomLeft, zoom + 1).getY() - new Tile(topRight, zoom + 1).getY()) > 2);
+
+ zoom = Tile.calcZoomLon(bottomLeft, topRight, 3);
+
+ assertTrue(Math.abs(new Tile(bottomLeft, zoom).getX() - new Tile(topRight, zoom).getX()) >= 2);
+ assertTrue(Math.abs(new Tile(bottomLeft, zoom + 1).getX() - new Tile(topRight, zoom + 1).getX()) > 2);
+
+ }
+
+ public static void testTiles1x2() {
+ Geopoint bottomLeft = new Geopoint(49.3, 8.3);
+ Geopoint topRight = new Geopoint(49.4, 8.4);
+
+ Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight));
+
+ assertEquals(2, tiles.size());
+ }
+
+ public static void testTiles2x3() {
+ Geopoint bottomLeft = new Geopoint(49.3, 8.3);
+ Geopoint topRight = new Geopoint(49.4, 8.4);
+
+ Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight), 3, Tile.ZOOMLEVEL_MIN);
+
+ assertEquals(6, tiles.size());
+ }
+
+ public static void testTilesZoom13() {
+ Geopoint bottomLeft = new Geopoint(49.3, 8.3);
+ Geopoint topRight = new Geopoint(49.4, 8.4);
+
+ Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight), 3, 13);
+
+ assertEquals(16, tiles.size());
+ }
}
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
index ea46bbe..ec5ebe2 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.connector.gc;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
import cgeo.geocaching.connector.ConnectorFactory;
+import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.geopoint.Viewport;
import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
@@ -12,9 +13,11 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
public static void testGetViewport() {
// backup user settings
final boolean excludeMine = Settings.isExcludeMyCaches();
+ final CacheType cacheType = Settings.getCacheType();
try {
// set up settings required for test
Settings.setExcludeMine(false);
+ Settings.setCacheType(CacheType.ALL);
Login.login();
String[] tokens = Login.getMapTokens();
@@ -37,6 +40,7 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
} finally {
// restore user settings
Settings.setExcludeMine(excludeMine);
+ Settings.setCacheType(cacheType);
}
}
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
index c8cb8fb..6a49c95 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
@@ -1,10 +1,10 @@
package cgeo.geocaching.connector.gc;
+import cgeo.geocaching.Image;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgImage;
-import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.enumerations.LoadFlags;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.geopoint.Geopoint;
@@ -18,32 +18,61 @@ import cgeo.test.Compare;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
+import android.os.Handler;
import android.test.suitebuilder.annotation.MediumTest;
import java.util.ArrayList;
public class GCParserTest extends AbstractResourceInstrumentationTestCase {
- public void testUnpublishedCache() {
- final String page = getFileContent(R.raw.cache_unpublished);
+
+ public void testUnpublishedCacheNotOwner() {
+ final int cache = R.raw.cache_unpublished;
+ assertUnpublished(cache);
+ }
+
+ public void testUnpublishedCacheOwner() {
+ final int cache = R.raw.gc433yc_owner_unpublished;
+ assertUnpublished(cache);
+ }
+
+ private void assertUnpublished(final int cache) {
+ final String page = getFileContent(cache);
SearchResult result = GCParser.parseCacheFromText(page, null);
assertNotNull(result);
assertTrue(result.isEmpty());
assertEquals(StatusCode.UNPUBLISHED_CACHE, result.getError());
}
+ public void testPublishedCacheWithUnpublishedInDescription1() {
+ assertPublishedCache(R.raw.gc430fm_published, "Cache is Unpublished");
+ }
+
+ public void testPublishedCacheWithUnpublishedInDescription2() {
+ assertPublishedCache(R.raw.gc431f2_published, "Needle in a Haystack");
+ }
+
+ private void assertPublishedCache(final int cachePage, final String cacheName) {
+ final String page = getFileContent(cachePage);
+ SearchResult result = GCParser.parseCacheFromText(page, null);
+ assertNotNull(result);
+ assertEquals(1, result.getCount());
+ cgCache cache = result.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
+ assertEquals(cacheName, cache.getName());
+ }
+
public void testOwnCache() {
final cgCache cache = parseCache(R.raw.own_cache);
assertNotNull(cache);
assertTrue(CollectionUtils.isNotEmpty(cache.getSpoilers()));
assertEquals(1, cache.getSpoilers().size());
- final cgImage spoiler = cache.getSpoilers().get(0);
+ final Image spoiler = cache.getSpoilers().get(0);
assertEquals("http://img.geocaching.com/cache/large/3f9365c3-f55c-4e55-9992-ee0e5175712c.jpg", spoiler.getUrl());
assertEquals("SPOILER", spoiler.getTitle());
assertNull(spoiler.getDescription());
}
private static cgCache createCache(int index) {
- final MockedCache mockedCache = RegExPerformanceTest.MOCKED_CACHES[index];
+ final MockedCache mockedCache = RegExPerformanceTest.MOCKED_CACHES.get(index);
// to get the same results we have to use the date format used when the mocked data was created
String oldCustomDate = Settings.getGcCustomDate();
@@ -121,9 +150,28 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
"Station3: N51 21.444 / E07 02.600\r\nStation4: N51 21.789 / E07 02.800\r\nStation5: N51 21.667 / E07 02.800\r\nStation6: N51 21.444 / E07 02.706\r\nStation7: N51 21.321 / E07 02.700\r\nStation8: N51 21.123 / E07 02.477\r\nStation9: N51 21.734 / E07 02.500\r\nStation10: N51 21.733 / E07 02.378\r\nFinal: N51 21.544 / E07 02.566");
}
+ @MediumTest
+ public static void testEditModifiedCoordinates() {
+ cgCache cache = new cgCache();
+ cache.setGeocode("GC2ZN4G");
+ // upload coordinates
+ GCParser.editModifiedCoordinates(cache, new Geopoint("N51 21.544", "E07 02.566"));
+ cache.drop(new Handler());
+ String page = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0");
+ cgCache cache2 = GCParser.parseCacheFromText(page, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY);
+ assertTrue(cache2.hasUserModifiedCoords());
+ assertEquals(new Geopoint("N51 21.544", "E07 02.566"), cache2.getCoords());
+ // delete coordinates
+ GCParser.deleteModifiedCoordinates(cache2);
+ cache2.drop(new Handler());
+ String page2 = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0");
+ cgCache cache3 = GCParser.parseCacheFromText(page2, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY);
+ assertFalse(cache3.hasUserModifiedCoords());
+ }
+
private static void assertWaypointsFromNote(final cgCache cache, Geopoint[] expected, String note) {
cache.setPersonalNote(note);
- cache.setWaypoints(new ArrayList<cgWaypoint>(), false);
+ cache.setWaypoints(new ArrayList<Waypoint>(), false);
cache.parseWaypointsFromNote();
assertEquals(expected.length, cache.getWaypoints().size());
for (int i = 0; i < expected.length; i++) {
diff --git a/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java b/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java
index 3fa17f8..af5d1bc 100644
--- a/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java
@@ -15,10 +15,10 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
final Bitmap bitmap = getBitmap(R.raw.tile14);
Log.d("Bitmap=" + bitmap.getWidth() + "x" + bitmap.getHeight());
- assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 97, 136, 14).getType());
- assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 226, 104, 14).getType());
- assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 54, 97, 14).getType());
- assertTrue(parseMapPNG(bitmap, 119, 108, 14).isFound());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 88, 124, 14).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 228, 104, 14).getType());
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 52, 92, 14).getType());
+ assertTrue(parseMapPNG(bitmap, 108, 112, 14).isFound());
}
private Bitmap getBitmap(int resourceId) {
@@ -58,7 +58,7 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
int mystery = 0;
mystery = parseMapPNG(bitmap, 37, 25, 12).getType() == CacheType.MYSTERY ? mystery + 1 : mystery;
mystery = parseMapPNG(bitmap, 49, 183, 12).getType() == CacheType.MYSTERY ? mystery + 1 : mystery;
- mystery = parseMapPNG(bitmap, 183, 181, 12).getType() == CacheType.MYSTERY ? mystery + 1 : mystery;
+ mystery = parseMapPNG(bitmap, 184, 181, 12).getType() == CacheType.MYSTERY ? mystery + 1 : mystery;
mystery = parseMapPNG(bitmap, 176, 94, 12).getType() == CacheType.MYSTERY ? mystery + 1 : mystery;
mystery = parseMapPNG(bitmap, 161, 124, 12).getType() == CacheType.MYSTERY ? mystery + 1 : mystery;
mystery = parseMapPNG(bitmap, 168, 118, 12).getType() == CacheType.MYSTERY ? mystery + 1 : mystery;
@@ -73,9 +73,351 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
tradi = parseMapPNG(bitmap, 117, 225, 12).getType() == CacheType.TRADITIONAL ? tradi + 1 : tradi;
tradi = parseMapPNG(bitmap, 90, 107, 12).getType() == CacheType.TRADITIONAL ? tradi + 1 : tradi;
+ int found = 0;
+ found = parseMapPNG(bitmap, 150, 124, 12).isFound() ? found + 1 : found;
+ found = parseMapPNG(bitmap, 176, 82, 12).isFound() ? found + 1 : found;
+ found = parseMapPNG(bitmap, 240, 140, 12).isFound() ? found + 1 : found;
+ found = parseMapPNG(bitmap, 211, 127, 12).isFound() ? found + 1 : found;
+
assertEquals(7, multi);
assertEquals(7, mystery);
assertEquals(7, tradi);
+ assertEquals(4, found);
+ }
+
+ public void testParseExtraMap1() {
+ final Bitmap bitmap = getBitmap(R.raw.map1);
+ assertTrue(parseMapPNG(bitmap, 128, 168, 12).isFound()); // GC3AT8B
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 172, 164, 12).getType()); // GC39EXB
+ assertTrue(parseMapPNG(bitmap, 164, 156, 12).isFound()); // GC30M7M
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 204, 72, 12).getType()); // GC3AN5Z
+ assertTrue(parseMapPNG(bitmap, 188, 92, 12).isFound()); // GC37T3R
+ assertTrue(parseMapPNG(bitmap, 164, 132, 12).isFound()); // GC34JME
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 176, 148, 12).getType()); // GC37TCY
+ assertEquals(CacheType.EARTH, parseMapPNG(bitmap, 180, 136, 12).getType()); // GC3947Z
+ assertTrue(parseMapPNG(bitmap, 164, 100, 12).isFound()); // GC2ZY3X
+ assertTrue(parseMapPNG(bitmap, 52, 104, 12).isFound()); // GC29RCW
+ assertTrue(parseMapPNG(bitmap, 168, 88, 12).isFound()); // GC264JZ
+ assertTrue(parseMapPNG(bitmap, 168, 140, 12).isFound()); // GC37RRV
+ }
+
+ public void testParseExtraMap2() {
+ final Bitmap bitmap = getBitmap(R.raw.map2);
+
+ assertTrue(parseMapPNG(bitmap, 132, 136, 12).isFound()); // GC3JDBW
+ assertTrue(parseMapPNG(bitmap, 68, 24, 12).isFound()); // GC2T0AH
+ assertTrue(parseMapPNG(bitmap, 176, 232, 12).isOwn()); // GC2RPBX
+ assertTrue(parseMapPNG(bitmap, 148, 60, 12).isFound()); // GC31FY6
+ assertTrue(parseMapPNG(bitmap, 216, 20, 12).isFound()); // GC2KP3M
+ assertTrue(parseMapPNG(bitmap, 212, 184, 12).isOwn()); // GC30W3K
+ assertTrue(parseMapPNG(bitmap, 148, 72, 12).isOwn()); // GC2RPAZ
+ assertTrue(parseMapPNG(bitmap, 216, 48, 12).isOwn()); // GC2RP8W
+ assertTrue(parseMapPNG(bitmap, 212, 60, 12).isFound()); // GC3CC97
+ assertTrue(parseMapPNG(bitmap, 148, 100, 12).isOwn()); // GC2RPAT
+ assertTrue(parseMapPNG(bitmap, 104, 136, 12).isFound()); // GC3AE31
+ assertTrue(parseMapPNG(bitmap, 52, 96, 12).isOwn()); // GC2RPCH
+ assertTrue(parseMapPNG(bitmap, 172, 156, 12).isOwn()); // GC2RQ07
+ assertTrue(parseMapPNG(bitmap, 116, 56, 12).isFound()); // GC3AYR2
+ assertTrue(parseMapPNG(bitmap, 208, 68, 12).isOwn()); // GC2RP93
+ assertTrue(parseMapPNG(bitmap, 200, 52, 12).isOwn()); // GC2RPAA
+ assertTrue(parseMapPNG(bitmap, 208, 44, 12).isFound()); // GC3HE15
+ assertTrue(parseMapPNG(bitmap, 112, 76, 12).isOwn()); // GC2RPBE
+ assertTrue(parseMapPNG(bitmap, 232, 192, 12).isOwn()); // GC2E1KF
+ assertTrue(parseMapPNG(bitmap, 184, 76, 12).isFound()); // GC2NK5R
+ assertTrue(parseMapPNG(bitmap, 132, 148, 12).isOwn()); // GC2RPBC
+ }
+
+ public void testParseExtraMap3() {
+ final Bitmap bitmap = getBitmap(R.raw.map3);
+
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 44, 0, 12).getType()); // GC1THF5
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 176, 100, 12).getType()); // GC29EGE
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 212, 128, 12).getType()); // GC1VR64
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 220, 56, 12).getType()); // GC1M13A
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 120, 80, 12).getType()); // GC1ZA2Z
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 148, 56, 12).getType()); // GC1MRD8
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 252, 8, 12).getType()); // GC3AGEX
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 76, 108, 12).getType()); // GC2C5RB
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 228, 188, 12).getType()); // GC33TWE
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 232, 128, 12).getType()); // GC38QDJ
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 228, 160, 12).getType()); // GC2G8M1
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 184, 64, 12).getType()); // GC2FYH4
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 60, 132, 12).getType()); // GC299CV
+ assertEquals(CacheType.EVENT, parseMapPNG(bitmap, 244, 124, 12).getType()); // GC3E5FW
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 160, 12).getType()); // GC29NR9
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 216, 116, 12).getType()); // GC17P5R
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 144, 92, 12).getType()); // GC1WYN3
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 80, 4, 12).getType()); // GC2Z90W
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 216, 148, 12).getType()); // GC29M3P
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 176, 148, 12).getType()); // GC2HJ88
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 68, 72, 12).getType()); // GC1VRB4
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 100, 12).getType()); // GC29EG4
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 68, 12).getType()); // GC2YXH8
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 248, 156, 12).getType()); // GC1F277
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 208, 80, 12).getType()); // GC2NV6T
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 60, 92, 12).getType()); // GC2Y2YY
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 188, 168, 12).getType()); // GC26RT7
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 224, 124, 12).getType()); // GC1ZBPC
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 144, 80, 12).getType()); // GC29NQJ
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 192, 124, 12).getType()); // GC1QRAP
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 104, 116, 12).getType()); // GC29NR1
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 240, 44, 12).getType()); // GC35KYR
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 168, 0, 12).getType()); // GC1VR78
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 200, 84, 12).getType()); // GC2YR8Z
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 52, 160, 12).getType()); // GC1MTD8
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 236, 156, 12).getType()); // GCYW8A
+
+ }
+
+ public void testParseExtraMap4() {
+ final Bitmap bitmap = getBitmap(R.raw.map4);
+
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 124, 84, 12).getType()); // GC2M3CD
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 92, 140, 12).getType()); // GC1W2A2
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 156, 108, 12).getType()); // GC3FR70
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 44, 72, 12).getType()); // GC10W91
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 104, 36, 12).getType()); // GCRC1W
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 88, 36, 12).getType()); // GC30PQF
+ assertTrue(parseMapPNG(bitmap, 116, 36, 12).isFound()); // GC17VWA
+ assertEquals(CacheType.EARTH, parseMapPNG(bitmap, 28, 56, 12).getType()); // GC1E6A6
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 96, 72, 12).getType()); // GCMVAC
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 140, 48, 12).getType()); // GCZPE4
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 88, 84, 12).getType()); // GC16G8B
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 116, 48, 12).getType()); // GCZPEB
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 148, 8, 12).getType()); // GC19QQ4
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 68, 124, 12).getType()); // GCXJGD
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 88, 156, 12).getType()); // GC1VNAE
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 24, 24, 12).getType()); // GC1AY4H
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 180, 60, 12).getType()); // GC3K4HB
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 56, 104, 12).getType()); // GC2M4EH
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 12, 132, 12).getType()); // GC2B92G
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 240, 180, 12).getType()); // GC2YJ88
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 220, 140, 12).getType()); // GC2AWBC
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 124, 44, 12).getType()); // GC16V66
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 116, 104, 12).getType()); // GC2MN5V
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 212, 4, 12).getType()); // GC3BF7V
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 168, 40, 12).getType()); // GC1PB21
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 252, 56, 12).getType()); // GC22VTB
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 108, 64, 12).getType()); // GCVE3B
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 20, 140, 12).getType()); // GC1R041
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 124, 244, 12).getType()); // GC3DWEA
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 240, 136, 12).getType()); // GC249ZE
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 124, 56, 12).getType()); // GC1X0XJ
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 56, 16, 12).getType()); // GC2ZVGB
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 164, 164, 12).getType()); // GC3D65W
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 240, 128, 12).getType()); // GC33KV9
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 244, 12).getType()); // GC21VT0
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 84, 24, 12).getType()); // GC1949K
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 104, 88, 12).getType()); // GC1FKZY
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 56, 248, 12).getType()); // GC2Y5Z4
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 72, 32, 12).getType()); // GC395J6
+ assertTrue(parseMapPNG(bitmap, 180, 4, 12).isFound()); // GC21MFG
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 96, 100, 12).getType()); // GC1W45E
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 144, 160, 12).getType()); // GC37BA1
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 12, 4, 12).getType()); // GC1K8KR
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 172, 92, 12).getType()); // GC3EZZ4
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 188, 132, 12).getType()); // GC26T9J
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 68, 192, 12).getType()); // GC1ZAMG
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 176, 180, 12).getType()); // GC21EZE
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 172, 76, 12).getType()); // GC1G5PT
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 208, 112, 12).getType()); // GC132VV
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 156, 40, 12).getType()); // GC264J4
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 252, 140, 12).getType()); // GC2JBNE
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 112, 76, 12).getType()); // GC16VKJ
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 16, 156, 12).getType()); // GC2ADX3
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 68, 48, 12).getType()); // GC2AZT1
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 176, 252, 12).getType()); // GC3DWNM
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 4, 156, 12).getType()); // GC30VHE
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 156, 120, 12).getType()); // GC1T9WM
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 40, 48, 12).getType()); // GC30MTZ
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 180, 232, 12).getType()); // GC2XVQA
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 72, 92, 12).getType()); // GC1VVA9
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 0, 132, 12).getType()); // GC1XNN4
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 92, 192, 12).getType()); // GC11D9P
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 52, 84, 12).getType()); // GC2M693
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 176, 196, 12).getType()); // GCZHVE
+ assertTrue(parseMapPNG(bitmap, 140, 108, 12).isFound()); // GC1Q5PW
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 108, 148, 12).getType()); // GC2ZR0C
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 168, 8, 12).getType()); // GCYWQH
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 196, 92, 12).getType()); // GC39VXN
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 148, 136, 12).getType()); // GC2MM6C
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 168, 28, 12).getType()); // GC2H1TG
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 240, 52, 12).getType()); // GC2QTXT
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 152, 148, 12).getType()); // GC3E7QD
+ assertTrue(parseMapPNG(bitmap, 160, 60, 12).isFound()); // GC2J3G9
+ assertTrue(parseMapPNG(bitmap, 160, 100, 12).isFound()); // GC2327G
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 136, 32, 12).getType()); // GC2JVEH
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 208, 164, 12).getType()); // GC1NN15
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 84, 244, 12).getType()); // GC3E5JP
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 172, 16, 12).getType()); // GC1Z581
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 104, 20, 12).getType()); // GC2MENX
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 144, 60, 12).getType()); // GC1V3MG
+ assertTrue(parseMapPNG(bitmap, 228, 56, 12).isFound()); // GC36WZN
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 144, 212, 12).getType()); // GCR9GB
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 180, 68, 12).getType()); // GC3JZ1K
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 228, 104, 12).getType()); // GCQ95T
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 84, 220, 12).getType()); // GCWTVM
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 228, 12).getType()); // GC3CC1A
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 204, 56, 12).getType()); // GC1K0WX
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 244, 208, 12).getType()); // GC1JVXG
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 84, 128, 12).getType()); // GC2XQ6C
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 248, 164, 12).getType()); // GC3B1JK
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 84, 12).getType()); // GC3AT8J
+ assertTrue(parseMapPNG(bitmap, 160, 88, 12).isFound()); // GC2MB4P
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 132, 20, 12).getType()); // GC2NW3F
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 56, 132, 12).getType()); // GC22ERA
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 28, 32, 12).getType()); // GC2EFFK
+ }
+
+ public void testParseExtraMap5() {
+ final Bitmap bitmap = getBitmap(R.raw.map5);
+
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 60, 32, 12).getType()); // GC31DNK
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 200, 120, 12).getType()); // GCP89K
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 144, 152, 12).getType()); // GC22AR8
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 164, 92, 12).getType()); // GC1MFB7
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 16, 212, 12).getType()); // GC12F2K
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 188, 12, 12).getType()); // GC24J14
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 36, 72, 12).getType()); // GC2J8MY
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 152, 140, 12).getType()); // GC1H9WQ
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 44, 40, 12).getType()); // GC31DNZ
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 8, 152, 12).getType()); // GC34YFB
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 216, 12).getType()); // GC30MK5
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 84, 20, 12).getType()); // GC304YY
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 192, 236, 12).getType()); // GC1D6AC
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 220, 48, 12).getType()); // GC1HQ8Y
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 136, 176, 12).getType()); // GC310B7
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 132, 232, 12).getType()); // GC12CR5
+ assertTrue(parseMapPNG(bitmap, 240, 40, 12).isFound()); // GC24GW1
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 140, 116, 12).getType()); // GC2YYE7
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 124, 144, 12).getType()); // GC111RZ
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 48, 128, 12).getType()); // GC13A7V
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 136, 92, 12).getType()); // GC2BKW9
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 184, 12).getType()); // GC30X0C
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 156, 200, 12).getType()); // GC17V4A
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 160, 120, 12).getType()); // GC2ZBWW
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 196, 36, 12).getType()); // GC14X25
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 192, 100, 12).getType()); // GC1HXAX
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 108, 168, 12).getType()); // GC3C043
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 28, 12).getType()); // GC1TEAR
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 204, 12).getType()); // GC3AKFV
+ assertTrue(parseMapPNG(bitmap, 228, 28, 12).isFound()); // GC2NMPR
+ //assertEquals(CacheType.VIRTUAL, parseMapPNG(bitmap, 232, 252, 12).getType()); // GC1AH0N - False detection
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 220, 188, 12).getType()); // GC1ZXDK
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 168, 212, 12).getType()); // GC3A919
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 152, 176, 12).getType()); // GC196WN
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 144, 180, 12).getType()); // GC12RE5
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 176, 116, 12).getType()); // GC1DY2M
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 44, 212, 12).getType()); // GC3MRNT
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 36, 12).getType()); // GC3CWZD
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 48, 160, 12).getType()); // GC1A8E3
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 8, 252, 12).getType()); // GC10W6W
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 60, 92, 12).getType()); // GC2D9DD
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 96, 164, 12).getType()); // GC1Z4QX
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 252, 12).getType()); // GCNEGK
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 32, 188, 12).getType()); // GC10916
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 204, 224, 12).getType()); // GC1CA2Y
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 120, 236, 12).getType()); // GC11B3J
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 248, 24, 12).getType()); // GCKX8C
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 128, 152, 12).getType()); // GC2V6AA
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 196, 48, 12).getType()); // GC2YG95
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 48, 64, 12).getType()); // GCHGR8
+ assertEquals(CacheType.EVENT, parseMapPNG(bitmap, 188, 96, 12).getType()); // GC3KBPK
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 208, 140, 12).getType()); // GC1C9B0
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 164, 100, 12).getType()); // GC29JGA
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 156, 28, 12).getType()); // GCN690
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 20, 12).getType()); // GC18Z53
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 152, 12).getType()); // GC18RB6
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 248, 12).getType()); // GC2378H
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 248, 244, 12).getType()); // GCV8QA
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 12, 232, 12).getType()); // GC2MXDG
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 48, 248, 12).getType()); // GCTHJR
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 216, 200, 12).getType()); // GC1EPM5
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 60, 12).getType()); // GC2N0PB
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 88, 56, 12).getType()); // GC1ZWNX
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 248, 56, 12).getType()); // GC1N11P
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 100, 180, 12).getType()); // GCM6AE
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 124, 12).getType()); // GC2A1RQ
+ assertTrue(parseMapPNG(bitmap, 212, 4, 12).isFound()); // GC1TVKE
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 28, 212, 12).getType()); // GC2A1RR
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 128, 84, 12).getType()); // GC16AWC
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 220, 16, 12).getType()); // GC282V9
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 112, 240, 12).getType()); // GC18VT5
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 80, 248, 12).getType()); // GC10YEK
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 224, 228, 12).getType()); // GC1EA70
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 244, 12).getType()); // GC14PNY
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 108, 32, 12).getType()); // GC2MMPN
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 144, 188, 12).getType()); // GC1CCF4
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 228, 208, 12).getType()); // GCV8C2
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 104, 252, 12).getType()); // GCTRPF
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 176, 92, 12).getType()); // GCRF8G
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 120, 140, 12).getType()); // GC210B9
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 204, 240, 12).getType()); // GC16NTW
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 192, 224, 12).getType()); // GC2PTVN
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 76, 116, 12).getType()); // GC1RPG0
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 144, 200, 12).getType()); // GC1FZ4T
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 172, 36, 12).getType()); // GC1ZYG8
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 248, 196, 12).getType()); // GC17FJQ
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 88, 140, 12).getType()); // GC1KWK0
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 168, 196, 12).getType()); // GC17MNG
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 20, 252, 12).getType()); // GC13M6V
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 120, 172, 12).getType()); // GC3B30A
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 104, 92, 12).getType()); // GC2GY9D
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 128, 120, 12).getType()); // GC2Y90M
+ assertTrue(parseMapPNG(bitmap, 204, 40, 12).isFound()); // GC1BZ6P
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 56, 76, 12).getType()); // GC10K7X
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 196, 108, 12).getType()); // GC1F0R5
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 120, 196, 12).getType()); // GC1KQQW
+ }
+
+ public void testParseExtraMap11() {
+ final Bitmap bitmap = getBitmap(R.raw.map11);
+ assertEquals(CacheType.EVENT, parseMapPNG(bitmap, 132, 16, 11).getType());
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 104, 48, 11).getType());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 128, 124, 11).getType());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 228, 8, 11).getType());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 160, 156, 11).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 208, 176, 11).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 252, 24, 11).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 216, 96, 11).getType());
+ assertEquals(CacheType.EARTH, parseMapPNG(bitmap, 24, 212, 11).getType());
+ }
+
+ public void testParseExtraMapall14() {
+ final Bitmap bitmap = getBitmap(R.raw.map_all14);
+ assertTrue(parseMapPNG(bitmap, 40, 16, 14).isFound());
+ assertTrue(parseMapPNG(bitmap, 72, 16, 14).isFound());
+ assertTrue(parseMapPNG(bitmap, 100, 16, 14).isFound());
+ assertTrue(parseMapPNG(bitmap, 128, 16, 14).isFound());
+ assertTrue(parseMapPNG(bitmap, 44, 44, 14).isOwn());
+ assertTrue(parseMapPNG(bitmap, 76, 44, 14).isOwn());
+ assertTrue(parseMapPNG(bitmap, 132, 44, 14).isOwn());
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 40, 72, 14).getType());
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 72, 72, 14).getType());
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 100, 72, 14).getType());
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 128, 72, 14).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 40, 96, 14).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 72, 96, 14).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 100, 96, 14).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 128, 96, 14).getType());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 40, 124, 14).getType());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 72, 124, 14).getType());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 100, 124, 14).getType());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 128, 124, 14).getType());
+ assertEquals(CacheType.WHERIGO, parseMapPNG(bitmap, 40, 160, 14).getType());
+ assertEquals(CacheType.WHERIGO, parseMapPNG(bitmap, 72, 160, 14).getType());
+ assertEquals(CacheType.WHERIGO, parseMapPNG(bitmap, 100, 160, 14).getType());
+ assertEquals(CacheType.WHERIGO, parseMapPNG(bitmap, 128, 160, 14).getType());
+ assertEquals(CacheType.LETTERBOX, parseMapPNG(bitmap, 40, 184, 14).getType());
+ assertEquals(CacheType.LETTERBOX, parseMapPNG(bitmap, 72, 184, 14).getType());
+ assertEquals(CacheType.LETTERBOX, parseMapPNG(bitmap, 100, 184, 14).getType());
+ assertEquals(CacheType.LETTERBOX, parseMapPNG(bitmap, 128, 184, 14).getType());
+ assertEquals(CacheType.CITO, parseMapPNG(bitmap, 12, 224, 14).getType());
+ assertEquals(CacheType.EVENT, parseMapPNG(bitmap, 40, 220, 14).getType());
+ assertEquals(CacheType.EARTH, parseMapPNG(bitmap, 68, 224, 14).getType());
+ assertEquals(CacheType.MEGA_EVENT, parseMapPNG(bitmap, 96, 224, 14).getType());
+ assertEquals(CacheType.WEBCAM, parseMapPNG(bitmap, 120, 224, 14).getType());
+ assertEquals(CacheType.VIRTUAL, parseMapPNG(bitmap, 144, 224, 14).getType());
}
}
diff --git a/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java b/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java
index 319a3b2..ea430ac 100644
--- a/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java
@@ -1,8 +1,10 @@
package cgeo.geocaching.connector.gc;
+import cgeo.geocaching.Image;
import cgeo.geocaching.LogEntry;
import cgeo.geocaching.TrackableLog;
-import cgeo.geocaching.cgTrackable;
+import cgeo.geocaching.Trackable;
+import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
import cgeo.geocaching.test.R;
import cgeo.geocaching.utils.BaseUtils;
@@ -27,36 +29,50 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase {
}
public void testTrackable() {
- final cgTrackable trackable = getTB2R124();
+ final Trackable trackable = getTB2R124();
assertEquals("TB2R124", trackable.getGeocode());
assertEquals("Bor. Dortmund - FC Schalke 04", trackable.getName());
assertEquals("Spiridon Lui", trackable.getOwner());
}
public void testTrackableWithoutImage() {
- final cgTrackable trackable = getTB2R124();
+ final Trackable trackable = getTB2R124();
assertNull(trackable.getImage());
assertNotNull(trackable.getDetails());
}
public void testTrackableWithLogImages() {
- final cgTrackable trackable = getTBXATG();
+ final Trackable trackable = getTBXATG();
assertEquals("TBXATG", trackable.getGeocode());
List<LogEntry> log = trackable.getLogs();
- // second log entry has several images; just check first two
- assertEquals("http://img.geocaching.com/track/log/large/f2e24c50-394c-4d74-8fb4-87298d8bff1d.jpg", log.get(4).getLogImages().get(0).getUrl());
- assertEquals("7b Welcome to Geowoodstock", log.get(4).getLogImages().get(0).getTitle());
- assertEquals("http://img.geocaching.com/track/log/large/b57c29c3-134e-4202-a2a1-69ce8920b055.jpg", log.get(4).getLogImages().get(1).getUrl());
- assertEquals("8 Crater Lake Natl Park Oregon", log.get(4).getLogImages().get(1).getTitle());
+ assertNotNull(log);
+ assertEquals(10, log.size());
+ // log entry 4 has several images; just check first two
+
+ final List<Image> log4Images = log.get(4).getLogImages();
+ assertNotNull(log4Images);
+ assertEquals(5, log4Images.size());
+ assertEquals("http://img.geocaching.com/track/log/large/f2e24c50-394c-4d74-8fb4-87298d8bff1d.jpg", log4Images.get(0).getUrl());
+ assertEquals("7b Welcome to Geowoodstock", log4Images.get(0).getTitle());
+ assertEquals("http://img.geocaching.com/track/log/large/b57c29c3-134e-4202-a2a1-69ce8920b055.jpg", log4Images.get(1).getUrl());
+ assertEquals("8 Crater Lake Natl Park Oregon", log4Images.get(1).getTitle());
// third log entry has one image
- assertEquals("http://img.geocaching.com/track/log/large/0096b42d-4d10-45fa-9be2-2d08c0d5cc61.jpg", log.get(5).getLogImages().get(0).getUrl());
- assertEquals("Traverski&#39;s GC Univ coin on tour", log.get(5).getLogImages().get(0).getTitle());
+ final List<Image> log5Images = log.get(5).getLogImages();
+ assertNotNull(log5Images);
+ assertEquals(1, log5Images.size());
+ assertEquals("http://img.geocaching.com/track/log/large/0096b42d-4d10-45fa-9be2-2d08c0d5cc61.jpg", log5Images.get(0).getUrl());
+ assertEquals("Traverski&#39;s GC Univ coin on tour", log5Images.get(0).getTitle());
+
+ for (LogEntry entry : log) {
+ assertFalse(entry.log.startsWith("<div>"));
+ }
+ assertEquals("traveling", log.get(0).log);
}
public void testParseTrackableWithoutReleaseDate() {
- cgTrackable trackable = GCParser.parseTrackable(getFileContent(R.raw.tb14wfv), null);
+ Trackable trackable = parseTrackable(R.raw.tb14wfv);
assertNotNull(trackable);
assertEquals("The Brickster", trackable.getName());
assertEquals("Adrian C", trackable.getOwner());
@@ -69,7 +85,7 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase {
}
public void testParseRelativeLink() {
- final cgTrackable trackable = GCParser.parseTrackable(getFileContent(R.raw.tb4cwjx), null);
+ final Trackable trackable = parseTrackable(R.raw.tb4cwjx);
assertNotNull(trackable);
assertEquals("The Golden Lisa", trackable.getName());
final String goal = trackable.getGoal();
@@ -78,16 +94,31 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase {
assertTrue(goal.contains("href=\"http://www.geocaching.com/seek/cache_details.aspx?wp=GC3B7PD#\""));
}
- private cgTrackable getTB2R124() {
- return GCParser.parseTrackable(BaseUtils.replaceWhitespace(getFileContent(R.raw.trackable_tb2r124)), null);
+ private Trackable parseTrackable(int trackablePage) {
+ String pageContent = getFileContent(trackablePage);
+ return GCParser.parseTrackable(BaseUtils.replaceWhitespace(pageContent), null);
}
- private cgTrackable getTBXATG() {
- return GCParser.parseTrackable(BaseUtils.replaceWhitespace(getFileContent(R.raw.trackable_tbxatg)), null);
+ public void testParseMarkMissing() {
+ final Trackable trackable = parseTrackable(R.raw.tb29ggq);
+ assertNotNull(trackable);
+ final List<LogEntry> logs = trackable.getLogs();
+ assertNotNull(logs);
+ assertFalse(logs.isEmpty());
+ LogEntry marked = logs.get(4);
+ assertEquals(LogType.MARKED_MISSING, marked.type);
+ }
+
+ private Trackable getTB2R124() {
+ return parseTrackable(R.raw.trackable_tb2r124);
+ }
+
+ private Trackable getTBXATG() {
+ return parseTrackable(R.raw.trackable_tbxatg);
}
public void testParseTrackableNotExisting() {
- cgTrackable trackable = GCParser.parseTrackable(getFileContent(R.raw.tb_not_existing), null);
+ Trackable trackable = GCParser.parseTrackable(getFileContent(R.raw.tb_not_existing), null);
assertNull(trackable);
}
diff --git a/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java
index 5576028..0519b58 100644
--- a/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java
+++ b/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java
@@ -2,7 +2,7 @@ package cgeo.geocaching.connector.opencaching;
import cgeo.CGeoTestCase;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.cgData;
import cgeo.geocaching.connector.oc.OkapiClient;
import cgeo.geocaching.enumerations.LoadFlags;
@@ -15,9 +15,8 @@ public class OkapiClientTest extends CGeoTestCase {
assertEquals(geoCode, cache.getGeocode());
assertEquals("Oshkosh Municipal Tank", cache.getName());
assertTrue(cache.isDetailed());
-
// cache should be stored to DB (to listID 0) when loaded above
- cache = cgeoapplication.getInstance().loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY);
+ cache = cgData.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY);
assertNotNull(cache);
assertEquals(geoCode, cache.getGeocode());
assertEquals("Oshkosh Municipal Tank", cache.getName());
diff --git a/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java b/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java
index c872c9d..9c3063d 100644
--- a/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java
+++ b/tests/src/cgeo/geocaching/enumerations/CacheSizeTest.java
@@ -2,6 +2,8 @@ package cgeo.geocaching.enumerations;
import android.test.AndroidTestCase;
+import java.util.Locale;
+
public class CacheSizeTest extends AndroidTestCase {
public static void testOrder() {
@@ -15,13 +17,14 @@ public class CacheSizeTest extends AndroidTestCase {
assertEquals(CacheSize.UNKNOWN, CacheSize.getById(null));
assertEquals(CacheSize.UNKNOWN, CacheSize.getById("random garbage"));
assertEquals(CacheSize.LARGE, CacheSize.getById("large"));
+ assertEquals(CacheSize.LARGE, CacheSize.getById("LARGE"));
}
public static void testGetByIdComplete() {
for (CacheSize size : CacheSize.values()) {
assertEquals(size, CacheSize.getById(size.id));
- assertEquals(size, CacheSize.getById(size.id.toLowerCase()));
- assertEquals(size, CacheSize.getById(size.id.toUpperCase()));
+ assertEquals(size, CacheSize.getById(size.id.toLowerCase(Locale.US)));
+ assertEquals(size, CacheSize.getById(size.id.toUpperCase(Locale.US)));
}
}
}
diff --git a/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java b/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java
index dd35669..21e97c0 100644
--- a/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java
+++ b/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java
@@ -2,6 +2,8 @@ package cgeo.geocaching.enumerations;
import android.test.AndroidTestCase;
+import java.util.Locale;
+
public class CacheTypeTest extends AndroidTestCase {
public static void testGetById() {
@@ -21,16 +23,16 @@ public class CacheTypeTest extends AndroidTestCase {
public static void testGetByIdComplete() {
for (CacheType type : CacheType.values()) {
assertEquals(type, CacheType.getById(type.id));
- assertEquals(type, CacheType.getById(type.id.toLowerCase()));
- assertEquals(type, CacheType.getById(type.id.toUpperCase()));
+ assertEquals(type, CacheType.getById(type.id.toLowerCase(Locale.US)));
+ assertEquals(type, CacheType.getById(type.id.toUpperCase(Locale.US)));
}
}
public static void testGetByPatternComplete() {
for (CacheType type : CacheType.values()) {
assertEquals(type, CacheType.getByPattern(type.pattern));
- assertEquals(type, CacheType.getByPattern(type.pattern.toLowerCase()));
- assertEquals(type, CacheType.getByPattern(type.pattern.toUpperCase()));
+ assertEquals(type, CacheType.getByPattern(type.pattern.toLowerCase(Locale.US)));
+ assertEquals(type, CacheType.getByPattern(type.pattern.toUpperCase(Locale.US)));
}
}
}
diff --git a/tests/src/cgeo/geocaching/enumerations/LogTypeTest.java b/tests/src/cgeo/geocaching/enumerations/LogTypeTest.java
index 44f464e..81ca33b 100644
--- a/tests/src/cgeo/geocaching/enumerations/LogTypeTest.java
+++ b/tests/src/cgeo/geocaching/enumerations/LogTypeTest.java
@@ -19,7 +19,8 @@ public class LogTypeTest extends AndroidTestCase {
public static void testGetByType() {
assertEquals(LogType.UNKNOWN, LogType.getByIconName(""));
assertEquals(LogType.UNKNOWN, LogType.getByIconName(null));
- assertEquals(LogType.GRABBED_IT, LogType.getByType("grabbed IT "));
+ assertEquals(LogType.GRABBED_IT, LogType.getByType("grabbed it"));
+ assertEquals(LogType.GRABBED_IT, LogType.getByType(" gRAbbed IT "));
}
}
diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
index da99c11..8c05ee0 100644
--- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
@@ -3,7 +3,7 @@ package cgeo.geocaching.files;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.cgData;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LoadFlags;
import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
@@ -71,8 +71,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertEquals(GPXImporter.IMPORT_STEP_FINISHED, iMsg.next().what);
SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj;
assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes()));
-
- cgCache cache = cgeoapplication.getInstance().loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
+ cgCache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
assertTrue(cache.getWaypoints().isEmpty());
@@ -99,8 +98,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj;
assertEquals(Collections.singletonList("GC31J2H"), new ArrayList<String>(search.getGeocodes()));
-
- cgCache cache = cgeoapplication.getInstance().loadCache("GC31J2H", LoadFlags.LOAD_CACHE_OR_DB);
+ cgCache cache = cgData.loadCache("GC31J2H", LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
assertEquals(2, cache.getWaypoints().size());
}
@@ -113,8 +111,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
runImportThread(importThread);
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
-
- final cgCache cache = cgeoapplication.getInstance().loadCache("AID1", LoadFlags.LOAD_CACHE_OR_DB);
+ final cgCache cache = cgData.loadCache("AID1", LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
assertEquals("First Aid Station #1", cache.getName());
}
@@ -136,8 +133,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj;
assertEquals(Collections.singletonList("OC5952"), new ArrayList<String>(search.getGeocodes()));
-
- cgCache cache = cgeoapplication.getInstance().loadCache("OC5952", LoadFlags.LOAD_CACHE_OR_DB);
+ cgCache cache = cgData.loadCache("OC5952", LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
}
@@ -179,8 +175,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj;
assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes()));
-
- cgCache cache = cgeoapplication.getInstance().loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
+ cgCache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
assertTrue(cache.getWaypoints().isEmpty());
@@ -198,8 +193,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj;
assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes()));
-
- cgCache cache = cgeoapplication.getInstance().loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
+ cgCache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
assertEquals(1, cache.getWaypoints().size()); // this is the original pocket query result without test waypoint
}
@@ -225,8 +219,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED);
SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj;
assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes()));
-
- cgCache cache = cgeoapplication.getInstance().loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
+ cgCache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
assertCacheProperties(cache);
assertEquals(1, cache.getWaypoints().size()); // this is the original pocket query result without test waypoint
}
@@ -266,10 +259,9 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
tempDir = new File(System.getProperty("java.io.tmpdir"), "cgeogpxesTest");
tempDir.mkdir();
-
// workaround to get storage initialized
- cgeoapplication.getInstance().getAllHistoricCachesCount();
- listId = cgeoapplication.getInstance().createList("cgeogpxesTest");
+ cgData.getAllHistoryCachesCount();
+ listId = cgData.createList("cgeogpxesTest");
importCacheStaticMaps = Settings.isStoreOfflineMaps();
Settings.setStoreOfflineMaps(true);
@@ -279,11 +271,11 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
@Override
protected void tearDown() throws Exception {
- SearchResult search = cgeoapplication.getInstance().getBatchOfStoredCaches(false, null, CacheType.ALL, listId);
+ SearchResult search = cgData.getBatchOfStoredCaches(null, CacheType.ALL, listId);
List<cgCache> cachesInList = new ArrayList<cgCache>();
cachesInList.addAll(search.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB));
- cgeoapplication.getInstance().markDropped(cachesInList);
- cgeoapplication.getInstance().removeList(listId);
+ cgData.markDropped(cachesInList);
+ cgData.removeList(listId);
deleteDirectory(tempDir);
Settings.setStoreOfflineMaps(importCacheStaticMaps);
Settings.setStoreOfflineWpMaps(importWpStaticMaps);
diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index c195953..db29813 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -4,8 +4,8 @@ import cgeo.geocaching.LogEntry;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.StoredList;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
-import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.cgData;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LoadFlags;
@@ -24,10 +24,11 @@ import java.util.Collection;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
- private static final SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); // 2010-04-20T07:00:00Z
+ private static final SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); // 2010-04-20T07:00:00Z
private int listId;
public void testGPXVersion100() throws Exception {
@@ -166,7 +167,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
private static void assertGc31j2hWaypoints(final cgCache cache) {
assertNotNull(cache.getWaypoints());
assertEquals(2, cache.getWaypoints().size());
- cgWaypoint wp = cache.getWaypoints().get(0);
+ Waypoint wp = cache.getWaypoints().get(0);
assertEquals("GC31J2H", wp.getGeocode());
assertEquals("00", wp.getPrefix());
assertEquals("---", wp.getLookup());
@@ -212,29 +213,19 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
}
}
// reload caches, because the parser only returns the minimum version of each cache
- return new ArrayList<cgCache>(cgeoapplication.getInstance().loadCaches(result, LoadFlags.LOAD_ALL_DB_ONLY));
+ return new ArrayList<cgCache>(cgData.loadCaches(result, LoadFlags.LOAD_ALL_DB_ONLY));
}
- public static void testParseDateWithFractionalSeconds() {
+ public static void testParseDateWithFractionalSeconds() throws ParseException {
// was experienced in GSAK file
final String dateString = "2011-08-13T02:52:18.103Z";
- try {
- GPXParser.parseDate(dateString);
- } catch (ParseException e) {
- fail();
- e.printStackTrace();
- }
+ GPXParser.parseDate(dateString);
}
- public static void testParseDateWithHugeFraction() {
+ public static void testParseDateWithHugeFraction() throws ParseException {
// see issue 821
String dateString = "2011-11-07T00:00:00.0000000-07:00";
- try {
- GPXParser.parseDate(dateString);
- } catch (ParseException e) {
- fail();
- e.printStackTrace();
- }
+ GPXParser.parseDate(dateString);
}
public void testSelfmadeGPXWithoutGeocodes() throws Exception {
@@ -265,10 +256,9 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
removeCacheCompletely(geocode);
final List<cgCache> caches = readGPX10(R.raw.lazy);
assertEquals(1, caches.size());
- cgeoapplication.getInstance().removeAllFromCache();
-
+ cgData.removeAllFromCache();
// load only the minimum cache, it has several members missing
- final cgCache minimalCache = cgeoapplication.getInstance().loadCache(geocode, EnumSet.of(LoadFlag.LOAD_DB_MINIMAL));
+ final cgCache minimalCache = cgData.loadCache(geocode, EnumSet.of(LoadFlag.LOAD_DB_MINIMAL));
// now check that we load lazy members on demand
assertFalse(minimalCache.getAttributes().isEmpty());
@@ -297,17 +287,17 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- listId = cgeoapplication.getInstance().createList("Temporary unit testing");
+ listId = cgData.createList("Temporary unit testing");
assertTrue(listId != StoredList.TEMPORARY_LIST_ID);
assertTrue(listId != StoredList.STANDARD_LIST_ID);
}
@Override
protected void tearDown() throws Exception {
- SearchResult search = cgeoapplication.getInstance().getBatchOfStoredCaches(false, null, CacheType.ALL, listId);
+ SearchResult search = cgData.getBatchOfStoredCaches(null, CacheType.ALL, listId);
assertNotNull(search);
- cgeoapplication.getInstance().removeCaches(search.getGeocodes(), LoadFlags.REMOVE_ALL);
- cgeoapplication.getInstance().removeList(listId);
+ cgData.removeCaches(search.getGeocodes(), LoadFlags.REMOVE_ALL);
+ cgData.removeList(listId);
super.tearDown();
}
}
diff --git a/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java b/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java
new file mode 100644
index 0000000..2578efa
--- /dev/null
+++ b/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java
@@ -0,0 +1,84 @@
+package cgeo.geocaching.files;
+
+import com.jayway.android.robotium.solo.Solo;
+
+import android.annotation.TargetApi;
+import android.os.Build;
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.suitebuilder.annotation.Suppress;
+import android.widget.CheckBox;
+
+import java.util.ArrayList;
+
+@TargetApi(Build.VERSION_CODES.FROYO)
+@Suppress() /* This test breaks the continuous integration server, do not run it for now. */
+public class SimpleDirChooserUITest extends ActivityInstrumentationTestCase2<SimpleDirChooser> {
+
+ private Solo solo;
+
+ public SimpleDirChooserUITest() {
+ super(SimpleDirChooser.class);
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ solo = new Solo(getInstrumentation(), getActivity());
+ }
+
+ public void testSingleSelection() throws InterruptedException {
+ // normally our activity should be ready, but we already had Jenkins report no checkboxes right here at the beginning
+ solo.waitForActivity(solo.getCurrentActivity().getClass().getSimpleName(), 2000);
+
+ assertChecked("Newly opened activity", 0);
+ solo.scrollToBottom();
+ pause();
+ // according to the documentation, automatic pauses only happen in the clickXYZ() methods.
+ // Therefore lets introduce a manual pause after the scrolling methods.
+
+ final int lastIndex = solo.getCurrentCheckBoxes().size() - 1;
+
+ solo.clickOnCheckBox(lastIndex);
+ assertTrue(solo.getCurrentCheckBoxes().get(lastIndex).isChecked());
+ assertFalse(solo.getCurrentCheckBoxes().get(0).isChecked());
+ assertChecked("Clicked last checkbox", 1);
+
+ solo.scrollUp();
+ pause();
+ solo.scrollToBottom();
+ pause();
+ assertChecked("Refreshing last checkbox", 1);
+
+ solo.scrollToTop();
+ pause();
+ solo.clickOnCheckBox(0);
+ assertChecked("Clicked first checkbox", 1);
+ assertTrue(solo.getCurrentCheckBoxes().get(0).isChecked());
+ solo.clickOnCheckBox(1);
+ assertChecked("Clicked second checkbox", 1);
+ assertTrue(solo.getCurrentCheckBoxes().get(1).isChecked());
+ }
+
+ private static void pause() throws InterruptedException {
+ Thread.sleep(500);
+ }
+
+ private void assertChecked(String message, int expectedChecked) {
+ int checked = 0;
+ final ArrayList<CheckBox> boxes = solo.getCurrentCheckBoxes();
+ assertNotNull("Could not get checkboxes", boxes);
+ assertTrue("There are no checkboxes", boxes.size() > 1);
+ for (CheckBox checkBox : boxes) {
+ if (checkBox.isChecked()) {
+ checked++;
+ }
+ }
+ assertEquals(message, expectedChecked, checked);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ solo.finishOpenedActivities();
+ super.tearDown();
+ }
+}
diff --git a/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java b/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
index 44fbe18..6b70523 100644
--- a/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
@@ -28,7 +28,7 @@ public class GeoPointParserTest extends AndroidTestCase {
} catch (Geopoint.ParseException e) {
// expected
}
- assertEquals(null, point);
+ assertNull(point);
}
@@ -55,7 +55,7 @@ public class GeoPointParserTest extends AndroidTestCase {
final Geopoint p2 = GeopointParser.parse("N51 21.523", "E07 02.680");
assertNotNull(p1);
assertNotNull(p2);
- assertTrue(p1.equals(p2));
+ assertEquals(p1, p2);
}
public static void testUnrelatedParts() {
@@ -65,7 +65,7 @@ public class GeoPointParserTest extends AndroidTestCase {
} catch (Geopoint.ParseException e) {
// expected
}
- assertEquals(null, point);
+ assertNull(point);
}
public static void testComma() {
@@ -75,6 +75,15 @@ public class GeoPointParserTest extends AndroidTestCase {
"E 15° 53' 41.68''");
assertNotNull(pointComma);
assertNotNull(pointDot);
- assertTrue(pointComma.equals(pointDot));
+ assertEquals(pointComma, pointDot);
}
+
+ public static void testBlankAddedByAutocorrectionDot() {
+ assertEquals(refLatitude, GeopointParser.parseLatitude("N 49° 56. 031"), 1e-8);
+ }
+
+ public static void testBlankAddedByAutocorrectionComma() {
+ assertEquals(refLatitude, GeopointParser.parseLatitude("N 49° 56, 031"), 1e-8);
+ }
+
}
diff --git a/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java b/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java
index fa3b16c..98c77fd 100644
--- a/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java
+++ b/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java
@@ -13,13 +13,7 @@ public class NameComparatorTest extends AndroidTestCase {
}
}
- private NameComparator comp;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- comp = new NameComparator();
- }
+ private NameComparator comp = new NameComparator();
public void testLexical() {
assertSorted(new NamedCache("A"), new NamedCache("Z"));
diff --git a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
index 0d3d53b..cd8b5e7 100644
--- a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
+++ b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
@@ -1,6 +1,6 @@
package cgeo.geocaching.test;
-import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.cgData;
import cgeo.geocaching.enumerations.LoadFlags;
import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag;
@@ -18,7 +18,7 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument
protected static void removeCacheCompletely(final String geocode) {
final EnumSet<RemoveFlag> flags = EnumSet.copyOf(LoadFlags.REMOVE_ALL);
flags.add(RemoveFlag.REMOVE_OWN_WAYPOINTS_ONLY_FOR_TESTING);
- cgeoapplication.getInstance().removeCache(geocode, flags);
+ cgData.removeCache(geocode, flags);
}
protected InputStream getResourceStream(int resourceId) {
diff --git a/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java b/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java
index b9f8138..bd30532 100644
--- a/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java
+++ b/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java
@@ -8,6 +8,7 @@ import cgeo.geocaching.test.mock.MockedCache;
import cgeo.geocaching.utils.BaseUtils;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
@@ -69,7 +70,10 @@ public class RegExPerformanceTest extends TestCase {
public final static Pattern PATTERN_DESCRIPTION = Pattern.compile("<span id=\"ctl00_ContentBody_LongDescription\">(.*?)</span>[^<]*</div>[^<]*<p>[^<]*</p>[^<]*<p>[^<]*<strong>\\W*Additional Hints</strong>");
- public final static MockedCache[] MOCKED_CACHES = { new GC2CJPF(), new GC1ZXX2(), new GC2JVEH(), new GC3XX5J() };
+ public final static List<MockedCache> MOCKED_CACHES;
+ static {
+ MOCKED_CACHES = Arrays.asList(new GC2CJPF(), new GC1ZXX2(), new GC2JVEH(), new GC3XX5J());
+ }
public static void testRegEx() {
List<String> output = doTheTests(10);
@@ -124,7 +128,7 @@ public class RegExPerformanceTest extends TestCase {
for (int j = 0; j < iterations; j++) {
BaseUtils.getMatch(page, pattern, true, "");
}
- return (System.currentTimeMillis() - start);
+ return System.currentTimeMillis() - start;
}
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
index 9aa18f9..5e8a1d7 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
@@ -1,7 +1,7 @@
package cgeo.geocaching.test.mock;
-import cgeo.geocaching.cgImage;
-import cgeo.geocaching.cgTrackable;
+import cgeo.geocaching.Image;
+import cgeo.geocaching.Trackable;
import cgeo.geocaching.connector.gc.Login;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
@@ -133,16 +133,16 @@ public class GC2JVEH extends MockedCache {
}
@Override
- public List<cgTrackable> getInventory() {
- final ArrayList<cgTrackable> inventory = new ArrayList<cgTrackable>();
- inventory.add(new cgTrackable());
+ public List<Trackable> getInventory() {
+ final ArrayList<Trackable> inventory = new ArrayList<Trackable>();
+ inventory.add(new Trackable());
return inventory;
}
@Override
- public List<cgImage> getSpoilers() {
- final ArrayList<cgImage> spoilers = new ArrayList<cgImage>();
- final cgImage mockedImage = new cgImage(null, null, null);
+ public List<Image> getSpoilers() {
+ final ArrayList<Image> spoilers = new ArrayList<Image>();
+ final Image mockedImage = new Image(null, null, null);
spoilers.add(mockedImage);
spoilers.add(mockedImage);
spoilers.add(mockedImage);
diff --git a/tests/src/cgeo/geocaching/test/mock/MockedCache.java b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
index 352c34d..f667264 100644
--- a/tests/src/cgeo/geocaching/test/mock/MockedCache.java
+++ b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
@@ -1,8 +1,8 @@
package cgeo.geocaching.test.mock;
import cgeo.geocaching.ICache;
-import cgeo.geocaching.cgImage;
-import cgeo.geocaching.cgTrackable;
+import cgeo.geocaching.Image;
+import cgeo.geocaching.Trackable;
import cgeo.geocaching.connector.gc.GCConstants;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.utils.BaseUtils;
@@ -70,7 +70,7 @@ public abstract class MockedCache implements ICache {
return BaseUtils.replaceWhitespace(buffer.toString());
} catch (IOException e) {
- e.printStackTrace();
+ Assert.fail(e.getMessage());
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(br);
@@ -134,12 +134,12 @@ public abstract class MockedCache implements ICache {
}
@Override
- public List<cgTrackable> getInventory() {
+ public List<Trackable> getInventory() {
return null;
}
@Override
- public List<cgImage> getSpoilers() {
+ public List<Image> getSpoilers() {
return null;
}
diff --git a/tests/src/cgeo/geocaching/ui/FormatterTest.java b/tests/src/cgeo/geocaching/ui/FormatterTest.java
new file mode 100644
index 0000000..5546ea5
--- /dev/null
+++ b/tests/src/cgeo/geocaching/ui/FormatterTest.java
@@ -0,0 +1,30 @@
+package cgeo.geocaching.ui;
+
+import cgeo.geocaching.R;
+import cgeo.geocaching.Waypoint;
+import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.enumerations.WaypointType;
+
+import android.test.AndroidTestCase;
+
+public class FormatterTest extends AndroidTestCase {
+
+ public static void testParkingWaypoint() {
+ assertFormatting(new Waypoint("you can park here", WaypointType.PARKING, false), WaypointType.PARKING.getL10n());
+ }
+
+ public static void testOriginalWaypoint() {
+ assertFormatting(new Waypoint("an original", WaypointType.ORIGINAL, false), WaypointType.ORIGINAL.getL10n());
+ }
+
+ public static void testOwnWaypoint() {
+ Waypoint own = new Waypoint("my own", WaypointType.OWN, true);
+ own.setPrefix(Waypoint.PREFIX_OWN);
+ assertFormatting(own, cgeoapplication.getInstance().getString(R.string.waypoint_custom));
+ }
+
+ private static void assertFormatting(Waypoint waypoint, String expected) {
+ assertEquals(expected, Formatter.formatWaypointInfo(waypoint));
+ }
+
+}