TestEmbeddedPhotoPickerProvider


@RequiresExtension(extension = 34, version = 15)
class TestEmbeddedPhotoPickerProvider : EmbeddedPhotoPickerProvider


A test implementation of EmbeddedPhotoPickerProvider 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 companion functions

TestEmbeddedPhotoPickerProvider
get()

Construct a EmbeddedPhotoPickerProvider that runs a fake embedded photopicker view using the InstrumentedTests context for the underlying empty View.

Public constructors

Public functions

Unit
notifyDeselectedUris(
    session: EmbeddedPhotoPickerSession,
    uris: List<Uri>
)

Direct the EmbeddedPhotoPickerSession to emit the provided list of Uri as deselected by the user.

Unit

Direct the EmbeddedPhotoPickerSession to emit the provided list of Uri as selected by the user.

Unit

Direct the EmbeddedPhotoPickerSession to emit the user has completed selection media.

Unit
notifySessionError(
    session: EmbeddedPhotoPickerSession,
    throwable: Throwable
)

Direct the provided EmbeddedPhotoPickerSession to throw an error to the client.

open Unit
openSession(
    hostToken: IBinder,
    displayId: Int,
    width: Int,
    height: Int,
    featureInfo: EmbeddedPhotoPickerFeatureInfo,
    clientExecutor: Executor,
    callback: EmbeddedPhotoPickerClient
)

Opens a fake EmbeddedPhotoPickerSession that can be used for testing.

Public properties

Set<EmbeddedPhotoPickerSession>

The list of sessions opened with this provider.

Public companion functions

get

Added in 1.0.0-alpha01
fun get(): TestEmbeddedPhotoPickerProvider

Construct a EmbeddedPhotoPickerProvider that runs a fake embedded photopicker view using the InstrumentedTests context for the underlying empty View.

Returns
TestEmbeddedPhotoPickerProvider

A test only implementation of EmbeddedPhotoPickerProvider.

Public constructors

TestEmbeddedPhotoPickerProvider

Added in 1.0.0-alpha01
TestEmbeddedPhotoPickerProvider(context: Context)

Public functions

notifyDeselectedUris

fun notifyDeselectedUris(
    session: EmbeddedPhotoPickerSession,
    uris: List<Uri>
): Unit

Direct the EmbeddedPhotoPickerSession to emit the provided list of Uri as deselected by the user.

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

Parameters
session: EmbeddedPhotoPickerSession

The EmbeddedPhotoPickerSession, created by calling openSession on this provider.

uris: List<Uri>

The list of Uris that the session should mark as deselected by the user.

notifySelectedUris

fun notifySelectedUris(session: EmbeddedPhotoPickerSession, uris: List<Uri>): Unit

Direct the EmbeddedPhotoPickerSession to emit the provided list of Uri as selected by the user.

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

Parameters
session: EmbeddedPhotoPickerSession

The EmbeddedPhotoPickerSession, created by calling openSession on this provider.

uris: List<Uri>

The list of Uris that the session should mark as selected by the user.

notifySelectionComplete

Added in 1.0.0-alpha01
fun notifySelectionComplete(session: EmbeddedPhotoPickerSession): Unit

Direct the EmbeddedPhotoPickerSession to emit the user has completed selection media.

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

Parameters
session: EmbeddedPhotoPickerSession

The EmbeddedPhotoPickerSession, created by calling openSession on this provider.

notifySessionError

Added in 1.0.0-alpha01
fun notifySessionError(
    session: EmbeddedPhotoPickerSession,
    throwable: Throwable
): Unit

Direct the provided EmbeddedPhotoPickerSession to throw an error to the client.

Parameters
session: EmbeddedPhotoPickerSession

The EmbeddedPhotoPickerSession, created by calling openSession on this provider.

throwable: Throwable

The Throwable this session should throw. The EmbeddedPhotoPickerClient will receive this error via the EmbeddedPhotoPickerClient#onSessionError callback.

openSession

Added in 1.0.0-alpha01
open fun openSession(
    hostToken: IBinder,
    displayId: Int,
    width: Int,
    height: Int,
    featureInfo: EmbeddedPhotoPickerFeatureInfo,
    clientExecutor: Executor,
    callback: EmbeddedPhotoPickerClient
): Unit

Opens a fake EmbeddedPhotoPickerSession that can be used for testing.

The session that is opened will render real, but empty Views in the client application, and the TestEmbeddedPhotoPickerProvider provides additional method for faking user intections between the client and EmbeddedPhotoPicker service.

Public properties

sessions

Added in 1.0.0-alpha01
val sessionsSet<EmbeddedPhotoPickerSession>

The list of sessions opened with this provider.