# TestEmbeddedPhotoPickerProvider

Artifact: [androidx.photopicker:photopicker-testing](https://developer.android.com/jetpack/androidx/releases/photopicker) [View Source](https://cs.android.com/search?q=file:androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider.kt+class:androidx.photopicker.testing.TestEmbeddedPhotoPickerProvider) Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

*** ** * ** ***


```
@RequiresApi(value = 34)
@RequiresExtension(extension = 34, version = 15)
public final class TestEmbeddedPhotoPickerProvider implements EmbeddedPhotoPickerProvider
```

<br />

*** ** * ** ***

A test implementation of `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerProvider.html` which provides a fake of the Embedded PhotoPicker and provides additional methods to allow tests to fake user interactions so that the client side flows can be tested.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider#TestEmbeddedPhotoPickerProvider(android.content.Context)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context)` |

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider` | `https://developer.android.com/reference/androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider#get()()` Construct a `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerProvider.html` that runs a fake embedded photopicker view using the InstrumentedTests context for the underlying empty View. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html>` | `https://developer.android.com/reference/androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider#getSessions()()` The list of sessions opened with this provider. |
| `final void` | `https://developer.android.com/reference/androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider#notifyDeselectedUris(android.widget.photopicker.EmbeddedPhotoPickerSession,kotlin.collections.List)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html session, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html> uris )` Direct the `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` to emit the provided list of `https://developer.android.com/reference/android/net/Uri.html` as deselected by the user. |
| `final void` | `https://developer.android.com/reference/androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider#notifySelectedUris(android.widget.photopicker.EmbeddedPhotoPickerSession,kotlin.collections.List)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html session, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html> uris )` Direct the `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` to emit the provided list of `https://developer.android.com/reference/android/net/Uri.html` as selected by the user. |
| `final void` | `https://developer.android.com/reference/androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider#notifySelectionComplete(android.widget.photopicker.EmbeddedPhotoPickerSession)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html session)` Direct the `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` to emit the user has completed selection media. |
| `final void` | `https://developer.android.com/reference/androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider#notifySessionError(android.widget.photopicker.EmbeddedPhotoPickerSession,kotlin.Throwable)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html session, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Throwable.html throwable )` Direct the provided `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` to throw an error to the client. |
| `void` | `https://developer.android.com/reference/androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider#openSession(android.os.IBinder,kotlin.Int,kotlin.Int,kotlin.Int,android.widget.photopicker.EmbeddedPhotoPickerFeatureInfo,java.util.concurrent.Executor,android.widget.photopicker.EmbeddedPhotoPickerClient)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/IBinder.html hostToken, int displayId, int width, int height, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerFeatureInfo.html featureInfo, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html clientExecutor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerClient.html callback )` Opens a fake `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` that can be used for testing. |

## Public constructors

### TestEmbeddedPhotoPickerProvider

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
public TestEmbeddedPhotoPickerProvider(@NonNull Context context)
```

## Public methods

### get

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
public static final @NonNull TestEmbeddedPhotoPickerProvider get()
```

Construct a `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerProvider.html` that runs a fake embedded photopicker view using the InstrumentedTests context for the underlying empty View.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider` | A test only implementation of `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerProvider.html`. |

### getSessions

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
public final @NonNull Set<@NonNull EmbeddedPhotoPickerSession> getSessions()
```

The list of sessions opened with this provider.

### notifyDeselectedUris

```
public final void notifyDeselectedUris(
    @NonNull EmbeddedPhotoPickerSession session,
    @NonNull List<@NonNull Uri> uris
)
```

Direct the `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` to emit the provided list of `https://developer.android.com/reference/android/net/Uri.html` as deselected by the user.

This will allow test cases to properly test the EmbeddedPhotoPickerClient#onUriPermissionRevoked callback.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html session` | The EmbeddedPhotoPickerSession, created by calling openSession on this provider. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html> uris` | The list of Uris that the session should mark as deselected by the user. |

### notifySelectedUris

```
public final void notifySelectedUris(
    @NonNull EmbeddedPhotoPickerSession session,
    @NonNull List<@NonNull Uri> uris
)
```

Direct the `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` to emit the provided list of `https://developer.android.com/reference/android/net/Uri.html` as selected by the user.

This will allow test cases to properly test the EmbeddedPhotoPickerClient#onUriPermissionGranted callback.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html session` | The EmbeddedPhotoPickerSession, created by calling openSession on this provider. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html> uris` | The list of Uris that the session should mark as selected by the user. |

### notifySelectionComplete

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
public final void notifySelectionComplete(@NonNull EmbeddedPhotoPickerSession session)
```

Direct the `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` to emit the user has completed selection media.

This will allow test cases to properly test the EmbeddedPhotoPickerClient#onSelectionComplete callback.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html session` | The EmbeddedPhotoPickerSession, created by calling openSession on this provider. |

### notifySessionError

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
public final void notifySessionError(
    @NonNull EmbeddedPhotoPickerSession session,
    @NonNull Throwable throwable
)
```

Direct the provided `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` to throw an error to the client.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html session` | The EmbeddedPhotoPickerSession, created by calling openSession on this provider. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Throwable.html throwable` | The `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html` this session should throw. The `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerClient.html` will receive this error via the EmbeddedPhotoPickerClient#onSessionError callback. |

### openSession

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
public void openSession(
    @NonNull IBinder hostToken,
    int displayId,
    int width,
    int height,
    @NonNull EmbeddedPhotoPickerFeatureInfo featureInfo,
    @NonNull Executor clientExecutor,
    @NonNull EmbeddedPhotoPickerClient callback
)
```

Opens a fake `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` that can be used for testing.

The session that is opened will render real, but empty Views in the client application, and the `https://developer.android.com/reference/androidx/photopicker/testing/TestEmbeddedPhotoPickerProvider` provides additional method for faking user intections between the client and EmbeddedPhotoPicker service.