86 lines
2.3 KiB
C
86 lines
2.3 KiB
C
/*
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/idle.h>
|
|
#include <core/playlist.h>
|
|
#include <core/settings.h>
|
|
#include <core/tags/artist.h>
|
|
#include <core/tags/library.h>
|
|
#include <core/tags/tags.h>
|
|
#include <tests/test.h>
|
|
|
|
|
|
void test_artist()
|
|
{
|
|
struct playlist *playlist;
|
|
struct artist *artist;
|
|
|
|
g_assert_null(playlist_new(PL_ARTIST, "Koji Kondo"));
|
|
g_assert_null(playlist_lookup(PL_ARTIST, "Koji Kondo"));
|
|
|
|
artist = artist_find("Koji Kondo");
|
|
g_assert_null(artist->ar_playlist);
|
|
g_assert_false(playlist_add(NULL, track_get(0)));
|
|
g_assert_false(playlist_select(NULL));
|
|
|
|
pl_artist_deinit();
|
|
pl_artist_init();
|
|
|
|
while (idle_run_task()) {};
|
|
|
|
playlist = playlist_lookup(PL_ARTIST, "Koji Kondo");
|
|
g_assert_nonnull(playlist);
|
|
|
|
g_assert_cmpuint(playlist->pl_id, ==, artist_index(artist));
|
|
g_assert_cmpuint(playlist_size(playlist), ==, 2);
|
|
g_assert_nonnull(artist->ar_playlist);
|
|
g_assert_false(playlist_remove(playlist, track_get(0)));
|
|
g_assert_cmpuint(playlist_size(playlist), ==, 2);
|
|
|
|
g_assert(playlist_current() != playlist);
|
|
g_assert_true(playlist_select(playlist));
|
|
g_assert_cmpuint(settings_get("core.playlist.cur.type"), ==, PL_ARTIST);
|
|
g_assert_cmpuint(settings_get("core.playlist.cur.id"), ==, 0);
|
|
g_assert(playlist_current() == playlist);
|
|
g_assert_false(playlist_select(playlist));
|
|
|
|
playlist_selected(track_get(0));
|
|
playlist_played(track_get(0));
|
|
|
|
g_assert_cmpuint(playlist_next()->tr_track, ==, 1);
|
|
g_assert_cmpuint(playlist_size(playlist), ==, 2);
|
|
g_assert_true(playlist_has(playlist, track_get(0)));
|
|
g_assert_true(playlist_has(playlist, track_get(1)));
|
|
|
|
g_assert_false(playlist_delete(playlist));
|
|
pl_artist_deinit();
|
|
g_assert_null(artist->ar_playlist);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
struct library *library;
|
|
int ret;
|
|
|
|
idle_init(IDLE_SYNC);
|
|
settings_init();
|
|
tags_init();
|
|
playlist_init(NULL);
|
|
while (idle_run_task()) {};
|
|
|
|
/* Add tracks to the collection. */
|
|
library = library_find("tests/Music");
|
|
track_add(library, "tests/Music/Hyrule Symphony/01 - Title Theme.ogg");
|
|
track_add(library, "tests/Music/Hyrule Symphony/02 - Kokiri Forest.ogg");
|
|
|
|
g_test_init(&argc, &argv, NULL);
|
|
g_test_add_func("/Core/Playlists/Artist", test_artist);
|
|
ret = g_test_run();
|
|
|
|
playlist_deinit();
|
|
tags_deinit();
|
|
settings_deinit();
|
|
idle_deinit();
|
|
return ret;
|
|
}
|