aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/cgeo/geocaching')
-rw-r--r--tests/src/cgeo/geocaching/CgeoApplicationTest.java6
-rw-r--r--tests/src/cgeo/geocaching/GeocacheTest.java2
-rw-r--r--tests/src/cgeo/geocaching/export/GpxSerializerTest.java2
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java39
-rw-r--r--tests/src/cgeo/geocaching/gcvote/GCVoteTest.java47
-rw-r--r--tests/src/cgeo/geocaching/sensors/SensorsTest.java3
-rw-r--r--tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java4
-rw-r--r--tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java5
-rw-r--r--tests/src/cgeo/geocaching/utils/TextUtilsTest.java7
-rw-r--r--tests/src/cgeo/geocaching/waypointactivity/AbstractAddWaypointActivityTest.java12
-rw-r--r--tests/src/cgeo/geocaching/waypointactivity/AbstractEditWaypointActivityTest.java28
-rw-r--r--tests/src/cgeo/geocaching/waypointactivity/AbstractWaypointActivityTest.java53
-rw-r--r--tests/src/cgeo/geocaching/waypointactivity/AddWaypointActivityTest.java62
-rw-r--r--tests/src/cgeo/geocaching/waypointactivity/AddWaypointMultiTest.java34
-rw-r--r--tests/src/cgeo/geocaching/waypointactivity/AddWaypointMysteryTest.java32
-rw-r--r--tests/src/cgeo/geocaching/waypointactivity/EditWaypointActivityTest.java29
16 files changed, 351 insertions, 14 deletions
diff --git a/tests/src/cgeo/geocaching/CgeoApplicationTest.java b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
index de3f4ba..5344742 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/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index 6171bab..7c72a61 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -375,14 +375,41 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
public void testGPXMysteryType() throws IOException, ParserException {
final List<Geocache> caches = readGPX10(R.raw.tc2012);
- Geocache mystery = null;
- for (Geocache geocache : caches) {
- if (geocache.getName().equals("U017")) {
- mystery = geocache;
- }
- }
+ Geocache mystery = getCache(caches, "U017");
assertThat(mystery).isNotNull();
assert (mystery != null);
assertThat(mystery.getType()).isEqualTo(CacheType.MYSTERY);
}
+
+ private static Geocache getCache(final List<Geocache> caches, String geocode) {
+ for (Geocache geocache : caches) {
+ if (geocache.getName().equals(geocode)) {
+ return geocache;
+ }
+ }
+ return null;
+ }
+
+ public void testLabCaches() throws IOException, ParserException {
+ final List<Geocache> caches = readGPX10(R.raw.giga_lab_caches);
+ assertThat(caches).hasSize(10);
+ Geocache lab = getCache(caches, "01_Munich Olympic Walk Of Stars_Updated-Project MUNICH2014 - Mia san Giga! Olympiapark");
+ assertThat(lab).isNotNull();
+
+ // parse labs as virtual for the time being
+ assertThat(lab.getType()).isEqualTo(CacheType.VIRTUAL);
+
+ // no difficulty and terrain rating
+ assertThat(lab.getTerrain()).isEqualTo(0);
+ assertThat(lab.getDifficulty()).isEqualTo(0);
+
+ // geocodes are just big hashes
+ assertThat(lab.getGeocode()).isEqualTo("01_Munich Olympic Walk Of Stars_Updated-Project MUNICH2014 - Mia san Giga! Olympiapark".toUpperCase(Locale.US));
+
+ // other normal cache properties
+ assertThat(lab.getName()).isEqualTo("01_Munich Olympic Walk Of Stars_Updated-Project MUNICH2014 - Mia san Giga! Olympiapark");
+ assertThat(lab.getShortDescription()).isEqualTo("01_Munich Olympic Walk Of Stars_Updated (Giga! Olympia Park)-Project MUNICH2014 - Mia san Giga! Olympiapark");
+ assertThat(lab.getDescription()).startsWith("DEU:");
+ }
+
}
diff --git a/tests/src/cgeo/geocaching/gcvote/GCVoteTest.java b/tests/src/cgeo/geocaching/gcvote/GCVoteTest.java
new file mode 100644
index 0000000..c1b5e75
--- /dev/null
+++ b/tests/src/cgeo/geocaching/gcvote/GCVoteTest.java
@@ -0,0 +1,47 @@
+package cgeo.geocaching.gcvote;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
+import cgeo.geocaching.test.R;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+public class GCVoteTest extends AbstractResourceInstrumentationTestCase {
+
+ private InputStream responseStream;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ responseStream = new ByteArrayInputStream(getFileContent(R.raw.gcvote).getBytes());
+ responseStream.mark(getFileContent(R.raw.gcvote).getBytes().length + 1);
+ }
+
+ private InputStream responseStream() {
+ try {
+ responseStream.reset();
+ } catch (final IOException ignored) {
+ // Cannot happen
+ }
+ return responseStream;
+ }
+
+ public void testGetRatingsByGeocode() {
+ final Map<String, GCVoteRating> ratings = GCVote.getRatingsFromXMLResponse(responseStream(), false);
+ assertThat(ratings).hasSize(10);
+ assertThat(ratings).containsKey("GCKF13");
+ assertThat(ratings.get("GC1WEVZ")).isEqualToComparingFieldByField(new GCVoteRating(3.75f, 2, 0));
+ }
+
+ public void testGetRatingsByGuid() {
+ final Map<String, GCVoteRating> ratings = GCVote.getRatingsFromXMLResponse(responseStream(), true);
+ assertThat(ratings).hasSize(10);
+ assertThat(ratings).containsKey("a02894bb-4a08-4c09-a73c-25939894ba15");
+ assertThat(ratings.get("5520c33b-3941-45ca-9056-ea655dbaadf7")).isEqualToComparingFieldByField(new GCVoteRating(3.75f, 2, 0));
+ }
+
+}
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/HtmlUtilsTest.java b/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java
index 65e86b8..e75c2e6 100644
--- a/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java
@@ -15,4 +15,9 @@ public class HtmlUtilsTest extends TestCase {
assertThat(HtmlUtils.extractText("<b>bold</b>")).isEqualTo("bold");
}
+ public static void testRemoveExtraParagraph() {
+ assertThat(HtmlUtils.removeExtraParagraph("<p></p>")).isEqualTo("");
+ assertThat(HtmlUtils.removeExtraParagraph("<p>Test</p>")).isEqualTo("Test");
+ assertThat(HtmlUtils.removeExtraParagraph("<p>1</p><p>2</p>")).isEqualTo("<p>1</p><p>2</p>");
+ }
}
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");
+ }
}
diff --git a/tests/src/cgeo/geocaching/waypointactivity/AbstractAddWaypointActivityTest.java b/tests/src/cgeo/geocaching/waypointactivity/AbstractAddWaypointActivityTest.java
new file mode 100644
index 0000000..b5dea39
--- /dev/null
+++ b/tests/src/cgeo/geocaching/waypointactivity/AbstractAddWaypointActivityTest.java
@@ -0,0 +1,12 @@
+package cgeo.geocaching.waypointactivity;
+
+import cgeo.geocaching.EditWaypointActivity_;
+
+public abstract class AbstractAddWaypointActivityTest extends AbstractWaypointActivityTest {
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ setActivityIntent(new EditWaypointActivity_.IntentBuilder_(getInstrumentation().getContext()).geocode(getCache().getGeocode()).get());
+ getActivity();
+ }
+}
diff --git a/tests/src/cgeo/geocaching/waypointactivity/AbstractEditWaypointActivityTest.java b/tests/src/cgeo/geocaching/waypointactivity/AbstractEditWaypointActivityTest.java
new file mode 100644
index 0000000..e5cdf69
--- /dev/null
+++ b/tests/src/cgeo/geocaching/waypointactivity/AbstractEditWaypointActivityTest.java
@@ -0,0 +1,28 @@
+package cgeo.geocaching.waypointactivity;
+
+import cgeo.geocaching.EditWaypointActivity_;
+import cgeo.geocaching.Waypoint;
+import cgeo.geocaching.enumerations.WaypointType;
+
+public abstract class AbstractEditWaypointActivityTest extends AbstractWaypointActivityTest {
+ private Waypoint waypoint;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ createWaypoint();
+ getCache().addOrChangeWaypoint(waypoint, true);
+ final int waypointId = getCache().getWaypoints().get(0).getId();
+ setActivityIntent(new EditWaypointActivity_.IntentBuilder_(getInstrumentation().getContext()).geocode(getCache().getGeocode()).waypointId(waypointId).get());
+ getActivity();
+ }
+
+ private void createWaypoint() {
+ waypoint = new Waypoint("Test waypoint", WaypointType.PUZZLE, true);
+ waypoint.setNote("Test note");
+ }
+
+ protected final Waypoint getWaypoint() {
+ return waypoint;
+ }
+}
diff --git a/tests/src/cgeo/geocaching/waypointactivity/AbstractWaypointActivityTest.java b/tests/src/cgeo/geocaching/waypointactivity/AbstractWaypointActivityTest.java
new file mode 100644
index 0000000..1a5783c
--- /dev/null
+++ b/tests/src/cgeo/geocaching/waypointactivity/AbstractWaypointActivityTest.java
@@ -0,0 +1,53 @@
+package cgeo.geocaching.waypointactivity;
+
+import cgeo.geocaching.DataStore;
+import cgeo.geocaching.EditWaypointActivity_;
+import cgeo.geocaching.Geocache;
+import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.LoadFlags;
+import cgeo.geocaching.enumerations.LoadFlags.SaveFlag;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+import java.util.Collections;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public abstract class AbstractWaypointActivityTest extends ActivityInstrumentationTestCase2<EditWaypointActivity_> {
+
+ private Geocache cache;
+
+ public AbstractWaypointActivityTest() {
+ super(EditWaypointActivity_.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ cache = createTestCache();
+ DataStore.saveCache(cache, Collections.singleton(SaveFlag.CACHE));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ removeTestCache();
+ super.tearDown();
+ }
+
+ protected final Geocache getCache() {
+ return cache;
+ }
+
+ private void removeTestCache() {
+ DataStore.removeCache(cache.getGeocode(), LoadFlags.REMOVE_ALL);
+ assertThat(DataStore.loadCache(cache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB)).isNull();
+ }
+
+ @SuppressWarnings("static-method")
+ protected Geocache createTestCache() {
+ Geocache testCache = new Geocache();
+ testCache.setGeocode("TEST");
+ testCache.setType(CacheType.TRADITIONAL);
+ return testCache;
+ }
+}
diff --git a/tests/src/cgeo/geocaching/waypointactivity/AddWaypointActivityTest.java b/tests/src/cgeo/geocaching/waypointactivity/AddWaypointActivityTest.java
new file mode 100644
index 0000000..cffdcfb
--- /dev/null
+++ b/tests/src/cgeo/geocaching/waypointactivity/AddWaypointActivityTest.java
@@ -0,0 +1,62 @@
+package cgeo.geocaching.waypointactivity;
+
+import cgeo.geocaching.R;
+import cgeo.geocaching.enumerations.WaypointType;
+
+import com.google.android.apps.common.testing.ui.espresso.action.ViewActions;
+
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onData;
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
+
+import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
+
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isClickable;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isDisplayed;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isNotChecked;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withChild;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
+
+import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click;
+
+import static org.hamcrest.Matchers.hasToString;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.startsWith;
+
+public class AddWaypointActivityTest extends AbstractAddWaypointActivityTest {
+
+ public static void testAddWayPointHasTypeSelection() {
+ onView(withId(R.id.type)).check(matches(isDisplayed()));
+ }
+
+ public static void testDefaultWaypointTypeForTraditional() {
+ onView(withId(R.id.type)).check(matches(withChild(withText(WaypointType.WAYPOINT.getL10n()))));
+ onView(withId(R.id.name)).check(matches(withText(WaypointType.WAYPOINT.getL10n() + " 1")));
+ }
+
+ public static void testFieldsAreEmpty() {
+ onView(withId(R.id.note)).check(matches(withText("")));
+ onView(withId(R.id.bearing)).check(matches(withText("")));
+ onView(withId(R.id.distance)).check(matches(withText("")));
+ }
+
+ public static void testNewWaypointNotVisited() {
+ onView(withId(R.id.wpt_visited_checkbox)).check(matches(isNotChecked()));
+ }
+
+ public static void testSwitchingWaypointTypeChangesWaypointName() {
+ WaypointType waypointType = WaypointType.FINAL;
+
+ // verify we don't have a final type yet
+ onView(withId(R.id.name)).check(matches(not(withText(waypointType.getL10n()))));
+
+ // open type selector
+ onView(withId(R.id.type)).perform(ViewActions.click());
+
+ // select final type
+ onData(hasToString(startsWith(waypointType.getL10n()))).inAdapterView(isClickable()).perform(click());
+
+ // verify changed name
+ onView(withId(R.id.name)).check(matches(withText(waypointType.getL10n())));
+ }
+}
diff --git a/tests/src/cgeo/geocaching/waypointactivity/AddWaypointMultiTest.java b/tests/src/cgeo/geocaching/waypointactivity/AddWaypointMultiTest.java
new file mode 100644
index 0000000..3a32570
--- /dev/null
+++ b/tests/src/cgeo/geocaching/waypointactivity/AddWaypointMultiTest.java
@@ -0,0 +1,34 @@
+package cgeo.geocaching.waypointactivity;
+
+import cgeo.geocaching.Geocache;
+import cgeo.geocaching.R;
+import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.WaypointType;
+
+import com.google.android.apps.common.testing.ui.espresso.ViewInteraction;
+
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
+
+import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
+
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isDisplayed;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withChild;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
+
+public class AddWaypointMultiTest extends AbstractAddWaypointActivityTest {
+
+ @Override
+ protected Geocache createTestCache() {
+ final Geocache cache = super.createTestCache();
+ cache.setType(CacheType.MULTI);
+ return cache;
+ }
+
+ public static void testMysteryDefaultWaypointFinal() {
+ final ViewInteraction waypointTypeSelector = onView(withId(R.id.type));
+ waypointTypeSelector.check(matches(isDisplayed()));
+ waypointTypeSelector.check(matches(withChild(withText(WaypointType.STAGE.getL10n()))));
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/waypointactivity/AddWaypointMysteryTest.java b/tests/src/cgeo/geocaching/waypointactivity/AddWaypointMysteryTest.java
new file mode 100644
index 0000000..248f107
--- /dev/null
+++ b/tests/src/cgeo/geocaching/waypointactivity/AddWaypointMysteryTest.java
@@ -0,0 +1,32 @@
+package cgeo.geocaching.waypointactivity;
+
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
+import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isDisplayed;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withChild;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
+
+import cgeo.geocaching.Geocache;
+import cgeo.geocaching.R;
+import cgeo.geocaching.enumerations.CacheType;
+import cgeo.geocaching.enumerations.WaypointType;
+
+import com.google.android.apps.common.testing.ui.espresso.ViewInteraction;
+
+public class AddWaypointMysteryTest extends AbstractAddWaypointActivityTest {
+
+ @Override
+ protected Geocache createTestCache() {
+ final Geocache cache = super.createTestCache();
+ cache.setType(CacheType.MYSTERY);
+ return cache;
+ }
+
+ public static void testMysteryDefaultWaypointFinal() {
+ final ViewInteraction waypointTypeSelector = onView(withId(R.id.type));
+ waypointTypeSelector.check(matches(isDisplayed()));
+ waypointTypeSelector.check(matches(withChild(withText(WaypointType.FINAL.getL10n()))));
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/waypointactivity/EditWaypointActivityTest.java b/tests/src/cgeo/geocaching/waypointactivity/EditWaypointActivityTest.java
new file mode 100644
index 0000000..eda86cc
--- /dev/null
+++ b/tests/src/cgeo/geocaching/waypointactivity/EditWaypointActivityTest.java
@@ -0,0 +1,29 @@
+package cgeo.geocaching.waypointactivity;
+
+import cgeo.geocaching.R;
+
+import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
+
+import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
+
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withChild;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
+import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class EditWaypointActivityTest extends AbstractEditWaypointActivityTest {
+
+ public void testFieldsAreNotEmpty() {
+ String name = getWaypoint().getName();
+ assertThat(name).isNotEmpty();
+ onView(withId(R.id.name)).check(matches(withText(name)));
+
+ final String note = getWaypoint().getNote();
+ assertThat(note).isNotEmpty();
+ onView(withId(R.id.note)).check(matches(withText(note)));
+
+ onView(withId(R.id.type)).check(matches(withChild(withText(getWaypoint().getWaypointType().getL10n()))));
+ }
+
+}