Exemple #1
0
func assertShuffleFirstTrack(t *testing.T, events *sconsify.Events, output *TestPrinter) {
	events.TrackPlaying(<-events.PlayUpdates())
	message := <-output.message
	if message != "Playing: artist3 - name3 [duration3]" {
		t.Errorf("Should be showing track3 instead is showing [%v]", message)
	}
}
Exemple #2
0
func Initialise(events *sconsify.Events) {
	playlists := sconsify.InitPlaylists()

	tracks := make([]*sconsify.Track, 2)
	tracks[0] = sconsify.InitTrack("bobmarley0", bobMarley, "Waiting in vain", "2m3s")
	tracks[1] = sconsify.InitTrack("bobmarley1", bobMarley, "Testing", "5m3s")
	playlists.AddPlaylist(sconsify.InitPlaylist("bobmarleyplaylist0", "Bob Marley", tracks))

	folderPlaylists := make([]*sconsify.Playlist, 2)

	tracks = make([]*sconsify.Track, 2)
	tracks[0] = sconsify.InitTrack("bobmarley2", bobMarley, "Waiting in vain", "2m3s")
	tracks[1] = sconsify.InitTrack("bobmarley3", bobMarley, "Testing", "5m3s")
	folderPlaylists[0] = sconsify.InitPlaylist("bobmarleyplaylist1", " Bob Marley and The Wailers", tracks)

	tracks = make([]*sconsify.Track, 3)
	tracks[0] = sconsify.InitTrack("ramones0", theRamones, "Ramones", "2m3s")
	tracks[1] = sconsify.InitTrack("ramones1", theRamones, "Ramones...", "3m21s")
	tracks[2] = sconsify.InitTrack("ramones2", theRamones, "The Ramones", "1m9s")
	folderPlaylists[1] = sconsify.InitPlaylist("ramonesplaylist0", " The Ramones", tracks)

	playlists.AddPlaylist(sconsify.InitFolder("folder", "My folder", folderPlaylists))

	tracks = make([]*sconsify.Track, 3)
	tracks[0] = sconsify.InitTrack("ramones3", theRamones, "I wanna be sedated", "2m3s")
	tracks[1] = sconsify.InitTrack("ramones4", theRamones, "Pet semetary", "3m21s")
	tracks[2] = sconsify.InitTrack("ramones5", theRamones, "Judy is a punk", "1m9s")
	playlists.AddPlaylist(sconsify.InitPlaylist("ramonesplaylist1", "Ramones", tracks))

	events.NewPlaylist(playlists)
	waitForMockEvents(events)
}
Exemple #3
0
func assertShutdown(t *testing.T, ui sconsify.UserInterface, events *sconsify.Events, finished chan bool) {
	go ui.Shutdown()

	// playing spotify shutdown here
	<-events.ShutdownSpotifyUpdates()
	events.ShutdownEngine()

	if !<-finished {
		t.Errorf("Not properly finished")
	}
}
Exemple #4
0
func assertNoNextTrack(events *sconsify.Events, finished chan bool) {
	events.NextPlay()

	// playing spotify shutdown here
	<-events.ShutdownSpotifyUpdates()
	events.ShutdownEngine()

	<-finished
}
Exemple #5
0
func playNext(t *testing.T, events *sconsify.Events, output *TestPrinter, tracks []string) {
	for _, track := range tracks {
		events.NextPlay()
		events.TrackPlaying(<-events.PlayUpdates())
		message := <-output.message
		expectedMessage := fmt.Sprintf("Playing: artist%v - name%v [duration%v]", track, track, track)
		if message != expectedMessage {
			t.Errorf("Should be showing track%v instead is showing [%v]", track, message)
		}
	}
}
Exemple #6
0
func waitForMockEvents(events *sconsify.Events) {
	for {
		select {
		case <-events.PlayUpdates():
		case <-events.PauseUpdates():
		case <-events.ReplayUpdates():
		case <-events.ShutdownSpotifyUpdates():
			events.ShutdownEngine()
		case <-events.SearchUpdates():
			events.NewPlaylist(getSearchedPlaylist())
		}
	}
}
Exemple #7
0
func Initialise(webApiAuth bool, username string, pass []byte, events *sconsify.Events, playlistFilter *string, preferredBitrate *string) {
	if err := initialiseSpotify(webApiAuth, username, pass, events, playlistFilter, preferredBitrate); err != nil {
		fmt.Printf("Error: %v\n", err)
		events.ShutdownEngine()
	}
}
Exemple #8
0
func Initialise(initConf *SpotifyInitConf, username string, pass []byte, events *sconsify.Events) {
	if err := initialiseSpotify(initConf, username, pass, events); err != nil {
		fmt.Printf("Error: %v\n", err)
		events.ShutdownEngine()
	}
}
Exemple #9
0
func sendNewPlaylist(events *sconsify.Events) {
	playlists := sconsify.InitPlaylists()
	playlists.AddPlaylist(createDummyPlaylist())
	events.NewPlaylist(playlists)
}
Exemple #10
0
func Initialise(username string, pass []byte, events *sconsify.Events, playlistFilter *string) {
	if err := initialiseSpotify(username, pass, events, playlistFilter); err != nil {
		fmt.Printf("Error: %v\n", err)
		events.ShutdownEngine()
	}
}