aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo
diff options
context:
space:
mode:
authorblafoo <github@blafoo.de>2012-02-22 22:09:36 +0100
committerblafoo <github@blafoo.de>2012-02-23 23:31:34 +0100
commit196dd6ab57977f778459ec4bb2a873b6d7734f6f (patch)
tree9b8629cbfb76e05c9a8e8ec825558f0d82ce4db6 /tests/src/cgeo
parent7ac4206e7c0308d2127845d7bf9214e73b845295 (diff)
downloadcgeo-196dd6ab57977f778459ec4bb2a873b6d7734f6f.zip
cgeo-196dd6ab57977f778459ec4bb2a873b6d7734f6f.tar.gz
cgeo-196dd6ab57977f778459ec4bb2a873b6d7734f6f.tar.bz2
Live Map optimizations
Diffstat (limited to 'tests/src/cgeo')
-rw-r--r--tests/src/cgeo/geocaching/GCConstantsTest.java7
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java (renamed from tests/src/cgeo/geocaching/connector/GCConnectorTest.java)29
2 files changed, 31 insertions, 5 deletions
diff --git a/tests/src/cgeo/geocaching/GCConstantsTest.java b/tests/src/cgeo/geocaching/GCConstantsTest.java
index 41b7dcb..a05abd9 100644
--- a/tests/src/cgeo/geocaching/GCConstantsTest.java
+++ b/tests/src/cgeo/geocaching/GCConstantsTest.java
@@ -6,6 +6,7 @@ import cgeo.geocaching.utils.BaseUtils;
import android.test.AndroidTestCase;
public class GCConstantsTest extends AndroidTestCase {
+
public static void testLocation() {
// GC37GFJ
assertEquals("Bretagne, France", parseLocation(" <span id=\"ctl00_ContentBody_Location\">In Bretagne, France</span><br />"));
@@ -28,4 +29,10 @@ public class GCConstantsTest extends AndroidTestCase {
private static void assertCacheCount(final int count, final String html) {
assertEquals(count, Integer.parseInt(BaseUtils.getMatch(html, GCConstants.PATTERN_CACHES_FOUND, true, "0").replaceAll(",", "")));
}
+
+ public static void testConstants() {
+ String session = "userSession = new Groundspeak.Map.UserSession('aKWZ', userOptions:'XPTf', sessionToken:'123pNKwdktYGZL0xd-I7yqA6nm_JE1BDUtM4KcOkifin2TRCMutBd_PZE14Ohpffs2ZgkTnxTSnxYpBigK4hBA2', subscriberType: 3, enablePersonalization: true });";
+ assertEquals("aKWZ", BaseUtils.getMatch(session, GCConstants.PATTERN_USERSESSION, ""));
+ assertTrue(BaseUtils.getMatch(session, GCConstants.PATTERN_USERSESSION, "").startsWith("123pNK"));
+ }
}
diff --git a/tests/src/cgeo/geocaching/connector/GCConnectorTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
index f012214..014c578 100644
--- a/tests/src/cgeo/geocaching/connector/GCConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
@@ -15,11 +15,11 @@ public class GCConnectorTest extends AndroidTestCase {
public static void testGetViewport() {
cgBase.login();
- String sessionToken = GCBase.getSessionToken();
+ String[] tokens = GCBase.getTokens();
{
final Viewport viewport = new Viewport(new Geopoint("N 52° 25.369 E 9° 35.499"), new Geopoint("N 52° 25.371 E 9° 35.501"));
- SearchResult searchResult = GCBase.searchByViewport(viewport, 14, false, sessionToken);
+ SearchResult searchResult = GCBase.searchByViewport(viewport, 14, false, tokens);
assertTrue(searchResult != null);
assertEquals(7, searchResult.getCount());
assertTrue(searchResult.getGeocodes().contains("GC211WG"));
@@ -33,7 +33,7 @@ public class GCConnectorTest extends AndroidTestCase {
{
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"));
- SearchResult searchResult = GCBase.searchByViewport(viewport, 14, false, sessionToken);
+ SearchResult searchResult = GCBase.searchByViewport(viewport, 14, false, tokens);
assertTrue(searchResult != null);
assertTrue(searchResult.getGeocodes().contains("GC211WG"));
}
@@ -48,6 +48,7 @@ public class GCConnectorTest extends AndroidTestCase {
assertEquals("GC211WG", GCBase.newidToGeocode("gEaR"));
}
+ /** Tile computation with different zoom levels */
public static void testTile() {
{
// http://coord.info/GC2CT8K = N 52° 30.462 E 013° 27.906
@@ -55,16 +56,34 @@ public class GCConnectorTest extends AndroidTestCase {
assertEquals(8804, tile.getX());
assertEquals(5374, tile.getY());
}
-
{
// (8633, 5381); N 52° 24,516 E 009° 42,592
Tile tile = new Tile(new Geopoint("N 52° 24,516 E 009° 42,592"), 14);
assertEquals(8633, tile.getX());
assertEquals(5381, tile.getY());
}
+ {
+ // Hannover, GC22VTB UKM Memorial Tour
+ Tile tile = new Tile(new Geopoint("N 52° 22.177 E 009° 45.385"), 12);
+ assertEquals(2159, tile.getX());
+ assertEquals(1346, tile.getY());
+ }
+ {
+ // Seatle, GCK25B Groundspeak Headquarters
+ Tile tile = new Tile(new Geopoint("N 47° 38.000 W 122° 20.000"), 15);
+ assertEquals(5248, tile.getX());
+ assertEquals(11440, tile.getY());
+ }
+ {
+ // Sydney, GCXT2R Victoria Cross
+ Tile tile = new Tile(new Geopoint("S 33° 50.326 E 151° 12.426"), 13);
+ assertEquals(7536, tile.getX());
+ assertEquals(4915, tile.getY());
+ }
- // TODO Valentine zoomlevel != 14, Seatle, Rio, Sydney
+ // TODO ebenfalls nutzen in searchByViewport und KOs vergleichen
}
+
}