2020-07-15 21:38:27 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2021-04-30 16:08:16 +08:00
|
|
|
|
|
|
|
"github.com/issadarkthing/gomu/player"
|
2020-07-15 21:38:27 +08:00
|
|
|
)
|
|
|
|
|
2021-02-15 20:32:50 +08:00
|
|
|
const (
|
|
|
|
testConfigPath = "./test/config-test"
|
|
|
|
)
|
|
|
|
|
2020-07-15 21:38:27 +08:00
|
|
|
func Test_NewPlayingBar(t *testing.T) {
|
|
|
|
|
2020-08-22 14:41:03 +08:00
|
|
|
gomu = newGomu()
|
2021-02-15 20:32:50 +08:00
|
|
|
err := execConfig(expandFilePath(testConfigPath))
|
2021-02-13 22:49:26 +08:00
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
gomu.colors = newColor()
|
|
|
|
|
2020-07-23 15:15:39 +08:00
|
|
|
p := newPlayingBar()
|
2020-07-15 21:38:27 +08:00
|
|
|
|
2021-02-25 16:46:52 +08:00
|
|
|
if p.update == nil {
|
2020-07-15 21:38:27 +08:00
|
|
|
t.Errorf("chan int == nil")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-02-23 15:46:51 +08:00
|
|
|
func Test_NewProgress(t *testing.T) {
|
2020-07-15 21:38:27 +08:00
|
|
|
|
2020-07-23 15:15:39 +08:00
|
|
|
p := newPlayingBar()
|
2020-07-15 21:38:27 +08:00
|
|
|
full := 100
|
2021-04-30 16:08:16 +08:00
|
|
|
audio := new(player.AudioFile)
|
|
|
|
audio.SetPath("./test/rap/audio_test.mp3")
|
2021-02-23 15:46:51 +08:00
|
|
|
|
2021-04-30 16:08:16 +08:00
|
|
|
p.newProgress(audio, full)
|
2020-07-15 21:38:27 +08:00
|
|
|
|
2021-04-19 22:50:02 +08:00
|
|
|
if p.full != int32(full) {
|
2020-07-16 22:16:02 +08:00
|
|
|
t.Errorf("Expected %d; got %d", full, p.full)
|
2020-07-15 21:38:27 +08:00
|
|
|
}
|
|
|
|
|
2021-02-25 16:46:52 +08:00
|
|
|
if p.progress != 0 {
|
|
|
|
t.Errorf("Expected %d; got %d", 0, p.progress)
|
2020-07-15 21:38:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-02-23 15:46:51 +08:00
|
|
|
|
2020-07-15 21:38:27 +08:00
|
|
|
func Test_Stop(t *testing.T) {
|
|
|
|
|
2020-07-23 15:15:39 +08:00
|
|
|
p := newPlayingBar()
|
2020-07-15 21:38:27 +08:00
|
|
|
|
2020-07-23 15:15:39 +08:00
|
|
|
p.stop()
|
2020-07-15 21:38:27 +08:00
|
|
|
|
|
|
|
if p.skip == false {
|
|
|
|
t.Errorf("Expected %t; got %t", true, p.skip)
|
|
|
|
}
|
|
|
|
}
|