code review
This commit is contained in:
parent
adb5b4c1b9
commit
e1292c03a1
@ -40,7 +40,7 @@ import kotlin.coroutines.resume
|
|||||||
class DeactivateAccountTest : InstrumentedTest {
|
class DeactivateAccountTest : InstrumentedTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun deactivateAccountTest() = runSessionTest(context()) { commonTestHelper ->
|
fun deactivateAccountTest() = runSessionTest(context(), false /* session will be deactivated */) { commonTestHelper ->
|
||||||
val session = commonTestHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(withInitialSync = true))
|
val session = commonTestHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(withInitialSync = true))
|
||||||
|
|
||||||
// Deactivate the account
|
// Deactivate the account
|
||||||
|
@ -57,25 +57,29 @@ import java.util.concurrent.TimeUnit
|
|||||||
class CommonTestHelper private constructor(context: Context) {
|
class CommonTestHelper private constructor(context: Context) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
internal fun runSessionTest(context: Context, block: (CommonTestHelper) -> Unit) {
|
internal fun runSessionTest(context: Context, autoSignoutOnClose: Boolean = true, block: (CommonTestHelper) -> Unit) {
|
||||||
val testHelper = CommonTestHelper(context)
|
val testHelper = CommonTestHelper(context)
|
||||||
return try {
|
return try {
|
||||||
block(testHelper)
|
block(testHelper)
|
||||||
} finally {
|
} finally {
|
||||||
|
if (autoSignoutOnClose) {
|
||||||
testHelper.cleanUpOpenedSessions()
|
testHelper.cleanUpOpenedSessions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal fun runCryptoTest(context: Context, block: (CryptoTestHelper, CommonTestHelper) -> Unit) {
|
internal fun runCryptoTest(context: Context, autoSignoutOnClose: Boolean = true, block: (CryptoTestHelper, CommonTestHelper) -> Unit) {
|
||||||
val testHelper = CommonTestHelper(context)
|
val testHelper = CommonTestHelper(context)
|
||||||
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
val cryptoTestHelper = CryptoTestHelper(testHelper)
|
||||||
return try {
|
return try {
|
||||||
block(cryptoTestHelper, testHelper)
|
block(cryptoTestHelper, testHelper)
|
||||||
} finally {
|
} finally {
|
||||||
|
if (autoSignoutOnClose) {
|
||||||
testHelper.cleanUpOpenedSessions()
|
testHelper.cleanUpOpenedSessions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal val matrix: TestMatrix
|
internal val matrix: TestMatrix
|
||||||
private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
||||||
@ -110,11 +114,7 @@ class CommonTestHelper private constructor(context: Context) {
|
|||||||
fun cleanUpOpenedSessions() {
|
fun cleanUpOpenedSessions() {
|
||||||
trackedSessions.forEach {
|
trackedSessions.forEach {
|
||||||
runBlockingTest {
|
runBlockingTest {
|
||||||
try {
|
|
||||||
it.signOutService().signOut(true)
|
it.signOutService().signOut(true)
|
||||||
} catch (failure: Throwable) {
|
|
||||||
// Well, as long as you tried.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trackedSessions.clear()
|
trackedSessions.clear()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user