Using Espresso, is there a way to determine if the...
# android
s
Using Espresso, is there a way to determine if the app under test has a certain permission granted? I've tried calling checkPermission on the target context, but the tests seem to run as a different user than the app, so it always indicates the permission is denied.
Also, this is the one permission (Write_Settings) that can't be automatically granted using the GrantPermissionRule đŸ˜¿
s
Can you just test the intent that requests permissions?
s
I'm actually not trying to test the permission. The issue I have is that it's requested right away, and depending on whether it's a fresh install or the app was already installed, the permission might have been granted
I don't care about the permission in the context of my tests. I just want to know if I should wait for the dialog to show and dismiss it or not
i
Maybe you can use UIAutomator just to detect the dialog?
s
I'll check it out, thanks.
I don't think that's what I want. I can't see how to detect the dialog if there
z
If you don't care about the permission in the context of my tests — it sounds like using
GrantPermissionRule
may be a good course of action. This lets you ensure that the permissions you need will already be granted and you don't need to worry about the uncertainty.
s
As I said earlier, this is the one permission (Write_Settings) that cannot be granted that way
z
Ah — sorry, missed that comment.
s
No worries. It looks like UiAutomator had what I need to quickly match or skip a dialog