diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2012-03-05 20:54:54 +0100 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2012-03-05 20:54:54 +0100 |
commit | a77e1b035b4b77be69d7858fa28b72b8bdaf57e1 (patch) | |
tree | e4cb4b56bf29e11815c381915728eb123c2c4c8a /tests/src/cgeo | |
parent | 12e87a9d50ed2e58ed83d1db81c62d46c5bb8f4e (diff) | |
parent | 355a04a3645858ac0bbe50a65e34481863237cc4 (diff) | |
download | cgeo-a77e1b035b4b77be69d7858fa28b72b8bdaf57e1.zip cgeo-a77e1b035b4b77be69d7858fa28b72b8bdaf57e1.tar.gz cgeo-a77e1b035b4b77be69d7858fa28b72b8bdaf57e1.tar.bz2 |
Merge remote-tracking branch 'marco-jacob/issue#285'
Conflicts:
main/src/cgeo/geocaching/StaticMapsProvider.java
Diffstat (limited to 'tests/src/cgeo')
-rw-r--r-- | tests/src/cgeo/geocaching/files/GPXImporterTest.java | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java index 33a1524..efc892b 100644 --- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java +++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java @@ -25,6 +25,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { private TestHandler progressHandler = new TestHandler(); private int listId; private File tempDir; + private boolean importCacheStaticMaps; + private boolean importWpStaticMaps; public void testGetWaypointsFileNameForGpxFile() throws IOException { String[] gpxFiles = new String[] { "1234567.gpx", "1.gpx", "1234567.9.gpx", @@ -58,13 +60,14 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler); runImportThread(importThread); - assertEquals(4, importStepHandler.messages.size()); + assertEquals(5, importStepHandler.messages.size()); Iterator<Message> iMsg = importStepHandler.messages.iterator(); assertEquals(GPXImporter.IMPORT_STEP_START, iMsg.next().what); assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, iMsg.next().what); assertEquals(GPXImporter.IMPORT_STEP_STORE_CACHES, iMsg.next().what); + assertEquals(GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, iMsg.next().what); assertEquals(GPXImporter.IMPORT_STEP_FINISHED, iMsg.next().what); - SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; + 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); @@ -92,8 +95,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler); runImportThread(importThread); - assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_CACHES, GPXImporter.IMPORT_STEP_FINISHED); - SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; + assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_CACHES, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED); + SearchResult search = (SearchResult) importStepHandler.messages.get(5).obj; assertEquals(Collections.singletonList("GC31J2H"), new ArrayList<String>(search.getGeocodes())); cgCache cache = cgeoapplication.getInstance().loadCache("GC31J2H", LoadFlags.LOAD_CACHE_OR_DB); @@ -115,8 +118,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { GPXImporter.ImportLocFileThread importThread = new GPXImporter.ImportLocFileThread(oc5952, listId, importStepHandler, progressHandler); runImportThread(importThread); - assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_CACHES, GPXImporter.IMPORT_STEP_FINISHED); - SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; + assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_CACHES, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED); + SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; assertEquals(Collections.singletonList("OC5952"), new ArrayList<String>(search.getGeocodes())); cgCache cache = cgeoapplication.getInstance().loadCache("OC5952", LoadFlags.LOAD_CACHE_OR_DB); @@ -156,8 +159,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { GPXImporter.ImportGpxAttachmentThread importThread = new GPXImporter.ImportGpxAttachmentThread(uri, getInstrumentation().getContext().getContentResolver(), listId, importStepHandler, progressHandler); runImportThread(importThread); - assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_CACHES, GPXImporter.IMPORT_STEP_FINISHED); - SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; + assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_CACHES, 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); @@ -174,8 +177,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { GPXImporter.ImportGpxZipFileThread importThread = new GPXImporter.ImportGpxZipFileThread(pq7545915, listId, importStepHandler, progressHandler); runImportThread(importThread); - assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_CACHES, GPXImporter.IMPORT_STEP_FINISHED); - SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; + assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_CACHES, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED); + SearchResult search = (SearchResult) importStepHandler.messages.get(5).obj; assertEquals(Collections.singletonList("GC31J2H"), new ArrayList<String>(search.getGeocodes())); cgCache cache = cgeoapplication.getInstance().loadCache("GC31J2H", LoadFlags.LOAD_CACHE_OR_DB); @@ -199,8 +202,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { GPXImporter.ImportGpxZipAttachmentThread importThread = new GPXImporter.ImportGpxZipAttachmentThread(uri, getInstrumentation().getContext().getContentResolver(), listId, importStepHandler, progressHandler); runImportThread(importThread); - assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_CACHES, GPXImporter.IMPORT_STEP_FINISHED); - SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; + assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_CACHES, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED); + SearchResult search = (SearchResult) importStepHandler.messages.get(5).obj; assertEquals(Collections.singletonList("GC31J2H"), new ArrayList<String>(search.getGeocodes())); cgCache cache = cgeoapplication.getInstance().loadCache("GC31J2H", LoadFlags.LOAD_CACHE_OR_DB); @@ -247,6 +250,11 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { // workaround to get storage initialized cgeoapplication.getInstance().getAllHistoricCachesCount(); listId = cgeoapplication.getInstance().createList("cgeogpxesTest"); + + importCacheStaticMaps = Settings.isStoreOfflineMaps(); + Settings.setStoreOfflineMaps(true); + importWpStaticMaps = Settings.isStoreOfflineWpMaps(); + Settings.setStoreOfflineWpMaps(true); } @Override @@ -254,6 +262,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { cgeoapplication.getInstance().dropList(listId); cgeoapplication.getInstance().removeList(listId); deleteDirectory(tempDir); + Settings.setStoreOfflineMaps(importCacheStaticMaps); + Settings.setStoreOfflineWpMaps(importWpStaticMaps); super.tearDown(); } |