app: test: Assert applicationInfo is non-null
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
parent
217fd97d3e
commit
4a235c6739
4 changed files with 13 additions and 13 deletions
|
@ -342,7 +342,7 @@ class MetadataManagerTest {
|
|||
|
||||
@Test
|
||||
fun `test onPackageBackedUp()`() {
|
||||
packageInfo.applicationInfo.flags = FLAG_SYSTEM
|
||||
packageInfo.applicationInfo!!.flags = FLAG_SYSTEM
|
||||
val updatedMetadata = initialMetadata.copy(
|
||||
time = time,
|
||||
packageMetadataMap = PackageMetadataMap() // otherwise this isn't copied, but referenced
|
||||
|
|
|
@ -118,12 +118,12 @@ internal class ApkBackupRestoreTest : TransportTest() {
|
|||
fun `test backup and restore with a split`(@TempDir tmpDir: Path) = runBlocking {
|
||||
val apkBytes = byteArrayOf(0x04, 0x05, 0x06)
|
||||
val tmpFile = File(tmpDir.toAbsolutePath().toString())
|
||||
packageInfo.applicationInfo.sourceDir = File(tmpFile, "test.apk").apply {
|
||||
packageInfo.applicationInfo!!.sourceDir = File(tmpFile, "test.apk").apply {
|
||||
assertTrue(createNewFile())
|
||||
writeBytes(apkBytes)
|
||||
}.absolutePath
|
||||
packageInfo.splitNames = arrayOf(splitName)
|
||||
packageInfo.applicationInfo.splitSourceDirs = arrayOf(File(tmpFile, "split.apk").apply {
|
||||
packageInfo.applicationInfo!!.splitSourceDirs = arrayOf(File(tmpFile, "split.apk").apply {
|
||||
assertTrue(createNewFile())
|
||||
writeBytes(splitBytes)
|
||||
}.absolutePath)
|
||||
|
@ -167,7 +167,7 @@ internal class ApkBackupRestoreTest : TransportTest() {
|
|||
coEvery { storagePlugin.getInputStream(token, name) } returns inputStream
|
||||
every { pm.getPackageArchiveInfo(capture(apkPath), any<Int>()) } returns packageInfo
|
||||
every { applicationInfo.loadIcon(pm) } returns icon
|
||||
every { pm.getApplicationLabel(packageInfo.applicationInfo) } returns appName
|
||||
every { pm.getApplicationLabel(packageInfo.applicationInfo!!) } returns appName
|
||||
every {
|
||||
splitCompatChecker.isCompatible(metadata.deviceName, listOf(splitName))
|
||||
} returns true
|
||||
|
|
|
@ -281,7 +281,7 @@ internal class ApkRestoreTest : TransportTest() {
|
|||
} returns apkInputStream
|
||||
every { pm.getPackageArchiveInfo(any(), any<Int>()) } returns packageInfo
|
||||
every { applicationInfo.loadIcon(pm) } returns icon
|
||||
every { pm.getApplicationLabel(packageInfo.applicationInfo) } returns appName
|
||||
every { pm.getApplicationLabel(packageInfo.applicationInfo!!) } returns appName
|
||||
coEvery {
|
||||
apkInstaller.install(match { it.size == 1 }, packageName, installerName, any())
|
||||
} returns installResult
|
||||
|
@ -706,7 +706,7 @@ internal class ApkRestoreTest : TransportTest() {
|
|||
coEvery { storagePlugin.getInputStream(token, name) } returns apkInputStream
|
||||
every { pm.getPackageArchiveInfo(any(), any<Int>()) } returns packageInfo
|
||||
every { applicationInfo.loadIcon(pm) } returns icon
|
||||
every { pm.getApplicationLabel(packageInfo.applicationInfo) } returns appName
|
||||
every { pm.getApplicationLabel(packageInfo.applicationInfo!!) } returns appName
|
||||
}
|
||||
|
||||
private suspend fun TurbineTestContext<InstallResult>.assertQueuedFailFinished() {
|
||||
|
|
|
@ -82,7 +82,7 @@ internal class ApkBackupTest : BackupTest() {
|
|||
|
||||
@Test
|
||||
fun `does not back up test-only apps`() = runBlocking {
|
||||
packageInfo.applicationInfo.flags = FLAG_TEST_ONLY
|
||||
packageInfo.applicationInfo!!.flags = FLAG_TEST_ONLY
|
||||
|
||||
every { settingsManager.isBackupEnabled(any()) } returns true
|
||||
every { settingsManager.backupApks() } returns true
|
||||
|
@ -91,7 +91,7 @@ internal class ApkBackupTest : BackupTest() {
|
|||
|
||||
@Test
|
||||
fun `does not back up system apps`() = runBlocking {
|
||||
packageInfo.applicationInfo.flags = FLAG_SYSTEM
|
||||
packageInfo.applicationInfo!!.flags = FLAG_SYSTEM
|
||||
|
||||
every { settingsManager.isBackupEnabled(any()) } returns true
|
||||
every { settingsManager.backupApks() } returns true
|
||||
|
@ -100,7 +100,7 @@ internal class ApkBackupTest : BackupTest() {
|
|||
|
||||
@Test
|
||||
fun `does not back up the same version`() = runBlocking {
|
||||
packageInfo.applicationInfo.flags = FLAG_UPDATED_SYSTEM_APP
|
||||
packageInfo.applicationInfo!!.flags = FLAG_UPDATED_SYSTEM_APP
|
||||
val packageMetadata = packageMetadata.copy(
|
||||
version = packageInfo.longVersionCode
|
||||
)
|
||||
|
@ -112,7 +112,7 @@ internal class ApkBackupTest : BackupTest() {
|
|||
|
||||
@Test
|
||||
fun `does back up the same version when signatures changes`() {
|
||||
packageInfo.applicationInfo.sourceDir = "/tmp/doesNotExist"
|
||||
packageInfo.applicationInfo!!.sourceDir = "/tmp/doesNotExist"
|
||||
|
||||
expectChecks()
|
||||
|
||||
|
@ -140,7 +140,7 @@ internal class ApkBackupTest : BackupTest() {
|
|||
fun `test successful APK backup`(@TempDir tmpDir: Path) = runBlocking {
|
||||
val apkBytes = byteArrayOf(0x04, 0x05, 0x06)
|
||||
val tmpFile = File(tmpDir.toAbsolutePath().toString())
|
||||
packageInfo.applicationInfo.sourceDir = File(tmpFile, "test.apk").apply {
|
||||
packageInfo.applicationInfo!!.sourceDir = File(tmpFile, "test.apk").apply {
|
||||
assertTrue(createNewFile())
|
||||
writeBytes(apkBytes)
|
||||
}.absolutePath
|
||||
|
@ -174,7 +174,7 @@ internal class ApkBackupTest : BackupTest() {
|
|||
// create base APK
|
||||
val apkBytes = byteArrayOf(0x04, 0x05, 0x06) // not random because of hash
|
||||
val tmpFile = File(tmpDir.toAbsolutePath().toString())
|
||||
packageInfo.applicationInfo.sourceDir = File(tmpFile, "test.apk").apply {
|
||||
packageInfo.applicationInfo!!.sourceDir = File(tmpFile, "test.apk").apply {
|
||||
assertTrue(createNewFile())
|
||||
writeBytes(apkBytes)
|
||||
}.absolutePath
|
||||
|
@ -187,7 +187,7 @@ internal class ApkBackupTest : BackupTest() {
|
|||
val split1Sha256 = "ZqZ1cVH47lXbEncWx-Pc4L6AdLZOIO2lQuXB5GypxB4"
|
||||
val split2Bytes = byteArrayOf(0x01, 0x02, 0x03)
|
||||
val split2Sha256 = "A5BYxvLAy0ksUzsKTRTvd8wPeKvMztUofYShogEc-4E"
|
||||
packageInfo.applicationInfo.splitSourceDirs = arrayOf(
|
||||
packageInfo.applicationInfo!!.splitSourceDirs = arrayOf(
|
||||
File(tmpFile, "test-$split1Name.apk").apply {
|
||||
assertTrue(createNewFile())
|
||||
writeBytes(split1Bytes)
|
||||
|
|
Loading…
Reference in a new issue