MCPcopy
hub / github.com/EngoEngine/engo / TestAudioSystemIntegrationNormalUse

Function TestAudioSystemIntegrationNormalUse

common/audio_test.go:64–122  ·  view source on GitHub ↗

TestAudioSystemIntegrationNormalUse tests using the AudioSystem as a part of engo. It doesn't fail on data because sometimes things "slip" and the data doesn't come out exactly right, but that's okay. If the audio system changes, check the logs and rerun accordingly.

(t *testing.T)

Source from the content-addressed store, hash-verified

62// come out exactly right, but that's okay. If the audio system changes, check
63// the logs and rerun accordingly.
64func TestAudioSystemIntegrationNormalUse(t *testing.T) {
65 s := testAudioScene{}
66 engo.Run(engo.RunOptions{
67 HeadlessMode: true,
68 NoRun: true,
69 AssetsRoot: "testdata",
70 }, &s)
71 p := otoPlayer.(*stepPlayer)
72
73 s.w.Update(1)
74 exp := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
75 actual := p.Bytes()
76 for i, b := range exp {
77 if b != actual[i] {
78 t.Logf("Audio byte values were incorrect. (First step)\nWanted: %v\nGot: %v\nIndex: %v", b, actual[i], i)
79 }
80 }
81 s.ogg.Player.Play()
82 s.w.Update(1)
83 p.Step()
84 exp = []byte{254, 255, 253, 255, 252, 255, 252, 255, 253, 255, 253, 255, 254, 255}
85 actual = p.Bytes()
86 for i, b := range exp {
87 if b != actual[i] {
88 t.Logf("Audio byte values were incorrect. (Second step)\nWanted: %v\nGot: %v\nIndex: %v", b, actual[i], i)
89 }
90 }
91 s.mp3.Player.Play()
92 s.w.Update(1)
93 p.Step()
94 exp = []byte{247, 255, 250, 255, 247, 255, 250, 255, 246, 255, 250, 255, 246, 255, 249}
95 actual = p.Bytes()
96 for i, b := range exp {
97 if b != actual[i] {
98 t.Logf("Audio byte values were incorrect. (Third step)\nWanted: %v\nGot: %v\nIndex: %v", b, actual[i], i)
99 }
100 }
101 s.wav.Player.Play()
102 s.w.Update(1)
103 p.Step()
104 exp = []byte{70, 25, 55, 25, 181, 25, 164, 25, 46, 33, 26, 33, 198, 33, 178, 33, 25, 33, 5, 33}
105 actual = p.Bytes()
106 for i, b := range exp {
107 if b != actual[i] {
108 t.Logf("Audio byte values were incorrect. (Fourth step)\nWanted: %v\nGot: %v\nIndex: %v", b, actual[i], i)
109 }
110 }
111 s.ogg.Player.Pause()
112 s.w.Update(1)
113 p.Step()
114 exp = []byte{90, 43, 90, 43, 92, 43, 92, 43, 40, 9, 40, 9, 37, 9, 37, 9, 177, 213, 177, 213, 175}
115 actual = p.Bytes()
116 for i, b := range exp {
117 if b != actual[i] {
118 t.Logf("Audio byte values were incorrect. (Fifth step)\nWanted: %v\nGot: %v\nIndex: %v", b, actual[i], i)
119 }
120 }
121 p.Step()

Callers

nothing calls this directly

Calls 6

RunFunction · 0.92
BytesMethod · 0.80
PlayMethod · 0.80
StepMethod · 0.80
UpdateMethod · 0.65
PauseMethod · 0.45

Tested by

no test coverage detected