android-test
android-test copied to clipboard
Remove need to initialize and teardown Intents support
@brettchabot Just so I'm clear on this one; this is regarding the Intents.init() and Intents.release() calls inside IntentsTestRule, correct?
What we'd like to do is use ServiceLoader to dynamically initialize this if the library is on the classpath. We'd like to do the same thing for the Accessibility support too and possibly use the plugin API to handle this. I was going to pair with Christian on this next week to see if it makes sense.
One thing that would help here would be to just add an updated or alternative version of IntentsTestRule
that manages the init
and release
calls. For instance:
class RecordedIntentsRule : TestRule {
override fun apply(base: Statement, description: Description): Statement {
return object : Statement() {
override fun evaluate() {
try {
Intents.init()
base.evaluate()
} finally {
Intents.release()
}
}
}
}
}
This would make it easier to write tests using Intents
and ActivityScenario
(as opposed to IntentsTestRule
which extends the old ActivityTestRule
) without needing to rework Intents
.