aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/connector/gc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/cgeo/geocaching/connector/gc')
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java10
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCParserTest.java11
2 files changed, 17 insertions, 4 deletions
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
index a5b9a44..47c3f6f 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
@@ -26,7 +26,7 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
{
final Viewport viewport = new Viewport(new Geopoint("N 52° 25.369 E 9° 35.499"), new Geopoint("N 52° 25.600 E 9° 36.200"));
- final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens);
+ final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens).toBlockingObservable().single();
assertNotNull(searchResult);
assertFalse(searchResult.isEmpty());
assertTrue(searchResult.getGeocodes().contains("GC4ER5H"));
@@ -35,7 +35,7 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
{
final Viewport viewport = new Viewport(new Geopoint("N 52° 24.000 E 9° 34.500"), new Geopoint("N 52° 26.000 E 9° 38.500"));
- final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens);
+ final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens).toBlockingObservable().single();
assertNotNull(searchResult);
assertTrue(searchResult.getGeocodes().contains("GC4ER5H"));
}
@@ -88,5 +88,11 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
public static void testGetGeocodeFromUrl() {
assertNull(GCConnector.getInstance().getGeocodeFromUrl("some string"));
assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/GC12ABC"));
+ assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/GC12ABC"));
+ assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://www.geocaching.com/geocache/GC12ABC_die-muhlen-im-schondratal-muhle-munchau"));
+ assertEquals("GC12ABC", GCConnector.getInstance().getGeocodeFromUrl("http://geocaching.com/geocache/GC12ABC_die-muhlen-im-schondratal-muhle-munchau"));
+
+ assertNull(GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/TB1234"));
+ assertNull(GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/TB1234"));
}
}
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
index 43b6d01..1509563 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
@@ -56,6 +56,8 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
assertNotNull(result);
assertEquals(1, result.getCount());
final Geocache cache = result.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
+ assertNotNull(cache);
+ assert (cache != null); // eclipse bug
assertEquals(cacheName, cache.getName());
}
@@ -158,6 +160,8 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
cache.drop(new Handler());
final String page = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0");
final Geocache cache2 = GCParser.parseCacheFromText(page, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY);
+ assertNotNull(cache2);
+ assert (cache2 != null); // eclipse bug
assertTrue(cache2.hasUserModifiedCoords());
assertEquals(new Geopoint("N51 21.544", "E07 02.566"), cache2.getCoords());
// delete coordinates
@@ -165,6 +169,8 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
cache2.drop(new Handler());
final String page2 = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0");
final Geocache cache3 = GCParser.parseCacheFromText(page2, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY);
+ assertNotNull(cache3);
+ assert (cache3 != null); // eclipse bug
assertFalse(cache3.hasUserModifiedCoords());
}
@@ -172,9 +178,10 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
cache.setPersonalNote(note);
cache.setWaypoints(new ArrayList<Waypoint>(), false);
cache.parseWaypointsFromNote();
- assertEquals(expected.length, cache.getWaypoints().size());
+ final List<Waypoint> waypoints = cache.getWaypoints();
+ assertEquals(expected.length, waypoints.size());
for (int i = 0; i < expected.length; i++) {
- assertTrue(expected[i].equals(cache.getWaypoint(i).getCoords()));
+ assertTrue(expected[i].equals(waypoints.get(i).getCoords()));
}
}