Adaptive Music v0.8.3 multiplayer and floating music controls
Validate and generate manual release / package (push) Waiting to run
Validate and generate manual release / package (push) Waiting to run
This commit is contained in:
1 parent
acc8cbafc6
commit
fbc265b526
33 files changed
+1673
-131
No files matched your search
@@ -1,12 +1,13 @@
|
||||
import {test} from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {createSetupClass,createListenerClass} from '../../src/foundry/setup.mjs';
|
||||
import {ListenerAudio} from '../../src/foundry/listener-audio.mjs';
|
||||
import {CampaignAudio,ListenerAudio} from '../../src/foundry/listener-audio.mjs';
|
||||
class Element{
|
||||
constructor(tag,dom){this.tag=tag;this.ownerDocument=dom;this.children=[];this.listeners={};this.dataset={};this.value='';}
|
||||
append(...children){this.children.push(...children);if(this.tag==='select'&&!this.value&&children[0]?.tag==='option')this.value=children[0].value;}
|
||||
replaceChildren(...children){this.children=[];this.append(...children);}
|
||||
setAttribute(){}
|
||||
classList={toggle(){}};
|
||||
addEventListener(name,fn){this.listeners[name]=fn;}
|
||||
}
|
||||
const descendants=node=>[node,...node.children.flatMap(descendants)];
|
||||
@@ -38,7 +39,47 @@ test('browser PCM sink resumes from gesture, decodes stereo frames and closes it
|
||||
|
||||
test('normal listener has one activation action and no token or invitation entry',async()=>{
|
||||
const dom={createElement:tag=>new Element(tag,dom)};globalThis.document=dom;let clicks=0;
|
||||
try{const Listener=createListenerClass({game:{settings:{get:()=>false}},audio:{stop(){}},resumeListener:()=>{clicks++;},Base:class{}});const root=await new Listener()._renderHTML();assert.ok(!descendants(root).some(e=>e.tag==='input'));await descendants(root).find(e=>e.textContent==='Enable Audio').listeners.click();assert.equal(clicks,1);}finally{delete globalThis.document;}
|
||||
const Listener=createListenerClass({game:{settings:{get:()=>false}},audio:{stop(){}},resumeListener:()=>{clicks++;},Base:class{}});
|
||||
const app=new Listener();
|
||||
try{
|
||||
const root=await app._renderHTML();
|
||||
assert.deepEqual(descendants(root).filter(e=>e.tag==='input').map(e=>e.type),['range']);
|
||||
await descendants(root).find(e=>e.textContent==='Enable Audio').listeners.click();
|
||||
assert.equal(clicks,1);
|
||||
}finally{app._onClose();delete globalThis.document;}
|
||||
});
|
||||
|
||||
test('WebRTC listening gain and mute are local and retained through stream replacement',async()=>{
|
||||
function player(initial){
|
||||
let mix;
|
||||
const element={paused:true,
|
||||
async play(){this.paused=false;},
|
||||
pause(){this.paused=true;},
|
||||
remove(){}
|
||||
};
|
||||
const context={currentTime:0,destination:{},state:'suspended',
|
||||
async resume(){this.state='running';},async close(){},
|
||||
createGain:()=>({gain:{setTargetAtTime(value){mix=value;}},connect(){},disconnect(){}}),
|
||||
createMediaStreamSource:()=>({connect(){},disconnect(){}})
|
||||
};
|
||||
const output=new CampaignAudio({preferences:initial,createElement:()=>element,createContext:()=>context});
|
||||
return {output,element,get mix(){return mix;}};
|
||||
}
|
||||
const first=player({volume:35,muted:true}),second=player();
|
||||
for(const listener of [first,second]){
|
||||
await listener.output.enable();
|
||||
await listener.output.attach({});
|
||||
}
|
||||
assert.equal(first.mix,0);
|
||||
assert.equal(second.mix,1);
|
||||
first.output.setPreferences({muted:false});
|
||||
assert.equal(first.mix,0.35);
|
||||
assert.equal(second.mix,1);
|
||||
await first.output.attach({});
|
||||
assert.equal(first.mix,0.35);
|
||||
assert.equal(first.element.muted,true);
|
||||
assert.equal(first.output.status.playing,true);
|
||||
first.output.close();second.output.close();
|
||||
});
|
||||
|
||||
test('failed wizard authentication can retry without reentering token',async()=>{
|
||||
|
||||
Reference in new issue
Block a user