Class ShadowParcel

java.lang.Object
org.robolectric.shadows.ShadowParcel

@Implements(android.os.Parcel.class) public class ShadowParcel extends Object
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 Details

  • Constructor Details

    • ShadowParcel

      public ShadowParcel()
  • Method Details

    • readParcelableCreator

      @HiddenApi @Implementation public Parcelable.Creator<?> readParcelableCreator(ClassLoader loader)
    • 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

      @Implementation protected void writeByteArray(byte[] b, int offset, int len)
    • nativeDataSize

      @Implementation protected static int nativeDataSize(long nativePtr)
    • nativeDataAvail

      @Implementation protected static int nativeDataAvail(long nativePtr)
    • nativeDataPosition

      @Implementation protected static int nativeDataPosition(long nativePtr)
    • nativeDataCapacity

      @Implementation protected static int nativeDataCapacity(long nativePtr)
    • nativeSetDataSize

      @Implementation protected static void nativeSetDataSize(long nativePtr, int size)
    • nativeSetDataPosition

      @Implementation protected static void nativeSetDataPosition(long nativePtr, int pos)
    • nativeSetDataCapacity

      @Implementation protected static void nativeSetDataCapacity(long nativePtr, int size)
    • nativeWriteByteArray

      @Implementation protected static void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len)
    • writeBlob

      @Implementation(minSdk=23) protected void writeBlob(byte[] b, int offset, int len)
    • nativeWriteBlob

      @Implementation protected static void nativeWriteBlob(long nativePtr, byte[] b, int offset, int len)
    • nativeWriteInt

      @Implementation protected static int nativeWriteInt(long nativePtr, int val)
    • nativeWriteLong

      @Implementation protected static int nativeWriteLong(long nativePtr, long val)
    • nativeWriteFloat

      @Implementation protected static int nativeWriteFloat(long nativePtr, float val)
    • nativeWriteDouble

      @Implementation protected static int nativeWriteDouble(long nativePtr, double val)
    • nativeWriteString

      @Implementation(maxSdk=29) protected static void nativeWriteString(long nativePtr, String val)
    • nativeWriteStrongBinder

      @Implementation protected static void nativeWriteStrongBinder(long nativePtr, IBinder val)
    • nativeCreateByteArray

      @Implementation protected static byte[] nativeCreateByteArray(long nativePtr)
    • nativeReadBlob

      @Implementation protected static byte[] nativeReadBlob(long nativePtr)
    • nativeReadByteArray

      @Implementation(minSdk=27) protected static boolean nativeReadByteArray(long nativePtr, byte[] dest, int destLen)
    • nativeReadInt

      @Implementation protected static int nativeReadInt(long nativePtr)
    • nativeReadLong

      @Implementation protected static long nativeReadLong(long nativePtr)
    • nativeReadFloat

      @Implementation protected static float nativeReadFloat(long nativePtr)
    • nativeReadDouble

      @Implementation protected static double nativeReadDouble(long nativePtr)
    • nativeReadString

      @Implementation(maxSdk=29) protected static String nativeReadString(long nativePtr)
    • nativeReadStrongBinder

      @Implementation protected static IBinder nativeReadStrongBinder(long nativePtr)
    • nativeCreate

      @Implementation @HiddenApi public static long nativeCreate()
    • nativeFreeBuffer

      @Implementation protected static void nativeFreeBuffer(long nativePtr)
    • nativeDestroy

      @Implementation protected static void nativeDestroy(long nativePtr)
    • nativeMarshall

      @Implementation protected static byte[] nativeMarshall(long nativePtr)
    • 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

      @Implementation protected static void nativeEnforceInterface(long nativePtr, String interfaceName)
    • 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

      @Implementation(minSdk=23) protected static FileDescriptor nativeReadFileDescriptor(long nativePtr)
    • nativeWriteString8

      @Implementation(minSdk=30) protected static void nativeWriteString8(long nativePtr, String val)
    • nativeWriteString16

      @Implementation(minSdk=30) protected static void nativeWriteString16(long nativePtr, String val)
    • nativeReadString8

      @Implementation(minSdk=30) protected static String nativeReadString8(long nativePtr)
    • nativeReadString16

      @Implementation(minSdk=30) protected static String nativeReadString16(long nativePtr)
    • reset

      @Resetter public static void reset()