77 lines
4.3 KiB
Kotlin
77 lines
4.3 KiB
Kotlin
import com.gorios.lanvoice.avatar.*
|
|
import com.gorios.lanvoice.dialogue.RoleEmotion
|
|
|
|
/** Callback-controlled ports test held exits and release fences, not physical playback. */
|
|
fun mediaBoundaryCheck() {
|
|
var cases=0
|
|
class Port: CompositeMediaPort {
|
|
lateinit var pack: ContinuousAvatarPack
|
|
lateinit var frame: (BodyFrameKey,Boolean)->Unit
|
|
lateinit var ended: ()->Unit
|
|
var advances=0;var loop=false
|
|
var release: (()->Unit)?=null
|
|
override fun prepare(pack: ContinuousAvatarPack,entryFrame: Int,mouth: Boolean,loop: Boolean,
|
|
frame: (BodyFrameKey,Boolean)->Unit,ended: ()->Unit,failed: ()->Unit) {
|
|
this.pack=pack;this.frame=frame;this.ended=ended;this.loop=loop
|
|
}
|
|
override fun advance() { advances++ }
|
|
override fun mouth(talk: Boolean,generation: Long,revision: Long) {}
|
|
override fun close(released: ()->Unit) { release=released }
|
|
fun emit(i: Int,ordinal: Long=0) { frame(BodyFrameKey(i,ordinal,pack.body.ptsUs[i]),true) }
|
|
}
|
|
val music=object: MusicMediaPort {
|
|
override fun prepare(media: ActionMedia,ready: ()->Unit,firstFrame: ()->Unit,ended: ()->Unit,failed: ()->Unit) { error("No action in this fixture") }
|
|
override fun start() { error("No action in this fixture") }
|
|
override fun close(released: ()->Unit) = released()
|
|
}
|
|
val original=mediaFixtureIndex()
|
|
val clip=original.edges.first { it.id=="neutral-happy" }.clip
|
|
for(loopBridge in listOf(false,true)) {
|
|
val edges=original.edges.map {
|
|
when {
|
|
loopBridge && it.id=="neutral-loop" -> it.copy(clip=clip,nativeLoop=false)
|
|
!loopBridge && it.id=="neutral-happy" -> it.copy(fromFrame=0)
|
|
else -> it
|
|
}
|
|
}
|
|
val ports=mutableListOf<Port>();val reports=mutableListOf<String>()
|
|
val driver=ConversationMediaDriver(original.copy(edges=edges),{ Port().also(ports::add) },music,{}, { phase,_-> reports.add(phase) })
|
|
driver.beginTurn(7);driver.start();val source=ports.single()
|
|
if(!loopBridge) driver.intent(mediaReply(RoleEmotion.HAPPY),true)
|
|
source.emit(0)
|
|
if(loopBridge) (1..96).forEach { source.emit(it) }
|
|
check(ports.size==3 && reports.last()=="body_neutral");cases++
|
|
val held=source.advances
|
|
val target=ports[1];val bridge=ports[2]
|
|
check(!bridge.loop && (!loopBridge || !source.loop));cases++
|
|
bridge.emit(0)
|
|
check(source.advances==held && reports.last()=="body_neutral");cases++
|
|
target.emit(0)
|
|
check(reports.last()=="bridge" && source.release!=null);cases++
|
|
bridge.emit(1);bridge.emit(2);bridge.ended()
|
|
check(reports.contains(if(loopBridge) "body_neutral" else "body_happy") && bridge.release!=null);cases++
|
|
driver.stop {}
|
|
val before=reports.size
|
|
source.emit(0);bridge.ended();target.emit(0)
|
|
check(reports.size==before);cases++
|
|
ports.forEach { it.release?.invoke() }
|
|
}
|
|
for(bad in listOf("index","ordinal")) {
|
|
val ports=mutableListOf<Port>();val reports=mutableListOf<String>()
|
|
val driver=ConversationMediaDriver(original,{ Port().also(ports::add) },music,{}, { phase,_->reports.add(phase) })
|
|
driver.beginTurn(7);driver.start();val source=ports.single();source.emit(0)
|
|
if(bad=="index") source.emit(2) else source.emit(1,1)
|
|
check(reports.last()=="media_failed" && source.release!=null);cases++
|
|
source.release?.invoke()
|
|
}
|
|
val noOwn=original.copy(visuals=original.visuals.map { if(it.id=="happy") it.copy(mouthBodySha=null) else it })
|
|
val ports=mutableListOf<Port>()
|
|
val driver=ConversationMediaDriver(noOwn,{ Port().also(ports::add) },music,{})
|
|
driver.beginTurn(7);driver.start();ports.single().emit(0)
|
|
driver.prepareExpression(mediaReply(RoleEmotion.HAPPY,seq=1))
|
|
driver.intent(mediaReply(RoleEmotion.HAPPY,intensity=2),true)
|
|
check(ports.size==1 && driver.selection?.let { it.packageId=="neutral" && it.selectedEmotion==RoleEmotion.HAPPY && it.selectedIntensity==2 }==true);cases++
|
|
driver.stop {};ports.forEach { it.release?.invoke() }
|
|
println("PASS: $cases production media driver boundary cases: frame0 exit held until target+bridge ready, actual non-native loop bridge, own-mouth whole fallback, exact frame/ordinal guards and retired callbacks; fixture only")
|
|
}
|