TestEmbeddedPhotoPickerProvider


@RequiresExtension(extension = 34, version = 15)
public final class TestEmbeddedPhotoPickerProvider implements 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 constructors

Public methods

static final @NonNull TestEmbeddedPhotoPickerProvider
get()

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

final @NonNull Set<@NonNull EmbeddedPhotoPickerSession>

The list of sessions opened with this provider.

final void

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

final void

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

final void

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

final void

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

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

Opens a fake EmbeddedPhotoPickerSession that can be used for testing.

Public constructors

TestEmbeddedPhotoPickerProvider

Added in 1.0.0-alpha01
public TestEmbeddedPhotoPickerProvider(@NonNull Context context)

Public methods

get

Added in 1.0.0-alpha01
public static final @NonNull TestEmbeddedPhotoPickerProvider get()

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

Returns
@NonNull TestEmbeddedPhotoPickerProvider

A test only implementation of EmbeddedPhotoPickerProvider.

getSessions

Added in 1.0.0-alpha01
public final @NonNull Set<@NonNull EmbeddedPhotoPickerSessiongetSessions()

The list of sessions opened with this provider.

notifyDeselectedUris

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

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
@NonNull EmbeddedPhotoPickerSession session

The EmbeddedPhotoPickerSession, created by calling openSession on this provider.

@NonNull List<@NonNull Uri> 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 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
@NonNull EmbeddedPhotoPickerSession session

The EmbeddedPhotoPickerSession, created by calling openSession on this provider.

@NonNull List<@NonNull Uri> uris

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

notifySelectionComplete

Added in 1.0.0-alpha01
public final void notifySelectionComplete(@NonNull EmbeddedPhotoPickerSession session)

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

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

Parameters
@NonNull EmbeddedPhotoPickerSession session

The EmbeddedPhotoPickerSession, created by calling openSession on this provider.

notifySessionError

Added in 1.0.0-alpha01
public final void notifySessionError(
    @NonNull EmbeddedPhotoPickerSession session,
    @NonNull Throwable throwable
)

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

Parameters
@NonNull EmbeddedPhotoPickerSession session

The EmbeddedPhotoPickerSession, created by calling openSession on this provider.

@NonNull 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
public void openSession(
    @NonNull IBinder hostToken,
    int displayId,
    int width,
    int height,
    @NonNull EmbeddedPhotoPickerFeatureInfo featureInfo,
    @NonNull Executor clientExecutor,
    @NonNull EmbeddedPhotoPickerClient callback
)

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.