INNER CODE UNIT · Kotlin
LocalSubtitleTest
anilbeesetti/nextplayer · app/src/androidTest/java/dev/anilbeesetti/nextplayer/LocalSubtitleTest.kt:36
class LocalSubtitleTest {
private val instrumentation = InstrumentationRegistry.getInstrumentation()
@Test
fun localTracksAndDecoderChoicesSurviveReloadsAndPlaylistNavigation() {
val context = instrumentation.targetContext
val directory = File(context.cacheDir, "local-subtitle-test-${System.nanoTime()}").apply { mkdirs() }
val pcm = ByteArray(16_000 * 2 * 60)
val header = ByteBuffer.allocate(44).order(ByteOrder.LITTLE_ENDIAN)
.put("RIFF".toByteArray()).putInt(36 + pcm.size).put("WAVEfmt ".toByteArray())
.putInt(16).putShort(1).putShort(1).putInt(16_000).putInt(32_000)
.putShort(2).putShort(16).put("data".toByteArray()).putInt(pcm.size)
val items = listOf("before", "current", "after").map { name ->
val audio = File(directory, "$name.wav")
audio.outputStream().use {
it.write(header.array())
it.write(pcm)