Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
[UI smoke test] For #21002: Ads new audio-video permissions test
Browse files Browse the repository at this point in the history
  • Loading branch information
Oana Horvath authored and mergify[bot] committed Jan 20, 2022
1 parent a377c35 commit d233ec1
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,89 @@ class SitePermissionsTest {
val activityTestRule = HomeActivityIntentTestRule()

@SmokeTest
@Test
fun audioVideoPermissionChoiceOnEachRequestTest() {
navigationToolbar {
}.enterURLAndEnterToBrowser(testPage.toUri()) {
waitForPageToLoad()
}.clickStartAudioVideoButton {
// allow app to record video
clickAppPermissionButton(true)
// allow app to record audio
clickAppPermissionButton(true)
verifyAudioVideoPermissionPrompt(testPageSubstring)
}.clickPagePermissionButton(false) {
verifyPageContent("Camera and Microphone not allowed")
}.clickStartAudioVideoButton {
}.clickPagePermissionButton(true) {
verifyPageContent("Camera and Microphone allowed")
}
}

@SmokeTest
@Test
fun rememberBlockAudioVideoPermissionChoiceTest() {
navigationToolbar {
}.enterURLAndEnterToBrowser(testPage.toUri()) {
waitForPageToLoad()
}.clickStartAudioVideoButton {
// allow app to record video
clickAppPermissionButton(true)
// allow app to record audio
clickAppPermissionButton(true)
verifyAudioVideoPermissionPrompt(testPageSubstring)
selectRememberPermissionDecision()
}.clickPagePermissionButton(false) {
verifyPageContent("Camera and Microphone not allowed")
}.openThreeDotMenu {
}.refreshPage {
waitForPageToLoad()
}.clickStartAudioVideoButton { }
browserScreen {
verifyPageContent("Camera and Microphone not allowed")
}
}

@SmokeTest
@Test
fun rememberAllowAudioVideoPermissionChoiceTest() {
navigationToolbar {
}.enterURLAndEnterToBrowser(testPage.toUri()) {
waitForPageToLoad()
}.clickStartAudioVideoButton {
// allow app to record video
clickAppPermissionButton(true)
// allow app to record audio
clickAppPermissionButton(true)
verifyAudioVideoPermissionPrompt(testPageSubstring)
selectRememberPermissionDecision()
}.clickPagePermissionButton(true) {
verifyPageContent("Camera and Microphone allowed")
}.openThreeDotMenu {
}.refreshPage {
waitForPageToLoad()
}.clickStartAudioVideoButton { }
browserScreen {
verifyPageContent("Camera and Microphone allowed")
}
}

@SmokeTest
@Test
fun blockAppUsingAudioVideoTest() {
navigationToolbar {
}.enterURLAndEnterToBrowser(testPage.toUri()) {
}.clickStartAudioVideoButton {
// allow app to record video
clickAppPermissionButton(false)
// allow app to record audio
clickAppPermissionButton(false)
}
browserScreen {
verifyPageContent("Camera and Microphone not allowed")
}
}

@Test
fun microphonePermissionChoiceOnEachRequestTest() {
navigationToolbar {
Expand All @@ -42,7 +125,6 @@ class SitePermissionsTest {
}
}

@SmokeTest
@Test
fun rememberBlockMicrophonePermissionChoiceTest() {
navigationToolbar {
Expand All @@ -64,7 +146,6 @@ class SitePermissionsTest {
}

@Ignore("Flaky, needs investigation: https://github.com/mozilla-mobile/fenix/issues/23298")
@SmokeTest
@Test
fun rememberAllowMicrophonePermissionChoiceTest() {
navigationToolbar {
Expand All @@ -85,7 +166,6 @@ class SitePermissionsTest {
}
}

@SmokeTest
@Test
fun blockAppUsingMicrophoneTest() {
navigationToolbar {
Expand All @@ -98,7 +178,6 @@ class SitePermissionsTest {
}
}

@SmokeTest
@Test
fun cameraPermissionChoiceOnEachRequestTest() {
navigationToolbar {
Expand All @@ -115,7 +194,6 @@ class SitePermissionsTest {
}
}

@SmokeTest
@Test
fun rememberBlockCameraPermissionChoiceTest() {
navigationToolbar {
Expand All @@ -136,7 +214,6 @@ class SitePermissionsTest {
}
}

@SmokeTest
@Test
fun rememberAllowCameraPermissionChoiceTest() {
navigationToolbar {
Expand All @@ -157,7 +234,6 @@ class SitePermissionsTest {
}
}

@SmokeTest
@Test
fun blockAppUsingCameraTest() {
navigationToolbar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,15 @@ class BrowserRobot {
return SitePermissionsRobot.Transition()
}

fun clickStartAudioVideoButton(interact: SitePermissionsRobot.() -> Unit): SitePermissionsRobot.Transition {
// Test page used for testing permissions located at https://mozilla-mobile.github.io/testapp/permissions
audioVideoButton.waitForExists(waitingTime)
audioVideoButton.click()

SitePermissionsRobot().interact()
return SitePermissionsRobot.Transition()
}

fun clickOpenNotificationButton(interact: SitePermissionsRobot.() -> Unit): SitePermissionsRobot.Transition {
// Test page used for testing permissions located at https://mozilla-mobile.github.io/testapp/permissions
notificationButton.waitForExists(waitingTime)
Expand Down Expand Up @@ -757,6 +766,8 @@ private val cameraButton = mDevice.findObject(UiSelector().text("Open camera"))

private val microphoneButton = mDevice.findObject(UiSelector().text("Open microphone"))

private val audioVideoButton = mDevice.findObject(UiSelector().text("Camera & Microphone"))

private val notificationButton = mDevice.findObject(UiSelector().text("Open notifications dialogue"))

private val getLocationButton = mDevice.findObject(UiSelector().text("Get Location"))
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ class SitePermissionsRobot {
assertTrue(allowPagePermissionButton.text.equals("Allow"))
}

fun verifyAudioVideoPermissionPrompt(url: String) {
assertTrue(
mDevice.findObject(UiSelector().text("Allow $url to use your camera and microphone?"))
.waitForExists(waitingTime)
)
assertTrue(denyPagePermissionButton.text.equals("Don’t allow"))
assertTrue(allowPagePermissionButton.text.equals("Allow"))
}

fun verifyLocationPermissionPrompt(url: String) {
assertTrue(
mDevice.findObject(UiSelector().text("Allow $url to use your location?"))
Expand Down

0 comments on commit d233ec1

Please sign in to comment.