aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/cgeo/geocaching/test')
-rw-r--r--tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java17
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC2CJPF.java4
-rw-r--r--tests/src/cgeo/geocaching/test/mock/MockedCache.java2
3 files changed, 20 insertions, 3 deletions
diff --git a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
index 304f98d..cb8238f 100644
--- a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
+++ b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
@@ -1,11 +1,14 @@
package cgeo.geocaching.test;
+import cgeo.geocaching.Geocache;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.StoredList;
import cgeo.geocaching.cgData;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LoadFlags;
import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag;
+import cgeo.geocaching.files.GPX10Parser;
+import cgeo.geocaching.files.ParserException;
import android.content.res.Resources;
import android.test.InstrumentationTestCase;
@@ -14,6 +17,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Collection;
import java.util.EnumSet;
import java.util.Scanner;
@@ -78,4 +82,17 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument
protected final int getTemporaryListId() {
return temporaryListId;
}
+
+ final protected Geocache loadCacheFromResource(int resourceId) throws IOException, ParserException {
+ final InputStream instream = getResourceStream(resourceId);
+ try {
+ GPX10Parser parser = new GPX10Parser(StoredList.TEMPORARY_LIST_ID);
+ Collection<Geocache> caches = parser.parse(instream, null);
+ assertNotNull(caches);
+ assertFalse(caches.isEmpty());
+ return caches.iterator().next();
+ } finally {
+ instream.close();
+ }
+ }
}
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
index 8b65d43..9ca8552 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
@@ -1,11 +1,11 @@
package cgeo.geocaching.test.mock;
-import cgeo.geocaching.Settings;
import cgeo.geocaching.connector.gc.Login;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.geopoint.Geopoint;
+import cgeo.geocaching.settings.Settings;
import java.text.ParseException;
import java.util.Date;
@@ -99,7 +99,7 @@ public class GC2CJPF extends MockedCache {
/*
* (non-Javadoc)
- *
+ *
* @see cgeo.geocaching.test.mock.MockedCache#isOwn()
*/
@Override
diff --git a/tests/src/cgeo/geocaching/test/mock/MockedCache.java b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
index 0085a18..d1252ce 100644
--- a/tests/src/cgeo/geocaching/test/mock/MockedCache.java
+++ b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
@@ -129,7 +129,7 @@ public abstract class MockedCache implements ICache {
}
@Override
- public boolean isWatchlist() {
+ public boolean isOnWatchlist() {
return false;
}