use of android.telephony.ims.ImsCallProfile in project android_frameworks_opt_telephony by LineageOS.
the class ImsCallProfileTest method testExtrasCleanup.
/**
* Ensures that the {@link ImsCallProfile} will discard invalid extras when it is parceled.
*/
@Test
@SmallTest
public void testExtrasCleanup() {
ImsCallProfile srcParcel = new ImsCallProfile();
// Put in a private parcelable type.
srcParcel.mCallExtras.putParcelable("JUNK", new JunkParcelable());
// Put in an api defined parcelable type.
srcParcel.mCallExtras.putParcelable("NOTJUNK", new DisconnectCause(DisconnectCause.BUSY));
// Put in some valid things.
srcParcel.mCallExtras.putInt("INT", 1);
srcParcel.mCallExtras.putString("STRING", "hello");
// Parcel it.
Parcel parcel = Parcel.obtain();
srcParcel.writeToParcel(parcel, 0);
byte[] parcelBytes = parcel.marshall();
parcel.recycle();
// Unparcel it.
parcel = Parcel.obtain();
parcel.unmarshall(parcelBytes, 0, parcelBytes.length);
parcel.setDataPosition(0);
ImsCallProfile unparceledProfile = ImsCallProfile.CREATOR.createFromParcel(parcel);
parcel.recycle();
assertNotNull(unparceledProfile.mCallExtras);
assertEquals(3, unparceledProfile.mCallExtras.size());
assertEquals(1, unparceledProfile.getCallExtraInt("INT"));
assertEquals("hello", unparceledProfile.getCallExtra("STRING"));
assertFalse(unparceledProfile.mCallExtras.containsKey("JUNK"));
DisconnectCause parceledCause = unparceledProfile.mCallExtras.getParcelable("NOTJUNK");
assertEquals(DisconnectCause.BUSY, parceledCause.getCode());
}
Aggregations