aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCConnector.java6
-rw-r--r--tests/src/cgeo/geocaching/GpxFileListActivityTest.java87
2 files changed, 59 insertions, 34 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCConnector.java b/main/src/cgeo/geocaching/connector/gc/GCConnector.java
index 50bf096..a2df060 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCConnector.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCConnector.java
@@ -27,7 +27,11 @@ public class GCConnector extends AbstractConnector implements ISearchByGeocode,
private static final String CACHE_URL_SHORT = "http://coord.info/";
// Double slash is used to force open in browser
private static final String CACHE_URL_LONG = "http://www.geocaching.com//seek/cache_details.aspx?wp=";
- private static final Pattern gpxZipFilePattern = Pattern.compile("\\d{7,}(_.+)?\\.zip", Pattern.CASE_INSENSITIVE);
+ /**
+ * Pocket queries downloaded from the website use a numeric prefix. The pocket query creator Android app adds a
+ * verbatim "pocketquery" prefix.
+ */
+ private static final Pattern gpxZipFilePattern = Pattern.compile("((\\d{7,})|(pocketquery))" + "(_.+)?" + "\\.zip", Pattern.CASE_INSENSITIVE);
private GCConnector() {
// singleton
diff --git a/tests/src/cgeo/geocaching/GpxFileListActivityTest.java b/tests/src/cgeo/geocaching/GpxFileListActivityTest.java
index a7605d6..2923bfc 100644
--- a/tests/src/cgeo/geocaching/GpxFileListActivityTest.java
+++ b/tests/src/cgeo/geocaching/GpxFileListActivityTest.java
@@ -11,39 +11,60 @@ public class GpxFileListActivityTest extends ActivityInstrumentationTestCase2<Gp
super(GpxFileListActivity.class);
}
- public void testFileNameMatches() {
- assertTrue(importGpxActivity.filenameBelongsToList("1234567.gpx"));
- assertTrue(importGpxActivity.filenameBelongsToList("1234567.GPX"));
- assertTrue(importGpxActivity.filenameBelongsToList(".gpx"));
- assertTrue(importGpxActivity.filenameBelongsToList("1234567.loc"));
- assertTrue(importGpxActivity.filenameBelongsToList("1234567.LOC"));
- assertTrue(importGpxActivity.filenameBelongsToList("1234567.zip"));
- assertTrue(importGpxActivity.filenameBelongsToList("1234567.ZIP"));
- assertTrue(importGpxActivity.filenameBelongsToList("12345678.zip"));
- assertTrue(importGpxActivity.filenameBelongsToList("1234567_query.zip"));
- assertTrue(importGpxActivity.filenameBelongsToList("12345678_query.zip"));
- assertTrue(importGpxActivity.filenameBelongsToList("12345678_my_query_1.zip"));
- assertTrue(importGpxActivity.filenameBelongsToList("12345678_my query.zip"));
- assertTrue(importGpxActivity.filenameBelongsToList("ocde12345.zip"));
- assertTrue(importGpxActivity.filenameBelongsToList("ocde12345678.zip"));
-
- assertFalse(importGpxActivity.filenameBelongsToList("1234567.gpy"));
- assertFalse(importGpxActivity.filenameBelongsToList("1234567.agpx"));
- assertFalse(importGpxActivity.filenameBelongsToList("1234567"));
- assertFalse(importGpxActivity.filenameBelongsToList(""));
- assertFalse(importGpxActivity.filenameBelongsToList("gpx"));
- assertFalse(importGpxActivity.filenameBelongsToList("test.zip"));
- assertFalse(importGpxActivity.filenameBelongsToList("zip"));
- assertFalse(importGpxActivity.filenameBelongsToList(".zip"));
- assertFalse(importGpxActivity.filenameBelongsToList("123456.zip"));
- assertFalse(importGpxActivity.filenameBelongsToList("1234567query.zip"));
- assertFalse(importGpxActivity.filenameBelongsToList("1234567_.zip"));
- assertFalse(importGpxActivity.filenameBelongsToList("ocde_12345678.zip"));
- assertFalse(importGpxActivity.filenameBelongsToList("acde12345678.zip"));
-
- assertFalse(importGpxActivity.filenameBelongsToList("1234567-wpts.gpx"));
- assertFalse(importGpxActivity.filenameBelongsToList("1234567-wpts-1.gpx"));
- assertFalse(importGpxActivity.filenameBelongsToList("1234567-wpts(1).gpx"));
+ public void testPocketQueryCreator() {
+ assertImport("pocketquery_name.zip");
+ assertImport("pocketquery_รค.1. .zip");
+ assertImport("pocketquery_name.ZIP");
+ assertImport("pocketquery_name.gpx");
}
+ public void testDifferentFileTypes() {
+ assertImport("1234567.gpx");
+ assertImport("1234567.GPX");
+ assertImport(".gpx");
+ assertImport("1234567.loc");
+ assertImport("1234567.LOC");
+ assertImport("1234567.zip");
+ assertImport("1234567.ZIP");
+ }
+
+ public void testPocketQueries() {
+ assertImport("12345678.zip");
+ assertImport("1234567_query.zip");
+ assertImport("12345678_query.zip");
+ assertImport("12345678_my_query_1.zip");
+ assertImport("12345678_my query.zip");
+
+ denyImport("1234567.gpy");
+ denyImport("1234567.agpx");
+ denyImport("1234567");
+ denyImport("");
+ denyImport("gpx");
+ denyImport("test.zip");
+ denyImport("zip");
+ denyImport(".zip");
+ denyImport("123456.zip");
+ denyImport("1234567query.zip");
+ denyImport("1234567_.zip");
+
+ denyImport("1234567-wpts.gpx");
+ denyImport("1234567-wpts-1.gpx");
+ denyImport("1234567-wpts(1).gpx");
+ }
+
+ public void testOpenCachingExports() {
+ assertImport("ocde12345.zip");
+ assertImport("ocde12345678.zip");
+
+ denyImport("ocde_12345678.zip");
+ denyImport("acde12345678.zip");
+ }
+
+ private void assertImport(String fileName) {
+ assertTrue(importGpxActivity.filenameBelongsToList(fileName));
+ }
+
+ private void denyImport(String fileName) {
+ assertFalse(importGpxActivity.filenameBelongsToList(fileName));
+ }
}