feat(ui): complete ABox app experience redesign #10
+1
@@ -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
|
||||
|
||||
+10
-35
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user