mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
8a7195e962
also handling MediaStream.stop deprecation
98 lines
No EOL
2.4 KiB
JavaScript
98 lines
No EOL
2.4 KiB
JavaScript
define(["helper/Basic", "Tone/source/ExternalInput", "Test", "Tone/source/Source"],
|
|
function (BasicTests, ExternalInput, Test, Source) {
|
|
|
|
describe("ExternalInput", function(){
|
|
|
|
//run the common tests
|
|
BasicTests(ExternalInput);
|
|
|
|
context("Source Tests", function(){
|
|
|
|
it ("can connect the output", function(){
|
|
var extIn = new ExternalInput();
|
|
extIn.connect(Test);
|
|
extIn.dispose();
|
|
});
|
|
|
|
it ("extends Tone.Source", function(){
|
|
var extIn = new ExternalInput();
|
|
expect(extIn).to.be.an.instanceof(Source);
|
|
extIn.dispose();
|
|
});
|
|
|
|
it ("can be constructed with the input number", function(){
|
|
var extIn = new ExternalInput(3);
|
|
extIn.dispose();
|
|
});
|
|
|
|
it ("can be constructed with an options object", function(){
|
|
var extIn = new ExternalInput({
|
|
"inputNum" : 2,
|
|
"volume" : -10
|
|
});
|
|
expect(extIn.volume.value).to.be.closeTo(-10, 0.1);
|
|
extIn.dispose();
|
|
});
|
|
|
|
it("starts and stops", function(done){
|
|
var extIn = new ExternalInput();
|
|
expect(extIn.state).to.equal("stopped");
|
|
extIn.start().stop("+0.2");
|
|
setTimeout(function(){
|
|
expect(extIn.state).to.equal("started");
|
|
}, 100);
|
|
setTimeout(function(){
|
|
expect(extIn.state).to.equal("stopped");
|
|
extIn.dispose();
|
|
done();
|
|
}, 300);
|
|
});
|
|
});
|
|
|
|
context("Static methods/members", function(){
|
|
|
|
it ("can get a list of sources", function(done){
|
|
ExternalInput.getSources(function(sources){
|
|
expect(sources).to.be.an.array;
|
|
done();
|
|
});
|
|
});
|
|
|
|
it ("has a list of sources", function(){
|
|
expect(ExternalInput.sources).to.be.an.array;
|
|
});
|
|
|
|
it ("indicates if the browser has UserMedia support", function(){
|
|
expect(ExternalInput.supported).to.be.a.boolean;
|
|
});
|
|
});
|
|
|
|
//if it is a manual test (i.e. there is a person to 'allow' the microphone)
|
|
if (window.MANUAL_TEST && ExternalInput.supported){
|
|
|
|
context("Opening and closing", function(){
|
|
|
|
//long timeout to give testers time to allow the microphone
|
|
this.timeout(100000);
|
|
|
|
it ("can open an input", function(done){
|
|
var extIn = new ExternalInput();
|
|
extIn.open(function(){
|
|
extIn.dispose();
|
|
done();
|
|
});
|
|
});
|
|
|
|
it ("can can close an input", function(done){
|
|
var extIn = new ExternalInput();
|
|
extIn.open(function(){
|
|
extIn.close();
|
|
extIn.dispose();
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
});
|
|
}); |