From 0c1147513e4cc21f74fcfb6d673b7e6d5fa3310c Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sat, 10 Sep 2016 14:31:43 -0400 Subject: [PATCH] core/playlist: playlist_size() takes a playlist pointer Signed-off-by: Anna Schumaker --- core/playlist.c | 9 ++-- gui/sidebar.c | 16 ++---- include/core/playlist.h | 2 +- tests/core/audio.c | 6 +-- tests/core/playlist.c | 1 + tests/core/playlists/artist.c | 4 +- tests/core/playlists/library.c | 26 +++++---- tests/core/playlists/system.c | 97 +++++++++++++++++----------------- tests/core/playlists/user.c | 8 +-- tests/gui/model.c | 13 ++--- tests/gui/playlists/artist.c | 3 +- tests/gui/playlists/library.c | 8 +-- 12 files changed, 95 insertions(+), 98 deletions(-) diff --git a/core/playlist.c b/core/playlist.c index 1f2a115f..4402c478 100644 --- a/core/playlist.c +++ b/core/playlist.c @@ -28,7 +28,7 @@ void playlist_init(struct queue_ops *ops) if (!settings_has(SETTINGS_CUR_TYPE) || !settings_has(SETTINGS_CUR_ID)) { playlist_select(PL_SYSTEM, "Collection"); - if (playlist_size(PL_SYSTEM, "Queued Tracks") > 0) + if (playlist_size(playlist_get(PL_SYSTEM, "Queued Tracks")) > 0) playlist_select(PL_SYSTEM, "Queued Tracks"); } } @@ -125,10 +125,9 @@ bool playlist_has(struct playlist *playlist, struct track *track) return queue_has(&playlist->pl_queue, track); } -unsigned int playlist_size(enum playlist_type_t type, const gchar *name) +unsigned int playlist_size(struct playlist *playlist) { - struct queue *queue = playlist_get_queue(type, name); - return queue ? queue_size(queue) : 0; + return playlist ? queue_size(&playlist->pl_queue) : 0; } void playlist_set_random(enum playlist_type_t type, const gchar *name, @@ -156,7 +155,7 @@ struct track *playlist_next(void) gchar *name = playlist_get_name(type, id); struct track *track = playlist_types[type]->pl_next(name); - if (playlist_size(type, name) == 0) { + if (playlist_size(playlist_get(type, name)) == 0) { settings_set(SETTINGS_CUR_ID, settings_get(SETTINGS_PREV_ID)); settings_set(SETTINGS_CUR_TYPE, settings_get(SETTINGS_PREV_TYPE)); } diff --git a/gui/sidebar.c b/gui/sidebar.c index 96cdf52c..ea2e96ff 100644 --- a/gui/sidebar.c +++ b/gui/sidebar.c @@ -23,7 +23,7 @@ static gchar *__gui_sidebar_size_str(struct playlist *playlist) if (!playlist) return NULL; - size = playlist_size(playlist->pl_type, playlist->pl_name); + size = playlist_size(playlist); if (playlist_cur() == playlist) fmt = "%s\n%d track%s"; return g_markup_printf_escaped(fmt, playlist->pl_name, size, @@ -96,18 +96,10 @@ static gboolean __gui_sidebar_visible_func(GtkTreeModel *model, gpointer data) { enum playlist_type_t type = gui_sidebar_iter_type(iter); - gboolean ret = TRUE; - gchar *name; - if (type == PL_SYSTEM || type == PL_ARTIST) { - name = gui_sidebar_iter_name(iter); - if (name) { - ret = playlist_size(type, name) > 0; - g_free(name); - } - } - - return ret; + if (type == PL_SYSTEM || type == PL_ARTIST) + return playlist_size(gui_sidebar_iter_playlist(iter)) > 0; + return TRUE; } static gboolean __gui_sidebar_can_select(GtkTreeSelection *selection, diff --git a/include/core/playlist.h b/include/core/playlist.h index 7c5fb9ad..2611083f 100644 --- a/include/core/playlist.h +++ b/include/core/playlist.h @@ -49,7 +49,7 @@ void playlist_update(enum playlist_type_t, const gchar *); bool playlist_has(struct playlist *, struct track *); /* Called to find the number of tracks in the playlist. */ -unsigned int playlist_size(enum playlist_type_t, const gchar *); +unsigned int playlist_size(struct playlist *); /* Called to set the playlist's random flag. */ diff --git a/tests/core/audio.c b/tests/core/audio.c index 4b7ad8b1..24b6e86a 100644 --- a/tests/core/audio.c +++ b/tests/core/audio.c @@ -93,7 +93,7 @@ static void test_playback() g_assert_true(audio_load(tracks[i])); else g_assert_false(audio_load(tracks[i])); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "History"), ==, 1); + g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "History")), ==, 1); g_assert_cmpuint(load_count, ==, 1); g_assert_cmpuint(state_count, ==, 1); g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING); @@ -141,7 +141,7 @@ static void test_next() playlist_add(playlist_get(PL_SYSTEM, "Queued Tracks"), track_get(0)); for (i = 2; i >= 0; i--) { - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Queued Tracks"), ==, i + 1); + g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "Queued Tracks")), ==, i + 1); if (i > 0) g_assert_cmpuint(audio_next()->tr_track, ==, track_get(i)->tr_track); else /* Simulate an error. */ @@ -151,7 +151,7 @@ static void test_next() g_assert(audio_cur_track() == track_get(i)); } g_assert_cmpuint(state_count, ==, 3); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Queued Tracks"), ==, 0); + g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "Queued Tracks")), ==, 0); /* Tracks should now be picked from the collection. */ playlist_select(PL_SYSTEM, "Collection"); diff --git a/tests/core/playlist.c b/tests/core/playlist.c index fd513267..f6596d50 100644 --- a/tests/core/playlist.c +++ b/tests/core/playlist.c @@ -16,6 +16,7 @@ static void test_null() g_assert_false(playlist_add(NULL, track_get(0))); g_assert_false(playlist_has(NULL, NULL)); g_assert_false(playlist_has(NULL, track_get(0))); + g_assert_cmpuint(playlist_size(NULL), ==, 0); g_assert_false(playlist_remove(NULL, NULL)); g_assert_false(playlist_remove(NULL, track_get(0))); } diff --git a/tests/core/playlists/artist.c b/tests/core/playlists/artist.c index 0c937aad..5c4e2828 100644 --- a/tests/core/playlists/artist.c +++ b/tests/core/playlists/artist.c @@ -34,10 +34,10 @@ void test_artist() playlist = playlist_get(PL_ARTIST, "Koji Kondo"); g_assert_nonnull(playlist); - g_assert_cmpuint(playlist_size(PL_ARTIST, "Koji Kondo"), ==, 2); + 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(PL_ARTIST, "Koji Kondo"), ==, 2); + g_assert_cmpuint(playlist_size(playlist), ==, 2); g_assert(playlist_cur() != playlist_get(PL_ARTIST, "Koji Kondo")); g_assert_true(playlist_select(PL_ARTIST, "Koji Kondo")); diff --git a/tests/core/playlists/library.c b/tests/core/playlists/library.c index e8bd1a09..622943b5 100644 --- a/tests/core/playlists/library.c +++ b/tests/core/playlists/library.c @@ -32,11 +32,13 @@ void test_library() g_assert_nonnull(library); g_assert_nonnull(playlist); - g_assert_cmpuint(playlist_size(PL_LIBRARY, "tests/Music"), ==, 0); + g_assert_cmpuint(playlist_size(playlist), ==, 0); while (idle_run_task()) {}; - g_assert_cmpuint(playlist_size(PL_LIBRARY, "tests/Music"), ==, 48); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Unplayed"), ==, 48); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Collection"), ==, 48); + g_assert_cmpuint(playlist_size(playlist), ==, 48); + g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "Unplayed")), + ==, 48); + g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "Collection")), + ==, 48); g_assert(playlist_cur() != playlist_get(PL_LIBRARY, "tests/Music")); g_assert_true(playlist_select(PL_LIBRARY, "tests/Music")); @@ -55,17 +57,17 @@ void test_library() pl_library_init(NULL); while (idle_run_task()) {}; + playlist = library->li_playlist; g_assert_nonnull(library->li_playlist); g_assert_nonnull(playlist_get_queue(PL_LIBRARY, "tests/Music")); - g_assert_cmpuint(playlist_size(PL_LIBRARY, "tests/Music"), ==, 48); + g_assert_cmpuint(playlist_size(playlist), ==, 48); g_assert(playlist_get_queue(PL_LIBRARY, "tests/Music")); - playlist = library->li_playlist; g_assert_false(playlist_add(playlist, track_get(0))); g_assert_false(playlist_add(playlist, track_get(1))); g_assert_false(playlist_remove(playlist, track_get(0))); g_assert_false(playlist_remove(playlist, track_get(1))); - g_assert_cmpuint(playlist_size(PL_LIBRARY, "tests/Music"), ==, 48); + g_assert_cmpuint(playlist_size(playlist), ==, 48); g_assert_false(playlist_get_random(PL_LIBRARY, "tests/Music")); playlist_set_random(PL_LIBRARY, "tests/Music", true); @@ -86,19 +88,21 @@ void test_library() while (idle_run_task()) {} g_assert_cmpuint(db_actual_size(track_db_get()), ==, 48); g_assert_cmpuint(track_db_get()->db_size, ==, 35); - g_assert_cmpuint(playlist_size(PL_LIBRARY, "tests/Music"), ==, 35); + g_assert_cmpuint(playlist_size(playlist), ==, 35); g_rename("tests/Hyrule Symphony", "tests/Music/Hyrule Symphony/"); playlist_update(PL_LIBRARY, "tests/Music"); while (idle_run_task()) {} g_assert_cmpuint(db_actual_size(track_db_get()), ==, 61); g_assert_cmpuint(track_db_get()->db_size, ==, 48); - g_assert_cmpuint(playlist_size(PL_LIBRARY, "tests/Music"), ==, 48); + g_assert_cmpuint(playlist_size(playlist), ==, 48); g_assert_true(playlist_delete(playlist)); g_assert_null(library_get(0)); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Unplayed"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Collection"), ==, 0); + g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "Unplayed")), + ==, 0); + g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "Collection")), + ==, 0); g_assert_cmpuint(track_db_get()->db_size, ==, 0); } diff --git a/tests/core/playlists/system.c b/tests/core/playlists/system.c index 84be4390..8df5df8f 100644 --- a/tests/core/playlists/system.c +++ b/tests/core/playlists/system.c @@ -19,7 +19,7 @@ g_assert_false(playlist_has(playlist_get(PL_SYSTEM, name), track)) #define __test_playlist_state(name, ex_size, ex_track0, ex_track1) \ - g_assert_cmpuint(playlist_size(PL_SYSTEM, name), ==, ex_size); \ + g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, name)), ==, ex_size); \ __test_playlist_has(name, track_get(0), ex_track0); \ __test_playlist_has(name, track_get(1), ex_track1) @@ -119,14 +119,14 @@ static void test_init() pl_system_new_track(track_get(1)); g_assert_null(playlist_new(PL_SYSTEM, "New Playlist")); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Favorites"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Hidden"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Queued"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Collection"), ==, 2); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "History"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Unplayed"), ==, 2); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Most Played"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Least Played"), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_favorites()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_hidden()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_queued()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_collection()), ==, 2); + g_assert_cmpuint(playlist_size(__test_pl_history()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_unplayed()), ==, 2); + g_assert_cmpuint(playlist_size(__test_pl_most_played()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_least_played()), ==, 0); } static void test_invalid() @@ -144,7 +144,6 @@ static void test_invalid() __test_playlist_noselect("Invalid"); playlist_update(PL_SYSTEM, NULL); - g_assert_cmpuint(playlist_size(PL_SYSTEM, NULL), ==, 0); g_assert_false(playlist_get_random(PL_SYSTEM, NULL)); playlist_set_random(PL_SYSTEM, NULL, true); @@ -202,13 +201,13 @@ static void test_queued() __test_playlist_reinit("Queued Tracks", 2, true, true); g_assert(playlist_next() == track_get(0)); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Queued Tracks"), ==, 1); + g_assert_cmpuint(playlist_size(__test_pl_queued()), ==, 1); playlist_select(PL_SYSTEM, "Collection"); g_assert(playlist_next() == track_get(0)); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Queued Tracks"), ==, 1); + g_assert_cmpuint(playlist_size(__test_pl_queued()), ==, 1); playlist_select(PL_SYSTEM, "Queued Tracks"); g_assert(playlist_next() == track_get(1)); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Queued Tracks"), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_queued()), ==, 0); g_assert(playlist_next() == track_get(1)); __test_playlist_add("Queued Tracks"); @@ -265,9 +264,9 @@ static void test_history() g_assert(playlist_prev() == track_get(1)); g_assert(playlist_prev() == track_get(0)); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "History"), ==, 4); + g_assert_cmpuint(playlist_size(__test_pl_history()), ==, 4); g_assert_true(playlist_add(__test_pl_history(), track_get(1))); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "History"), ==, 5); + g_assert_cmpuint(playlist_size(__test_pl_history()), ==, 5); g_assert(playlist_prev() == track_get(1)); __test_playlist_update("History", 5, true, true); @@ -391,9 +390,9 @@ static void test_add() g_assert_true( playlist_add(__test_pl_history(), track_get(0))); g_assert_true( playlist_add(__test_pl_history(), track_get(0))); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Favorites"), ==, 1); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Queued Tracks"), ==, 1); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "History"), ==, 2); + g_assert_cmpuint(playlist_size(__test_pl_favorites()), ==, 1); + g_assert_cmpuint(playlist_size(__test_pl_queued()), ==, 1); + g_assert_cmpuint(playlist_size(__test_pl_history()), ==, 2); g_assert_true(playlist_has(__test_pl_favorites(), track_get(0))); g_assert_true(playlist_has(__test_pl_queued(), track_get(0))); @@ -409,11 +408,11 @@ static void test_add() g_assert_false(playlist_add(__test_pl_least_played(), track_get(1))); g_assert_false(playlist_add(__test_pl_unplayed(), track_get(2))); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Hidden"), ==, 3); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Collection"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Most Played"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Least Played"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Unplayed"), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_hidden()), ==, 3); + g_assert_cmpuint(playlist_size(__test_pl_collection()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_most_played()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_least_played()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_unplayed()), ==, 0); g_assert_true( playlist_has(__test_pl_hidden(), track_get(0))); g_assert_true( playlist_has(__test_pl_hidden(), track_get(1))); @@ -434,9 +433,9 @@ static void test_remove() g_assert_false(playlist_remove(__test_pl_queued(), track_get(0))); g_assert_false(playlist_remove(__test_pl_history(), track_get(0))); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Favorites"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Queued Tracks"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "History"), ==, 2); + g_assert_cmpuint(playlist_size(__test_pl_favorites()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_queued()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_history()), ==, 2); g_assert_false(playlist_has(__test_pl_favorites(), track_get(0))); g_assert_false(playlist_has(__test_pl_queued(), track_get(0))); @@ -449,11 +448,11 @@ static void test_remove() g_assert_false(playlist_remove(__test_pl_least_played(), track_get(1))); g_assert_false(playlist_remove(__test_pl_unplayed(), track_get(2))); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Hidden"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Collection"), ==, 3); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Most Played"), ==, 1); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Least Played"), ==, 1); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Unplayed"), ==, 1); + g_assert_cmpuint(playlist_size(__test_pl_hidden()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_collection()), ==, 3); + g_assert_cmpuint(playlist_size(__test_pl_most_played()), ==, 1); + g_assert_cmpuint(playlist_size(__test_pl_least_played()), ==, 1); + g_assert_cmpuint(playlist_size(__test_pl_unplayed()), ==, 1); g_assert_false(playlist_has(__test_pl_hidden(), track_get(0))); g_assert_false(playlist_has(__test_pl_hidden(), track_get(1))); @@ -466,8 +465,8 @@ static void test_remove() g_assert_true( playlist_has(__test_pl_unplayed(), track_get(2))); g_assert_true(playlist_remove(__test_pl_collection(), track_get(0))); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Hidden"), ==, 1); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Collection"), ==, 2); + g_assert_cmpuint(playlist_size(__test_pl_hidden()), ==, 1); + g_assert_cmpuint(playlist_size(__test_pl_collection()), ==, 2); g_assert_true (playlist_has(__test_pl_hidden(), track_get(0))); g_assert_false(playlist_has(__test_pl_collection(), track_get(0))); } @@ -489,14 +488,14 @@ static void test_delete() g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, "Most Played"))); g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, "Least Played"))); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Favorites"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Hidden"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Queued Tracks"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Collection"), ==, 3); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "History"), ==, 3); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Unplayed"), ==, 1); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Most Played"), ==, 1); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Least Played"), ==, 1); + g_assert_cmpuint(playlist_size(__test_pl_favorites()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_hidden()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_queued()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_collection()), ==, 3); + g_assert_cmpuint(playlist_size(__test_pl_history()), ==, 3); + g_assert_cmpuint(playlist_size(__test_pl_unplayed()), ==, 1); + g_assert_cmpuint(playlist_size(__test_pl_most_played()), ==, 1); + g_assert_cmpuint(playlist_size(__test_pl_least_played()), ==, 1); } static void test_delete_tracks() @@ -509,14 +508,14 @@ static void test_delete_tracks() pl_system_delete_track(track_get(1)); pl_system_delete_track(track_get(2)); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Favorites"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Hidden"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Queued Tracks"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Collection"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "History"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Unplayed"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Most Played"), ==, 0); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Least Played"), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_favorites()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_hidden()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_queued()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_collection()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_history()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_unplayed()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_most_played()), ==, 0); + g_assert_cmpuint(playlist_size(__test_pl_least_played()), ==, 0); } diff --git a/tests/core/playlists/user.c b/tests/core/playlists/user.c index 5fd491db..4a7dbba3 100644 --- a/tests/core/playlists/user.c +++ b/tests/core/playlists/user.c @@ -38,12 +38,12 @@ void test_user() g_assert(playlist_cur() == playlist_get(PL_USER, "Test Playlist")); g_assert_false(playlist_select(PL_USER, "No Playlist")); - g_assert_cmpuint(playlist_size(PL_USER, "Test Playlist"), ==, 0); + g_assert_cmpuint(playlist_size(playlist), ==, 0); g_assert_false(playlist_has(playlist, track_get(0))); g_assert_true( playlist_add(playlist, track_get(0))); g_assert_false(playlist_add(playlist, track_get(0))); g_assert_true( playlist_has(playlist, track_get(0))); - g_assert_cmpuint(playlist_size(PL_USER, "Test Playlist"), ==, 1); + g_assert_cmpuint(playlist_size(playlist), ==, 1); playlist_update(PL_USER, "Test Playlist"); pl_user_deinit(); @@ -55,12 +55,12 @@ void test_user() playlist = playlist_get(PL_USER, "Test Playlist"); g_assert_nonnull(playlist); - g_assert_cmpuint(playlist_size(PL_USER, "Test Playlist"), ==, 1); + g_assert_cmpuint(playlist_size(playlist), ==, 1); g_assert_true( playlist_has( playlist, track_get(0))); g_assert_true( playlist_remove(playlist, track_get(0))); g_assert_false(playlist_remove(playlist, track_get(0))); g_assert_false(playlist_has( playlist, track_get(0))); - g_assert_cmpuint(playlist_size(PL_USER, "Test Playlist"), ==, 0); + g_assert_cmpuint(playlist_size(playlist), ==, 0); g_assert_true(playlist_delete(playlist)); g_assert_cmpuint(db->db_size, ==, 0); diff --git a/tests/gui/model.c b/tests/gui/model.c index 911bc64a..fa3f7765 100644 --- a/tests/gui/model.c +++ b/tests/gui/model.c @@ -163,6 +163,7 @@ static void test_empty() static void test_model() { GtkTreeModel *model = GTK_TREE_MODEL(gui_model_get()); + struct playlist *collection, *favorites; struct track *track; GtkTreePath *path; GtkTreeIter iter; @@ -177,20 +178,20 @@ static void test_model() g_signal_connect(model, "row-changed", (GCallback)on_row_changed, NULL); /* Okay, now scan a directory ... */ - playlist_get_queue(PL_SYSTEM, "Collection")->q_private = - playlist_get(PL_SYSTEM, "Collection"); - playlist_get_queue(PL_SYSTEM, "Favorites")->q_private = - playlist_get(PL_SYSTEM, "Favorites"); + collection = playlist_get(PL_SYSTEM, "Collection"); + favorites = playlist_get(PL_SYSTEM, "Favorites"); + collection->pl_queue.q_private = collection; + favorites->pl_queue.q_private = favorites; playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony"); while (idle_run_task() == true) {} - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Collection"), ==, 13); + g_assert_cmpuint(playlist_size(collection), ==, 13); g_assert_cmpuint(count_insert, ==, 13); queue_resort(playlist_get_queue(PL_SYSTEM, "Collection")); g_assert_cmpuint(count_update, ==, 13); playlist_add(playlist_get(PL_SYSTEM, "Favorites"), track_get(0)); playlist_add(playlist_get(PL_SYSTEM, "Favorites"), track_get(1)); playlist_add(playlist_get(PL_SYSTEM, "Favorites"), track_get(2)); - g_assert_cmpuint(playlist_size(PL_SYSTEM, "Favorites"), ==, 3); + g_assert_cmpuint(playlist_size(favorites), ==, 3); g_assert_cmpstr(gtk_label_get_text(gui_model_runtime()), ==, "42 minutes, 45 seconds"); diff --git a/tests/gui/playlists/artist.c b/tests/gui/playlists/artist.c index 7e1a76d6..ab5061fa 100644 --- a/tests/gui/playlists/artist.c +++ b/tests/gui/playlists/artist.c @@ -31,7 +31,8 @@ static void test_artist() while (idle_run_task()) {} g_assert_cmpuint(artist_db_get()->db_size, ==, 1); g_assert_nonnull(playlist_get(PL_ARTIST, "Koji Kondo")); - g_assert_cmpuint(playlist_size(PL_ARTIST, "Koji Kondo"), ==, 13); + g_assert_cmpuint(playlist_size(playlist_get(PL_ARTIST, "Koji Kondo")), + ==, 13); g_assert_true(gtk_tree_model_iter_has_child(model, &iter)); g_assert_cmpuint(gtk_tree_model_iter_n_children(model, &iter), ==, 1); diff --git a/tests/gui/playlists/library.c b/tests/gui/playlists/library.c index 50048e1b..ba2a63b1 100644 --- a/tests/gui/playlists/library.c +++ b/tests/gui/playlists/library.c @@ -39,11 +39,11 @@ static void test_library() g_assert_true(gtk_tree_model_iter_has_child(model, &iter)); g_assert_cmpuint(gtk_tree_model_iter_n_children(model, &iter), ==, 2); - g_assert_cmpuint(playlist_size(ocarina->pl_type, ocarina->pl_name), ==, 0); - g_assert_cmpuint(playlist_size(hyrule->pl_type, hyrule->pl_name), ==, 0); + g_assert_cmpuint(playlist_size(ocarina), ==, 0); + g_assert_cmpuint(playlist_size(hyrule), ==, 0); while (idle_run_task()) {} - g_assert_cmpuint(playlist_size(hyrule->pl_type, hyrule->pl_name), ==, 13); - g_assert_cmpuint(playlist_size(ocarina->pl_type, ocarina->pl_name), ==, 35); + g_assert_cmpuint(playlist_size(hyrule), ==, 13); + g_assert_cmpuint(playlist_size(ocarina), ==, 35); g_assert_true(gtk_tree_model_iter_has_child(model, &iter)); g_assert_cmpuint(gtk_tree_model_iter_n_children(model, &iter), ==, 2);