This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UI smoke test] For #21002: Ads app permissions UI tests
- Loading branch information
Oana Horvath
committed
Jan 19, 2022
1 parent
af5b2c9
commit 29c14bc
Showing
4 changed files
with
404 additions
and
10 deletions.
There are no files selected for viewing
226 changes: 226 additions & 0 deletions
226
app/src/androidTest/java/org/mozilla/fenix/ui/SitePermissionsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
/* 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 | ||
|
||
import androidx.core.net.toUri | ||
import org.junit.Ignore | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.mozilla.fenix.customannotations.SmokeTest | ||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule | ||
import org.mozilla.fenix.ui.robots.browserScreen | ||
import org.mozilla.fenix.ui.robots.navigationToolbar | ||
|
||
/** | ||
* Tests for verifying site permissions prompts & functionality | ||
* | ||
*/ | ||
class SitePermissionsTest { | ||
/* Test page created and handled by the Mozilla mobile test-eng team */ | ||
private val testPage = "https://mozilla-mobile.github.io/testapp/permissions" | ||
private val testPageSubstring = "https://mozilla-mobile.github.io:443" | ||
|
||
@get:Rule | ||
val activityTestRule = HomeActivityIntentTestRule() | ||
|
||
@SmokeTest | ||
@Test | ||
fun microphonePermissionChoiceOnEachRequestTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
waitForPageToLoad() | ||
}.clickStartMicrophoneButton { | ||
clickAppPermissionButton(true) | ||
verifyMicrophonePermissionPrompt(testPageSubstring) | ||
}.clickPagePermissionButton(false) { | ||
verifyPageContent("Microphone not allowed") | ||
}.clickStartMicrophoneButton { | ||
}.clickPagePermissionButton(true) { | ||
verifyPageContent("Microphone allowed") | ||
} | ||
} | ||
|
||
@SmokeTest | ||
@Test | ||
fun rememberBlockMicrophonePermissionChoiceTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
waitForPageToLoad() | ||
}.clickStartMicrophoneButton { | ||
clickAppPermissionButton(true) | ||
verifyMicrophonePermissionPrompt(testPageSubstring) | ||
selectRememberPermissionDecision() | ||
}.clickPagePermissionButton(false) { | ||
verifyPageContent("Microphone not allowed") | ||
}.openThreeDotMenu { | ||
}.refreshPage { | ||
waitForPageToLoad() | ||
}.clickStartMicrophoneButton { } | ||
browserScreen { | ||
verifyPageContent("Microphone not allowed") | ||
} | ||
} | ||
|
||
@Ignore("Flaky, needs investigation: https://github.com/mozilla-mobile/fenix/issues/23298") | ||
@SmokeTest | ||
@Test | ||
fun rememberAllowMicrophonePermissionChoiceTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
waitForPageToLoad() | ||
}.clickStartMicrophoneButton { | ||
clickAppPermissionButton(true) | ||
verifyMicrophonePermissionPrompt(testPageSubstring) | ||
selectRememberPermissionDecision() | ||
}.clickPagePermissionButton(true) { | ||
verifyPageContent("Microphone allowed") | ||
}.openThreeDotMenu { | ||
}.refreshPage { | ||
waitForPageToLoad() | ||
}.clickStartMicrophoneButton { } | ||
browserScreen { | ||
verifyPageContent("Microphone allowed") | ||
} | ||
} | ||
|
||
@SmokeTest | ||
@Test | ||
fun blockAppUsingMicrophoneTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
}.clickStartMicrophoneButton { | ||
clickAppPermissionButton(false) | ||
} | ||
browserScreen { | ||
verifyPageContent("Microphone not allowed") | ||
} | ||
} | ||
|
||
@SmokeTest | ||
@Test | ||
fun cameraPermissionChoiceOnEachRequestTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
waitForPageToLoad() | ||
}.clickStartCameraButton { | ||
clickAppPermissionButton(true) | ||
verifyCameraPermissionPrompt(testPageSubstring) | ||
}.clickPagePermissionButton(false) { | ||
verifyPageContent("Camera not allowed") | ||
}.clickStartCameraButton { | ||
}.clickPagePermissionButton(true) { | ||
verifyPageContent("Camera allowed") | ||
} | ||
} | ||
|
||
@SmokeTest | ||
@Test | ||
fun rememberBlockCameraPermissionChoiceTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
waitForPageToLoad() | ||
}.clickStartCameraButton { | ||
clickAppPermissionButton(true) | ||
verifyCameraPermissionPrompt(testPageSubstring) | ||
selectRememberPermissionDecision() | ||
}.clickPagePermissionButton(false) { | ||
verifyPageContent("Camera not allowed") | ||
}.openThreeDotMenu { | ||
}.refreshPage { | ||
waitForPageToLoad() | ||
}.clickStartCameraButton { } | ||
browserScreen { | ||
verifyPageContent("Camera not allowed") | ||
} | ||
} | ||
|
||
@SmokeTest | ||
@Test | ||
fun rememberAllowCameraPermissionChoiceTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
waitForPageToLoad() | ||
}.clickStartCameraButton { | ||
clickAppPermissionButton(true) | ||
verifyCameraPermissionPrompt(testPageSubstring) | ||
selectRememberPermissionDecision() | ||
}.clickPagePermissionButton(true) { | ||
verifyPageContent("Camera allowed") | ||
}.openThreeDotMenu { | ||
}.refreshPage { | ||
waitForPageToLoad() | ||
}.clickStartCameraButton { } | ||
browserScreen { | ||
verifyPageContent("Camera allowed") | ||
} | ||
} | ||
|
||
@SmokeTest | ||
@Test | ||
fun blockAppUsingCameraTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
}.clickStartCameraButton { | ||
clickAppPermissionButton(false) | ||
} | ||
browserScreen { | ||
verifyPageContent("Camera not allowed") | ||
} | ||
} | ||
|
||
@Test | ||
fun blockNotificationsPermissionPromptTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
}.clickOpenNotificationButton { | ||
verifyNotificationsPermissionPrompt(testPageSubstring) | ||
}.clickPagePermissionButton(false) { | ||
verifyPageContent("Notifications not allowed") | ||
}.openThreeDotMenu { | ||
}.refreshPage { | ||
waitForPageToLoad() | ||
}.clickOpenNotificationButton { | ||
verifyNotificationsPermissionPrompt(testPageSubstring, true) | ||
} | ||
} | ||
|
||
@Test | ||
fun allowNotificationsPermissionPromptTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
}.clickOpenNotificationButton { | ||
verifyNotificationsPermissionPrompt(testPageSubstring) | ||
}.clickPagePermissionButton(true) { | ||
verifyPageContent("Notifications allowed") | ||
} | ||
} | ||
|
||
@Ignore("Needs mocking location for Firebase - to do: https://github.com/mozilla-mobile/mobile-test-eng/issues/585") | ||
@Test | ||
fun allowLocationPermissionsTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
}.clickGetLocationButton { | ||
clickAppPermissionButton(true) | ||
verifyLocationPermissionPrompt(testPageSubstring) | ||
}.clickPagePermissionButton(true) { | ||
verifyPageContent("longitude") | ||
verifyPageContent("latitude") | ||
} | ||
} | ||
|
||
@Ignore("Needs mocking location for Firebase - to do: https://github.com/mozilla-mobile/mobile-test-eng/issues/585") | ||
@Test | ||
fun blockLocationPermissionsTest() { | ||
navigationToolbar { | ||
}.enterURLAndEnterToBrowser(testPage.toUri()) { | ||
}.clickGetLocationButton { | ||
clickAppPermissionButton(true) | ||
verifyLocationPermissionPrompt(testPageSubstring) | ||
}.clickPagePermissionButton(false) { | ||
verifyPageContent("User denied geolocation prompt") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.