Karumi / Dexter

Android library that simplifies the process of requesting permissions at runtime.
http://karumi.com
Apache License 2.0
5.23k stars 671 forks source link

Any response in MultiplePermissionsListener while testing with Robolectric #95

Closed PawelDedio closed 7 years ago

PawelDedio commented 7 years ago

I'm checking permission in my fragment onCreate with Dexter.checkPermissions(new MultiplePermissionsListener() {}); when I'm running app on device everything working fine, but the problem is when I want to test app via Robolectric, before testing I'm granting all required permissions ShadowApplication shadowApplication = Shadows.shadowOf(RuntimeEnvironment.application); shadowApplication.grantPermissions(permission.RECORD_AUDIO, permission.CAMERA, permission.WRITE_EXTERNAL_STORAGE); and after that I'm starting fragment with CameraFragment_ fragment = (CameraFragment_) CameraFragment_.builder().build(); SupportFragmentTestUtil.startFragment(fragment); but I'm don't getting any response to MultiplePermissionsListener, I checked via ContextCompat.checkSelfPermission() and I have these permissions.

My version of library is 2.3.1

Serchinastico commented 7 years ago

Hi @PawelDedio

First of all, sorry for the late response.

By the snippets you copied here I'm guessing you are not implementing onPermissionRationaleShouldBeShown. If you really want an empty listener, you should be at least implementing that to call token.continuePermissionRequest(). Keep in mind that Android might be asking you to display a rationale during the process and you need to tell it that you are done with that phase.

You can find more information here: https://github.com/Karumi/Dexter#showing-a-rationale

Thanks for reporting, please, tell us if that solves your issue.

Serchinastico commented 7 years ago

I'm closing this. Please, feel free to reopen it if the issue persists.

Thanks for your time!