Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Commit

Permalink
Better explain how to mock the camera (AdevintaSpain#325)
Browse files Browse the repository at this point in the history
Right now, we're only showing the method that mocks the camera. But we don't share how to do it.
  • Loading branch information
rocboronat authored Nov 12, 2019
1 parent 5e882f0 commit 7cbb2e4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,17 @@ assertAny<RadioGroup>(R.id.radioGroup, "selected option is the second one") {
}
```

## Barista’s Intents API
## Mocking the Intent results

Mocking the Android Camera Intent is a tricky thing to do. To accomplish it in no time, Barista gives a way to do it in one line: the method `mockAndroidCamera()`. This method does all the magic to mock the result of the camera. One more thing to do: you have to call `Intents.init()` before calling `mockAndroidCamera()`, and `Intents.release()` after doing the action that launches the camera. You could also use `IntentsTestRule` instead of the common `ActivityTestRule` to skip it, but as we recommend the use of `BaristaRule`, it's easier to just call both methods manually when needed.

Here's an example to copy paste:

```java
// Creates a Bitmap on a camera provided URI
Intents.init();
mockAndroidCamera();
clickOn(R.id.launch_camera);
Intents.release();
```

## Runtime Permissions
Expand Down

0 comments on commit 7cbb2e4

Please sign in to comment.