Support signed numbers in numeric div input

41377450d84af22f5c33a995f063d9be1352ed9f
This commit is contained in:
alex-kozyakov
2024-04-08 22:19:36 +03:00
parent 8b608a7273
commit a2e784e2b7
3 changed files with 44 additions and 13 deletions
@@ -235,7 +235,7 @@ internal class DivInputBinder @Inject constructor(
DivInput.KeyboardType.URI -> InputType.TYPE_CLASS_TEXT or
InputType.TYPE_TEXT_VARIATION_URI
DivInput.KeyboardType.NUMBER -> InputType.TYPE_CLASS_NUMBER or
InputType.TYPE_NUMBER_FLAG_DECIMAL
InputType.TYPE_NUMBER_FLAG_DECIMAL or InputType.TYPE_NUMBER_FLAG_SIGNED
DivInput.KeyboardType.PHONE -> InputType.TYPE_CLASS_PHONE
DivInput.KeyboardType.PASSWORD -> InputType.TYPE_CLASS_TEXT or
InputType.TYPE_TEXT_VARIATION_PASSWORD
@@ -21,39 +21,71 @@ class DivInputKeyboardTypeTest {
@Test
fun checkMultiLineText() {
checkType("multi_line_text", TEXT_WITH_DIFFERENT_SYMBOLS)
checkType(
type = "multi_line_text",
expectedText = TEXT_WITH_DIFFERENT_SYMBOLS
)
}
@Test
fun checkSingleLineText() {
checkType("single_line_text", TEXT_BEFORE_BREAK)
checkType(
type = "single_line_text",
expectedText = TEXT_BEFORE_BREAK
)
}
@Test
fun checkNumber() {
checkType("number", "912302.")
fun checkPositiveNumber() {
checkType(
type = "number",
expectedText = "912302.",
typedText = "912302."
)
}
@Test
fun checkNegativeNumber() {
checkType(
type = "number",
expectedText = "-912302.",
typedText = "-912302."
)
}
@Test
fun checkPhone() {
checkType("phone", ";//- N+(123)2.")
checkType(
type = "phone",
expectedText = ";//- N+(123)2."
)
}
@Test
fun checkEmail() {
checkType("email", TEXT_BEFORE_BREAK)
checkType(
type = "email",
expectedText = TEXT_BEFORE_BREAK
)
}
@Test
fun checkUri() {
checkType("uri", TEXT_BEFORE_BREAK)
checkType(
type = "uri",
expectedText = TEXT_BEFORE_BREAK
)
}
private fun checkType(type: String, typedText: String) {
private fun checkType(
type: String,
expectedText: String,
typedText: String = TEXT_WITH_DIFFERENT_SYMBOLS
) {
divInput {
activityRule.buildContainerForCase(type)
typeTextInInput()
assert { textTyped(typedText) }
typeTextInInput(typedText)
assert { textTyped(expectedText) }
}
}
}
@@ -11,7 +11,6 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withTagValue
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.rule.ActivityTestRule
import com.yandex.div.TEXT_WITH_DIFFERENT_SYMBOLS
import com.yandex.divkit.demo.DummyActivity
import com.yandex.test.util.Report.step
import com.yandex.test.util.StepsDsl
@@ -27,7 +26,7 @@ class DivInputSteps : DivTestAssetSteps() {
buildContainer(MATCH_PARENT, MATCH_PARENT)
}
fun typeTextInInput(text: String = TEXT_WITH_DIFFERENT_SYMBOLS): Unit = step("Enter text ") {
fun typeTextInInput(text: String): Unit = step("Enter text ") {
onView(isAssignableFrom(EditText::class.java)).perform(typeText(text))
}