Parcelize: Add a test for parcelize of IBinder and IInterface
This commit is contained in:
committed by
Alexander Udalov
parent
6cf3e0e38e
commit
43bccff135
+5
@@ -44,6 +44,11 @@ public class ParcelBoxTestGenerated extends AbstractParcelBoxTest {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/arrays.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("binder.kt")
|
||||
public void testBinder() throws Exception {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/binder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boxedTypes.kt")
|
||||
public void testBoxedTypes() throws Exception {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/boxedTypes.kt");
|
||||
|
||||
+5
@@ -44,6 +44,11 @@ public class ParcelIrBoxTestGenerated extends AbstractParcelIrBoxTest {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/arrays.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("binder.kt")
|
||||
public void testBinder() throws Exception {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/binder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boxedTypes.kt")
|
||||
public void testBoxedTypes() throws Exception {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/boxedTypes.kt");
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
// See KT-38103
|
||||
// There is no such thing as a readStrongInterface method to deserialize arbitrary IIinterface implementations
|
||||
// WITH_RUNTIME
|
||||
|
||||
@file:JvmName("TestKt")
|
||||
package test
|
||||
|
||||
import kotlinx.android.parcel.*
|
||||
import android.os.Binder
|
||||
import android.os.IBinder
|
||||
import android.os.IInterface
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import java.io.Serializable
|
||||
|
||||
class MockBinder : Binder(), Serializable
|
||||
|
||||
@Parcelize
|
||||
class MockIInterface : IInterface, Parcelable {
|
||||
override fun asBinder(): IBinder = MockBinder()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
class ServiceContainer(
|
||||
val binder: MockBinder,
|
||||
val iinterface: MockIInterface,
|
||||
val binderArray: Array<IBinder>,
|
||||
val binderList: List<IBinder>
|
||||
) : Parcelable
|
||||
|
||||
fun box() = parcelTest { parcel ->
|
||||
val test = ServiceContainer(MockBinder(), MockIInterface(), arrayOf(MockBinder()), listOf(MockBinder()))
|
||||
test.writeToParcel(parcel, 0)
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
|
||||
val test2 = readFromParcel<ServiceContainer>(parcel)
|
||||
}
|
||||
Reference in New Issue
Block a user