2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

[fenix] Bug 1812616 - Enable clear button on the Password and Host fields

Add UI test for both clear buttons visibility and enabled state
This commit is contained in:
Titouan Thibaud 2023-01-27 16:16:05 +01:00 committed by mergify[bot]
parent ab743d4066
commit cac4d8b1d8
4 changed files with 19 additions and 2 deletions

View File

@ -89,4 +89,10 @@ object MatcherHelper {
assertTrue(appItem.waitForExists(waitingTime))
}
}
fun assertItemIsEnabledAndVisible(vararg appItems: UiObject) {
for (appItem in appItems) {
assertTrue(appItem.waitForExists(waitingTime) && appItem.isEnabled)
}
}
}

View File

@ -561,11 +561,13 @@ class LoginsTest {
enterSiteCredential("mozilla")
verifyHostnameErrorMessage()
enterSiteCredential(loginPage)
verifyHostnameClearButtonEnabled()
setNewUserName("mozilla")
setNewPassword("firefox")
clickClearPasswordButton()
verifyPasswordErrorMessage()
setNewPassword("firefox")
verifyPasswordClearButtonEnabled()
saveEditedLogin()
}

View File

@ -26,6 +26,7 @@ import org.junit.Assert.assertEquals
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.MatcherHelper.assertItemContainingTextExists
import org.mozilla.fenix.helpers.MatcherHelper.assertItemIsEnabledAndVisible
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdExists
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
@ -77,6 +78,12 @@ class SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot {
fun verifyPasswordErrorMessage() =
assertItemContainingTextExists(itemContainingText(getStringResource(R.string.saved_login_password_required)))
fun verifyPasswordClearButtonEnabled() =
assertItemIsEnabledAndVisible(itemWithResId("$packageName:id/clearPasswordTextButton"))
fun verifyHostnameClearButtonEnabled() =
assertItemIsEnabledAndVisible(itemWithResId("$packageName:id/clearHostnameTextButton"))
fun clickSearchLoginButton() = itemWithResId("$packageName:id/search").click()
fun clickSavedLoginsChevronIcon() = itemWithResId("$packageName:id/toolbar_chevron_icon").click()

View File

@ -161,18 +161,19 @@ class AddLoginFragment : Fragment(R.layout.fragment_add_login), MenuProvider {
hostnameText.isEmpty() -> {
setHostnameError()
binding.clearHostnameTextButton.isEnabled = false
binding.clearHostnameTextButton.isVisible = false
}
!Patterns.WEB_URL.matcher(hostnameText).matches() -> {
setHostnameError()
binding.clearHostnameTextButton.isEnabled = true
binding.clearHostnameTextButton.isVisible = false
}
else -> {
validHostname = true
binding.clearHostnameTextButton.isEnabled = true
binding.inputLayoutHostname.error = null
binding.inputLayoutHostname.errorIconDrawable = null
binding.clearHostnameTextButton.isVisible = true
findDuplicate()
}
}
@ -233,6 +234,7 @@ class AddLoginFragment : Fragment(R.layout.fragment_add_login), MenuProvider {
binding.inputLayoutPassword.error = null
binding.inputLayoutPassword.errorIconDrawable = null
binding.clearPasswordTextButton.isVisible = true
binding.clearPasswordTextButton.isEnabled = true
}
}
setSaveButtonState()