InteractionRequest.Builder

public class InteractionRequest.Builder


Creates an instance of InteractionRequest from a View matcher and action.

Summary

Public constructors

Creates a new Builder instance.

Public methods

InteractionRequest

Builds an InteractionRequest object.

InteractionRequest.Builder
setRequestProto(byte[] protoByteArray)

Set the result proto as a byte array.

InteractionRequest.Builder
setRootMatcher(Matcher<Root> rootMatcher)

Sets the root matcher for this InteractionRequest

InteractionRequest.Builder

Sets the ViewAction for this InteractionRequest

InteractionRequest.Builder

Sets the ViewAssertion for this InteractionRequest

InteractionRequest.Builder
setViewMatcher(Matcher<View> viewMatcher)

Sets the view matcher for this InteractionRequest

Public constructors

Builder

public Builder()

Creates a new Builder instance.

Public methods

build

public InteractionRequest build()

Builds an InteractionRequest object.

Throws
java.lang.IllegalStateException java.lang.IllegalStateException

when conflicting properties are set. You can either set a < and a ViewAction or set the proto byte array but not both. Setting all values would result in an override, therefore setting both properties will result in an exception.

androidx.test.espresso.remote.RemoteProtocolException androidx.test.espresso.remote.RemoteProtocolException

when the provided proto byte array cannot be parsed into a protocol buffer of type InteractionRequestProto

setRequestProto

public InteractionRequest.Builder setRequestProto(byte[] protoByteArray)

Set the result proto as a byte array. This byte array will be parsed into an InteractionRequestProto. Providing an invalid byte array will result in a RemoteProtocolException when the build method is called!

Parameters
byte[] protoByteArray

the proto byte array to set

Returns
InteractionRequest.Builder

fluent interface Builder

setRootMatcher

public InteractionRequest.Builder setRootMatcher(Matcher<Root> rootMatcher)

Sets the root matcher for this InteractionRequest

Parameters
Matcher<Root> rootMatcher

the root matcher to set

Returns
InteractionRequest.Builder

fluent interface

See also
Root

setViewAction

public InteractionRequest.Builder setViewAction(ViewAction viewAction)

Sets the ViewAction for this InteractionRequest

Parameters
ViewAction viewAction

the view action to set

Returns
InteractionRequest.Builder

fluent interface

Throws
java.lang.IllegalStateException java.lang.IllegalStateException

if a ViewAssertion was already set through setViewAssertion before. InteractionRequest supports only one of ViewAction or ViewAssertion, but not both.

setViewAssertion

public InteractionRequest.Builder setViewAssertion(ViewAssertion viewAssertion)

Sets the ViewAssertion for this InteractionRequest

Parameters
ViewAssertion viewAssertion

the view action to set

Returns
InteractionRequest.Builder

fluent interface

Throws
java.lang.IllegalStateException java.lang.IllegalStateException

if a ViewAction was already set through setViewAction before. InteractionRequest supports only one of ViewAction or ViewAssertion, but not both.

setViewMatcher

public InteractionRequest.Builder setViewMatcher(Matcher<View> viewMatcher)

Sets the view matcher for this InteractionRequest

Parameters
Matcher<View> viewMatcher

the view matcher to set

Returns
InteractionRequest.Builder

fluent interface