Show app is in progress before we download APKs
This commit is contained in:
parent
7214d9c666
commit
40d0f55012
3 changed files with 23 additions and 0 deletions
|
@ -153,6 +153,13 @@ internal class ApkRestore(
|
||||||
packageName: String,
|
packageName: String,
|
||||||
metadata: PackageMetadata,
|
metadata: PackageMetadata,
|
||||||
) {
|
) {
|
||||||
|
// show that app is in progress, before we start downloading stuff
|
||||||
|
mInstallResult.update {
|
||||||
|
it.update(packageName) { result ->
|
||||||
|
result.copy(state = IN_PROGRESS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// cache the APK and get its hash
|
// cache the APK and get its hash
|
||||||
val (cachedApk, sha256) = cacheApk(backup.version, backup.token, backup.salt, packageName)
|
val (cachedApk, sha256) = cacheApk(backup.version, backup.token, backup.salt, packageName)
|
||||||
|
|
||||||
|
|
|
@ -194,6 +194,13 @@ internal class ApkBackupRestoreTest : TransportTest() {
|
||||||
assertEquals(IN_PROGRESS, it.installResults[packageName]?.state)
|
assertEquals(IN_PROGRESS, it.installResults[packageName]?.state)
|
||||||
assertFalse(it.isFinished)
|
assertFalse(it.isFinished)
|
||||||
}
|
}
|
||||||
|
awaitItem().also {
|
||||||
|
assertFalse(it.hasFailed)
|
||||||
|
assertEquals(1, it.total)
|
||||||
|
assertEquals(1, it.list.size)
|
||||||
|
assertEquals(IN_PROGRESS, it.installResults[packageName]?.state)
|
||||||
|
assertFalse(it.isFinished)
|
||||||
|
}
|
||||||
awaitItem().also {
|
awaitItem().also {
|
||||||
assertFalse(it.hasFailed)
|
assertFalse(it.hasFailed)
|
||||||
assertEquals(1, it.total)
|
assertEquals(1, it.total)
|
||||||
|
|
|
@ -46,6 +46,7 @@ import kotlinx.coroutines.runBlocking
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
import org.junit.jupiter.api.Assertions.assertFalse
|
import org.junit.jupiter.api.Assertions.assertFalse
|
||||||
|
import org.junit.jupiter.api.Assertions.assertNull
|
||||||
import org.junit.jupiter.api.Assertions.assertTrue
|
import org.junit.jupiter.api.Assertions.assertTrue
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.io.TempDir
|
import org.junit.jupiter.api.io.TempDir
|
||||||
|
@ -758,6 +759,14 @@ internal class ApkRestoreTest : TransportTest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun TurbineTestContext<InstallResult>.awaitInProgressItem(): InstallResult {
|
private suspend fun TurbineTestContext<InstallResult>.awaitInProgressItem(): InstallResult {
|
||||||
|
awaitItem().also { item ->
|
||||||
|
val result = item[packageName]
|
||||||
|
assertEquals(IN_PROGRESS, result.state)
|
||||||
|
assertFalse(item.hasFailed)
|
||||||
|
assertEquals(1, item.total)
|
||||||
|
assertEquals(1, item.list.size)
|
||||||
|
assertNull(result.icon)
|
||||||
|
}
|
||||||
val item = awaitItem()
|
val item = awaitItem()
|
||||||
// name and icon are available now
|
// name and icon are available now
|
||||||
val result = item[packageName]
|
val result = item[packageName]
|
||||||
|
|
Loading…
Reference in a new issue