-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathmix_test.go
129 lines (106 loc) · 2.62 KB
/
mix_test.go
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Sequence-based Go-native audio mixer for music apps
package mix
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/go-mix/mix/bind/spec"
"github.com/go-mix/mix/lib/mix"
)
func TestDebug(t *testing.T) {
// TODO: Test API Debug
}
func TestConfigure(t *testing.T) {
// TODO: Test API Configure
}
func TestConfigure_FailureFreqNotGreaterThanZero(t *testing.T) {
defer func() {
msg := recover()
assert.IsType(t, "", msg)
assert.Equal(t, "Must specify a mixing frequency greater than zero.", msg)
}()
Configure(spec.AudioSpec{
Freq: -100,
Format: spec.AudioS16,
Channels: 2,
})
}
func TestTeardown(t *testing.T) {
testAPISetup()
Teardown()
}
func TestSpec(t *testing.T) {
testAPISetup()
assert.Equal(t, &spec.AudioSpec{
Freq: 44100,
Format: spec.AudioF32,
Channels: 1,
}, Spec())
Teardown()
}
func TestSetFire(t *testing.T) {
testAPISetup()
fire := SetFire("lib/source/testdata/Signed16bitLittleEndian44100HzMono.wav", time.Duration(0), 0, 1.0, 0)
assert.NotNil(t, fire)
}
func TestFireCount(t *testing.T) {
testAPISetup()
assert.Equal(t, 0, FireCount())
SetFire("lib/source/testdata/Float32bitLittleEndian48000HzEstéreo.wav", time.Duration(0), 0, 1.0, 0)
assert.Equal(t, 1, FireCount())
SetFire("lib/source/testdata/Signed16bitLittleEndian44100HzMono.wav", time.Duration(0), 0, 1.0, 0)
assert.Equal(t, 2, FireCount())
// TODO: assert count drains during back to 0 as a result of playback
}
func TestClearAllFires(t *testing.T) {
testAPISetup()
SetFire("lib/source/testdata/Signed16bitLittleEndian44100HzMono.wav", time.Duration(0), 0, 1.0, 0)
ClearAllFires()
assert.Equal(t, 0, FireCount())
}
func TestSetSoundsPath(t *testing.T) {
// TODO: Test API SetSoundsPath
}
func TestSetGetMixCycleDuration(t *testing.T) {
testAPISetup()
SetMixCycleDuration(2 * time.Second)
assert.Equal(t, spec.Tz(88200), mix.GetCycleDurationTz())
}
func TestStart(t *testing.T) {
Start()
}
func TestStartAt(t *testing.T) {
StartAt(time.Now().Add(1 * time.Second))
}
func TestGetStartTime(t *testing.T) {
startExpect := time.Now().Add(1 * time.Second)
StartAt(startExpect)
startActual := GetStartTime()
assert.Equal(t, startExpect, startActual)
}
func TestGetNowAt(t *testing.T) {
// TODO
}
func TestOutputStart(t *testing.T) {
// TODO: Test
}
func TestOutputContinueTo(t *testing.T) {
// TODO: Test
}
func TestOutputClose(t *testing.T) {
// TODO: Test
}
func TestAudioCallback(t *testing.T) {
// TODO: Test API AudioCallback
}
//
// Test Components
//
func testAPISetup() {
ClearAllFires()
Configure(spec.AudioSpec{
Freq: 44100,
Format: spec.AudioF32,
Channels: 1,
})
}