MCPcopy Create free account
hub / github.com/EngoEngine/engo / TestAudioPlayerVolume

Function TestAudioPlayerVolume

common/audio_test.go:308–345  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

306}
307
308func TestAudioPlayerVolume(t *testing.T) {
309 engo.Files.SetRoot("testdata")
310 if err := engo.Files.Load("1.ogg"); err != nil {
311 t.Errorf("Could not load file. Error was: %v\n", err)
312 }
313 p, err := LoadedPlayer("1.ogg")
314 if err != nil {
315 t.Errorf("Could not get player. Error was: %v\n", err)
316 }
317 buf := bytes.NewBuffer([]byte{})
318 log.SetOutput(buf)
319 if p.GetVolume() != 1 {
320 t.Error("Initial volume was not 1")
321 }
322 p.SetVolume(0.5)
323 if p.GetVolume() != 0.5 {
324 t.Error("Volume was not 0.5 after being set to it")
325 }
326 p.SetVolume(-1)
327 if p.GetVolume() != 0.5 {
328 t.Error("Volume was not retained after trying to set to an invalid value")
329 }
330 if !strings.HasSuffix(buf.String(), "Volume can only be set between zero and one. Volume was not set.\n") {
331 t.Errorf("Logged value was not what was expected. Got: %v\n", buf.String())
332 }
333 buf.Reset()
334 p.SetVolume(1)
335 if p.GetVolume() != 1 {
336 t.Error("Volume was not 1 after being set to it")
337 }
338 p.SetVolume(10)
339 if p.GetVolume() != 1 {
340 t.Error("Volume was not retained after trying to set it to an invalid value")
341 }
342 if !strings.HasSuffix(buf.String(), "Volume can only be set between zero and one. Volume was not set.\n") {
343 t.Errorf("Logged value was not what was expected. Got: %v\n", buf.String())
344 }
345}
346
347func TestAudioMasterVolume(t *testing.T) {
348 buf := bytes.NewBuffer([]byte{})

Callers

nothing calls this directly

Calls 6

LoadedPlayerFunction · 0.85
GetVolumeMethod · 0.80
SetVolumeMethod · 0.80
SetRootMethod · 0.65
LoadMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected