forked from Blendman974/faceclaw
Merge branch 'main' into ring-health-fixes
This commit is contained in:
commit
4f8c082b52
368 files changed
+26238
-3401
No files matched your search
+4
-2
@@ -10,9 +10,11 @@ import kotlin.test.*
|
||||
*/
|
||||
class PreviewAnimationListenerTest {
|
||||
// FrameDisplayListTest's menu golden (a 2x2 highlight sliding in to rest at (3, 2)),
|
||||
// restarted at 0 of its 240 ms so the slide is still in flight at the first pull.
|
||||
// restarted at 1 of its 240 ms so the slide is still in flight at the first pull. Not 0:
|
||||
// at exactly 0 the highlight is wholly above this 8x8 screen, so a pull in the same
|
||||
// millisecond as the submit (a warm JIT) would match the settled frame.
|
||||
private val menu = "077f0000000300020002000200022a00000096000000010002000200ffffffff0200080000ff24017e30020000000001812c8001812c1611010017328001812c16103001812c3023414031ff24017c30020000000001812c8001812c1611010017328001812c16103001812c30234140310200020001000103100400000000000000001f"
|
||||
.chunked(2).map { it.toInt(16).toByte() }.toByteArray().also { it.fill(0, 18, 22) }
|
||||
.chunked(2).map { it.toInt(16).toByte() }.toByteArray().also { it.fill(0, 18, 22); it[18] = 1 }
|
||||
|
||||
private fun settledPreview(): ByteArray {
|
||||
val reader = ArrayByteReader(menu)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.faceclaw.app
|
||||
|
||||
import java.io.File
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class WavRecorderRepairTest {
|
||||
@Test
|
||||
fun repairsTheHeaderOfARecordingThatWasNeverFinished() {
|
||||
val file = File.createTempFile("unfinished", ".wav")
|
||||
try {
|
||||
// What a process death mid-recording leaves: the empty header from the start, the PCM
|
||||
// written since, and a torn half-sample at the end.
|
||||
file.writeBytes(BinaryEncoding.wavHeader(0, 16000, 1) + ByteArray(3201) { 1 })
|
||||
assertEquals(3200L, FaceclawWavRecorder.repairHeader(file.path, 16000, 1))
|
||||
val bytes = file.readBytes()
|
||||
assertEquals(44 + 3200, bytes.size)
|
||||
assertEquals(BinaryEncoding.wavHeader(3200, 16000, 1).toList(), bytes.copyOf(44).toList())
|
||||
assertEquals(-1L, FaceclawWavRecorder.repairHeader(file.path + ".missing", 16000, 1))
|
||||
} finally {
|
||||
file.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user