-
Notifications
You must be signed in to change notification settings - Fork 31
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
base: main
Are you sure you want to change the base?
Conversation
- created permissions folder - create viewmodel outside of permissions screen
…oked while on preview screen
app/src/androidTest/java/com/google/jetpackcamera/PermissionsTest.kt
Outdated
Show resolved
Hide resolved
app/src/androidTest/java/com/google/jetpackcamera/PermissionsTest.kt
Outdated
Show resolved
Hide resolved
app/src/androidTest/java/com/google/jetpackcamera/PermissionsTest.kt
Outdated
Show resolved
Hide resolved
Build.VERSION.SDK_INT == 23 -> "Allow" | ||
Build.VERSION.SDK_INT <= 28 -> "ALLOW" | ||
Build.VERSION.SDK_INT == 29 -> "Allow only while using the app" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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/src/androidTest/java/com/google/jetpackcamera/UiTestUtil.kt
Outdated
Show resolved
Hide resolved
app/build.gradle.kts
Outdated
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 | ||
} | ||
} |
There was a problem hiding this comment.
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?
feature/permissions/src/test/java/com/google/jetpackcamera/permissions/ExampleUnitTest.kt
Outdated
Show resolved
Hide resolved
feature/permissions/src/main/java/com/google/jetpackcamera/permissions/ui/TestTags.kt
Outdated
Show resolved
Hide resolved
ResId for finding components, refactor constant names, removed unused methods, cleanup
app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt
Outdated
Show resolved
Hide resolved
app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt
Outdated
Show resolved
Hide resolved
app/src/androidTest/java/com/google/jetpackcamera/PermissionsTest.kt
Outdated
Show resolved
Hide resolved
app/src/androidTest/java/com/google/jetpackcamera/PermissionsTest.kt
Outdated
Show resolved
Hide resolved
app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt
Outdated
Show resolved
Hide resolved
app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt
Outdated
Show resolved
Hide resolved
app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt
Outdated
Show resolved
Hide resolved
feature/permissions/src/main/java/com/google/jetpackcamera/permissions/ui/TestTags.kt
Outdated
Show resolved
Hide resolved
# Conflicts: # app/src/androidTest/java/com/google/jetpackcamera/utils/UiTestUtil.kt
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.