Class ShadowBluetoothSocket

java.lang.Object
org.robolectric.shadows.ShadowBluetoothSocket

@Implements(android.bluetooth.BluetoothSocket.class) public class ShadowBluetoothSocket extends Object
  • Constructor Details

    • ShadowBluetoothSocket

      public ShadowBluetoothSocket()
  • Method Details

    • setOutputStream

      public void setOutputStream(PipedOutputStream outputStream)
      Set the output stream. write() operations on this stream can be observed to verify expected behavior.
    • getInputStreamFeeder

      public PipedOutputStream getInputStreamFeeder()
      Returns PipedOutputStream that controls input stream of the BluetoothSocket.
    • getOutputStreamSink

      public PipedInputStream getOutputStreamSink()
      Returns PipedInputStream that controls output stream of the BluetoothSocket.
    • blockConnect

      public void blockConnect()
      Causes calls to connect() to block until either unblockConnect() or close() are called. Note that the real implementation of connect() is expected to unblock when the socket is closed from a different thread.

      This method may only be called once per instance (a socket is only expected to be connected once).

    • unblockConnect

      public void unblockConnect()
      Causes calls to connect() to unblock. This may be called while connect() is being called from another thread, or before connect() is called.

      blockConnect() must be called before calling this method (otherwise, the socket is already unblocked, so there is no need to call this method).

    • setConnectException

      public void setConnectException(IOException connectException)
      Set the exception that connect() will throw if the socket is closed. This can be used to test situations where BluetoothSocketException is thrown.
    • getInputStream

      @Implementation protected InputStream getInputStream()
    • getOutputStream

      @Implementation protected OutputStream getOutputStream()
    • isConnected

      @Implementation protected boolean isConnected()
    • connect

      @Implementation protected void connect() throws IOException
      Throws:
      IOException
    • close

      @Implementation protected void close() throws IOException
      Throws:
      IOException