2020-11-04 23:56:12 -08:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
type spotifyArgs struct {
|
2020-11-12 00:43:32 -08:00
|
|
|
title string
|
|
|
|
runError error
|
2020-11-04 23:56:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
func bootStrapSpotifyWindowsTest(args *spotifyArgs) *spotify {
|
|
|
|
env := new(MockedEnvironment)
|
2020-11-12 00:43:32 -08:00
|
|
|
env.On("getWindowTitle", "spotify.exe").Return(args.title, args.runError)
|
2020-11-04 23:56:12 -08:00
|
|
|
props := &properties{}
|
|
|
|
s := &spotify{
|
|
|
|
env: env,
|
|
|
|
props: props,
|
|
|
|
}
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSpotifyWindowsEnabledAndSpotifyNotRunning(t *testing.T) {
|
|
|
|
args := &spotifyArgs{
|
2020-11-12 00:43:32 -08:00
|
|
|
runError: errors.New(""),
|
2020-11-04 23:56:12 -08:00
|
|
|
}
|
|
|
|
s := bootStrapSpotifyWindowsTest(args)
|
|
|
|
assert.Equal(t, false, s.enabled())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSpotifyWindowsEnabledAndSpotifyPlaying(t *testing.T) {
|
|
|
|
args := &spotifyArgs{
|
2020-11-12 00:43:32 -08:00
|
|
|
title: "Candlemass - Spellbreaker",
|
2020-11-04 23:56:12 -08:00
|
|
|
}
|
|
|
|
s := bootStrapSpotifyWindowsTest(args)
|
|
|
|
assert.Equal(t, true, s.enabled())
|
|
|
|
assert.Equal(t, "\ue602 Candlemass - Spellbreaker", s.string())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSpotifyWindowsEnabledAndSpotifyStopped(t *testing.T) {
|
|
|
|
args := &spotifyArgs{
|
2020-11-12 00:43:32 -08:00
|
|
|
title: "Spotify premium",
|
2020-11-04 23:56:12 -08:00
|
|
|
}
|
|
|
|
s := bootStrapSpotifyWindowsTest(args)
|
2020-11-14 00:49:40 -08:00
|
|
|
assert.Equal(t, false, s.enabled())
|
2020-11-04 23:56:12 -08:00
|
|
|
}
|