Parcelize: Fix test code
On Android, we would need to call `setDataPosition(0)` after unmarshalling a parcel. The reason why the test code is currently working is purely because the Robolectric test framework is more permissive.
This commit is contained in:
committed by
Yan Zhulanow
parent
d93e5d3dc0
commit
9b7a95b05c
Vendored
+1
@@ -51,6 +51,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<PrimitiveTypes>(parcel)
|
||||
val second2 = readFromParcel<PrimitiveTypes>(parcel)
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
+1
@@ -69,6 +69,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
+1
@@ -35,6 +35,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<ServiceContainer>(parcel)
|
||||
}
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<BoxedTypes>(parcel)
|
||||
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<User>(parcel)
|
||||
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
Vendored
+1
@@ -29,6 +29,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val userParcelable2 = readFromParcel<UserParcelable>(parcel)
|
||||
|
||||
|
||||
Vendored
+1
@@ -34,6 +34,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<Ints>(parcel)
|
||||
|
||||
|
||||
plugins/android-extensions/android-extensions-compiler/testData/parcel/box/customSerializerBoxing.kt
Vendored
+1
@@ -39,6 +39,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
plugins/android-extensions/android-extensions-compiler/testData/parcel/box/customSerializerSimple.kt
Vendored
+1
@@ -40,6 +40,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
+1
@@ -41,6 +41,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val user2 = readFromParcel<User>(parcel)
|
||||
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val black2 = readFromParcel<Color>(parcel)
|
||||
val obj2 = readFromParcel<Obj>(parcel)
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<Test>(parcel)
|
||||
assert(test == test2)
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<ExceptionContainer>(parcel)
|
||||
}
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val film2 = readFromParcel<Film>(parcel)
|
||||
assert(film == film2)
|
||||
|
||||
+1
@@ -26,6 +26,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val second = J.readParcel(parcel)
|
||||
assert(first == second)
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<J>(parcel)
|
||||
|
||||
|
||||
+1
@@ -21,6 +21,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<M>(parcel)
|
||||
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
+1
@@ -39,6 +39,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
+1
@@ -22,6 +22,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
readFromParcel<User>(parcel)
|
||||
readFromParcel<User2>(parcel)
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val foo2 = readFromParcel<Foo>(parcel)
|
||||
assert(foo2.values.size() == 1)
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
readFromParcel<MyObject>(parcel)
|
||||
}
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
+1
@@ -35,6 +35,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
+1
@@ -33,6 +33,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
|
||||
|
||||
Vendored
+1
@@ -27,6 +27,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<Test>(parcel)
|
||||
assert(test == test2)
|
||||
|
||||
Vendored
+1
@@ -28,6 +28,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
val second2 = readFromParcel<Test>(parcel)
|
||||
|
||||
Vendored
+1
@@ -19,6 +19,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<Test>(parcel)
|
||||
val second2 = readFromParcel<Test>(parcel)
|
||||
|
||||
+1
@@ -24,6 +24,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<Test>(parcel)
|
||||
assert(test == test2)
|
||||
|
||||
Vendored
+1
@@ -23,6 +23,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<User>(parcel)
|
||||
|
||||
|
||||
Vendored
+1
@@ -29,6 +29,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val first2 = readFromParcel<PrimitiveTypes>(parcel)
|
||||
val second2 = readFromParcel<PrimitiveTypes>(parcel)
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val user2 = readFromParcel<User>(parcel)
|
||||
assert(user == user2)
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val user2 = readFromParcel<User>(parcel)
|
||||
|
||||
|
||||
Vendored
+1
@@ -17,6 +17,7 @@ fun box() = parcelTest { parcel ->
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
parcel.setDataPosition(0)
|
||||
|
||||
val test2 = readFromParcel<User>(parcel)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user