import com.gorios.lanvoice.avatar.* import com.gorios.lanvoice.dialogue.RoleEmotion fun actionCheck() { val sha="a".repeat(64) val statuses=mutableListOf() var now=100L; var confirm: ((Boolean)->Unit)?=null var playing=false;var finish: ((ActionEnd)->Unit)?=null var release: (()->Unit)?=null val picked=mutableListOf() val player=object: ActionPlayer { override fun play(asset: ActionAsset, finished: (ActionEnd)->Unit, failed: ()->Unit) { check(!playing);playing=true;picked.add(asset.id);finish=finished } override fun stop(released: ()->Unit) { release={ playing=false;released() } } } val pack=ReviewedActionPack(sha,listOf(ActionAsset("asset_01",1000),ActionAsset("asset_02",1200))) val controller=ActionController(pack,player,{now},{confirm=it},{statuses.add(it)},choose={0}) fun plan(turn: Long)=ActionPlan("id".repeat(12)+turn,turn,sha,10000) check(controller.offer(plan(1))) check(controller.active && !playing && statuses.isEmpty()) // Intent is not recording-stop evidence. confirm!!(true);check(playing && statuses.single().status=="started") now+=1000;playing=false;finish!!(ActionEnd(true,true,true)) check(!controller.active && statuses.last().status=="completed") check(controller.offer(plan(2)));confirm!!(true) check(picked==listOf("asset_01","asset_02")) val stale=finish!! controller.cancel();check(controller.active) // No recording resume before music release fence. check(statuses.last().status=="started") release!!();check(!controller.active && statuses.last().status=="cancelled") stale(ActionEnd(true,true,true));check(statuses.last().status=="cancelled") check(controller.offer(plan(6))) val pendingStop=confirm!! controller.cancel();release!!() check(controller.active && statuses.last().status=="cancelled") pendingStop(true);check(!controller.active && statuses.last().turn==6L && statuses.last().status=="cancelled") check(controller.offer(plan(7))) pendingStop(false) // Duplicate retired callback must not poison current capture gate. check(controller.active && !playing) confirm!!(true);check(playing) controller.cancel();release!!();check(!controller.active) check(controller.offer(plan(4)));confirm!!(true) now+=10001;controller.tick();release!!();check(statuses.last().status=="failed") check(controller.offer(plan(3)));confirm!!(false);release!!() check(statuses.last().status=="failed" && controller.active && picked.size==4) val repeated=mutableListOf() var done: ((ActionEnd)->Unit)?=null val randomPlayer=object: ActionPlayer { override fun play(asset: ActionAsset,finished: (ActionEnd)->Unit,failed: ()->Unit) { repeated.add(asset.id);done=finished } override fun stop(released: ()->Unit) { released() } } val random=ActionController(pack,randomPlayer,{now},{it(true)},{},choose={it-1}) check(random.offer(plan(20)));now+=1200;done!!(ActionEnd(true,true,true)) check(random.offer(plan(21)));now+=1200;done!!(ActionEnd(true,true,true)) check(repeated==listOf("asset_02","asset_02")) // Repeat is possible, not forced exact alternation. val missing=ActionController(null,player,{now},{confirm=it},{statuses.add(it)}) check(missing.capability==null && !missing.offer(plan(5))) val pts=List(97) { it*1_000_000L/24 } val neutral=TalkPackage("neutral",RoleEmotion.NEUTRAL,sha,sha,pts,pts,true) val happy=TalkPackage("happy",RoleEmotion.HAPPY,"b".repeat(64),"b".repeat(64),pts,pts,true) val slight=RoleVisualSelector.select(RoleEmotion.HAPPY,2,listOf(neutral,happy),"neutral") check(slight.selectedIntensity==2 && slight.visualIntensity==1 && slight.reason=="slight_only") val mismatch=RoleVisualSelector.select(RoleEmotion.HAPPY,1,listOf(neutral,happy.copy(mouthBodySha=sha)),"neutral") check(mismatch.selectedEmotion==RoleEmotion.HAPPY && mismatch.visualEmotion==RoleEmotion.NEUTRAL && mismatch.degraded) val shifted=RoleVisualSelector.select(RoleEmotion.HAPPY,1,listOf(neutral,happy.copy(mouthPtsUs=pts.map { it+1 })),"neutral") check(shifted.packageId=="neutral") println("PASS: action fixture record-stop/music-release/return-A/TTL/cancel/stale/no-repeat and expression own-body/PTS/slight-only selection; no device/naturalness claim") }