diff options
author | blafoo <github@blafoo.de> | 2012-02-28 21:36:54 +0100 |
---|---|---|
committer | blafoo <github@blafoo.de> | 2012-02-28 22:46:33 +0100 |
commit | 6ab9615e71c242232946146680c086cda11e11fe (patch) | |
tree | 9c6366d4f77fb6ea4946ebfd63d3cd06bfdc7874 /tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java | |
parent | 54fc6da3c6fa0e87a866a95baf50b4dcc272875b (diff) | |
download | cgeo-6ab9615e71c242232946146680c086cda11e11fe.zip cgeo-6ab9615e71c242232946146680c086cda11e11fe.tar.gz cgeo-6ab9615e71c242232946146680c086cda11e11fe.tar.bz2 |
Improved PNG parsing
Diffstat (limited to 'tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java')
-rw-r--r-- | tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java index 07bf78a..c3e800b 100644 --- a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java @@ -1,14 +1,21 @@ package cgeo.geocaching.connector.gc; import cgeo.geocaching.SearchResult; +import cgeo.geocaching.Settings; import cgeo.geocaching.cgBase; +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.test.AbstractResourceInstrumentationTestCase; +import cgeo.geocaching.test.R; -import android.test.AndroidTestCase; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.util.Log; -public class GCConnectorTest extends AndroidTestCase { +public class GCConnectorTest extends AbstractResourceInstrumentationTestCase { public static void testGetViewport() { cgBase.login(); @@ -77,6 +84,46 @@ public class GCConnectorTest extends AndroidTestCase { // TODO ebenfalls nutzen in searchByViewport und KOs vergleichen } + public void testparseMapPNG() { + // createApplication(); + // cgBase.initialize(getApplication()); + + 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"; + + Log.d(Settings.tag, "Bitmap=" + bitmap.getWidth() + "x" + bitmap.getHeight()); + + 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 + } } |