Merge "Avoid to save result of blank input." into main
This commit is contained in:
@@ -87,12 +87,17 @@ private fun LabelSimPreference(
|
|||||||
}
|
}
|
||||||
val phoneNumber = phoneNumber(subInfo)
|
val phoneNumber = phoneNumber(subInfo)
|
||||||
val alertDialogPresenter = rememberAlertDialogPresenter(
|
val alertDialogPresenter = rememberAlertDialogPresenter(
|
||||||
confirmButton = AlertDialogButton(stringResource(R.string.mobile_network_sim_name_rename)) {
|
confirmButton = AlertDialogButton(
|
||||||
|
stringResource(R.string.mobile_network_sim_name_rename),
|
||||||
|
titleSimName.isNotBlank()
|
||||||
|
) {
|
||||||
onboardingService.addItemForRenaming(
|
onboardingService.addItemForRenaming(
|
||||||
subInfo, if (titleSimName.isEmpty()) originalSimCarrierName else titleSimName
|
subInfo, if (titleSimName.isEmpty()) originalSimCarrierName else titleSimName
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
dismissButton = AlertDialogButton(stringResource(R.string.cancel)) {
|
dismissButton = AlertDialogButton(
|
||||||
|
stringResource(R.string.cancel),
|
||||||
|
) {
|
||||||
titleSimName = onboardingService.getSubscriptionInfoDisplayName(subInfo)
|
titleSimName = onboardingService.getSubscriptionInfoDisplayName(subInfo)
|
||||||
},
|
},
|
||||||
title = stringResource(R.string.sim_onboarding_label_sim_dialog_title),
|
title = stringResource(R.string.sim_onboarding_label_sim_dialog_title),
|
||||||
@@ -107,7 +112,7 @@ private fun LabelSimPreference(
|
|||||||
placeholder = {Text(text = originalSimCarrierName)},
|
placeholder = {Text(text = originalSimCarrierName)},
|
||||||
modifier = Modifier.fillMaxWidth().testTag("contentInput")
|
modifier = Modifier.fillMaxWidth().testTag("contentInput")
|
||||||
) {
|
) {
|
||||||
titleSimName = if (it.matches(Regex("^\\s*$"))) originalSimCarrierName else it
|
titleSimName = it
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@@ -28,6 +28,8 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
import androidx.compose.ui.platform.LocalLifecycleOwner
|
import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||||
import androidx.compose.ui.semantics.SemanticsProperties
|
import androidx.compose.ui.semantics.SemanticsProperties
|
||||||
import androidx.compose.ui.test.assertIsDisplayed
|
import androidx.compose.ui.test.assertIsDisplayed
|
||||||
|
import androidx.compose.ui.test.assertIsEnabled
|
||||||
|
import androidx.compose.ui.test.assertIsNotEnabled
|
||||||
import androidx.compose.ui.test.hasText
|
import androidx.compose.ui.test.hasText
|
||||||
import androidx.compose.ui.test.junit4.createComposeRule
|
import androidx.compose.ui.test.junit4.createComposeRule
|
||||||
import androidx.compose.ui.test.onNodeWithTag
|
import androidx.compose.ui.test.onNodeWithTag
|
||||||
@@ -186,7 +188,7 @@ class SimOnboardingLabelSimTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showDialog_clearContent_showOriginalDisplayName() {
|
fun showDialog_clearContent_saveBtnIsDisabled() {
|
||||||
preSetupContent()
|
preSetupContent()
|
||||||
|
|
||||||
composeTestRule.setContent {
|
composeTestRule.setContent {
|
||||||
@@ -196,15 +198,12 @@ class SimOnboardingLabelSimTest {
|
|||||||
composeTestRule.onNodeWithText(DISPLAY_NAME_1).performClick()
|
composeTestRule.onNodeWithText(DISPLAY_NAME_1).performClick()
|
||||||
composeTestRule.onNodeWithTag(TEXT_FIELD_INPUT).performTextClearance()
|
composeTestRule.onNodeWithTag(TEXT_FIELD_INPUT).performTextClearance()
|
||||||
|
|
||||||
assertEquals(
|
composeTestRule.onNodeWithText(context.getString(R.string.mobile_network_sim_name_rename))
|
||||||
composeTestRule.onNodeWithTag(TEXT_FIELD_INPUT)
|
.assertIsNotEnabled()
|
||||||
.fetchSemanticsNode()
|
|
||||||
.config[SemanticsProperties.EditableText].text, DISPLAY_NAME_1
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showDialog_modifyContent_showModifiedDisplayName() {
|
fun showDialog_modifyContent_showAndSaveModifiedDisplayName() {
|
||||||
val inputData = "input_data"
|
val inputData = "input_data"
|
||||||
preSetupContent()
|
preSetupContent()
|
||||||
|
|
||||||
@@ -232,7 +231,7 @@ class SimOnboardingLabelSimTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun showDialog_onlySpaceCharContent_showAndSaveOriginalDisplayName() {
|
fun showDialog_onlySpaceCharContent_saveBtnIsDisabled() {
|
||||||
val spaceChars = " ";
|
val spaceChars = " ";
|
||||||
preSetupContent()
|
preSetupContent()
|
||||||
|
|
||||||
@@ -241,30 +240,12 @@ class SimOnboardingLabelSimTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simulate real operation,
|
// Simulate real operation,
|
||||||
// 1. Click preference of DISPLAY_NAME_1
|
|
||||||
composeTestRule.onNodeWithText(DISPLAY_NAME_1).performClick()
|
composeTestRule.onNodeWithText(DISPLAY_NAME_1).performClick()
|
||||||
// 2. Input space chars to EditText view
|
composeTestRule.onNodeWithTag(TEXT_FIELD_INPUT).performTextClearance()
|
||||||
composeTestRule.onNodeWithTag(TEXT_FIELD_INPUT).performTextInput(spaceChars)
|
composeTestRule.onNodeWithTag(TEXT_FIELD_INPUT).performTextInput(spaceChars)
|
||||||
// 3. Remove the string of DISPLAY_NAME_1 from EditText view
|
|
||||||
repeat(DISPLAY_NAME_1.length) {
|
|
||||||
composeTestRule.onNodeWithTag(TEXT_FIELD_INPUT)
|
|
||||||
.performKeyPress(KeyEvent(NativeKeyEvent(ACTION_DOWN, KEYCODE_FORWARD_DEL)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Due to this TextField with Text and EditText, it need fetch correct node to get correct
|
|
||||||
// content.
|
|
||||||
assertEquals(
|
|
||||||
DISPLAY_NAME_1, composeTestRule.onNodeWithTag(TEXT_FIELD_INPUT)
|
|
||||||
.fetchSemanticsNode()
|
|
||||||
.config[SemanticsProperties.EditableText].text
|
|
||||||
)
|
|
||||||
|
|
||||||
// Click save button
|
|
||||||
composeTestRule.onNodeWithText(context.getString(R.string.mobile_network_sim_name_rename))
|
composeTestRule.onNodeWithText(context.getString(R.string.mobile_network_sim_name_rename))
|
||||||
.performClick()
|
.assertIsNotEnabled()
|
||||||
|
|
||||||
// Check preference's name is still DISPLAY_NAME_1
|
|
||||||
composeTestRule.onNodeWithText(DISPLAY_NAME_1).assertExists()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun preSetupContent() {
|
fun preSetupContent() {
|
||||||
|
Reference in New Issue
Block a user