From 06d6621f6667b8547530995ed85d827f79ba8fc2 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Sun, 7 Sep 2014 12:19:19 +0200 Subject: verify waypoint name change on type change --- .../waypointactivity/AddWaypointActivityTest.java | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'tests/src') diff --git a/tests/src/cgeo/geocaching/waypointactivity/AddWaypointActivityTest.java b/tests/src/cgeo/geocaching/waypointactivity/AddWaypointActivityTest.java index 86a7684..cffdcfb 100644 --- a/tests/src/cgeo/geocaching/waypointactivity/AddWaypointActivityTest.java +++ b/tests/src/cgeo/geocaching/waypointactivity/AddWaypointActivityTest.java @@ -1,15 +1,27 @@ 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 cgeo.geocaching.R; -import cgeo.geocaching.enumerations.WaypointType; +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 { @@ -31,4 +43,20 @@ public class AddWaypointActivityTest extends AbstractAddWaypointActivityTest { 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()))); + } } -- cgit v1.1