diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2011-11-13 08:02:12 +0100 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2011-11-13 08:02:12 +0100 |
commit | dc30da9a8b2d430152e125512e37fefe4d25008c (patch) | |
tree | 1a46e1b35881a1833e51108017ce220a772f076a /tests/src | |
parent | 01a6ad62356e5bb3d67b60508abed7771fbc2603 (diff) | |
parent | 759f158b115fe27f7c61409d5f540d1effb6c0e1 (diff) | |
download | cgeo-dc30da9a8b2d430152e125512e37fefe4d25008c.zip cgeo-dc30da9a8b2d430152e125512e37fefe4d25008c.tar.gz cgeo-dc30da9a8b2d430152e125512e37fefe4d25008c.tar.bz2 |
Merge remote branch 'stephanme/importwpt'
Conflicts:
tests/src/cgeo/geocaching/files/GPXImporterTest.java
tests/src/cgeo/geocaching/files/GPXParserTest.java
tests/src/cgeo/geocaching/files/LocParserTest.java
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/cgeo/geocaching/files/GPXImporterTest.java | 20 | ||||
-rw-r--r-- | tests/src/cgeo/geocaching/files/GPXParserTest.java | 4 | ||||
-rw-r--r-- | tests/src/cgeo/geocaching/files/LocParserTest.java | 4 |
3 files changed, 19 insertions, 9 deletions
diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java index ad4bfe7..d23521b 100644 --- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java +++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java @@ -5,8 +5,8 @@ import cgeo.geocaching.cgSearch; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase; import cgeo.geocaching.test.R; +import cgeo.geocaching.utils.CancellableHandler; -import android.os.Handler; import android.os.Message; import java.io.File; @@ -116,12 +116,26 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { assertEquals(GPXImporter.IMPORT_STEP_FINISHED_WITH_ERROR, importStepHandler.messages.get(1).what); } - static class TestHandler extends Handler { + public void testImportGpxCancel() throws IOException { + File gc31j2h = new File(tempDir, "gc31j2h.gpx"); + copyResourceToFile(R.raw.gc31j2h, gc31j2h); + + progressHandler.cancel(); + GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler); + importThread.run(); + importStepHandler.waitForCompletion(); + + assertEquals(2, importStepHandler.messages.size()); + assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, importStepHandler.messages.get(0).what); + assertEquals(GPXImporter.IMPORT_STEP_CANCELED, importStepHandler.messages.get(1).what); + } + + static class TestHandler extends CancellableHandler { private final List<Message> messages = new ArrayList<Message>(); private long lastMessage = System.currentTimeMillis(); @Override - public synchronized void handleMessage(Message msg) { + public synchronized void handleRegularMessage(Message msg) { final Message msg1 = new Message(); msg1.copyFrom(msg); messages.add(msg1); diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java index 3d5a640..11d0161 100644 --- a/tests/src/cgeo/geocaching/files/GPXParserTest.java +++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java @@ -11,8 +11,6 @@ import cgeo.geocaching.geopoint.GeopointFormatter; import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase; import cgeo.geocaching.test.R; -import android.os.Handler; - import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -188,7 +186,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase { for (int resourceId : resourceIds) { final InputStream instream = getResourceStream(resourceId); try { - caches = parser.parse(instream, new Handler()); + caches = parser.parse(instream, null); assertNotNull(caches); } finally { instream.close(); diff --git a/tests/src/cgeo/geocaching/files/LocParserTest.java b/tests/src/cgeo/geocaching/files/LocParserTest.java index 540c554..8facfe4 100644 --- a/tests/src/cgeo/geocaching/files/LocParserTest.java +++ b/tests/src/cgeo/geocaching/files/LocParserTest.java @@ -6,8 +6,6 @@ import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase; import cgeo.geocaching.test.R; -import android.os.Handler; - import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -20,7 +18,7 @@ public class LocParserTest extends AbstractResourceInstrumentationTestCase { Collection<cgCache> caches = null; final InputStream instream = getResourceStream(resourceId); try { - caches = parser.parse(instream, new Handler()); + caches = parser.parse(instream, null); assertNotNull(caches); assertTrue(caches.size() > 0); } finally { |