aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/cgeoApplicationTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/cgeo/geocaching/cgeoApplicationTest.java')
-rw-r--r--tests/src/cgeo/geocaching/cgeoApplicationTest.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/src/cgeo/geocaching/cgeoApplicationTest.java b/tests/src/cgeo/geocaching/cgeoApplicationTest.java
index f7d3158..5e23d98 100644
--- a/tests/src/cgeo/geocaching/cgeoApplicationTest.java
+++ b/tests/src/cgeo/geocaching/cgeoApplicationTest.java
@@ -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;
@@ -263,10 +263,12 @@ public class cgeoApplicationTest extends CGeoTestCase {
// backup user settings
final boolean excludeMine = Settings.isExcludeMyCaches();
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());
@@ -279,8 +281,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
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);
+ cgCache parsedCache = cgData.loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
assertEquals(Settings.isPremiumMember(), mockedCache.getCoords().equals(parsedCache.getCoords()));
assertEquals(Settings.isPremiumMember(), parsedCache.isReliableLatLon());
@@ -292,8 +293,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
search = ConnectorFactory.searchByViewport(viewport, tokens);
assertNotNull(search);
assertTrue(search.getGeocodes().contains(mockedCache.getGeocode()));
-
- parsedCache = cgeoapplication.getInstance().loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
+ parsedCache = cgData.loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
assertEquals(Settings.isPremiumMember(), mockedCache.getCoords().equals(parsedCache.getCoords()));
assertEquals(Settings.isPremiumMember(), parsedCache.isReliableLatLon());
@@ -302,6 +302,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
// restore user settings
Settings.setExcludeMine(excludeMine);
Settings.setLiveMapStrategy(strategy);
+ Settings.setCacheType(cacheType);
}
}
@@ -316,6 +317,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 +327,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 +335,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 +359,7 @@ public class cgeoApplicationTest extends CGeoTestCase {
Settings.setMemberStatus(memberStatus);
Login.login();
Settings.setLiveMapStrategy(strategy);
+ Settings.setCacheType(cacheType);
}
}
@@ -390,7 +394,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 */