log stopped packages in CI test

This commit is contained in:
Torsten Grote 2024-10-11 12:46:16 -03:00
parent b8c87a6928
commit 1d17adedff
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF

View file

@ -5,7 +5,6 @@
package com.stevesoltys.seedvault.e2e.impl package com.stevesoltys.seedvault.e2e.impl
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.util.Log import android.util.Log
import androidx.test.filters.LargeTest import androidx.test.filters.LargeTest
@ -13,7 +12,7 @@ import com.stevesoltys.seedvault.MAGIC_PACKAGE_MANAGER
import com.stevesoltys.seedvault.e2e.SeedvaultLargeTest import com.stevesoltys.seedvault.e2e.SeedvaultLargeTest
import com.stevesoltys.seedvault.e2e.SeedvaultLargeTestResult import com.stevesoltys.seedvault.e2e.SeedvaultLargeTestResult
import com.stevesoltys.seedvault.metadata.PackageState import com.stevesoltys.seedvault.metadata.PackageState
import com.stevesoltys.seedvault.settings.SettingsActivity import com.stevesoltys.seedvault.transport.backup.isStopped
import org.junit.Test import org.junit.Test
@LargeTest @LargeTest
@ -67,7 +66,8 @@ internal class BackupRestoreTest : SeedvaultLargeTest() {
private fun launchStoppedApps() { private fun launchStoppedApps() {
val packageManager = targetContext.packageManager val packageManager = targetContext.packageManager
packageService.notBackedUpPackages.forEach { packageInfo -> val notBackedUp = packageService.notBackedUpPackages
notBackedUp.forEach { packageInfo ->
val i = packageManager.getLaunchIntentForPackage(packageInfo.packageName)?.apply { val i = packageManager.getLaunchIntentForPackage(packageInfo.packageName)?.apply {
addFlags(FLAG_ACTIVITY_NEW_TASK) addFlags(FLAG_ACTIVITY_NEW_TASK)
} }
@ -77,12 +77,13 @@ internal class BackupRestoreTest : SeedvaultLargeTest() {
} catch (e: Exception) { } catch (e: Exception) {
Log.e("TEST", "Could not launch activity for ${packageInfo.packageName}", e) Log.e("TEST", "Could not launch activity for ${packageInfo.packageName}", e)
} }
waitUntilIdle()
} }
// at the end launch us again, so we are back to foreground waitUntilIdle()
val i = Intent(targetContext, SettingsActivity::class.java).apply { notBackedUp.forEach { packageInfo ->
flags = FLAG_ACTIVITY_NEW_TASK val pi = packageManager.getPackageInfo(packageInfo.packageName, 0)
Log.e("TEST", "${packageInfo.packageName} isStopped: ${pi.isStopped()}")
} }
targetContext.startActivity(i)
} }
private fun assertValidResults( private fun assertValidResults(