diff options
Diffstat (limited to 'tests/src')
6 files changed, 16 insertions, 8 deletions
diff --git a/tests/src/cgeo/geocaching/CgeoApplicationTest.java b/tests/src/cgeo/geocaching/CgeoApplicationTest.java index ae182d7..7e7801b 100644 --- a/tests/src/cgeo/geocaching/CgeoApplicationTest.java +++ b/tests/src/cgeo/geocaching/CgeoApplicationTest.java @@ -165,7 +165,7 @@ public class CgeoApplicationTest extends CGeoTestCase { deleteCacheFromDBAndLogout(cache.getGeocode()); - SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST_ID, true, null); + SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST.id, true, null); assertThat(search).isNotNull(); assertThat(search.getGeocodes()).hasSize(1); assertThat(search.getGeocodes().contains(cache.getGeocode())).isTrue(); @@ -180,7 +180,7 @@ public class CgeoApplicationTest extends CGeoTestCase { deleteCacheFromDBAndLogout(cache.getGeocode()); - search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST_ID, true, null); + search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST.id, true, null); assertThat(search).isNotNull(); assertThat(search.getGeocodes()).isEmpty(); } @@ -201,7 +201,7 @@ public class CgeoApplicationTest extends CGeoTestCase { deleteCacheFromDBAndLogout(cache.getGeocode()); - final SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST_ID, true, null); + final SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST.id, true, null); assertThat(search).isNotNull(); assertThat(search.getGeocodes()).isEmpty(); } diff --git a/tests/src/cgeo/geocaching/GeocacheTest.java b/tests/src/cgeo/geocaching/GeocacheTest.java index b3ec6be..722e1cf 100644 --- a/tests/src/cgeo/geocaching/GeocacheTest.java +++ b/tests/src/cgeo/geocaching/GeocacheTest.java @@ -86,7 +86,7 @@ public class GeocacheTest extends CGeoTestCase { assertThat(waypoint.getCoords()).isEqualTo(new Geopoint("N51 13.888 E007 03.444")); // assertThat(waypoint.getNote()).isEqualTo("Test"); assertThat(waypoint.getName()).isEqualTo(CgeoApplication.getInstance().getString(R.string.cache_personal_note) + " 1"); - cache.store(StoredList.TEMPORARY_LIST_ID, null); + cache.store(StoredList.TEMPORARY_LIST.id, null); } removeCacheCompletely(geocode); } finally { diff --git a/tests/src/cgeo/geocaching/export/GpxSerializerTest.java b/tests/src/cgeo/geocaching/export/GpxSerializerTest.java index 809c121..c43ad38 100644 --- a/tests/src/cgeo/geocaching/export/GpxSerializerTest.java +++ b/tests/src/cgeo/geocaching/export/GpxSerializerTest.java @@ -67,7 +67,7 @@ public class GpxSerializerTest extends AbstractResourceInstrumentationTestCase { assertThat(gpxFirst.length() > 0).isTrue(); - final GPX10Parser parser = new GPX10Parser(StoredList.TEMPORARY_LIST_ID); + final GPX10Parser parser = new GPX10Parser(StoredList.TEMPORARY_LIST.id); final InputStream stream = new ByteArrayInputStream(gpxFirst.getBytes(CharEncoding.UTF_8)); Collection<Geocache> caches = parser.parse(stream, null); diff --git a/tests/src/cgeo/geocaching/sensors/SensorsTest.java b/tests/src/cgeo/geocaching/sensors/SensorsTest.java index c4f70aa..b54cd13 100644 --- a/tests/src/cgeo/geocaching/sensors/SensorsTest.java +++ b/tests/src/cgeo/geocaching/sensors/SensorsTest.java @@ -3,6 +3,7 @@ package cgeo.geocaching.sensors; import static org.assertj.core.api.Assertions.assertThat; import cgeo.geocaching.MainActivity; +import cgeo.geocaching.utils.AngleUtils; import android.test.ActivityInstrumentationTestCase2; @@ -18,7 +19,7 @@ public class SensorsTest extends ActivityInstrumentationTestCase2<MainActivity> } public static void testGetDirectionNow() { - final float angle = DirectionProvider.getDirectionNow(1.0f); + final float angle = AngleUtils.getDirectionNow(1.0f); assertThat(angle == 1.0f || angle == 91.0f || angle == 181.0f || angle == 271.0f).isTrue(); } diff --git a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java index eaac181..2a22895 100644 --- a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java +++ b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java @@ -75,7 +75,7 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument protected void setUp() throws Exception { super.setUp(); temporaryListId = DataStore.createList("Temporary unit testing"); - assertThat(temporaryListId != StoredList.TEMPORARY_LIST_ID).isTrue(); + assertThat(temporaryListId != StoredList.TEMPORARY_LIST.id).isTrue(); assertThat(temporaryListId != StoredList.STANDARD_LIST_ID).isTrue(); } @@ -95,7 +95,7 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument final protected Geocache loadCacheFromResource(int resourceId) throws IOException, ParserException { final InputStream instream = getResourceStream(resourceId); try { - GPX10Parser parser = new GPX10Parser(StoredList.TEMPORARY_LIST_ID); + GPX10Parser parser = new GPX10Parser(StoredList.TEMPORARY_LIST.id); Collection<Geocache> caches = parser.parse(instream, null); assertThat(caches).isNotNull(); assertThat(caches.isEmpty()).isFalse(); diff --git a/tests/src/cgeo/geocaching/utils/TextUtilsTest.java b/tests/src/cgeo/geocaching/utils/TextUtilsTest.java index 29c4864..709fcc4 100644 --- a/tests/src/cgeo/geocaching/utils/TextUtilsTest.java +++ b/tests/src/cgeo/geocaching/utils/TextUtilsTest.java @@ -26,4 +26,11 @@ public class TextUtilsTest extends AndroidTestCase { assertThat(TextUtils.getMatch("some" + "\u001C" + "control" + (char) 0x1D + "characters removed", patternAll, "")).isEqualTo("some control characters removed"); assertThat(TextUtils.getMatch("newline\nalso\nremoved", patternAll, "")).isEqualTo("newline also removed"); } + + public static void testGetMatch() { + final Pattern patternAll = Pattern.compile("foo(...)"); + final String text = "abc-foobar-def-fooxyz-ghi-foobaz-jkl"; + assertThat(TextUtils.getMatch(text, patternAll, false, 1, null, false)).isEqualTo("bar"); + assertThat(TextUtils.getMatch(text, patternAll, false, 1, null, true)).isEqualTo("baz"); + } } |
