testing that the Transport is the same after Tone.Offline

resolves #314
This commit is contained in:
tambien 2018-07-30 13:07:23 -04:00
parent ea3e628e6d
commit 0b50aca977
3 changed files with 49 additions and 1 deletions

View file

@ -178,6 +178,15 @@ define(["helper/Test", "Tone/core/Context", "Tone/core/Tone", "helper/Offline",
return Tone.context.dispose(); return Tone.context.dispose();
}); });
it("has a consistent context after offline rendering", function(){
var initialContext = Tone.context;
var initialTransport = Tone.Transport;
return Offline(function(){}).then(function(){
expect(Tone.context).to.equal(initialContext);
expect(Tone.Transport).to.equal(initialTransport);
});
});
it("invokes the resume promise", function(){ it("invokes the resume promise", function(){
return Tone.context.resume(); return Tone.context.resume();
}); });
@ -211,7 +220,15 @@ define(["helper/Test", "Tone/core/Context", "Tone/core/Tone", "helper/Offline",
if (window.__karma__){ if (window.__karma__){
baseUrl = "/base/test/html/"; baseUrl = "/base/test/html/";
} }
return LoadHTML(baseUrl + "same_context.html"); return LoadHTML(baseUrl + "multiple_instances.html");
});
it("Transport and Master instance is the same after running Tone.Offline", function(){
var baseUrl = "../test/html/";
if (window.__karma__){
baseUrl = "/base/test/html/";
}
return LoadHTML(baseUrl + "same_transport.html");
}); });
}); });

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>SAME TRANSPORT</title>
<script src="../../build/Tone.js"></script>
<script src="/base/build/Tone.js"></script>
<script>
function assert(statement, error){
if (!statement){
throw new Error(error);
}
}
</script>
</head>
<body>
<script>
if (Tone){
var Transport = Tone.Transport
Tone.Offline(function(){}, 0.1).then(function(){})
assert(Tone.Transport === Transport, "Different Transports!")
} else {
throw new Error("NO TONE!");
}
</script>
</body>
</html>