@ -9,7 +9,6 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
import androidx.test.espresso.matcher.ViewMatchers.withChild
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
@ -29,9 +28,6 @@ import org.mozilla.fenix.helpers.click
* /
class SettingsSubMenuDeleteBrowsingDataRobot {
fun verifyNavigationToolBarHeader ( ) = assertNavigationToolBarHeader ( )
fun verifyDeleteBrowsingDataButton ( ) = assertDeleteBrowsingDataButton ( )
fun verifyAllOptionsAndCheckBoxes ( ) = assertAllOptionsAndCheckBoxes ( )
fun verifyAllCheckBoxesAreChecked ( ) = assertAllCheckBoxesAreChecked ( )
fun verifyOpenTabsCheckBox ( status : Boolean ) = assertOpenTabsCheckBox ( status )
fun verifyBrowsingHistoryDetails ( status : Boolean ) = assertBrowsingHistoryCheckBox ( status )
@ -151,66 +147,30 @@ class SettingsSubMenuDeleteBrowsingDataRobot {
private fun goBackButton ( ) =
onView ( allOf ( withContentDescription ( " Navigate up " ) ) )
private fun navigationToolBarHeader ( ) =
onView (
allOf (
withId ( R . id . navigationToolbar ) ,
withChild ( withText ( R . string . preferences _delete _browsing _data ) ) ,
) ,
)
private fun deleteBrowsingDataButton ( ) = onView ( withId ( R . id . delete _data ) )
private fun assertNavigationToolBarHeader ( ) =
navigationToolBarHeader ( ) . check ( ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) ) )
private fun assertDeleteBrowsingDataButton ( ) =
deleteBrowsingDataButton ( ) . check ( ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) ) )
private fun dialogDeleteButton ( ) = onView ( withText ( " Delete " ) ) . inRoot ( isDialog ( ) )
private fun dialogCancelButton ( ) = onView ( withText ( " Cancel " ) ) . inRoot ( isDialog ( ) )
private fun openTabsSubsection ( ) = onView ( withText ( R . string . preferences _delete _browsing _data _tabs _title _2 ) )
private fun openTabsDescription ( tabNumber : String ) = onView ( withText ( " $tabNumber tabs " ) )
private fun openTabsCheckBox ( ) = onView ( allOf ( withId ( R . id . checkbox ) , hasSibling ( withText ( " Open tabs " ) ) ) )
private fun browsingHistorySubsection ( ) =
onView ( withText ( R . string . preferences _delete _browsing _data _browsing _data _title ) )
private fun browsingHistoryDescription ( addresses : String ) = mDevice . findObject ( UiSelector ( ) . textContains ( " $addresses addresses " ) )
private fun browsingHistoryCheckBox ( ) =
onView ( allOf ( withId ( R . id . checkbox ) , hasSibling ( withText ( " Browsing history " ) ) ) )
private fun cookiesSubsection ( ) =
onView ( withText ( R . string . preferences _delete _browsing _data _cookies ) )
private fun cookiesAndSiteDataDescription ( ) = onView ( withText ( R . string . preferences _delete _browsing _data _cookies _subtitle ) )
private fun cookiesAndSiteDataCheckBox ( ) =
onView ( allOf ( withId ( R . id . checkbox ) , hasSibling ( withText ( " Cookies and site data " ) ) ) )
private fun cachedFilesSubsection ( ) =
onView ( withText ( R . string . preferences _delete _browsing _data _cached _files ) )
private fun cachedFilesDescription ( ) =
onView ( withText ( R . string . preferences _delete _browsing _data _cached _files _subtitle ) )
private fun cachedFilesCheckBox ( ) =
onView ( allOf ( withId ( R . id . checkbox ) , hasSibling ( withText ( " Cached images and files " ) ) ) )
private fun sitePermissionsSubsection ( ) =
onView ( withText ( R . string . preferences _delete _browsing _data _site _permissions ) )
private fun sitePermissionsCheckBox ( ) =
onView ( allOf ( withId ( R . id . checkbox ) , hasSibling ( withText ( " Site permissions " ) ) ) )
private fun downloadsSubsection ( ) =
onView ( withText ( R . string . preferences _delete _browsing _data _downloads ) )
private fun downloadsCheckBox ( ) =
onView ( allOf ( withId ( R . id . checkbox ) , hasSibling ( withText ( " Downloads " ) ) ) )
@ -218,25 +178,6 @@ private fun dialogMessage() =
onView ( withText ( " $appName will delete the selected browsing data. " ) )
. inRoot ( isDialog ( ) )
private fun assertAllOptionsAndCheckBoxes ( ) {
openTabsSubsection ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
openTabsDescription ( " 0 " ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
openTabsCheckBox ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
browsingHistorySubsection ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
assertTrue ( browsingHistoryDescription ( " 0 " ) . waitForExists ( waitingTime ) )
browsingHistoryCheckBox ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
cookiesSubsection ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
cookiesAndSiteDataDescription ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
cookiesAndSiteDataCheckBox ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
cachedFilesSubsection ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
cachedFilesDescription ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
cachedFilesCheckBox ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
sitePermissionsSubsection ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
sitePermissionsCheckBox ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
downloadsSubsection ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
downloadsCheckBox ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
}
private fun assertAllCheckBoxesAreChecked ( ) {
openTabsCheckBox ( ) . assertIsChecked ( true )
browsingHistoryCheckBox ( ) . assertIsChecked ( true )