-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTestMixedBundle.sc
88 lines (62 loc) · 2.04 KB
/
TestMixedBundle.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
TestMixedBundle : UnitTest {
var t;
setUp {
this.bootServer;
t = MixedBundle.new;
}
// helper method, not a test
makeDefs { |numDefs|
numDefs.do({ |i|
var d;
d = SynthDef( "TestOSCBundle" ++ i,{
SinOsc.ar([400,403] + i)
});
t.addPrepare( ["/d_recv", d.asBytes] )
});
}
test_prepare { arg numDefs = 100;
var functionFired = false, sent;
this.makeDefs(numDefs);
t.addFunction({ functionFired = true });
t.send(Server.default);
this.wait( { functionFired }, "wait for functionFired to be set by bundle.doFunction");
}
// crashes the language !
// test_largePrepare {
// this.test_prepare(1000)
// }
test_send {
var functionFired = false, sent,onSendFired = false;
this.makeDefs(1);
// defs should be loaded
t.add( Synth.basicNew("TestOSCBundle" ++ 0).newMsg );
t.addFunction({ functionFired = true });
t.onSend({ onSendFired = true });
t.send(Server.default);
this.wait( { functionFired }, "wait for functionFired to be set by bundle.doFunction");
this.assert( onSendFired,"onSendFired should be set to true");
// now we want something that can catch all failures back from the server
2.0.wait;
if(Server.default.aliveThreadIsRunning.not,{
"Server is not running alive thread, unit test cannot check numSynths".die;
});
// one synth should be playing
this.assertEquals( Server.default.numSynths, 1, "should be one synth playing");
}
test_mediumSend {
var functionFired = false, sent;
this.makeDefs(100);
// defs should be loaded
t.add( Synth.basicNew("TestOSCBundle" ++ 0).newMsg );
t.addFunction({ functionFired = true });
t.send(Server.default);
this.wait( { functionFired }, "wait for functionFired to be set by bundle.doFunction");
// now we want something that can catch all failures back from the server
2.0.wait;
if(Server.default.aliveThreadIsRunning.not,{
"Server is not running alive thread, unit test cannot check numSynths".die;
});
// one synth should be playing
this.assertEquals( Server.default.numSynths, 1, "should be one synth playing");
}
}