Improve HelpActivity TestSetup & add test for #98

This commit is contained in:
ligi 2016-08-21 19:23:24 +02:00
parent 3f5ffb18ea
commit a6a23834d9
2 changed files with 36 additions and 37 deletions

View file

@ -1,37 +0,0 @@
package org.ligi.passandroid;
import android.support.test.filters.SmallTest;
import com.squareup.spoon.Spoon;
import org.ligi.passandroid.ui.HelpActivity;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription;
import static org.ligi.passandroid.steps.HelpSteps.checkThatHelpIsThere;
public class TheHelpActivity extends BaseIntegration<HelpActivity> {
public TheHelpActivity() {
super(HelpActivity.class);
}
@Override
public void setUp() throws Exception {
super.setUp();
getActivity();
}
@SmallTest
public void testHelpIsThere() {
checkThatHelpIsThere();
Spoon.screenshot(getActivity(), "help");
}
@SmallTest
public void test_that_help_finishes_on_home() {
onView(withContentDescription(R.string.abc_action_bar_up_description)).perform(click());
assertTrue(getActivity().isFinishing());
}
}

View file

@ -0,0 +1,36 @@
package org.ligi.passandroid
import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.action.ViewActions.click
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.*
import android.support.test.rule.ActivityTestRule
import junit.framework.Assert
import org.junit.Rule
import org.junit.Test
import org.ligi.passandroid.helper.ScreenshotTaker
import org.ligi.passandroid.steps.HelpSteps.checkThatHelpIsThere
import org.ligi.passandroid.ui.HelpActivity
class TheHelpActivity {
@get:Rule
val rule: ActivityTestRule<HelpActivity> = ActivityTestRule(HelpActivity::class.java)
@Test
fun testHelpIsThere() {
checkThatHelpIsThere()
ScreenshotTaker.takeScreenshot(rule.activity, "help")
}
@Test
fun test_that_help_finishes_on_home() {
onView(withContentDescription(R.string.abc_action_bar_up_description)).perform(click())
Assert.assertTrue(rule.activity.isFinishing)
}
@Test
fun test_that_version_is_shown() {
onView(withText("v" + BuildConfig.VERSION_NAME)).check(matches(isDisplayed()))
}
}