下面列出了android.os.Parcelable#describeContents ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void allParcelables() throws IllegalAccessException, InstantiationException, NoSuchFieldException {
ModelPopulator populator = new ModelPopulator("CREATOR", "$jacocoData");
for (Class<? extends Parcelable> modelClass : getModelClasses()) {
Parcelable instance = populator.populateWithRandomValues(modelClass);
testSingleParcelable(instance);
testParcelableArray(instance);
/* Trick to increase code coverage */
instance.describeContents();
((Parcelable.Creator<?>) modelClass.getField("CREATOR").get(null)).newArray(13);
}
}
private static void writeParcelable(LinkedList<Object> parcelData, Parcelable parcelable, Parcel parcel1) {
if (parcelable == null) {
parcelData.add(null);
} else {
parcelable.describeContents();
parcelData.add(parcelable.getClass());
parcelable.writeToParcel(parcel1, 0);
}
}