/* * Copyright 2016 (c) Anna Schumaker. */ #include #include #include #include #include #include #include void test_artist() { struct playlist *playlist; struct artist *artist; g_assert_null(playlist_new(PL_ARTIST, "Koji Kondo")); g_assert_null(playlist_get_queue(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(PL_ARTIST, "Koji Kondo")); g_assert_false(playlist_select(PL_ARTIST, "Hajime Wakai")); pl_artist_deinit(); pl_artist_init(NULL); g_assert_cmpuint(playlist_get_id(PL_ARTIST, "Koji Kondo"), ==, 0); g_assert_cmpstr_free(playlist_get_name(PL_ARTIST, 0), ==, "Koji Kondo"); while (idle_run_task()) {}; playlist = playlist_get(PL_ARTIST, "Koji Kondo"); g_assert_nonnull(playlist); g_assert_cmpuint(playlist_size(PL_ARTIST, "Koji Kondo"), ==, 2); g_assert_nonnull(artist->ar_playlist); g_assert_false(playlist_remove(playlist, track_get(0))); g_assert_cmpuint(playlist_size(PL_ARTIST, "Koji Kondo"), ==, 2); g_assert(playlist_cur() != playlist_get(PL_ARTIST, "Koji Kondo")); g_assert_true(playlist_select(PL_ARTIST, "Koji Kondo")); g_assert_cmpuint(settings_get("core.playlist.cur.type"), ==, PL_ARTIST); g_assert_cmpuint(settings_get("core.playlist.cur.id"), ==, 0); g_assert(playlist_cur() == playlist_get(PL_ARTIST, "Koji Kondo")); 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_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; }