Skip to content

Instantly share code, notes, and snippets.

@Cassie-von-Clausewitz
Created September 8, 2017 05:40
Show Gist options
  • Save Cassie-von-Clausewitz/47a60e0dda2ebaee8d577094ea8e9501 to your computer and use it in GitHub Desktop.
Save Cassie-von-Clausewitz/47a60e0dda2ebaee8d577094ea8e9501 to your computer and use it in GitHub Desktop.
Blank extension of an ActivityTestRule, need to extend if you want to be able to do something before or after the activity is launched or finished
import android.app.Activity
import android.content.Intent
import android.support.test.rule.ActivityTestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
class AcceptanceTestRule<A : Activity?>(activityClass: Class<A>?, initialTouchMode: Boolean, launchActivity: Boolean) : ActivityTestRule<A>(activityClass, initialTouchMode, launchActivity) {
override fun afterActivityLaunched() {
super.afterActivityLaunched()
}
override fun beforeActivityLaunched() {
super.beforeActivityLaunched()
}
override fun apply(base: Statement?, description: Description?): Statement =
super.apply(base, description)
override fun afterActivityFinished() {
super.afterActivityFinished()
}
override fun getActivityIntent(): Intent = super.getActivityIntent()
override fun getActivity(): A = super.getActivity()
override fun launchActivity(startIntent: Intent?): A = super.launchActivity(startIntent)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment