Conduit

Conduit

public final class Conduit
extends Object

java.lang.Object
   ↳ android.support.test.espresso.web.bridge.Conduit


A mechanism to get results out of a Javascript context and into a Java context.

Users can get instances of this class via JavaScriptBridge.makeConduit(). Each conduit can be used once (and only once) to transmit results. Before evaluating javascript via a loadUrl call the caller should call wrapScriptInConduit with the script to be evaluated. The script is wrapped up into an additional handler statement which forwards the result of the script to the JavaScriptBridge object. After calling loadUrl the caller can use the getResult method to get a Future which will contain the result of the javascript execution.

Summary

Public methods

ListenableFuture<String> getResult()

The future that will be resolved when the Javascript evaluation completes.

String wrapScriptInConduit(String script)

Takes Javascript code and wraps it within a statement that will pipe the results of evaluation to the ListenableFuture this conduit holds.

StringBuilder wrapScriptInConduit(StringBuilder script)

Wraps a script within additional javascript code that will allow the function to return its results back thru this conduit.

Inherited methods

From class java.lang.Object

Public methods

getResult

ListenableFuture<String> getResult ()

The future that will be resolved when the Javascript evaluation completes.

Returns
ListenableFuture<String>

wrapScriptInConduit

String wrapScriptInConduit (String script)

Takes Javascript code and wraps it within a statement that will pipe the results of evaluation to the ListenableFuture this conduit holds.

Parameters
script String
Returns
String

wrapScriptInConduit

StringBuilder wrapScriptInConduit (StringBuilder script)

Wraps a script within additional javascript code that will allow the function to return its results back thru this conduit.

Parameters
script StringBuilder: the buffer holding the script, it will be modified in place.
Returns
StringBuilder the StringBuilder passed in.