no issue: Added settings_privacy_items_test (#10474)
parent
9177871edc
commit
2e45244b6c
@ -0,0 +1,89 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withParent
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.assertIsEnabled
|
||||
import org.mozilla.fenix.helpers.click
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the settings Data Collection sub menu.
|
||||
*/
|
||||
class SettingsSubMenuDataCollectionRobot {
|
||||
|
||||
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
|
||||
|
||||
fun verifyDataCollectionOptions() = assertDataCollectionOptions()
|
||||
|
||||
fun verifyUsageAndTechnicalDataSwitchDefault() = assertUsageAndTechnicalDataSwitchDefault()
|
||||
|
||||
fun verifyMarketingDataSwitchDefault() = assertMarketingDataValueSwitchDefault()
|
||||
|
||||
fun verifyDataCollectionSubMenuItems() {
|
||||
verifyDataCollectionOptions()
|
||||
verifyUsageAndTechnicalDataSwitchDefault()
|
||||
verifyMarketingDataSwitchDefault()
|
||||
}
|
||||
|
||||
class Transition {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
|
||||
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
||||
goBackButton().click()
|
||||
|
||||
SettingsRobot().interact()
|
||||
return SettingsRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun goBackButton() =
|
||||
onView(withContentDescription("Navigate up"))
|
||||
|
||||
private fun assertNavigationToolBarHeader() = onView(
|
||||
allOf(withParent(withId(R.id.navigationToolbar)),
|
||||
withText(R.string.preferences_data_collection)))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertDataCollectionOptions() {
|
||||
|
||||
onView(withText(R.string.preference_usage_data))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
val usageAndTechnicalDataText =
|
||||
"Shares performance, usage, hardware and customization data about your browser with Mozilla to help us make Firefox Preview better"
|
||||
|
||||
onView(withText(usageAndTechnicalDataText))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_marketing_data))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
val marketingDataText =
|
||||
"Shares data about what features you use in Firefox Preview with Leanplum, our mobile marketing vendor."
|
||||
|
||||
onView(withText(marketingDataText))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun usageAndTechnicalDataButton() = onView(withText(R.string.preference_usage_data))
|
||||
|
||||
private fun assertUsageAndTechnicalDataSwitchDefault() = usageAndTechnicalDataButton()
|
||||
.assertIsEnabled(isEnabled = true)
|
||||
|
||||
private fun marketingDataButton() = onView(withText(R.string.preferences_marketing_data))
|
||||
|
||||
private fun assertMarketingDataValueSwitchDefault() = marketingDataButton()
|
||||
.assertIsEnabled(isEnabled = true)
|
@ -0,0 +1,107 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
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
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withParentIndex
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withResourceName
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.click
|
||||
import org.mozilla.fenix.helpers.isChecked
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the settings Delete Browsing Data On Quit sub menu.
|
||||
*/
|
||||
class SettingsSubMenuDeleteBrowsingDataOnQuitRobot {
|
||||
|
||||
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
|
||||
|
||||
fun verifyDeleteBrowsingOnQuitButton() = assertDeleteBrowsingOnQuitButton()
|
||||
|
||||
fun verifyDeleteBrowsingOnQuitButtonSummary() = assertDeleteBrowsingOnQuitButtonSummary()
|
||||
|
||||
fun verifyDeleteBrowsingOnQuitButtonSwitchDefault() = assertDeleteBrowsingOnQuitButtonSwitchDefault()
|
||||
|
||||
fun clickDeleteBrowsingOnQuitButtonSwitchDefaultChange() = verifyDeleteBrowsingOnQuitButtonSwitchDefault().click()
|
||||
|
||||
fun verifyAllTheCheckBoxesText() = assertAllTheCheckBoxesText()
|
||||
|
||||
fun verifyAllTheCheckBoxesChecked() = assertAllTheCheckBoxesChecked()
|
||||
|
||||
fun verifyDeleteBrowsingDataOnQuitSubMenuItems() {
|
||||
verifyDeleteBrowsingOnQuitButton()
|
||||
verifyDeleteBrowsingOnQuitButtonSummary()
|
||||
verifyDeleteBrowsingOnQuitButtonSwitchDefault()
|
||||
clickDeleteBrowsingOnQuitButtonSwitchDefaultChange()
|
||||
verifyAllTheCheckBoxesText()
|
||||
verifyAllTheCheckBoxesChecked()
|
||||
}
|
||||
|
||||
class Transition {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
|
||||
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
||||
goBackButton().click()
|
||||
|
||||
SettingsRobot().interact()
|
||||
return SettingsRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun goBackButton() = onView(withContentDescription("Navigate up"))
|
||||
|
||||
private fun assertNavigationToolBarHeader() = onView(allOf(withId(R.id.navigationToolbar),
|
||||
withChild(withText(R.string.preferences_delete_browsing_data_on_quit))))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun deleteBrowsingOnQuitButton() = onView(allOf(withParentIndex(0),
|
||||
withChild(withText(R.string.preferences_delete_browsing_data_on_quit))))
|
||||
|
||||
private fun assertDeleteBrowsingOnQuitButton() = deleteBrowsingOnQuitButton()
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertDeleteBrowsingOnQuitButtonSummary() = onView(
|
||||
withText(R.string.preference_summary_delete_browsing_data_on_quit_2))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertDeleteBrowsingOnQuitButtonSwitchDefault() = onView(withResourceName("switch_widget"))
|
||||
.check(matches(isChecked(false)))
|
||||
|
||||
private fun assertAllTheCheckBoxesText() {
|
||||
onView(withText(R.string.preferences_delete_browsing_data_tabs_title))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_on_quit_browsing_history))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_cookies))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_cookies_subtitle))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_cached_files))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_cached_files_subtitle))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_site_permissions))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun assertAllTheCheckBoxesChecked() {
|
||||
// Only verifying the options, checkboxes default value can't be verified due to issue #9471
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
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.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
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import androidx.test.uiautomator.UiSelector
|
||||
import androidx.test.uiautomator.Until
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.assertIsChecked
|
||||
import org.mozilla.fenix.helpers.click
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the settings Delete Browsing Data sub menu.
|
||||
*/
|
||||
class SettingsSubMenuDeleteBrowsingDataRobot {
|
||||
|
||||
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
|
||||
|
||||
fun verifyDeleteBrowsingDataButton() = assertDeleteBrowsingDataButton()
|
||||
|
||||
fun verifyClickDeleteBrowsingDataButton() = assertClickDeleteBrowsingDataButton()
|
||||
|
||||
fun verifyMessageInDialogBox() = assertMessageInDialogBox()
|
||||
|
||||
fun verifyDeleteButtonInDialogBox() = assertDeleteButtonInDialogBox()
|
||||
|
||||
fun verifyCancelButtonInDialogBox() = assertCancelButtonInDialogBox()
|
||||
|
||||
fun verifyAllTheCheckBoxesText() = assertAllTheCheckBoxesText()
|
||||
|
||||
fun verifyAllTheCheckBoxesChecked() = assertAllTheCheckBoxesChecked()
|
||||
|
||||
fun verifyContentsInDialogBox() {
|
||||
verifyMessageInDialogBox()
|
||||
verifyDeleteButtonInDialogBox()
|
||||
verifyCancelButtonInDialogBox()
|
||||
}
|
||||
|
||||
fun clickCancelButtonInDialogBoxAndVerifyContentsInDialogBox() {
|
||||
mDevice.wait(
|
||||
Until.findObject(By.text("Delete browsing data")),
|
||||
TestAssetHelper.waitingTime
|
||||
)
|
||||
verifyClickDeleteBrowsingDataButton()
|
||||
verifyContentsInDialogBox()
|
||||
cancelButton().click()
|
||||
}
|
||||
|
||||
fun verifyDeleteBrowsingDataSubMenuItems() {
|
||||
verifyDeleteBrowsingDataButton()
|
||||
clickCancelButtonInDialogBoxAndVerifyContentsInDialogBox()
|
||||
verifyAllTheCheckBoxesText()
|
||||
verifyAllTheCheckBoxesChecked()
|
||||
}
|
||||
|
||||
class Transition {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
|
||||
|
||||
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
||||
goBackButton().click()
|
||||
|
||||
SettingsRobot().interact()
|
||||
return SettingsRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun goBackButton() =
|
||||
onView(allOf(withContentDescription("Navigate up")))
|
||||
|
||||
private fun assertNavigationToolBarHeader() {
|
||||
onView(allOf(withId(R.id.navigationToolbar),
|
||||
withChild(withText(R.string.preferences_delete_browsing_data))))
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||
}
|
||||
|
||||
private fun assertDeleteBrowsingDataButton() {
|
||||
onView(withId(R.id.delete_data))
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||
}
|
||||
|
||||
private fun assertClickDeleteBrowsingDataButton() {
|
||||
onView(withId(R.id.delete_data))
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE)))).click()
|
||||
}
|
||||
|
||||
private fun cancelButton() =
|
||||
mDevice.findObject(UiSelector().textStartsWith("CANCEL"))
|
||||
|
||||
private fun assertMessageInDialogBox() =
|
||||
onView(withText("Firefox Preview will delete the selected browsing data."))
|
||||
.inRoot(isDialog())
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertDeleteButtonInDialogBox() =
|
||||
onView(withText("Delete"))
|
||||
.inRoot(isDialog())
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertCancelButtonInDialogBox() =
|
||||
onView(withText("Cancel"))
|
||||
.inRoot(isDialog())
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertAllTheCheckBoxesText() {
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_tabs_title))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText("0 tabs"))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_browsing_data_title))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText("0 addresses"))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_cookies))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_cookies_subtitle))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_cached_files))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_cached_files_subtitle))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText(R.string.preferences_delete_browsing_data_site_permissions))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun assertAllTheCheckBoxesChecked() {
|
||||
onView(allOf(withId(R.id.checkbox), hasSibling(withText("Open Tabs")))).assertIsChecked(true)
|
||||
|
||||
onView(allOf(withId(R.id.checkbox), hasSibling(withText("Browsing history and site data")))).assertIsChecked(true)
|
||||
|
||||
onView(allOf(withId(R.id.checkbox), hasSibling(withText("Cookies")))).assertIsChecked(true)
|
||||
|
||||
onView(allOf(withId(R.id.checkbox), hasSibling(withText("Cached images and files")))).assertIsChecked(true)
|
||||
|
||||
onView(allOf(withId(R.id.checkbox), hasSibling(withText("Site permissions")))).assertIsChecked(true)
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.assertIsChecked
|
||||
import org.mozilla.fenix.helpers.click
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the settings Site Permissions sub menu.
|
||||
*/
|
||||
class SettingsSubMenuSitePermissionsCommonRobot {
|
||||
|
||||
fun verifyNavigationToolBarHeader(header: String) = assertNavigationToolBarHeader(header)
|
||||
|
||||
fun verifyBlockAudioAndVideoOnMobileDataOnlyAudioAndVideoWillPlayOnWiFi() = assertBlockAudioAndVideoOnMobileDataOnlyAudioAndVideoWillPlayOnWiFi()
|
||||
|
||||
fun verifyBlockAudioOnly() = assertBlockAudioOnly()
|
||||
|
||||
fun verifyVideoAndAudioBlockedRecommended() = assertVideoAndAudioBlockedRecommended()
|
||||
|
||||
fun verifyCheckAutoPlayRadioButtonDefault() = assertCheckAutoPayRadioButtonDefault()
|
||||
|
||||
fun verifyassertAskToAllowRecommended() = assertAskToAllowRecommended()
|
||||
|
||||
fun verifyassertBlocked() = assertBlocked()
|
||||
|
||||
fun verifyCheckCommonRadioButtonDefault() = assertCheckCommonRadioButtonDefault()
|
||||
|
||||
fun verifyBlockedByAndroid() = assertBlockedByAndroid()
|
||||
|
||||
fun verifyToAllowIt() = assertToAllowIt()
|
||||
|
||||
fun verifyGotoAndroidSettings() = assertGotoAndroidSettings()
|
||||
|
||||
fun verifyTapPermissions() = assertTapPermissions()
|
||||
|
||||
fun verifyToggleNameToON(name: String) = assertToggleNameToON(name)
|
||||
|
||||
fun verifyGoToSettingsButton() = assertGoToSettingsButton()
|
||||
|
||||
fun verifySitePermissionsAutoPlaySubMenuItems() {
|
||||
verifyBlockAudioAndVideoOnMobileDataOnlyAudioAndVideoWillPlayOnWiFi()
|
||||
verifyBlockAudioOnly()
|
||||
verifyVideoAndAudioBlockedRecommended()
|
||||
verifyCheckAutoPlayRadioButtonDefault()
|
||||
}
|
||||
|
||||
fun verifySitePermissionsCommonSubMenuItems() {
|
||||
verifyassertAskToAllowRecommended()
|
||||
verifyassertBlocked()
|
||||
verifyCheckCommonRadioButtonDefault()
|
||||
verifyBlockedByAndroid()
|
||||
verifyToAllowIt()
|
||||
verifyGotoAndroidSettings()
|
||||
verifyTapPermissions()
|
||||
verifyGoToSettingsButton()
|
||||
}
|
||||
|
||||
fun verifySitePermissionsNotificationSubMenuItems() {
|
||||
verifyassertAskToAllowRecommended()
|
||||
verifyassertBlocked()
|
||||
verifyCheckCommonRadioButtonDefault()
|
||||
}
|
||||
|
||||
class Transition {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
|
||||
|
||||
fun goBack(interact: SettingsSubMenuSitePermissionsRobot.() -> Unit): SettingsSubMenuSitePermissionsRobot.Transition {
|
||||
goBackButton().click()
|
||||
|
||||
SettingsSubMenuSitePermissionsRobot().interact()
|
||||
return SettingsSubMenuSitePermissionsRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun assertNavigationToolBarHeader(header: String) = onView(allOf(withContentDescription(header)))
|
||||
|
||||
private fun assertBlockAudioAndVideoOnMobileDataOnlyAudioAndVideoWillPlayOnWiFi() =
|
||||
onView(withId(R.id.block_radio))
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||
|
||||
private fun assertBlockAudioOnly() = onView(withId(R.id.third_radio))
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||
|
||||
private fun assertVideoAndAudioBlockedRecommended() = onView(withId(R.id.fourth_radio))
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||
|
||||
private fun assertCheckAutoPayRadioButtonDefault() {
|
||||
|
||||
onView(withId(R.id.block_radio))
|
||||
.assertIsChecked(isChecked = false)
|
||||
|
||||
onView(withId(R.id.third_radio))
|
||||
.assertIsChecked(isChecked = false)
|
||||
|
||||
onView(withId(R.id.fourth_radio))
|
||||
.assertIsChecked(isChecked = true)
|
||||
}
|
||||
|
||||
private fun assertAskToAllowRecommended() = onView(withId(R.id.ask_to_allow_radio))
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||
|
||||
private fun assertBlocked() = onView(withId(R.id.block_radio))
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||
|
||||
private fun assertCheckCommonRadioButtonDefault() {
|
||||
onView(withId(R.id.ask_to_allow_radio)).assertIsChecked(isChecked = true)
|
||||
onView(withId(R.id.block_radio)).assertIsChecked(isChecked = false)
|
||||
}
|
||||
|
||||
private fun assertBlockedByAndroid() = onView(withText(R.string.phone_feature_blocked_by_android))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertToAllowIt() = onView(withText(R.string.phone_feature_blocked_intro))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertGotoAndroidSettings() = onView(withText(R.string.phone_feature_blocked_step_settings))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertTapPermissions() = onView(withText("2. Tap Permissions"))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertToggleNameToON(name: String) = onView(withText(name))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertGoToSettingsButton() = onView(withId(R.id.settings_button))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun goBackButton() =
|
||||
onView(allOf(withContentDescription("Navigate up")))
|
@ -0,0 +1,53 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.click
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the settings Site Permissions Notification sub menu.
|
||||
*/
|
||||
class SettingsSubMenuSitePermissionsExceptionsRobot {
|
||||
|
||||
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
|
||||
|
||||
fun verifyExceptionDefault() = assertExceptionDefault()!!
|
||||
|
||||
fun verifySitePermissionsExceptionSubMenuItems() {
|
||||
verifyExceptionDefault()
|
||||
}
|
||||
|
||||
class Transition {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
|
||||
|
||||
fun goBack(interact: SettingsSubMenuSitePermissionsRobot.() -> Unit): SettingsSubMenuSitePermissionsRobot.Transition {
|
||||
goBackButton().click()
|
||||
|
||||
SettingsSubMenuSitePermissionsRobot().interact()
|
||||
return SettingsSubMenuSitePermissionsRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun goBackButton() =
|
||||
onView(allOf(withContentDescription("Navigate up")))
|
||||
|
||||
private fun assertNavigationToolBarHeader() {
|
||||
onView(withText(R.string.preference_exceptions))
|
||||
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||
}
|
||||
|
||||
private fun assertExceptionDefault() =
|
||||
onView(allOf(withText(R.string.no_site_exceptions)))
|
@ -0,0 +1,203 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import androidx.preference.R
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.mozilla.fenix.helpers.click
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the settings Site Permissions sub menu.
|
||||
*/
|
||||
class SettingsSubMenuSitePermissionsRobot {
|
||||
|
||||
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
|
||||
|
||||
fun verifySitePermissionsSubMenuItems() = assertSitePermissionsSubMenuItems()
|
||||
|
||||
class Transition {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
|
||||
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
||||
goBackButton().click()
|
||||
|
||||
SettingsRobot().interact()
|
||||
return SettingsRobot.Transition()
|
||||
}
|
||||
|
||||
fun openAutoPlay(
|
||||
interact: SettingsSubMenuSitePermissionsCommonRobot.() -> Unit
|
||||
): SettingsSubMenuSitePermissionsCommonRobot.Transition {
|
||||
|
||||
onView(withId(R.id.recycler_view)).perform(
|
||||
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||
hasDescendant(withText("Autoplay"))
|
||||
)
|
||||
)
|
||||
|
||||
openAutoPlay().click()
|
||||
|
||||
SettingsSubMenuSitePermissionsCommonRobot().interact()
|
||||
return SettingsSubMenuSitePermissionsCommonRobot.Transition()
|
||||
}
|
||||
|
||||
fun openCamera(
|
||||
interact: SettingsSubMenuSitePermissionsCommonRobot.() -> Unit
|
||||
): SettingsSubMenuSitePermissionsCommonRobot.Transition {
|
||||
|
||||
onView(withId(R.id.recycler_view)).perform(
|
||||
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||
hasDescendant(withText("Camera"))
|
||||
)
|
||||
)
|
||||
|
||||
openCamera().click()
|
||||
|
||||
SettingsSubMenuSitePermissionsCommonRobot().interact()
|
||||
return SettingsSubMenuSitePermissionsCommonRobot.Transition()
|
||||
}
|
||||
|
||||
fun openLocation(
|
||||
interact: SettingsSubMenuSitePermissionsCommonRobot.() -> Unit
|
||||
): SettingsSubMenuSitePermissionsCommonRobot.Transition {
|
||||
|
||||
onView(withId(R.id.recycler_view)).perform(
|
||||
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||
hasDescendant(withText("Location"))
|
||||
)
|
||||
)
|
||||
|
||||
openLocation().click()
|
||||
|
||||
SettingsSubMenuSitePermissionsCommonRobot().interact()
|
||||
return SettingsSubMenuSitePermissionsCommonRobot.Transition()
|
||||
}
|
||||
|
||||
fun openMicrophone(
|
||||
interact: SettingsSubMenuSitePermissionsCommonRobot.() -> Unit
|
||||
): SettingsSubMenuSitePermissionsCommonRobot.Transition {
|
||||
|
||||
onView(withId(R.id.recycler_view)).perform(
|
||||
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||
hasDescendant(withText("Microphone"))
|
||||
)
|
||||
)
|
||||
|
||||
openMicrophone().click()
|
||||
|
||||
SettingsSubMenuSitePermissionsCommonRobot().interact()
|
||||
return SettingsSubMenuSitePermissionsCommonRobot.Transition()
|
||||
}
|
||||
|
||||
fun openNotification(
|
||||
interact: SettingsSubMenuSitePermissionsCommonRobot.() -> Unit
|
||||
): SettingsSubMenuSitePermissionsCommonRobot.Transition {
|
||||
|
||||
onView(withId(R.id.recycler_view)).perform(
|
||||
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||
hasDescendant(withText("Notification"))
|
||||
)
|
||||
)
|
||||
|
||||
openNotification().click()
|
||||
|
||||
SettingsSubMenuSitePermissionsCommonRobot().interact()
|
||||
return SettingsSubMenuSitePermissionsCommonRobot.Transition()
|
||||
}
|
||||
|
||||
fun openExceptions(
|
||||
interact: SettingsSubMenuSitePermissionsExceptionsRobot.() -> Unit
|
||||
): SettingsSubMenuSitePermissionsExceptionsRobot.Transition {
|
||||
|
||||
onView(withId(R.id.recycler_view)).perform(
|
||||
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||
hasDescendant(withText("Exceptions"))
|
||||
)
|
||||
)
|
||||
|
||||
openExceptions().click()
|
||||
|
||||
SettingsSubMenuSitePermissionsExceptionsRobot().interact()
|
||||
return SettingsSubMenuSitePermissionsExceptionsRobot.Transition()
|
||||
}
|
||||
}
|
||||
|
||||
private fun assertNavigationToolBarHeader() = onView(withText("Site permissions"))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertSitePermissionsSubMenuItems() {
|
||||
|
||||
onView(withText("Autoplay"))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
val autoplayText = "Block audio and video"
|
||||
onView(withText(autoplayText))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
val cameraText =
|
||||
"Blocked by Android"
|
||||
onView(withId(R.id.recycler_view)).perform(
|
||||
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||
allOf(hasDescendant(withText("Camera")), hasDescendant(withText(cameraText)))
|
||||
)
|
||||
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
val locationText =
|
||||
"Blocked by Android"
|
||||
onView(withId(R.id.recycler_view)).perform(
|
||||
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||
allOf(hasDescendant(withText("Location")), hasDescendant(withText(locationText)))
|
||||
)
|
||||
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
val microphoneText =
|
||||
"Blocked by Android"
|
||||
onView(withId(R.id.recycler_view)).perform(
|
||||
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||
allOf(hasDescendant(withText("Microphone")), hasDescendant(withText(microphoneText)))
|
||||
)
|
||||
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
onView(withText("Notification"))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
val notificationText =
|
||||
"Ask to allow"
|
||||
onView(withText(notificationText))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
}
|
||||
|
||||
private fun goBackButton() =
|
||||
onView(withContentDescription("Navigate up"))
|
||||
|
||||
private fun openAutoPlay() =
|
||||
onView(allOf(withText("Autoplay")))
|
||||
|
||||
private fun openCamera() =
|
||||
onView(allOf(withText("Camera")))
|
||||
|
||||
private fun openLocation() =
|
||||
onView(allOf(withText("Location")))
|
||||
|
||||
private fun openMicrophone() =
|
||||
onView(allOf(withText("Microphone")))
|
||||
|
||||
private fun openNotification() =
|
||||
onView(allOf(withText("Notification")))
|
||||
|
||||
private fun openExceptions() =
|
||||
onView(allOf(withText("Exceptions")))
|
Loading…
Reference in New Issue