Package org.robolectric.shadows
Class ShadowParcel
java.lang.Object
org.robolectric.shadows.ShadowParcel
Robolectric's
Parcel pretends to be backed by a byte buffer, closely matching Parcel's position, size, and capacity behavior. However, its internal pure-Java representation
is strongly typed, to detect non-portable code and common testing mistakes. It may throw IllegalArgumentException or IllegalStateException for error-prone behavior normal Parcel tolerates.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidnativeAppendFrom(long thisNativePtr, long otherNativePtr, int offset, int length) static longprotected static byte[]nativeCreateByteArray(long nativePtr) protected static intnativeDataAvail(long nativePtr) protected static intnativeDataCapacity(long nativePtr) protected static intnativeDataPosition(long nativePtr) protected static intnativeDataSize(long nativePtr) protected static voidnativeDestroy(long nativePtr) protected static voidnativeEnforceInterface(long nativePtr, String interfaceName) protected static voidnativeFreeBuffer(long nativePtr) protected static byte[]nativeMarshall(long nativePtr) protected static byte[]nativeReadBlob(long nativePtr) protected static booleannativeReadByteArray(long nativePtr, byte[] dest, int destLen) protected static doublenativeReadDouble(long nativePtr) protected static FileDescriptornativeReadFileDescriptor(long nativePtr) protected static floatnativeReadFloat(long nativePtr) protected static intnativeReadInt(long nativePtr) protected static longnativeReadLong(long nativePtr) protected static StringnativeReadString(long nativePtr) protected static StringnativeReadString16(long nativePtr) protected static StringnativeReadString8(long nativePtr) protected static IBindernativeReadStrongBinder(long nativePtr) protected static voidnativeSetDataCapacity(long nativePtr, int size) protected static voidnativeSetDataPosition(long nativePtr, int pos) protected static voidnativeSetDataSize(long nativePtr, int size) protected static voidnativeUnmarshall(long nativePtr, byte[] data, int offset, int length) protected static voidnativeWriteBlob(long nativePtr, byte[] b, int offset, int len) protected static voidnativeWriteByteArray(long nativePtr, byte[] b, int offset, int len) protected static intnativeWriteDouble(long nativePtr, double val) protected static longnativeWriteFileDescriptor(long nativePtr, FileDescriptor val) protected static intnativeWriteFloat(long nativePtr, float val) protected static intnativeWriteInt(long nativePtr, int val) protected static voidnativeWriteInterfaceToken(long nativePtr, String interfaceName) protected static intnativeWriteLong(long nativePtr, long val) protected static voidnativeWriteString(long nativePtr, String val) protected static voidnativeWriteString16(long nativePtr, String val) protected static voidnativeWriteString8(long nativePtr, String val) protected static voidnativeWriteStrongBinder(long nativePtr, IBinder val) protected static FileDescriptoropenFileDescriptor(String file, int mode) readParcelableCreator(ClassLoader loader) protected <T> Parcelable.Creator<T>readParcelableCreatorInternal(ClassLoader loader, Class<T> clazz) The goal of this shadow method is to workaround a JVM/ART incompatibility.static voidreset()protected voidwriteBlob(byte[] b, int offset, int len) protected voidwriteByteArray(byte[] b, int offset, int len)
-
Field Details
-
TAG
- See Also:
-
-
Constructor Details
-
ShadowParcel
public ShadowParcel()
-
-
Method Details
-
readParcelableCreator
-
readParcelableCreatorInternal
@Implementation(minSdk=33) protected <T> Parcelable.Creator<T> readParcelableCreatorInternal(ClassLoader loader, Class<T> clazz) The goal of this shadow method is to workaround a JVM/ART incompatibility.In ART, a public field is visible regardless whether or not the enclosing class is public. On the JVM, this is not the case. For compatibility, we need to use
Field.setAccessible(boolean)to simulate the same behavior. -
writeByteArray
-
nativeDataSize
-
nativeDataAvail
-
nativeDataPosition
-
nativeDataCapacity
-
nativeSetDataSize
-
nativeSetDataPosition
-
nativeSetDataCapacity
-
nativeWriteByteArray
@Implementation protected static void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len) -
writeBlob
-
nativeWriteBlob
@Implementation protected static void nativeWriteBlob(long nativePtr, byte[] b, int offset, int len) -
nativeWriteInt
-
nativeWriteLong
-
nativeWriteFloat
-
nativeWriteDouble
-
nativeWriteString
-
nativeWriteStrongBinder
-
nativeCreateByteArray
-
nativeReadBlob
-
nativeReadByteArray
@Implementation(minSdk=27) protected static boolean nativeReadByteArray(long nativePtr, byte[] dest, int destLen) -
nativeReadInt
-
nativeReadLong
-
nativeReadFloat
-
nativeReadDouble
-
nativeReadString
-
nativeReadStrongBinder
-
nativeCreate
-
nativeFreeBuffer
-
nativeDestroy
-
nativeMarshall
-
nativeUnmarshall
@Implementation protected static void nativeUnmarshall(long nativePtr, byte[] data, int offset, int length) -
nativeAppendFrom
@Implementation protected static void nativeAppendFrom(long thisNativePtr, long otherNativePtr, int offset, int length) -
nativeWriteInterfaceToken
@Implementation protected static void nativeWriteInterfaceToken(long nativePtr, String interfaceName) -
nativeEnforceInterface
-
openFileDescriptor
@Implementation(maxSdk=28) protected static FileDescriptor openFileDescriptor(String file, int mode) throws IOException - Throws:
IOException
-
nativeWriteFileDescriptor
@Implementation(minSdk=23) protected static long nativeWriteFileDescriptor(long nativePtr, FileDescriptor val) -
nativeReadFileDescriptor
-
nativeWriteString8
-
nativeWriteString16
-
nativeReadString8
-
nativeReadString16
-
reset
-