Created
February 21, 2019 12:17
-
-
Save pedrovgs/6a305ba4c5e3acfac854ce4c36558d9b to your computer and use it in GitHub Desktop.
Revisions
-
pedrovgs created this gist
Feb 21, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ package com.aplazame.utils import android.app.Activity import androidx.test.espresso.intent.Intents import androidx.test.rule.ActivityTestRule class ExhaustiveIntentsTestRule<T : Activity> : ActivityTestRule<T> { private var isInitialized: Boolean = false constructor(activityClass: Class<T>) : super(activityClass) constructor(activityClass: Class<T>, initialTouchMode: Boolean) : super(activityClass, initialTouchMode) constructor(activityClass: Class<T>, initialTouchMode: Boolean, launchActivity: Boolean) : super( activityClass, initialTouchMode, launchActivity ) override fun beforeActivityLaunched() { super.beforeActivityLaunched() Intents.init() isInitialized = true } override fun afterActivityFinished() { super.afterActivityFinished() if (isInitialized) { // Otherwise will throw a NPE if Intents.init() wasn't called. Intents.release() isInitialized = false } } }