diff --git a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt index 8ed5683..cbdc034 100644 --- a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt +++ b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt @@ -121,22 +121,24 @@ internal class DeviceRunController( val deviceActions = mutableListOf() // App installation - deviceActions.add( - DeviceAction( - androidInstallPackages = AndroidInstallPackagesDeviceAction( - targetApp = appApk?.let { - AndroidInstallable( - files = listOf(InputFile(gcsInputFile = GcsPath(path = appApk.gcsPath.path))) - ) - }, - postTargetAppInstallables = deviceSetup?.additionalApks?.map { - AndroidInstallable( - files = listOf(InputFile(gcsInputFile = GcsPath(path = it.gcsPath.path))) - ) - } + if (appApk != null || deviceSetup?.additionalApks?.isNotEmpty() == true) { + deviceActions.add( + DeviceAction( + androidInstallPackages = AndroidInstallPackagesDeviceAction( + targetApp = appApk?.let { + AndroidInstallable( + files = listOf(InputFile(gcsInputFile = GcsPath(path = appApk.gcsPath.path))) + ) + }, + postTargetAppInstallables = deviceSetup?.additionalApks?.map { + AndroidInstallable( + files = listOf(InputFile(gcsInputFile = GcsPath(path = it.gcsPath.path))) + ) + } + ) ) ) - ) + } // Orientation & Locale deviceActions.add(DeviceAction(androidOrientation = AndroidOrientationDeviceAction(orientation = orientation))) diff --git a/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt b/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt index c4db2c4..c3d023c 100644 --- a/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt +++ b/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt @@ -340,6 +340,30 @@ internal class DeviceRunControllerTest { assertThat(postInstallPaths).containsExactly(extraApk1.gcsPath.path, extraApk2.gcsPath.path).inOrder() } + @Test + fun testSubmitTests_noAdditionalApks() = runBlocking { + val testApk = createUploadedApk("test.apk") + val devices = listOf(AndroidDevice("tokay", "34", "en_US", "portrait")) + + val session = controller.submitTests( + appApk = null, + testApk = testApk, + devicePicker = { devices }, + deviceSetup = DeviceSetup(), + pullScreenshots = false, + testTargets = null, + flakyTestAttempts = 0, + testTimeoutSeconds = 900, + gcsResultPath = "gs://results", + gcsSmartShardingFilePath = "gs://smartShardingFile" + ) + + val job = session.sessionConfig.jobConfigs.first() + val installPackages = job.allocationConfig.deviceConfigs.first().actions + ?.firstNotNullOfOrNull { it.androidInstallPackages } + assertThat(installPackages).isNull() + } + @Test fun testSubmitTests_pullScreenshotsAndDirectoriesToPull() = runBlocking { val appApk = createUploadedApk("app.apk")