concretesolutions / kappuccino

A kotlin library to simplify how to do espresso tests on Android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Permission actions not working

92alanc opened this issue · comments

The grant function is actually denying the permissions, while deny isn't doing anything at all.
This behaviour might have something to do with the index of the button in the dialogue.

In the code, the DENY button is at index 0 and the ALLOW button is at index 1, but when pressing the button at index 1, the test is pressing the first button (DENY), so I guess the permission dialogue doesn't work with zero-based indices.

My suggestion is to deprecate or even delete that permissionUtils file, because in the support library there is a very straightfoward rule that handles permissions. Here is an example:

@Rule
@JvmField
val cameraPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(CAMERA)

Using the support library, this is all that needs to be done in order to grant a permission.

That is great!
At the time of I've created this permissionUtils file, we didn't have this on support library.
Much better now!

Hey @alancamargo92
Just for curiosity, did you tried to uninstall the app before running the permission tests?

Yes I did. The thing is, the permission handling functions we have here do interact with the permission modal but they just aren't as reliable as the support library's permission test rule from what I noticed after a few tests

Yes, it's been a while since I don't update those methods, it would be good if we can refactor those methods and classes.

Ok, so how about deleting this permissionUtils file and sticking to the PermissionTestRule?

Are you talking about GrantPermissionRule ?
The idea of permissionUtils is to be able to test those scenarios:

  • if the app is displaying the custom permission message dialog, before the default one.
  • when you deny the permission request, if your app is displaying the correct message/dialog/ui
  • when you allow the permission request, if your app is displaying the correct message/dialog/ui

With GrantPermissionRule you will allow the permission for all tests, which make sense if you don't want to test the scenarios described above.
Anyways, the user still can use the GrantPermissionRule and not use permissionUtils in the current versions. Perhaps what we need (after fixing the bug) it's a better documentation about those methods and what they should be used for. What do you think?

Yeah I was talking about GrantPermissionRule. Ok now it makes complete sense to have the permissionUtils. We can definitely keep working on it

Why did you close it? The PR wasn't merged yet 😆

My bad haha I clicked on the "close and comment" button by accident

@alancamargo92 that can be closed now 👍