diff options
author | Stephan Merker <merker.stephan@googlemail.com> | 2011-11-20 23:20:38 +0100 |
---|---|---|
committer | Stephan Merker <merker.stephan@googlemail.com> | 2011-11-21 22:37:30 +0100 |
commit | 6ac087e09a128e6383e0a13f4ce7b09da8455717 (patch) | |
tree | 67af96dcdc4c3bd87487132f32629530146a4b1d /tests/src/cgeo/geocaching | |
parent | b7a29f6579f2a3a76af212a965049ec028d584b0 (diff) | |
download | cgeo-6ac087e09a128e6383e0a13f4ce7b09da8455717.zip cgeo-6ac087e09a128e6383e0a13f4ce7b09da8455717.tar.gz cgeo-6ac087e09a128e6383e0a13f4ce7b09da8455717.tar.bz2 |
import PQ zips from browser and email attachments
Diffstat (limited to 'tests/src/cgeo/geocaching')
-rw-r--r-- | tests/src/cgeo/geocaching/files/GPXImporterTest.java | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java index e80e254..7e9a62c 100644 --- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java +++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java @@ -7,6 +7,7 @@ import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase; import cgeo.geocaching.test.R; import cgeo.geocaching.utils.CancellableHandler; +import android.net.Uri; import android.os.Message; import java.io.File; @@ -152,6 +153,26 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { assertEquals(GPXImporter.IMPORT_STEP_CANCELED, importStepHandler.messages.get(1).what); } + public void testImportGpxAttachment() { + Uri uri = Uri.parse("android.resource://cgeo.geocaching.test/raw/gc31j2h"); + + GPXImporter.ImportGpxAttachmentThread importThread = new GPXImporter.ImportGpxAttachmentThread(uri, getInstrumentation().getContext().getContentResolver(), listId, importStepHandler, progressHandler); + runImportThread(importThread); + + assertEquals(3, importStepHandler.messages.size()); + assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, importStepHandler.messages.get(0).what); + assertEquals(GPXImporter.IMPORT_STEP_STORE_CACHES, importStepHandler.messages.get(1).what); + assertEquals(GPXImporter.IMPORT_STEP_FINISHED, importStepHandler.messages.get(2).what); + cgSearch search = (cgSearch) importStepHandler.messages.get(2).obj; + assertEquals(Collections.singletonList("GC31J2H"), search.getGeocodes()); + + cgCache cache = cgeoapplication.getInstance().getCacheByGeocode("GC31J2H"); + assertCacheProperties(cache); + + // can't assert, for whatever reason the waypoints are remembered in DB + // assertNull(cache.waypoints); + } + public void testImportGpxZip() throws IOException { File pq7545915 = new File(tempDir, "7545915.zip"); copyResourceToFile(R.raw.pq7545915, pq7545915); @@ -184,6 +205,25 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { assertEquals(GPXImporter.IMPORT_STEP_FINISHED_WITH_ERROR, importStepHandler.messages.get(0).what); } + public void testImportGpxZipAttachment() { + Uri uri = Uri.parse("android.resource://cgeo.geocaching.test/raw/pq7545915"); + + GPXImporter.ImportGpxZipAttachmentThread importThread = new GPXImporter.ImportGpxZipAttachmentThread(uri, getInstrumentation().getContext().getContentResolver(), listId, importStepHandler, progressHandler); + runImportThread(importThread); + + assertEquals(4, importStepHandler.messages.size()); + assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, importStepHandler.messages.get(0).what); + assertEquals(GPXImporter.IMPORT_STEP_READ_WPT_FILE, importStepHandler.messages.get(1).what); + assertEquals(GPXImporter.IMPORT_STEP_STORE_CACHES, importStepHandler.messages.get(2).what); + assertEquals(GPXImporter.IMPORT_STEP_FINISHED, importStepHandler.messages.get(3).what); + cgSearch search = (cgSearch) importStepHandler.messages.get(3).obj; + assertEquals(Collections.singletonList("GC31J2H"), search.getGeocodes()); + + cgCache cache = cgeoapplication.getInstance().getCacheByGeocode("GC31J2H"); + assertCacheProperties(cache); + assertEquals(1, cache.getWaypoints().size()); // this is the original pocket query result without test waypoint + } + static class TestHandler extends CancellableHandler { private final List<Message> messages = new ArrayList<Message>(); private long lastMessage = System.currentTimeMillis(); @@ -244,4 +284,4 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { dir.delete(); } -}
\ No newline at end of file +} |