Package org.robolectric.shadows
Class ShadowNetwork
- java.lang.Object
-
- org.robolectric.shadows.ShadowNetwork
-
@Implements(value=android.net.Network.class, minSdk=21) public class ShadowNetwork extends Object
-
-
Constructor Summary
Constructors Constructor Description ShadowNetwork()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbindSocket(FileDescriptor fd)Simulates a socket bind.protected voidbindSocket(DatagramSocket socket)Simulates a socket bind.protected voidbindSocket(Socket socket)Simulates a socket bind.intboundSocketCount()Returns the total number of sockets bound to this network interface.intgetNetId()Allows to get the stored netId.booleanisSocketBound(FileDescriptor fd)Checks if thefileDescriptorwas previously bound to this network.booleanisSocketBound(DatagramSocket socket)Checks if thedatagramSocketwas previously bound to this network.booleanisSocketBound(Socket socket)Checks if thesocketwas previously bound to this network.static NetworknewInstance(int netId)Creates new instance ofNetwork, because its constructor is hidden.
-
-
-
Method Detail
-
newInstance
public static Network newInstance(int netId)
Creates new instance ofNetwork, because its constructor is hidden.- Parameters:
netId- The netId.- Returns:
- The Network instance.
-
isSocketBound
public boolean isSocketBound(Socket socket)
Checks if thesocketwas previously bound to this network.
-
isSocketBound
public boolean isSocketBound(DatagramSocket socket)
Checks if thedatagramSocketwas previously bound to this network.
-
isSocketBound
public boolean isSocketBound(FileDescriptor fd)
Checks if thefileDescriptorwas previously bound to this network.
-
boundSocketCount
public int boundSocketCount()
Returns the total number of sockets bound to this network interface.
-
bindSocket
@Implementation(minSdk=22) protected void bindSocket(DatagramSocket socket)
Simulates a socket bind. isSocketBound can be called to verify that the socket was bound to this network interface, and boundSocketCount() will increment for any unique socket.
-
bindSocket
@Implementation protected void bindSocket(Socket socket)
Simulates a socket bind. isSocketBound can be called to verify that the socket was bound to this network interface, and boundSocketCount() will increment for any unique socket.
-
bindSocket
@Implementation(minSdk=23) protected void bindSocket(FileDescriptor fd)
Simulates a socket bind. isSocketBound can be called to verify that the fd was bound to this network interface, and boundSocketCount() will increment for any unique socket.
-
getNetId
@Implementation(minSdk=30) public int getNetId()
Allows to get the stored netId.- Returns:
- The netId.
-
-