aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-08-28 23:25:08 +0200
committerBananeweizen <bananeweizen@gmx.de>2013-08-28 23:25:08 +0200
commit34b097ce9d166f40f9633d6227de058c447b85c9 (patch)
tree49ab2924bc101bce14b762a215cd1fc3cf20d2e8 /tests/src/cgeo
parent8e739e6a227a2e40285ac5fed9da64d7a63480f3 (diff)
downloadcgeo-34b097ce9d166f40f9633d6227de058c447b85c9.zip
cgeo-34b097ce9d166f40f9633d6227de058c447b85c9.tar.gz
cgeo-34b097ce9d166f40f9633d6227de058c447b85c9.tar.bz2
refactoring: avoid filling sdcard during tests
Diffstat (limited to 'tests/src/cgeo')
-rw-r--r--tests/src/cgeo/CGeoTestCase.java14
-rw-r--r--tests/src/cgeo/geocaching/GeocacheTest.java11
2 files changed, 19 insertions, 6 deletions
diff --git a/tests/src/cgeo/CGeoTestCase.java b/tests/src/cgeo/CGeoTestCase.java
index 6a63cbc..88184e0 100644
--- a/tests/src/cgeo/CGeoTestCase.java
+++ b/tests/src/cgeo/CGeoTestCase.java
@@ -3,9 +3,12 @@ package cgeo;
import cgeo.geocaching.cgData;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.enumerations.LoadFlags;
+import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag;
import android.test.ApplicationTestCase;
+import java.util.EnumSet;
+
public abstract class CGeoTestCase extends ApplicationTestCase<cgeoapplication> {
public CGeoTestCase() {
@@ -23,4 +26,15 @@ public abstract class CGeoTestCase extends ApplicationTestCase<cgeoapplication>
cgData.removeCache(geocode, LoadFlags.REMOVE_ALL);
}
+ /**
+ * remove cache from database and file system
+ *
+ * @param geocode
+ */
+ 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);
+ cgData.removeCache(geocode, flags);
+ }
+
}
diff --git a/tests/src/cgeo/geocaching/GeocacheTest.java b/tests/src/cgeo/geocaching/GeocacheTest.java
index 4c09594..9606287 100644
--- a/tests/src/cgeo/geocaching/GeocacheTest.java
+++ b/tests/src/cgeo/geocaching/GeocacheTest.java
@@ -1,16 +1,14 @@
package cgeo.geocaching;
+import cgeo.CGeoTestCase;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.geopoint.Geopoint;
-import android.os.Handler;
-import android.test.AndroidTestCase;
-
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-public class GeocacheTest extends AndroidTestCase {
+public class GeocacheTest extends CGeoTestCase {
final static private class MockedEventCache extends Geocache {
public MockedEventCache(final Date date) {
@@ -62,7 +60,8 @@ public class GeocacheTest extends AndroidTestCase {
private static void assertWaypointsParsed(String note, int expectedWaypoints) {
Geocache cache = new Geocache();
- cache.setGeocode("Test" + System.nanoTime());
+ final String geocode = "Test" + System.nanoTime();
+ cache.setGeocode(geocode);
cache.setWaypoints(new ArrayList<Waypoint>(), false);
for (int i = 0; i < 2; i++) {
cache.setPersonalNote(note);
@@ -76,7 +75,7 @@ public class GeocacheTest extends AndroidTestCase {
assertEquals(cgeoapplication.getInstance().getString(R.string.cache_personal_note) + " 1", waypoint.getName());
cache.store(StoredList.TEMPORARY_LIST_ID, null);
}
- cache.drop(new Handler());
+ removeCacheCompletely(geocode);
}
public static void testMergeDownloadedStored() {