From 57eeb6214fb178c45685f7bd5f4cdb2706326994 Mon Sep 17 00:00:00 2001 From: blafoo Date: Thu, 10 May 2012 12:17:11 +0200 Subject: Drop caches created during GPX import test --- main/src/cgeo/geocaching/cgData.java | 11 +++++++++-- 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 cachesInList = new ArrayList(); + cachesInList.addAll(search.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB)); + cgeoapplication.getInstance().markDropped(cachesInList); cgeoapplication.getInstance().removeList(listId); deleteDirectory(tempDir); Settings.setStoreOfflineMaps(importCacheStaticMaps); -- cgit v1.1