Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permissions flow test #215

Open
wants to merge 64 commits into
base: main
Choose a base branch
from
Open

permissions flow test #215

wants to merge 64 commits into from

Conversation

Kimblebee
Copy link
Collaborator

@Kimblebee Kimblebee commented May 31, 2024

Tests written for permissions UI flow

Also added some reusable utilities for interacting with permissions dialogs and finding system UI components by text.

Test orchestration is required for each permissions test. Each test must be isolated to its own instrumentation since permissions are being granted and reset during the tests. resetting or revorking permissions between tests isn't supported for testing in a single instrumentation -- it can cause unexpected, flaky behavior when tests are run in sequence.

@Kimblebee Kimblebee marked this pull request as ready for review June 3, 2024 17:21
@Kimblebee Kimblebee requested review from yasith and temcguir June 3, 2024 17:27
Comment on lines 132 to 134
Build.VERSION.SDK_INT == 23 -> "Allow"
Build.VERSION.SDK_INT <= 28 -> "ALLOW"
Build.VERSION.SDK_INT == 29 -> "Allow only while using the app"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finding system strings by literals is probably going to be flaky. If the device is set to a different language these will fail. Also, it's possible for the device manufacturer to override these strings with overlays.

Maybe you could try what CTS is doing here: https://cs.android.com/android/platform/superproject/main/+/main:packages/modules/Permission/tests/cts/permission/src/android/permission/cts/OneTimePermissionTest.java;l=326;drc=e35f81feee1a91cd31db16967cc3c3de35109071

If that doesn't work, then I would say we should limit these tests to very specific devices and API levels, and skip otherwise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

is it possible for this resource id value to be different depending on the device manufacturer? It seems it has changed once for allow and deny after api 30.

So far the deny and allow once id's work. but uiautomator still can't find the Allow button. Not sure why that is but i'll take another minute to look into it.

app/build.gradle.kts Outdated Show resolved Hide resolved
Comment on lines 91 to 97
unitTests.all {
it.testLogging {
events("failed", "standardOut", "standardError") // Log events
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL // Show full stack traces
showStackTraces = true
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, unitTests shouldn't affect instrumentation tests. So this shouldn't have any effect. Are you actually seeing this do something?

.idea/androidTestResultsUserPreferences.xml Outdated Show resolved Hide resolved
.idea/deploymentTargetSelector.xml Outdated Show resolved Hide resolved
 ResId for finding components, refactor constant names, removed unused methods, cleanup
# Conflicts:
#	app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants