Package org.robolectric.shadows
Class ShadowBluetoothSocket
java.lang.Object
org.robolectric.shadows.ShadowBluetoothSocket
@Implements(android.bluetooth.BluetoothSocket.class)
public class ShadowBluetoothSocket
extends Object
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
close()
protected void
connect()
protected InputStream
ReturnsPipedOutputStream
that controls input stream of theBluetoothSocket
.protected OutputStream
ReturnsPipedInputStream
that controls output stream of theBluetoothSocket
.protected boolean
void
setConnectException
(IOException connectException) Set the exception thatconnect()
will throw if the socket is closed.void
setOutputStream
(PipedOutputStream outputStream) Set the output stream.void
Causes calls toconnect()
to unblock.
-
Constructor Details
-
ShadowBluetoothSocket
public ShadowBluetoothSocket()
-
-
Method Details
-
setOutputStream
Set the output stream.write()
operations on this stream can be observed to verify expected behavior. -
getInputStreamFeeder
ReturnsPipedOutputStream
that controls input stream of theBluetoothSocket
. -
getOutputStreamSink
ReturnsPipedInputStream
that controls output stream of theBluetoothSocket
. -
blockConnect
public void blockConnect()Causes calls toconnect()
to block until eitherunblockConnect()
orclose()
are called. Note that the real implementation ofconnect()
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 toconnect()
to unblock. This may be called whileconnect()
is being called from another thread, or beforeconnect()
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
Set the exception thatconnect()
will throw if the socket is closed. This can be used to test situations whereBluetoothSocketException
is thrown. -
getInputStream
-
getOutputStream
-
isConnected
-
connect
- Throws:
IOException
-
close
- Throws:
IOException
-