0

I have an app and I am trying to write some instrumented test on it. One feature of that app is a button that, when clicked, open the default camera intent of the phone to record a video. It is done by starting the intent ACTION_VIDEO_CAPTURE. After opening that intent, the user can record a video, when finished, he will be redirected to my activity which will upload the video using some API and open a Toast explaining to the user that the video has been uploaded (or not).

Now, I want to write an instrumented test to test that class. I can easily press the button to open the default camera intent, but after this I am stuck. How can I -automatically- start recording, stop recording after a few seconds, then press the "OK" button to go back to my activity? Is this even possible using Espresso or any other library?

Anael
  • 417
  • 1
  • 6
  • 18
  • 1
    Hey, you can try to use espresso to do clicks on certain coordinates. In your case the x and y positions of the start / stop recording buttons, etc. It's described [here](https://stackoverflow.com/a/22798043/3559908). If you use the same test device all the time this might work, although it's not a good solution – Vall0n Oct 11 '21 at 14:20
  • 1
    You can also try to mock the camera video recording like descriped [here in the 2nd part](https://proandroiddev.com/testing-camera-and-galley-intents-with-espresso-218eb9f59da9). this is probably the better solution – Vall0n Oct 11 '21 at 14:23

0 Answers0