diff options
| author | blafoo <github@blafoo.de> | 2012-05-10 12:17:11 +0200 |
|---|---|---|
| committer | blafoo <github@blafoo.de> | 2012-05-10 20:30:53 +0200 |
| commit | 57eeb6214fb178c45685f7bd5f4cdb2706326994 (patch) | |
| tree | 6dc05f5afe9c224701b326a2f21a4c370332c5f9 | |
| parent | 0b43cdc54f10dd0a7a57ac2cf8f67e26c3ddc7d1 (diff) | |
| download | cgeo-57eeb6214fb178c45685f7bd5f4cdb2706326994.zip cgeo-57eeb6214fb178c45685f7bd5f4cdb2706326994.tar.gz cgeo-57eeb6214fb178c45685f7bd5f4cdb2706326994.tar.bz2 | |
Drop caches created during GPX import test
| -rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 11 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/files/GPXImporterTest.java | 5 |
2 files changed, 14 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index 6daeb1f..8d10fb7 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -2300,7 +2300,7 @@ public class cgData { // offline caches only if (stored) { - where.append(" and reason >= 1"); + where.append(" and reason >= " + StoredList.STANDARD_LIST_ID); } try { @@ -2737,6 +2737,12 @@ public class cgData { return count; } + /** + * Remove a list. Caches in the list are moved to the standard list. + * + * @param listId + * @return true if the list got deleted, false else + */ public boolean removeList(int listId) { boolean status = false; if (listId < customListIdOffset) { @@ -2750,8 +2756,9 @@ public class cgData { int cnt = databaseRW.delete(dbTableLists, "_id = " + (listId - customListIdOffset), null); if (cnt > 0) { + // move caches from deleted list to standard list ContentValues values = new ContentValues(); - values.put("reason", 1); + values.put("reason", StoredList.STANDARD_LIST_ID); databaseRW.update(dbTableCaches, values, "reason = " + listId, null); status = true; diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java index 66334d7..6c28a07 100644 --- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java +++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java @@ -4,6 +4,7 @@ import cgeo.geocaching.SearchResult; import cgeo.geocaching.Settings; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgeoapplication; +import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase; import cgeo.geocaching.test.R; @@ -273,6 +274,10 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { @Override protected void tearDown() throws Exception { + SearchResult search = cgeoapplication.getInstance().getBatchOfStoredCaches(false, 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); deleteDirectory(tempDir); Settings.setStoreOfflineMaps(importCacheStaticMaps); |
