From cd4a5ea04c0129f8402b542448ecd871f0bd2923 Mon Sep 17 00:00:00 2001 From: KremeCN <3265494849@qq.com> Date: Wed, 26 Aug 2026 21:24:20 +0800 Subject: [PATCH] test: align infrared UI instrumentation coverage --- .../remote/InfraredRemoteScreenTest.kt | 1 + .../infrared/ui/InfraredControlScreenTest.kt | 45 +++++-------------- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/android/feature/infrared/src/androidTest/kotlin/com/flagship/abox/manager/infrared/remote/InfraredRemoteScreenTest.kt b/android/feature/infrared/src/androidTest/kotlin/com/flagship/abox/manager/infrared/remote/InfraredRemoteScreenTest.kt index a071166..593331b 100644 --- a/android/feature/infrared/src/androidTest/kotlin/com/flagship/abox/manager/infrared/remote/InfraredRemoteScreenTest.kt +++ b/android/feature/infrared/src/androidTest/kotlin/com/flagship/abox/manager/infrared/remote/InfraredRemoteScreenTest.kt @@ -8,6 +8,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import com.flagship.abox.manager.domain.DeviceName import com.flagship.abox.manager.infrared.remote.ui.InfraredRemoteScreen import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith diff --git a/android/feature/infrared/src/androidTest/kotlin/com/flagship/abox/manager/infrared/ui/InfraredControlScreenTest.kt b/android/feature/infrared/src/androidTest/kotlin/com/flagship/abox/manager/infrared/ui/InfraredControlScreenTest.kt index 99699b1..f1a796d 100644 --- a/android/feature/infrared/src/androidTest/kotlin/com/flagship/abox/manager/infrared/ui/InfraredControlScreenTest.kt +++ b/android/feature/infrared/src/androidTest/kotlin/com/flagship/abox/manager/infrared/ui/InfraredControlScreenTest.kt @@ -3,17 +3,13 @@ package com.flagship.abox.manager.infrared.ui import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag -import androidx.compose.ui.test.performClick +import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performTextInput import androidx.test.ext.junit.runners.AndroidJUnit4 import com.flagship.abox.manager.domain.DeviceName import com.flagship.abox.manager.domain.ProviderProfileId import com.flagship.abox.manager.domain.ProviderType -import com.flagship.abox.manager.domain.infrared.InfraredKeyId -import com.flagship.abox.manager.domain.infrared.InfraredKeyStatus -import com.flagship.abox.manager.domain.infrared.SavedInfraredKey import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -25,53 +21,32 @@ class InfraredControlScreenTest { val composeTestRule = createComposeRule() @Test - fun rendersControlScreenAndTriggersKeyOperations() { - val testKey = SavedInfraredKey( - id = InfraredKeyId("k1"), - profileId = ProviderProfileId("profile1"), - deviceName = DeviceName("ir-1"), - displayName = "Power", - sdkKey = "1", - status = InfraredKeyStatus.READY, - lastErrorCode = null, - lastErrorDetail = null, - createdAtEpochMillis = 100L, - updatedAtEpochMillis = 100L, - ) + fun rendersDeviceConfigurationAndAcceptsDeviceNameInput() { val state = InfraredControlUiState( profileId = ProviderProfileId("profile1"), providerType = ProviderType.LOCAL_EXPERIENCE, savedDeviceName = DeviceName("ir-1"), - keys = listOf(testKey), loading = false, ) - var sendClicked = false - var deleteClicked = false + var changedName: String? = null composeTestRule.setContent { InfraredControlScreen( state = state, onBack = {}, onSessionInvalid = {}, - onDeviceNameChanged = {}, + onDeviceNameChanged = { changedName = it }, onSaveDeviceName = {}, - onLearn = { _, _ -> }, - onRetry = {}, - onSend = { sendClicked = true }, - onRename = { _, _ -> }, - onDelete = { deleteClicked = true }, onMessageShown = {}, - nextSlot = 2, ) } - composeTestRule.onNodeWithTag("infrared_key_k1").assertIsDisplayed() - composeTestRule.onNodeWithTag("infrared_send_k1").assertIsDisplayed().performClick() - assertTrue(sendClicked) - - composeTestRule.onNodeWithTag("infrared_delete_btn_k1").assertIsDisplayed().performClick() - composeTestRule.onNodeWithTag("infrared_delete_confirm").assertIsDisplayed().performClick() - assertTrue(deleteClicked) + composeTestRule.onNodeWithText("运行环境与连接信息").assertIsDisplayed() + composeTestRule.onNodeWithTag("infrared_device_name_input") + .assertIsDisplayed() + .performTextInput("-updated") + composeTestRule.waitForIdle() + assertEquals("-updated", changedName) } }