2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-17 15:26:23 +00:00

[fenix] No issue - Use android resource for positive/negative dialog buttons

This commit is contained in:
AndiAJ 2023-01-04 15:01:17 +02:00 committed by mergify[bot]
parent 2910ab4642
commit a9840d1abb
3 changed files with 27 additions and 26 deletions

View File

@ -7,6 +7,7 @@ package org.mozilla.fenix.ui.robots
import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.hasContentDescription import androidx.compose.ui.test.hasContentDescription
import androidx.compose.ui.test.hasText import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.isDialog
import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTouchInput import androidx.compose.ui.test.performTouchInput
@ -15,6 +16,7 @@ import androidx.compose.ui.test.swipeRight
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.NoMatchingViewException import androidx.test.espresso.NoMatchingViewException
import androidx.test.espresso.action.ViewActions.pressImeActionButton import androidx.test.espresso.action.ViewActions.pressImeActionButton
import androidx.test.espresso.matcher.RootMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.uiautomator.By import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiScrollable import androidx.test.uiautomator.UiScrollable
@ -28,6 +30,7 @@ import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestHelper.mDevice import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestHelper.packageName import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull import org.mozilla.fenix.helpers.ext.waitNotNull
class CollectionRobot { class CollectionRobot {
@ -59,10 +62,7 @@ class CollectionRobot {
fun typeCollectionNameAndSave(collectionName: String) { fun typeCollectionNameAndSave(collectionName: String) {
collectionNameTextField().text = collectionName collectionNameTextField().text = collectionName
addCollectionButtonPanel.waitForExists(waitingTime) addCollectionButtonPanel.waitForExists(waitingTime)
addCollectionOkButton.also { addCollectionOkButton.click()
it.waitForExists(waitingTime)
it.click()
}
} }
fun verifyTabsSelectedCounterText(numOfTabs: Int) { fun verifyTabsSelectedCounterText(numOfTabs: Int) {
@ -297,5 +297,4 @@ private fun backButton() =
private val addCollectionButtonPanel = private val addCollectionButtonPanel =
itemWithResId("$packageName:id/buttonPanel") itemWithResId("$packageName:id/buttonPanel")
private val addCollectionOkButton = private val addCollectionOkButton = onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog())
itemWithResId("android:id/button1")

View File

@ -4,6 +4,9 @@
package org.mozilla.fenix.ui.robots package org.mozilla.fenix.ui.robots
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.matcher.RootMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.UiSelector
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.mozilla.fenix.R import org.mozilla.fenix.R
@ -12,6 +15,7 @@ import org.mozilla.fenix.helpers.TestHelper.getStringResource
import org.mozilla.fenix.helpers.TestHelper.mDevice import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestHelper.packageName import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
import org.mozilla.fenix.helpers.click
class SettingsSubMenuAutofillRobot { class SettingsSubMenuAutofillRobot {
@ -22,14 +26,10 @@ class SettingsSubMenuAutofillRobot {
deleteAddressButton.waitForExists(waitingTime) deleteAddressButton.waitForExists(waitingTime)
deleteAddressButton.click() deleteAddressButton.click()
} }
fun clickCancelDeleteAddressButton() { fun clickCancelDeleteAddressButton() = cancelDeleteAddressButton.click()
cancelDeleteAddressButton.waitForExists(waitingTime)
cancelDeleteAddressButton.click() fun clickConfirmDeleteAddressButton() = confirmDeleteAddressButton.click()
}
fun clickConfirmDeleteAddressButton() {
confirmDeleteAddressButton.waitForExists(waitingTime)
confirmDeleteAddressButton.click()
}
fun clickSubRegionOption(subRegion: String) { fun clickSubRegionOption(subRegion: String) {
subRegionOption(subRegion).waitForExists(waitingTime) subRegionOption(subRegion).waitForExists(waitingTime)
subRegionOption(subRegion).click() subRegionOption(subRegion).click()
@ -81,10 +81,7 @@ class SettingsSubMenuAutofillRobot {
deleteCreditCardButton.click() deleteCreditCardButton.click()
} }
fun clickConfirmDeleteCreditCardButton() { fun clickConfirmDeleteCreditCardButton() = confirmDeleteCreditCardButton.click()
confirmDeleteCreditCardButton.waitForExists(waitingTime)
confirmDeleteCreditCardButton.click()
}
fun clickExpiryMonthOption(expiryMonth: String) { fun clickExpiryMonthOption(expiryMonth: String) {
expiryMonthOption(expiryMonth).waitForExists(waitingTime) expiryMonthOption(expiryMonth).waitForExists(waitingTime)
@ -142,8 +139,8 @@ private val phoneTextInput = mDevice.findObject(UiSelector().resourceId("$packag
private val emailTextInput = mDevice.findObject(UiSelector().resourceId("$packageName:id/email_input")) private val emailTextInput = mDevice.findObject(UiSelector().resourceId("$packageName:id/email_input"))
private val saveButton = mDevice.findObject(UiSelector().resourceId("$packageName:id/save_button")) private val saveButton = mDevice.findObject(UiSelector().resourceId("$packageName:id/save_button"))
private val deleteAddressButton = mDevice.findObject(UiSelector().resourceId("$packageName:id/delete_address_button")) private val deleteAddressButton = mDevice.findObject(UiSelector().resourceId("$packageName:id/delete_address_button"))
private val cancelDeleteAddressButton = mDevice.findObject(UiSelector().resourceId("android:id/button2")) private val cancelDeleteAddressButton = onView(withId(android.R.id.button2)).inRoot(RootMatchers.isDialog())
private val confirmDeleteAddressButton = mDevice.findObject(UiSelector().resourceId("android:id/button1")) private val confirmDeleteAddressButton = onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog())
private val addCreditCardButton = mDevice.findObject(UiSelector().textContains(getStringResource(R.string.preferences_credit_cards_add_credit_card))) private val addCreditCardButton = mDevice.findObject(UiSelector().textContains(getStringResource(R.string.preferences_credit_cards_add_credit_card)))
private val manageSavedCardsButton = mDevice.findObject(UiSelector().textContains(getStringResource(R.string.preferences_credit_cards_manage_saved_cards))) private val manageSavedCardsButton = mDevice.findObject(UiSelector().textContains(getStringResource(R.string.preferences_credit_cards_manage_saved_cards)))
@ -153,8 +150,8 @@ private val expiryMonthDropDown = mDevice.findObject(UiSelector().resourceId("$p
private val expiryYearDropDown = mDevice.findObject(UiSelector().resourceId("$packageName:id/expiry_year_drop_down")) private val expiryYearDropDown = mDevice.findObject(UiSelector().resourceId("$packageName:id/expiry_year_drop_down"))
private val savedCreditCardNumber = mDevice.findObject(UiSelector().resourceId("$packageName:id/credit_card_logo")) private val savedCreditCardNumber = mDevice.findObject(UiSelector().resourceId("$packageName:id/credit_card_logo"))
private val deleteCreditCardButton = mDevice.findObject(UiSelector().resourceId("$packageName:id/delete_credit_card_button")) private val deleteCreditCardButton = mDevice.findObject(UiSelector().resourceId("$packageName:id/delete_credit_card_button"))
private val confirmDeleteCreditCardButton = mDevice.findObject(UiSelector().resourceId("android:id/button1")) private val confirmDeleteCreditCardButton = onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog())
private val securedCreditCardsLaterButton = mDevice.findObject(UiSelector().resourceId("android:id/button2")) private val securedCreditCardsLaterButton = onView(withId(android.R.id.button2)).inRoot(RootMatchers.isDialog())
private fun savedAddress(firstName: String) = mDevice.findObject(UiSelector().textContains(firstName)) private fun savedAddress(firstName: String) = mDevice.findObject(UiSelector().textContains(firstName))
private fun subRegionOption(subRegion: String) = mDevice.findObject(UiSelector().textContains(subRegion)) private fun subRegionOption(subRegion: String) = mDevice.findObject(UiSelector().textContains(subRegion))

View File

@ -6,6 +6,11 @@
package org.mozilla.fenix.ui.robots package org.mozilla.fenix.ui.robots
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.RootMatchers
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.UiSelector
import mozilla.components.support.ktx.kotlin.tryGetHostFromUrl import mozilla.components.support.ktx.kotlin.tryGetHostFromUrl
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
@ -50,8 +55,8 @@ private fun assertSecureConnectionSubMenu(pageTitle: String = "", url: String =
private fun assertClearSiteDataPrompt(url: String) { private fun assertClearSiteDataPrompt(url: String) {
assertTrue(clearSiteDataPrompt(url).waitForExists(waitingTime)) assertTrue(clearSiteDataPrompt(url).waitForExists(waitingTime))
assertTrue(cancelClearSiteDataButton.waitForExists(waitingTime)) cancelClearSiteDataButton.check(matches(isDisplayed()))
assertTrue(deleteSiteDataButton.waitForExists(waitingTime)) deleteSiteDataButton.check(matches(isDisplayed()))
} }
private fun quickActionSheet() = private fun quickActionSheet() =
@ -145,5 +150,5 @@ private fun clearSiteDataPrompt(url: String) =
.textContains(url), .textContains(url),
) )
private val cancelClearSiteDataButton = mDevice.findObject(UiSelector().resourceId("android:id/button2")) private val cancelClearSiteDataButton = onView(withId(android.R.id.button2)).inRoot(RootMatchers.isDialog())
private val deleteSiteDataButton = mDevice.findObject(UiSelector().resourceId("android:id/button1")) private val deleteSiteDataButton = onView(withId(android.R.id.button1)).inRoot(RootMatchers.isDialog())