Issue#67 Extract ActivityScenario.safeClose into separate module
This commit is contained in:
parent
689aee9702
commit
1c0153db75
8 changed files with 15 additions and 9 deletions
|
|
@ -31,4 +31,5 @@ android {
|
|||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
|
||||
implementation "androidx.test:core:$androidx_test_version"
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package org.fnives.test.showcase.android.testutil.activity
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
|
||||
/**
|
||||
* Workaround for issue: https://github.com/android/android-test/issues/676.
|
||||
*
|
||||
* Call this instead of ActivityScenario.close().
|
||||
*/
|
||||
fun <T : Activity> ActivityScenario<T>.safeClose() {
|
||||
workaroundForActivityScenarioCLoseLockingUp()
|
||||
close()
|
||||
}
|
||||
|
||||
/**
|
||||
* This should not be needed, we shouldn't use sleep basically ever.
|
||||
* However, it seems to be and issue described here: https://github.com/android/android-test/issues/676
|
||||
*
|
||||
* If an activity is finished in code, the ActivityScenario.close() can hang 30 to 45 seconds.
|
||||
* This sleep let's the Activity finish it's state change and unlocks the ActivityScenario.
|
||||
*
|
||||
* As soon as that issue is closed, this should be removed as well.
|
||||
*/
|
||||
private fun workaroundForActivityScenarioCLoseLockingUp() {
|
||||
Thread.sleep(1000L)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue