public final class

Conduit

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

Class Overview

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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public ListenableFuture<String> getResult ()

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

public 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.

public 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 the buffer holding the script, it will be modified in place.
Returns
  • the StringBuilder passed in.