diff options
Diffstat (limited to 'tests/src/cgeo/geocaching/activity/AbstractEspressoTest.java')
-rw-r--r-- | tests/src/cgeo/geocaching/activity/AbstractEspressoTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/activity/AbstractEspressoTest.java b/tests/src/cgeo/geocaching/activity/AbstractEspressoTest.java new file mode 100644 index 0000000..0647ec8 --- /dev/null +++ b/tests/src/cgeo/geocaching/activity/AbstractEspressoTest.java @@ -0,0 +1,30 @@ +package cgeo.geocaching.activity; + +import static com.google.android.apps.common.testing.ui.espresso.Espresso.onData; +import static com.google.android.apps.common.testing.ui.espresso.Espresso.openActionBarOverflowOrOptionsMenu; +import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click; +import static org.hamcrest.Matchers.hasToString; +import static org.hamcrest.Matchers.startsWith; + +import android.app.Activity; +import android.test.ActivityInstrumentationTestCase2; + +public abstract class AbstractEspressoTest<T extends Activity> extends ActivityInstrumentationTestCase2<T> { + + public AbstractEspressoTest(Class<T> activityClass) { + super(activityClass); + } + + protected final void clickActionBarItem(int labelResourceId) { + onData(hasToString(startsWith(getString(labelResourceId)))).perform(click()); + } + + protected final void openActionBar() { + openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext()); + } + + protected final String getString(int resId) { + return getActivity().getString(resId); + } + +} |