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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static void
nativeAppendFrom
(long thisNativePtr, long otherNativePtr, int offset, int length) static long
protected static byte[]
nativeCreateByteArray
(long nativePtr) protected static int
nativeDataAvail
(long nativePtr) protected static int
nativeDataCapacity
(long nativePtr) protected static int
nativeDataPosition
(long nativePtr) protected static int
nativeDataSize
(long nativePtr) protected static void
nativeDestroy
(long nativePtr) protected static void
nativeEnforceInterface
(long nativePtr, String interfaceName) protected static void
nativeFreeBuffer
(long nativePtr) protected static byte[]
nativeMarshall
(long nativePtr) protected static byte[]
nativeReadBlob
(long nativePtr) protected static boolean
nativeReadByteArray
(long nativePtr, byte[] dest, int destLen) protected static double
nativeReadDouble
(long nativePtr) protected static FileDescriptor
nativeReadFileDescriptor
(long nativePtr) protected static float
nativeReadFloat
(long nativePtr) protected static int
nativeReadInt
(long nativePtr) protected static long
nativeReadLong
(long nativePtr) protected static String
nativeReadString
(long nativePtr) protected static String
nativeReadString16
(long nativePtr) protected static String
nativeReadString8
(long nativePtr) protected static IBinder
nativeReadStrongBinder
(long nativePtr) protected static void
nativeSetDataCapacity
(long nativePtr, int size) protected static void
nativeSetDataPosition
(long nativePtr, int pos) protected static void
nativeSetDataSize
(long nativePtr, int size) protected static void
nativeUnmarshall
(long nativePtr, byte[] data, int offset, int length) protected static void
nativeWriteBlob
(long nativePtr, byte[] b, int offset, int len) protected static void
nativeWriteByteArray
(long nativePtr, byte[] b, int offset, int len) protected static int
nativeWriteDouble
(long nativePtr, double val) protected static long
nativeWriteFileDescriptor
(long nativePtr, FileDescriptor val) protected static int
nativeWriteFloat
(long nativePtr, float val) protected static int
nativeWriteInt
(long nativePtr, int val) protected static void
nativeWriteInterfaceToken
(long nativePtr, String interfaceName) protected static int
nativeWriteLong
(long nativePtr, long val) protected static void
nativeWriteString
(long nativePtr, String val) protected static void
nativeWriteString16
(long nativePtr, String val) protected static void
nativeWriteString8
(long nativePtr, String val) protected static void
nativeWriteStrongBinder
(long nativePtr, IBinder val) protected static FileDescriptor
openFileDescriptor
(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 void
reset()
protected void
writeBlob
(byte[] b, int offset, int len) protected void
writeByteArray
(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
-