diff --git a/core/audio.c b/core/audio.c index 400d10bf..db3538c6 100644 --- a/core/audio.c +++ b/core/audio.c @@ -60,7 +60,7 @@ static struct track *__audio_load_basic(struct track *track, GstState state) static struct track *__audio_load(struct track *track, GstState state) { if (__audio_load_basic(track, state)) - playlist_add(playlist_get(PL_SYSTEM, "History"), track); + playlist_add(playlist_lookup(PL_SYSTEM, "History"), track); return track; } diff --git a/core/playlist.c b/core/playlist.c index 47a1c388..a2c5be58 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(playlist_get(PL_SYSTEM, "Queued Tracks")) > 0) + if (playlist_size(playlist_lookup(PL_SYSTEM, "Queued Tracks")) > 0) playlist_select(PL_SYSTEM, "Queued Tracks"); } } @@ -85,6 +85,13 @@ bool playlist_delete(struct playlist *playlist) return ret; } +struct playlist *playlist_lookup(enum playlist_type_t type, const gchar *name) +{ + if (type >= PL_MAX_TYPE) + return NULL; + return playlist_types[type]->pl_lookup(name); +} + bool playlist_add(struct playlist *playlist, struct track *track) { bool ret; @@ -95,7 +102,7 @@ bool playlist_add(struct playlist *playlist, struct track *track) ret = playlist->pl_ops->pl_add(playlist, track); if (ret) playlist_types[playlist->pl_type]->pl_save(); - if (playlist == playlist_get(PL_SYSTEM, "Queued Tracks")) + if (playlist == playlist_lookup(PL_SYSTEM, "Queued Tracks")) playlist_select(PL_SYSTEM, "Queued Tracks"); return ret; } @@ -160,7 +167,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(playlist_get(type, name)) == 0) { + if (playlist_size(playlist_lookup(type, name)) == 0) { settings_set(SETTINGS_CUR_ID, settings_get(SETTINGS_PREV_ID)); settings_set(SETTINGS_CUR_TYPE, settings_get(SETTINGS_PREV_TYPE)); } @@ -174,17 +181,12 @@ struct track *playlist_prev(void) return playlist_types[PL_SYSTEM]->pl_next("History"); } -struct playlist *playlist_get(enum playlist_type_t type, const gchar *name) -{ - return playlist_types[type]->pl_get_playlist(name); -} - struct playlist *playlist_cur(void) { enum playlist_type_t type = settings_get(SETTINGS_CUR_TYPE); unsigned int id = settings_get(SETTINGS_CUR_ID); gchar *name = playlist_get_name(type, id); - struct playlist *ret = playlist_get(type, name); + struct playlist *ret = playlist_lookup(type, name); g_free(name); return ret; @@ -192,7 +194,7 @@ struct playlist *playlist_cur(void) struct queue *playlist_get_queue(enum playlist_type_t type, const gchar *name) { - struct playlist *playlist = playlist_get(type, name); + struct playlist *playlist = playlist_lookup(type, name); return playlist ? &playlist->pl_queue : NULL; } diff --git a/core/playlists/artist.c b/core/playlists/artist.c index c7bcef2b..aa879593 100644 --- a/core/playlists/artist.c +++ b/core/playlists/artist.c @@ -100,7 +100,7 @@ static void pl_artist_save(void) file_close(&artist_file); } -static struct playlist *pl_artist_get_playlist(const gchar *name) +static struct playlist *pl_artist_lookup(const gchar *name) { return __artist_pl_lookup(name); } @@ -137,13 +137,13 @@ static struct track *pl_artist_next(const gchar *name) struct playlist_type pl_artist = { - .pl_save = pl_artist_save, - .pl_get_playlist = pl_artist_get_playlist, - .pl_get_id = pl_artist_get_id, - .pl_get_name = pl_artist_get_name, - .pl_can_select = pl_artist_can_select, - .pl_update = pl_artist_update, - .pl_next = pl_artist_next, + .pl_save = pl_artist_save, + .pl_lookup = pl_artist_lookup, + .pl_get_id = pl_artist_get_id, + .pl_get_name = pl_artist_get_name, + .pl_can_select = pl_artist_can_select, + .pl_update = pl_artist_update, + .pl_next = pl_artist_next, }; diff --git a/core/playlists/library.c b/core/playlists/library.c index 6a125a1d..882aca18 100644 --- a/core/playlists/library.c +++ b/core/playlists/library.c @@ -217,7 +217,7 @@ static void pl_library_save(void) file_close(&lib_file); } -static struct playlist *pl_library_get_playlist(const gchar *name) +static struct playlist *pl_library_lookup(const gchar *name) { return __lib_pl_lookup(name); } @@ -271,14 +271,14 @@ static struct track *pl_library_next(const gchar *name) struct playlist_type pl_library = { - .pl_save = pl_library_save, - .pl_get_playlist = pl_library_get_playlist, - .pl_get_id = pl_library_get_id, - .pl_get_name = pl_library_get_name, - .pl_can_select = pl_library_can_select, - .pl_new = pl_library_new, - .pl_update = pl_library_update, - .pl_next = pl_library_next, + .pl_save = pl_library_save, + .pl_lookup = pl_library_lookup, + .pl_get_id = pl_library_get_id, + .pl_get_name = pl_library_get_name, + .pl_can_select = pl_library_can_select, + .pl_new = pl_library_new, + .pl_update = pl_library_update, + .pl_next = pl_library_next, }; diff --git a/core/playlists/system.c b/core/playlists/system.c index 442e6b69..f19382d4 100644 --- a/core/playlists/system.c +++ b/core/playlists/system.c @@ -5,7 +5,7 @@ #include #include -static struct playlist *pl_system_get_playlist(const gchar *); +static struct playlist *pl_system_lookup(const gchar *); static void pl_system_update(const gchar *); static inline struct queue *__sys_pl_queue(enum sys_playlist_t); static void __sys_pl_save(); @@ -100,11 +100,11 @@ static struct sys_playlist sys_favorites = { */ static bool sys_pl_hidden_add(struct playlist *playlist, struct track *track) { - bool ret = playlist_generic_add_track(pl_system_get_playlist("Hidden"), track); - playlist_generic_remove_track(pl_system_get_playlist("Collection"), track); - playlist_generic_remove_track(pl_system_get_playlist("Unplayed"), track); - playlist_generic_remove_track(pl_system_get_playlist("Most Played"), track); - playlist_generic_remove_track(pl_system_get_playlist("Least Played"), track); + bool ret = playlist_generic_add_track(pl_system_lookup("Hidden"), track); + playlist_generic_remove_track(pl_system_lookup("Collection"), track); + playlist_generic_remove_track(pl_system_lookup("Unplayed"), track); + playlist_generic_remove_track(pl_system_lookup("Most Played"), track); + playlist_generic_remove_track(pl_system_lookup("Least Played") , track); return ret; } @@ -114,13 +114,13 @@ static bool sys_pl_hidden_remove(struct playlist *playlist, struct track *track) struct playlist *add; if (track->tr_count == 0) - add = pl_system_get_playlist("Unplayed"); + add = pl_system_lookup("Unplayed"); else if (track->tr_count > track_db_average_plays()) - add = pl_system_get_playlist("Most Played"); + add = pl_system_lookup("Most Played"); else - add = pl_system_get_playlist("Least Played"); + add = pl_system_lookup("Least Played"); - playlist_generic_add_track(pl_system_get_playlist("Collection"), track); + playlist_generic_add_track(pl_system_lookup("Collection"), track); playlist_generic_add_track(add, track); return ret; } @@ -478,7 +478,7 @@ static void pl_system_save(void) __sys_pl_save(); } -static struct playlist *pl_system_get_playlist(const gchar *name) +static struct playlist *pl_system_lookup(const gchar *name) { struct sys_playlist *sys_pl = __sys_pl_lookup(name); return sys_pl ? &sys_pl->spl_playlist : NULL; @@ -528,13 +528,13 @@ static struct track *pl_system_next(const gchar *name) struct playlist_type pl_system = { - .pl_save = pl_system_save, - .pl_get_playlist = pl_system_get_playlist, - .pl_get_id = pl_system_get_id, - .pl_get_name = pl_system_get_name, - .pl_can_select = pl_system_can_select, - .pl_update = pl_system_update, - .pl_next = pl_system_next, + .pl_save = pl_system_save, + .pl_lookup = pl_system_lookup, + .pl_get_id = pl_system_get_id, + .pl_get_name = pl_system_get_name, + .pl_can_select = pl_system_can_select, + .pl_update = pl_system_update, + .pl_next = pl_system_next, }; @@ -561,8 +561,8 @@ void pl_system_deinit() void pl_system_new_track(struct track *track) { - playlist_generic_add_track(pl_system_get_playlist("Collection"), track); - playlist_generic_add_track(pl_system_get_playlist("Unplayed"), track); + playlist_generic_add_track(pl_system_lookup("Collection"), track); + playlist_generic_add_track(pl_system_lookup("Unplayed"), track); } void pl_system_delete_track(struct track *track) diff --git a/core/playlists/user.c b/core/playlists/user.c index 1b2e16d7..18b6b787 100644 --- a/core/playlists/user.c +++ b/core/playlists/user.c @@ -90,20 +90,15 @@ static struct playlist_ops user_ops = { }; -static struct playlist *__user_pl_lookup(const gchar *name) -{ - struct db_entry *dbe = db_get(&user_db, name); - return dbe ? &USER_PLAYLIST(dbe)->pl_playlist : NULL; -} - static void pl_user_save(void) { db_save(&user_db); } -static struct playlist *pl_user_get_playlist(const gchar *name) +static struct playlist *pl_user_lookup(const gchar *name) { - return __user_pl_lookup(name); + struct db_entry *dbe = db_get(&user_db, name); + return dbe ? &USER_PLAYLIST(dbe)->pl_playlist : NULL; } static unsigned int pl_user_get_id(const gchar *name) @@ -139,7 +134,7 @@ static void pl_user_update(const gchar *name) static struct track *pl_user_next(const gchar *name) { - struct playlist *playlist = __user_pl_lookup(name); + struct playlist *playlist = pl_user_lookup(name); struct track *track = playlist_generic_next(playlist); pl_user_save(); return track; @@ -147,14 +142,14 @@ static struct track *pl_user_next(const gchar *name) struct playlist_type pl_user = { - .pl_save = pl_user_save, - .pl_get_playlist = pl_user_get_playlist, - .pl_get_id = pl_user_get_id, - .pl_get_name = pl_user_get_name, - .pl_can_select = pl_user_can_select, - .pl_new = pl_user_new, - .pl_update = pl_user_update, - .pl_next = pl_user_next, + .pl_save = pl_user_save, + .pl_lookup = pl_user_lookup, + .pl_get_id = pl_user_get_id, + .pl_get_name = pl_user_get_name, + .pl_can_select = pl_user_can_select, + .pl_new = pl_user_new, + .pl_update = pl_user_update, + .pl_next = pl_user_next, }; diff --git a/gui/playlist.c b/gui/playlist.c index 396c4f72..a879697a 100644 --- a/gui/playlist.c +++ b/gui/playlist.c @@ -102,12 +102,12 @@ static void __gui_playlist_add_selected_to(struct playlist *playlist) void __gui_playlist_add_favorites(GtkMenuItem *item, gpointer data) { - __gui_playlist_add_selected_to(playlist_get(PL_SYSTEM, "Favorites")); + __gui_playlist_add_selected_to(playlist_lookup(PL_SYSTEM, "Favorites")); } void __gui_playlist_add_hidden(GtkMenuItem *item, gpointer data) { - __gui_playlist_add_selected_to(playlist_get(PL_SYSTEM, "Hidden")); + __gui_playlist_add_selected_to(playlist_lookup(PL_SYSTEM, "Hidden")); } void __gui_playlist_add_user(GtkMenuItem *item, gpointer data) @@ -122,7 +122,7 @@ void __gui_playlist_add_other(GtkMenuItem *item, gpointer data) void __gui_playlist_add_queued(GtkMenuItem *item, gpointer data) { - __gui_playlist_add_selected_to(playlist_get(PL_SYSTEM, "Queued Tracks")); + __gui_playlist_add_selected_to(playlist_lookup(PL_SYSTEM, "Queued Tracks")); } void __gui_playlist_delete(GtkMenuItem *item, gpointer data) diff --git a/gui/playlists/system.c b/gui/playlists/system.c index b2b695fb..3ec4d982 100644 --- a/gui/playlists/system.c +++ b/gui/playlists/system.c @@ -59,27 +59,27 @@ static bool __gui_pl_system_init_idle() /* Add toplevel playlists. */ gui_sidebar_iter_first(&iter); - gui_sidebar_iter_add(&iter, playlist_get(PL_SYSTEM, "Queued Tracks"), + gui_sidebar_iter_add(&iter, playlist_lookup(PL_SYSTEM, "Queued Tracks"), "audio-x-generic"); - gui_sidebar_iter_add(&iter, playlist_get(PL_SYSTEM, "Collection"), + gui_sidebar_iter_add(&iter, playlist_lookup(PL_SYSTEM, "Collection"), "media-optical"); - gui_sidebar_iter_add(&iter, playlist_get(PL_SYSTEM, "History"), + gui_sidebar_iter_add(&iter, playlist_lookup(PL_SYSTEM, "History"), "document-open-recent"); /* Add user-modifiable playlists. */ gui_sidebar_iter_find(&iter, "Playlists", PL_MAX_TYPE); - gui_sidebar_iter_append_child(&iter, playlist_get(PL_SYSTEM, "Favorites"), + gui_sidebar_iter_append_child(&iter, playlist_lookup(PL_SYSTEM, "Favorites"), "emblem-favorite"); - gui_sidebar_iter_append_child(&iter, playlist_get(PL_SYSTEM, "Hidden"), + gui_sidebar_iter_append_child(&iter, playlist_lookup(PL_SYSTEM, "Hidden"), "window-close"); /* Add dynamic playlists. */ gui_sidebar_iter_find(&iter, "Dynamic", PL_MAX_TYPE); - gui_sidebar_iter_append_child(&iter, playlist_get(PL_SYSTEM, "Most Played"), + gui_sidebar_iter_append_child(&iter, playlist_lookup(PL_SYSTEM, "Most Played"), "go-up"); - gui_sidebar_iter_append_child(&iter, playlist_get(PL_SYSTEM, "Least Played"), + gui_sidebar_iter_append_child(&iter, playlist_lookup(PL_SYSTEM, "Least Played"), "go-down"); - gui_sidebar_iter_append_child(&iter, playlist_get(PL_SYSTEM, "Unplayed"), + gui_sidebar_iter_append_child(&iter, playlist_lookup(PL_SYSTEM, "Unplayed"), "audio-x-generic"); return true; @@ -87,8 +87,8 @@ static bool __gui_pl_system_init_idle() void gui_pl_system_init() { - favorites = playlist_get(PL_SYSTEM, "Favorites"); - hidden = playlist_get(PL_SYSTEM, "Hidden"); + favorites = playlist_lookup(PL_SYSTEM, "Favorites"); + hidden = playlist_lookup(PL_SYSTEM, "Hidden"); idle_schedule(IDLE_SYNC, __gui_pl_system_init_idle, NULL); } diff --git a/gui/sidebar.c b/gui/sidebar.c index 00edcb8d..24ef3d13 100644 --- a/gui/sidebar.c +++ b/gui/sidebar.c @@ -237,7 +237,7 @@ struct playlist *gui_sidebar_iter_playlist(GtkTreeIter *iter) { enum playlist_type_t type = gui_sidebar_iter_type(iter); gchar *name = gui_sidebar_iter_name(iter); - struct playlist *playlist = playlist_get(type, name); + struct playlist *playlist = playlist_lookup(type, name); g_free(name); return playlist; diff --git a/include/core/playlist.h b/include/core/playlist.h index cef9d382..440a9235 100644 --- a/include/core/playlist.h +++ b/include/core/playlist.h @@ -35,6 +35,10 @@ struct playlist *playlist_new(enum playlist_type_t, const gchar *); bool playlist_delete(struct playlist *); +/* Called to look up playlists. */ +struct playlist *playlist_lookup(enum playlist_type_t, const gchar *); + + /* Called to add a track to a playlist. */ bool playlist_add(struct playlist *, struct track *); @@ -69,9 +73,6 @@ struct track *playlist_next(void); struct track *playlist_prev(void); -/* Called to access the playlist. */ -struct playlist *playlist_get(enum playlist_type_t, const gchar *); - /* Called to access the current playlist. */ struct playlist *playlist_cur(void); diff --git a/include/core/playlists/type.h b/include/core/playlists/type.h index 2027004d..c7a15d72 100644 --- a/include/core/playlists/type.h +++ b/include/core/playlists/type.h @@ -59,8 +59,8 @@ struct playlist_type { /* Called to save all playlists of the given type. */ void (*pl_save)(void); - /* Called to get the playlist. */ - struct playlist *(*pl_get_playlist)(const gchar *); + /* Called to look up playlists. */ + struct playlist *(*pl_lookup)(const gchar *); /* Called to convert a playlist name to an integer id. */ unsigned int (*pl_get_id)(const gchar *); diff --git a/tests/core/audio.c b/tests/core/audio.c index 24b6e86a..2f2ec66b 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(playlist_get(PL_SYSTEM, "History")), ==, 1); + g_assert_cmpuint(playlist_size(playlist_lookup(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); @@ -136,12 +136,12 @@ static void test_next() state_count = 0; /* First, let's test getting tracks from a temporary queue. */ - playlist_add(playlist_get(PL_SYSTEM, "Queued Tracks"), track_get(2)); - playlist_add(playlist_get(PL_SYSTEM, "Queued Tracks"), track_get(1)); - playlist_add(playlist_get(PL_SYSTEM, "Queued Tracks"), track_get(0)); + playlist_add(playlist_lookup(PL_SYSTEM, "Queued Tracks"), track_get(2)); + playlist_add(playlist_lookup(PL_SYSTEM, "Queued Tracks"), track_get(1)); + playlist_add(playlist_lookup(PL_SYSTEM, "Queued Tracks"), track_get(0)); for (i = 2; i >= 0; i--) { - g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "Queued Tracks")), ==, i + 1); + g_assert_cmpuint(playlist_size(playlist_lookup(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(playlist_get(PL_SYSTEM, "Queued Tracks")), ==, 0); + g_assert_cmpuint(playlist_size(playlist_lookup(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 5f130e8c..ca6f85e6 100644 --- a/tests/core/playlist.c +++ b/tests/core/playlist.c @@ -12,6 +12,8 @@ static void test_null() g_assert_null(playlist_new(PL_MAX_TYPE, NULL)); g_assert_false(playlist_delete(NULL)); + g_assert_null(playlist_lookup(PL_MAX_TYPE, NULL)); + g_assert_false(playlist_add(NULL, NULL)); g_assert_false(playlist_add(NULL, track_get(0))); g_assert_false(playlist_has(NULL, NULL)); diff --git a/tests/core/playlists/artist.c b/tests/core/playlists/artist.c index 5c4e2828..50ae266f 100644 --- a/tests/core/playlists/artist.c +++ b/tests/core/playlists/artist.c @@ -31,7 +31,7 @@ void test_artist() g_assert_cmpstr_free(playlist_get_name(PL_ARTIST, 0), ==, "Koji Kondo"); while (idle_run_task()) {}; - playlist = playlist_get(PL_ARTIST, "Koji Kondo"); + playlist = playlist_lookup(PL_ARTIST, "Koji Kondo"); g_assert_nonnull(playlist); g_assert_cmpuint(playlist_size(playlist), ==, 2); @@ -39,11 +39,11 @@ void test_artist() g_assert_false(playlist_remove(playlist, track_get(0))); g_assert_cmpuint(playlist_size(playlist), ==, 2); - g_assert(playlist_cur() != playlist_get(PL_ARTIST, "Koji Kondo")); + g_assert(playlist_cur() != playlist_lookup(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(playlist_cur() == playlist_lookup(PL_ARTIST, "Koji Kondo")); g_assert_false(playlist_delete(playlist)); pl_artist_deinit(); diff --git a/tests/core/playlists/library.c b/tests/core/playlists/library.c index 28a8d906..b3761578 100644 --- a/tests/core/playlists/library.c +++ b/tests/core/playlists/library.c @@ -35,16 +35,16 @@ void test_library() g_assert_cmpuint(playlist_size(playlist), ==, 0); while (idle_run_task()) {}; g_assert_cmpuint(playlist_size(playlist), ==, 48); - g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "Unplayed")), + g_assert_cmpuint(playlist_size(playlist_lookup(PL_SYSTEM, "Unplayed")), ==, 48); - g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "Collection")), + g_assert_cmpuint(playlist_size(playlist_lookup(PL_SYSTEM, "Collection")), ==, 48); - g_assert(playlist_cur() != playlist_get(PL_LIBRARY, "tests/Music")); + g_assert(playlist_cur() != playlist_lookup(PL_LIBRARY, "tests/Music")); g_assert_true(playlist_select(PL_LIBRARY, "tests/Music")); g_assert_cmpuint(settings_get("core.playlist.cur.type"), ==, PL_LIBRARY); g_assert_cmpuint(settings_get("core.playlist.cur.id"), ==, 0); - g_assert(playlist_cur() == playlist_get(PL_LIBRARY, "tests/Music")); + g_assert(playlist_cur() == playlist_lookup(PL_LIBRARY, "tests/Music")); g_assert_false(playlist_add(playlist, track_get(0))); g_assert_false(playlist_add(playlist, track_get(1))); @@ -101,9 +101,9 @@ void test_library() g_assert_true(playlist_delete(playlist)); g_assert_null(library_get(0)); - g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "Unplayed")), + g_assert_cmpuint(playlist_size(playlist_lookup(PL_SYSTEM, "Unplayed")), ==, 0); - g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, "Collection")), + g_assert_cmpuint(playlist_size(playlist_lookup(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 2041ad72..c3eef1a1 100644 --- a/tests/core/playlists/system.c +++ b/tests/core/playlists/system.c @@ -14,28 +14,28 @@ #define __test_playlist_has(name, track, expected) \ if (expected) \ - g_assert_true(playlist_has(playlist_get(PL_SYSTEM, name), track)); \ + g_assert_true(playlist_has(playlist_lookup(PL_SYSTEM, name), track)); \ else \ - g_assert_false(playlist_has(playlist_get(PL_SYSTEM, name), track)) + g_assert_false(playlist_has(playlist_lookup(PL_SYSTEM, name), track)) #define __test_playlist_state(name, ex_size, ex_track0, ex_track1) \ - g_assert_cmpuint(playlist_size(playlist_get(PL_SYSTEM, name)), ==, ex_size); \ + g_assert_cmpuint(playlist_size(playlist_lookup(PL_SYSTEM, name)), ==, ex_size); \ __test_playlist_has(name, track_get(0), ex_track0); \ __test_playlist_has(name, track_get(1), ex_track1) #define __test_playlist_add(name) \ __test_playlist_state(name, 0, false, false); \ - g_assert_true( playlist_add(playlist_get(PL_SYSTEM, name), track_get(0))); \ - g_assert_false(playlist_add(playlist_get(PL_SYSTEM, name), track_get(0))); \ - g_assert_true( playlist_add(playlist_get(PL_SYSTEM, name), track_get(1))); \ - g_assert_false(playlist_add(playlist_get(PL_SYSTEM, name), track_get(1))); \ + g_assert_true( playlist_add(playlist_lookup(PL_SYSTEM, name), track_get(0))); \ + g_assert_false(playlist_add(playlist_lookup(PL_SYSTEM, name), track_get(0))); \ + g_assert_true( playlist_add(playlist_lookup(PL_SYSTEM, name), track_get(1))); \ + g_assert_false(playlist_add(playlist_lookup(PL_SYSTEM, name), track_get(1))); \ __test_playlist_state(name, 2, true, true) #define __test_playlist_remove(name) \ - g_assert_true( playlist_remove(playlist_get(PL_SYSTEM, name), track_get(0))); \ - g_assert_false(playlist_remove(playlist_get(PL_SYSTEM, name), track_get(0))); \ - g_assert_true( playlist_remove(playlist_get(PL_SYSTEM, name), track_get(1))); \ - g_assert_false(playlist_remove(playlist_get(PL_SYSTEM, name), track_get(1))); \ + g_assert_true( playlist_remove(playlist_lookup(PL_SYSTEM, name), track_get(0))); \ + g_assert_false(playlist_remove(playlist_lookup(PL_SYSTEM, name), track_get(0))); \ + g_assert_true( playlist_remove(playlist_lookup(PL_SYSTEM, name), track_get(1))); \ + g_assert_false(playlist_remove(playlist_lookup(PL_SYSTEM, name), track_get(1))); \ __test_playlist_state(name, 0, false, false) #define __test_playlist_update(name, ex_size, ex_track0, ex_track1) \ @@ -44,23 +44,23 @@ __test_playlist_state(name, ex_size, ex_track0, ex_track1) #define __test_playlist_hide_track(name, ex_size, ex_track0, ex_track1) \ - g_assert_true(playlist_add(playlist_get(PL_SYSTEM, "Hidden"), track_get(0))); \ + g_assert_true(playlist_add(playlist_lookup(PL_SYSTEM, "Hidden"), track_get(0))); \ __test_playlist_state(name, ex_size, ex_track0, ex_track1); \ - g_assert_false(playlist_add(playlist_get(PL_SYSTEM, name), track_get(0))) + g_assert_false(playlist_add(playlist_lookup(PL_SYSTEM, name), track_get(0))) #define __test_playlist_unhide_track(name, ex_size, ex_track0, ex_track1) \ - g_assert_true(playlist_remove(playlist_get(PL_SYSTEM, "Hidden"), track_get(0))); \ + g_assert_true(playlist_remove(playlist_lookup(PL_SYSTEM, "Hidden"), track_get(0))); \ __test_playlist_state(name, ex_size, ex_track0, ex_track1) #define __test_playlist_clear_hidden(name, ex_size, ex_track0, ex_track1) \ - g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, "Hidden"))); \ + g_assert_false(playlist_delete(playlist_lookup(PL_SYSTEM, "Hidden"))); \ __test_playlist_state("Hidden", 0, false, false); \ __test_playlist_state(name, ex_size, ex_track0, ex_track1); #define __test_playlist_select(name, id) \ g_assert_true(playlist_select(PL_SYSTEM, name)); \ g_assert_cmpuint(settings_get("core.playlist.cur.id"), ==, id); \ - g_assert(playlist_cur() == playlist_get(PL_SYSTEM, name)) + g_assert(playlist_cur() == playlist_lookup(PL_SYSTEM, name)) #define __test_playlist_noselect(name) \ do { \ @@ -84,21 +84,21 @@ do { \ } while (0) static inline struct playlist *__test_pl_favorites(void) - { return playlist_get(PL_SYSTEM, "Favorites"); } + { return playlist_lookup(PL_SYSTEM, "Favorites"); } static inline struct playlist *__test_pl_hidden(void) - { return playlist_get(PL_SYSTEM, "Hidden"); } + { return playlist_lookup(PL_SYSTEM, "Hidden"); } static inline struct playlist *__test_pl_queued(void) - { return playlist_get(PL_SYSTEM, "Queued Tracks"); } + { return playlist_lookup(PL_SYSTEM, "Queued Tracks"); } static inline struct playlist *__test_pl_collection(void) - { return playlist_get(PL_SYSTEM, "Collection"); } + { return playlist_lookup(PL_SYSTEM, "Collection"); } static inline struct playlist *__test_pl_history(void) - { return playlist_get(PL_SYSTEM, "History"); } + { return playlist_lookup(PL_SYSTEM, "History"); } static inline struct playlist *__test_pl_unplayed(void) - { return playlist_get(PL_SYSTEM, "Unplayed"); } + { return playlist_lookup(PL_SYSTEM, "Unplayed"); } static inline struct playlist *__test_pl_most_played(void) - { return playlist_get(PL_SYSTEM, "Most Played"); } + { return playlist_lookup(PL_SYSTEM, "Most Played"); } static inline struct playlist *__test_pl_least_played(void) - { return playlist_get(PL_SYSTEM, "Least Played"); } + { return playlist_lookup(PL_SYSTEM, "Least Played"); } static void test_init() @@ -540,14 +540,14 @@ static void test_delete() playlist_add(__test_pl_queued(), track_get(0)); playlist_add(__test_pl_history(), track_get(0)); - g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, "Favorites"))); - g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, "Hidden"))); - g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, "Queued Tracks"))); - g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, "Collection"))); - g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, "History"))); - g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, "Unplayed"))); - g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, "Most Played"))); - g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, "Least Played"))); + g_assert_false(playlist_delete(__test_pl_favorites())); + g_assert_false(playlist_delete(__test_pl_hidden())); + g_assert_false(playlist_delete(__test_pl_queued())); + g_assert_false(playlist_delete(__test_pl_collection())); + g_assert_false(playlist_delete(__test_pl_history())); + g_assert_false(playlist_delete(__test_pl_unplayed())); + g_assert_false(playlist_delete(__test_pl_most_played())); + g_assert_false(playlist_delete(__test_pl_least_played())); g_assert_cmpuint(playlist_size(__test_pl_favorites()), ==, 0); g_assert_cmpuint(playlist_size(__test_pl_hidden()), ==, 0); diff --git a/tests/core/playlists/user.c b/tests/core/playlists/user.c index 633de520..14f51413 100644 --- a/tests/core/playlists/user.c +++ b/tests/core/playlists/user.c @@ -33,9 +33,9 @@ void test_user() g_assert_cmpstr_free(playlist_get_name(PL_USER, 0), ==, "Test Playlist"); g_assert_null(playlist_get_name(PL_USER, 1)); - g_assert(playlist_cur() != playlist_get(PL_USER, "Test Playlist")); + g_assert(playlist_cur() != playlist_lookup(PL_USER, "Test Playlist")); g_assert_true( playlist_select(PL_USER, "Test Playlist")); - g_assert(playlist_cur() == playlist_get(PL_USER, "Test Playlist")); + g_assert(playlist_cur() == playlist_lookup(PL_USER, "Test Playlist")); g_assert_false(playlist_select(PL_USER, "No Playlist")); g_assert_cmpuint(playlist_size(playlist), ==, 0); @@ -52,7 +52,7 @@ void test_user() while (idle_run_task()) {}; g_assert_cmpuint(db->db_size, ==, 1); - playlist = playlist_get(PL_USER, "Test Playlist"); + playlist = playlist_lookup(PL_USER, "Test Playlist"); g_assert_nonnull(playlist); g_assert_cmpuint(playlist_size(playlist), ==, 1); diff --git a/tests/gui/filter.c b/tests/gui/filter.c index 990835b7..de895c6d 100644 --- a/tests/gui/filter.c +++ b/tests/gui/filter.c @@ -62,10 +62,10 @@ void test_filter() entry = GTK_ENTRY(gui_filter_search()); model = GTK_TREE_MODEL(gui_filter_get()); playlist_get_queue(PL_SYSTEM, "Collection")->q_private = - playlist_get(PL_SYSTEM, "Collection"); + playlist_lookup(PL_SYSTEM, "Collection"); g_assert_false(gtk_tree_model_get_iter_first(model, &iter)); - gui_filter_set_playlist(playlist_get(PL_SYSTEM, "Collection")); + gui_filter_set_playlist(playlist_lookup(PL_SYSTEM, "Collection")); g_assert_false(gtk_tree_model_get_iter_first(model, &iter)); playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony"); @@ -99,11 +99,11 @@ void test_filter() gtk_combo_box_set_active(gui_filter_how(), GUI_FILTER_TITLE); g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 2); - gui_filter_set_playlist(playlist_get(PL_SYSTEM, "Unplayed")); + gui_filter_set_playlist(playlist_lookup(PL_SYSTEM, "Unplayed")); g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 13); g_assert_cmpstr(gtk_entry_get_text(entry), ==, ""); - gui_filter_set_playlist(playlist_get(PL_SYSTEM, "Collection")); + gui_filter_set_playlist(playlist_lookup(PL_SYSTEM, "Collection")); g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 2); g_assert_cmpstr(gtk_entry_get_text(entry), ==, "hyrule"); diff --git a/tests/gui/model.c b/tests/gui/model.c index fa3f7765..163efdee 100644 --- a/tests/gui/model.c +++ b/tests/gui/model.c @@ -66,10 +66,10 @@ static void test_init() GType type; g_assert_null(gui_model_get_playlist()); - gui_model_set_playlist(playlist_get(PL_SYSTEM, "Collection")); + gui_model_set_playlist(playlist_lookup(PL_SYSTEM, "Collection")); g_assert_nonnull(model); g_assert_true(GTK_IS_TREE_MODEL(model)); - g_assert(gui_model_get_playlist() == playlist_get(PL_SYSTEM, "Collection")); + g_assert(gui_model_get_playlist() == playlist_lookup(PL_SYSTEM, "Collection")); g_assert_cmpuint(gtk_tree_model_get_flags(treemodel), ==, GTK_TREE_MODEL_LIST_ONLY); @@ -106,7 +106,7 @@ static void __test_empty_subprocess() GValue value; GType type; - gui_model_set_playlist(playlist_get(PL_SYSTEM, "Collection")); + gui_model_set_playlist(playlist_lookup(PL_SYSTEM, "Collection")); memset(&value, 0, sizeof(GValue)); g_assert_false(gtk_tree_model_get_iter_first(model, &iter)); @@ -169,7 +169,7 @@ static void test_model() GtkTreeIter iter; GValue value; - gui_model_set_playlist(playlist_get(PL_SYSTEM, "Collection")); + gui_model_set_playlist(playlist_lookup(PL_SYSTEM, "Collection")); g_assert_cmpstr(gtk_label_get_text(gui_model_runtime()), ==, ""); memset(&value, 0, sizeof(GValue)); @@ -178,8 +178,8 @@ static void test_model() g_signal_connect(model, "row-changed", (GCallback)on_row_changed, NULL); /* Okay, now scan a directory ... */ - collection = playlist_get(PL_SYSTEM, "Collection"); - favorites = playlist_get(PL_SYSTEM, "Favorites"); + collection = playlist_lookup(PL_SYSTEM, "Collection"); + favorites = playlist_lookup(PL_SYSTEM, "Favorites"); collection->pl_queue.q_private = collection; favorites->pl_queue.q_private = favorites; playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony"); @@ -188,9 +188,9 @@ static void test_model() 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)); + playlist_add(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(0)); + playlist_add(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(1)); + playlist_add(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(2)); g_assert_cmpuint(playlist_size(favorites), ==, 3); g_assert_cmpstr(gtk_label_get_text(gui_model_runtime()), ==, "42 minutes, 45 seconds"); @@ -257,7 +257,7 @@ static void test_model() g_assert_cmpuint(gtk_tree_model_iter_n_children(model, &iter), ==, 0); g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 13); - gui_model_set_playlist(playlist_get(PL_SYSTEM, "Favorites")); + gui_model_set_playlist(playlist_lookup(PL_SYSTEM, "Favorites")); g_assert_cmpuint(count_delete, ==, 13); g_assert_cmpuint(count_insert, ==, 14); g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 3); @@ -270,7 +270,7 @@ static void test_model() g_assert_cmpuint(gtk_tree_model_iter_n_children(model, NULL), ==, 0); g_assert_cmpstr(gtk_label_get_text(gui_model_runtime()), ==, ""); - gui_model_set_playlist(playlist_get(PL_SYSTEM, "Collection")); + gui_model_set_playlist(playlist_lookup(PL_SYSTEM, "Collection")); g_assert_cmpuint(count_delete, ==, 16); g_assert_cmpuint(count_insert, ==, 15); g_assert_cmpstr(gtk_label_get_text(gui_model_runtime()), ==, @@ -282,12 +282,12 @@ static void test_model() g_assert_false(gtk_tree_model_iter_parent(model, &iter, &iter)); - gui_model_set_playlist(playlist_get(PL_SYSTEM, "Favorites")); + gui_model_set_playlist(playlist_lookup(PL_SYSTEM, "Favorites")); g_assert_cmpuint(count_delete, ==, 29); g_assert_cmpuint(count_insert, ==, 16); - playlist_remove(playlist_get(PL_SYSTEM, "Favorites"), track_get(0)); - playlist_remove(playlist_get(PL_SYSTEM, "Favorites"), track_get(1)); - playlist_remove(playlist_get(PL_SYSTEM, "Favorites"), track_get(2)); + playlist_remove(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(0)); + playlist_remove(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(1)); + playlist_remove(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(2)); g_assert_cmpuint(count_delete, ==, 32); } diff --git a/tests/gui/playlist.c b/tests/gui/playlist.c index 494bff84..dcd3413f 100644 --- a/tests/gui/playlist.c +++ b/tests/gui/playlist.c @@ -22,13 +22,13 @@ static void test_playlist() gui_pl_library_add("tests/Music/Hyrule Symphony"); while (idle_run_task()) {} - playlist_add(playlist_get(PL_SYSTEM, "Favorites"), track_get(0)); + playlist_add(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(0)); gtk_tree_model_filter_refilter(gui_sidebar_filter()); g_assert_true(gui_sidebar_iter_first(&iter)); path = gtk_tree_model_get_path(gui_sidebar_model(), &iter); gtk_tree_view_row_activated(gui_sidebar_treeview(), path, NULL); - g_assert_true(playlist_cur() == playlist_get(PL_SYSTEM, "Collection")); + g_assert_true(playlist_cur() == playlist_lookup(PL_SYSTEM, "Collection")); gtk_tree_path_free(path); g_assert_false(settings_has("gui.sidebar.expand.Playlists")); @@ -52,7 +52,7 @@ static void test_playlist() &iter); g_assert_nonnull(path); gtk_tree_view_row_activated(gui_sidebar_treeview(), path, NULL); - g_assert_true(playlist_cur() == playlist_get(PL_SYSTEM, "Favorites")); + g_assert_true(playlist_cur() == playlist_lookup(PL_SYSTEM, "Favorites")); gtk_tree_path_free(path); } diff --git a/tests/gui/playlists/artist.c b/tests/gui/playlists/artist.c index ab5061fa..250b3961 100644 --- a/tests/gui/playlists/artist.c +++ b/tests/gui/playlists/artist.c @@ -26,12 +26,12 @@ static void test_artist() g_assert_nonnull(gui_pl_library_add("tests/Music/Hyrule Symphony")); g_assert_cmpuint(artist_db_get()->db_size, ==, 0); - g_assert_null(playlist_get(PL_ARTIST, "Koji Kondo")); + g_assert_null(playlist_lookup(PL_ARTIST, "Koji Kondo")); g_assert_false(gtk_tree_model_iter_has_child(model, &iter)); 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(playlist_get(PL_ARTIST, "Koji Kondo")), + g_assert_nonnull(playlist_lookup(PL_ARTIST, "Koji Kondo")); + g_assert_cmpuint(playlist_size(playlist_lookup(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 ba2a63b1..bd31d796 100644 --- a/tests/gui/playlists/library.c +++ b/tests/gui/playlists/library.c @@ -26,8 +26,8 @@ static void test_library() g_assert_false(gtk_tree_model_iter_has_child(model, &iter)); g_assert_cmpuint(library_db_get()->db_size, ==, 0); - g_assert_null(playlist_get(PL_LIBRARY, "tests/Music/Ocarina of Time")); - g_assert_null(playlist_get(PL_LIBRARY, "tests/Music/Hyrule Symphony")); + g_assert_null(playlist_lookup(PL_LIBRARY, "tests/Music/Ocarina of Time")); + g_assert_null(playlist_lookup(PL_LIBRARY, "tests/Music/Hyrule Symphony")); ocarina = gui_pl_library_add("tests/Music/Ocarina of Time"); g_assert_nonnull(ocarina); diff --git a/tests/gui/playlists/system.c b/tests/gui/playlists/system.c index 9ada8a0f..1df70787 100644 --- a/tests/gui/playlists/system.c +++ b/tests/gui/playlists/system.c @@ -65,8 +65,8 @@ static void test_system() static void test_buttons() { - struct playlist *favorites = playlist_get(PL_SYSTEM, "Favorites"); - struct playlist *hidden = playlist_get(PL_SYSTEM, "Hidden"); + struct playlist *favorites = playlist_lookup(PL_SYSTEM, "Favorites"); + struct playlist *hidden = playlist_lookup(PL_SYSTEM, "Hidden"); g_assert_nonnull(gui_pl_library_add("tests/Music/Hyrule Symphony")); while (idle_run_task()) {} diff --git a/tests/gui/sidebar.c b/tests/gui/sidebar.c index 5b6bbbcb..ace4cec0 100644 --- a/tests/gui/sidebar.c +++ b/tests/gui/sidebar.c @@ -39,8 +39,8 @@ static void test_sidebar() g_assert_true(GTK_IS_TOGGLE_BUTTON(gui_random_button())); g_assert_true(gui_sidebar_iter_first(&iter)); - gui_sidebar_iter_add(&iter, playlist_get(PL_SYSTEM, "Collection"), NULL); - gui_sidebar_iter_add(&iter, playlist_get(PL_SYSTEM, "History"), NULL); + gui_sidebar_iter_add(&iter, playlist_lookup(PL_SYSTEM, "Collection"), NULL); + gui_sidebar_iter_add(&iter, playlist_lookup(PL_SYSTEM, "History"), NULL); g_assert_true(gui_sidebar_iter_first(&iter)); for (i = 0; i < 8; i++) { @@ -60,9 +60,9 @@ static void test_sidebar() g_assert_cmpuint(gui_sidebar_iter_type(&iter), ==, PL_MAX_TYPE); g_assert_false(gui_sidebar_iter_down(&iter, &child)); - gui_sidebar_iter_append_child(&iter, playlist_get(PL_SYSTEM, "Favorites"), + gui_sidebar_iter_append_child(&iter, playlist_lookup(PL_SYSTEM, "Favorites"), NULL); - gui_sidebar_iter_append_child(&iter, playlist_get(PL_SYSTEM, "Hidden"), + gui_sidebar_iter_append_child(&iter, playlist_lookup(PL_SYSTEM, "Hidden"), NULL); g_assert_true(gui_sidebar_iter_down(&iter, &child)); @@ -79,15 +79,15 @@ static void test_sidebar() g_assert_cmpstr_free(gui_sidebar_iter_name(&iter), ==, "History"); g_assert_cmpuint(gui_sidebar_iter_type(&iter), ==, PL_SYSTEM); g_assert(gui_sidebar_iter_playlist(&iter) == - playlist_get(PL_SYSTEM, "History")); + playlist_lookup(PL_SYSTEM, "History")); g_assert_true(gui_sidebar_iter_find(&iter, "Dynamic", PL_MAX_TYPE)); g_assert_false(gui_sidebar_iter_down(&iter, &child)); - gui_sidebar_iter_sort_child(&iter, playlist_get(PL_SYSTEM, "Most Played"), + gui_sidebar_iter_sort_child(&iter, playlist_lookup(PL_SYSTEM, "Most Played"), NULL); - gui_sidebar_iter_sort_child(&iter, playlist_get(PL_SYSTEM, "Least Played"), + gui_sidebar_iter_sort_child(&iter, playlist_lookup(PL_SYSTEM, "Least Played"), NULL); - gui_sidebar_iter_sort_child(&iter, playlist_get(PL_SYSTEM, "Unplayed"), + gui_sidebar_iter_sort_child(&iter, playlist_lookup(PL_SYSTEM, "Unplayed"), NULL); g_assert_true(gui_sidebar_iter_down(&iter, &child)); @@ -110,7 +110,7 @@ static void test_sidebar_selection() GtkTreeIter iter; unsigned int i, n; - collection = playlist_get(PL_SYSTEM, "Collection"); + collection = playlist_lookup(PL_SYSTEM, "Collection"); selection = gtk_tree_view_get_selection(gui_sidebar_treeview()); filter = GTK_TREE_MODEL(gui_sidebar_filter()); random = gui_random_button(); @@ -118,14 +118,14 @@ static void test_sidebar_selection() g_assert_cmpuint(gtk_tree_model_iter_n_children(filter, NULL), ==, 6); playlist_new(PL_LIBRARY, "tests/Music/Hyrule Symphony"); while (idle_run_task()) {} - playlist_add(playlist_get(PL_SYSTEM, "History"), track_get(0)); - playlist_add(playlist_get(PL_SYSTEM, "Favorites"), track_get(0)); + playlist_add(playlist_lookup(PL_SYSTEM, "History"), track_get(0)); + playlist_add(playlist_lookup(PL_SYSTEM, "Favorites"), track_get(0)); gtk_tree_model_filter_refilter(gui_sidebar_filter()); g_assert_cmpuint(gtk_tree_model_iter_n_children(filter, NULL), ==, 8); playlist_set_random(collection, true); g_assert_true(playlist_select(PL_SYSTEM, "Favorites")); - g_assert(playlist_cur() == playlist_get(PL_SYSTEM, "Favorites")); + g_assert(playlist_cur() == playlist_lookup(PL_SYSTEM, "Favorites")); g_assert_true(gui_sidebar_iter_first(&iter)); path = gtk_tree_model_get_path(gui_sidebar_model(), &iter); @@ -145,7 +145,7 @@ static void test_sidebar_selection() g_assert_true(playlist_get_random(collection)); } else if (i == 1) { g_assert(gui_model_get_playlist() == - playlist_get(PL_SYSTEM, "History")); + playlist_lookup(PL_SYSTEM, "History")); g_assert_false(gtk_toggle_button_get_active(random)); g_assert_false(gtk_widget_get_sensitive( GTK_WIDGET(random))); @@ -157,7 +157,7 @@ static void test_sidebar_selection() } gui_sidebar_filter_path_select(path); - g_assert(playlist_cur() == playlist_get(PL_SYSTEM, "Collection")); + g_assert(playlist_cur() == playlist_lookup(PL_SYSTEM, "Collection")); gtk_tree_selection_unselect_all(selection); gui_sidebar_iter_next(&iter); diff --git a/tests/gui/treeview.c b/tests/gui/treeview.c index 24ccbbff..dd641f5e 100644 --- a/tests/gui/treeview.c +++ b/tests/gui/treeview.c @@ -53,9 +53,9 @@ void test_treeview_init() gtk_tree_view_get_cursor(gui_treeview(), &path, NULL); g_assert_null(path); - gui_treeview_set_playlist(playlist_get(PL_SYSTEM, "Collection")); + gui_treeview_set_playlist(playlist_lookup(PL_SYSTEM, "Collection")); g_assert(gui_model_get_playlist() == - playlist_get(PL_SYSTEM, "Collection")); + playlist_lookup(PL_SYSTEM, "Collection")); /* No scrolling when playlist index is -1. */ gui_treeview_scroll(); @@ -63,7 +63,7 @@ void test_treeview_init() g_assert_null(path); /* Okay, NOW we can scroll! */ - playlist_get(PL_SYSTEM, "Collection")->pl_queue.q_cur.it_pos = 4; + playlist_lookup(PL_SYSTEM, "Collection")->pl_queue.q_cur.it_pos = 4; gui_treeview_scroll(); gtk_tree_view_get_cursor(gui_treeview(), &path, NULL); g_assert_nonnull(path); @@ -84,9 +84,9 @@ void test_treeview_select() selection = gtk_tree_view_get_selection(gui_treeview()); - gui_treeview_set_playlist(playlist_get(PL_SYSTEM, "Collection")); + gui_treeview_set_playlist(playlist_lookup(PL_SYSTEM, "Collection")); g_assert(gui_model_get_playlist() == - playlist_get(PL_SYSTEM, "Collection")); + playlist_lookup(PL_SYSTEM, "Collection")); g_assert_cmpuint(audio_cur_track()->tr_track, !=, 2); path = gui_filter_path_from_index(1); @@ -116,9 +116,9 @@ void test_treeview_sort() unsigned int i, sort; /* Switch to collection playlist and check sort arrows. */ - gui_treeview_set_playlist(playlist_get(PL_SYSTEM, "Collection")); + gui_treeview_set_playlist(playlist_lookup(PL_SYSTEM, "Collection")); g_assert(gui_model_get_playlist() == - playlist_get(PL_SYSTEM, "Collection")); + playlist_lookup(PL_SYSTEM, "Collection")); for (i = 0; i < GUI_MODEL_N_COLUMNS; i++) { col = gtk_tree_view_get_column(gui_treeview(), i); @@ -188,9 +188,9 @@ void test_treeview_sort() } /* History playlist should not have any sort arrows. */ - gui_treeview_set_playlist(playlist_get(PL_SYSTEM, "History")); + gui_treeview_set_playlist(playlist_lookup(PL_SYSTEM, "History")); g_assert(gui_model_get_playlist() == - playlist_get(PL_SYSTEM, "History")); + playlist_lookup(PL_SYSTEM, "History")); g_assert_cmpstr(gtk_label_get_text(gui_sorting()), ==, ""); for (i = 0; i < GUI_MODEL_N_COLUMNS; i++) {