Crocodile
Crocodile

Reputation: 5855

Instrumentation tests don't ask for user permissions in Firebase Test Lab

When I run instrumentation tests in Firebase Test Lab, the system dialogs asking the user to grant permissions don't come up, as if they were approved without the need for user action. For example when asking to approve screen recording:

  val mediaProjMgr = activity.getSystemService(Context.MEDIA_PROJECTION_SERVICE) as MediaProjectionManager
  startForResult.launch(mediaProjMgr.createScreenCaptureIntent())

When I run the same test locally the pop up asking to start the recording does show as expected.

How does this work with Test Lab? Do they disable the need for user permissions somehow? What's the mechanism behind it?

Upvotes: 2

Views: 620

Answers (1)

robigroza
robigroza

Reputation: 589

By default, all permissions are granted on the Firebase Test lab. To simulate the same environment inside your tests, use GrantPermissionRule in test classes that require permissions.

Upvotes: 2

Related Questions