diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2012-03-10 21:46:32 +0100 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2012-03-10 21:46:32 +0100 |
commit | 491fdefaf2ab8adff5c62898fa00f9af2220b214 (patch) | |
tree | 9091734e7f8786b8fcc5f1adc3cf23e822c9eae8 /tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java | |
parent | d40313cf48a9956487afd2b591b34d588bb4ae82 (diff) | |
download | cgeo-491fdefaf2ab8adff5c62898fa00f9af2220b214.zip cgeo-491fdefaf2ab8adff5c62898fa00f9af2220b214.tar.gz cgeo-491fdefaf2ab8adff5c62898fa00f9af2220b214.tar.bz2 |
fix #1262: icon decoding does not work well
Diffstat (limited to 'tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java')
-rw-r--r-- | tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java | 89 |
1 files changed, 14 insertions, 75 deletions
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java index 3696568..dfa9a8b 100644 --- a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java @@ -1,19 +1,11 @@ package cgeo.geocaching.connector.gc; import cgeo.geocaching.SearchResult; -import cgeo.geocaching.Settings; -import cgeo.geocaching.cgCache; import cgeo.geocaching.connector.ConnectorFactory; -import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.network.Login; import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase; -import cgeo.geocaching.test.R; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.util.Log; public class GCConnectorTest extends AbstractResourceInstrumentationTestCase { @@ -50,78 +42,25 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase { /** Tile computation with different zoom levels */ public static void testTile() { - { - // http://coord.info/GC2CT8K = N 52° 30.462 E 013° 27.906 - Tile tile = new Tile(new Geopoint(52.5077, 13.4651), 14); - 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()); - } - } + // http://coord.info/GC2CT8K = N 52° 30.462 E 013° 27.906 + assertTileAt(8804, 5374, new Tile(new Geopoint(52.5077, 13.4651), 14)); - public void testparseMapPNG() { - // createApplication(); - // cgBase.initialize(getApplication()); + // (8633, 5381); N 52° 24,516 E 009° 42,592 + assertTileAt(8633, 5381, new Tile(new Geopoint("N 52° 24,516 E 009° 42,592"), 14)); - BitmapFactory.Options options = new BitmapFactory.Options(); - options.inScaled = false; - Bitmap bitmap = BitmapFactory.decodeStream(getInstrumentation().getContext().getResources().openRawResource(R.raw.tile14)); - assert bitmap.getWidth() == Tile.TILE_SIZE : "Wrong size"; + // Hannover, GC22VTB UKM Memorial Tour + assertTileAt(2159, 1346, new Tile(new Geopoint("N 52° 22.177 E 009° 45.385"), 12)); - Log.d(Settings.tag, "Bitmap=" + bitmap.getWidth() + "x" + bitmap.getHeight()); + // Seattle, GCK25B Groundspeak Headquarters + assertTileAt(5248, 11440, new Tile(new Geopoint("N 47° 38.000 W 122° 20.000"), 15)); - cgCache cache = new cgCache(); - - // Tradi - GCBase.parseMapPNG14(cache, bitmap, new UTFGridPosition(97 / 4, 136 / 4)); - assertEquals(CacheType.TRADITIONAL, cache.getType()); - // Mystery - GCBase.parseMapPNG14(cache, bitmap, new UTFGridPosition(226 / 4, 104 / 4)); - assertEquals(CacheType.MYSTERY, cache.getType()); - // Multi - GCBase.parseMapPNG14(cache, bitmap, new UTFGridPosition(54 / 4, 97 / 4)); - assertEquals(CacheType.MULTI, cache.getType()); - // Found - GCBase.parseMapPNG14(cache, bitmap, new UTFGridPosition(119 / 4, 108 / 4)); - assertTrue(cache.isFound()); - cache.setFound(false); // reset - - bitmap = BitmapFactory.decodeStream(getInstrumentation().getContext().getResources().openRawResource(R.raw.tile13)); - - // Tradi - GCBase.parseMapPNG13(cache, bitmap, new UTFGridPosition(146 / 4, 225 / 4)); - assertEquals(CacheType.TRADITIONAL, cache.getType()); - // Mystery - GCBase.parseMapPNG13(cache, bitmap, new UTFGridPosition(181 / 4, 116 / 4)); - assertEquals(CacheType.MYSTERY, cache.getType()); - // Multi - GCBase.parseMapPNG13(cache, bitmap, new UTFGridPosition(118 / 4, 230 / 4)); - assertEquals(CacheType.MULTI, cache.getType()); - // Found - not available in parseMapPNG13 + // Sydney, GCXT2R Victoria Cross + assertTileAt(7536, 4915, new Tile(new Geopoint("S 33° 50.326 E 151° 12.426"), 13)); } + private static void assertTileAt(int x, int y, final Tile tile) { + assertEquals(x, tile.getX()); + assertEquals(y, tile.getY()); + } } |