From b1c5d42387cd7132f7916ae4e1ced816d172ba84 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 9 Dec 2015 08:11:21 -0500 Subject: [PATCH] core/playlist: Move playlist_init() out of the playlist namespace Signed-off-by: Anna Schumaker --- core/core.cpp | 2 +- core/playlist.cpp | 4 ++-- include/core/playlist.h | 10 ++++------ tests/core/playlist.cpp | 26 +++++++++++++------------- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/core/core.cpp b/core/core.cpp index 9d385207..d9e02bdd 100644 --- a/core/core.cpp +++ b/core/core.cpp @@ -17,7 +17,7 @@ void core :: init(struct core_init_data *init) filter_init(); tags_init(); collection_init(init->collection_ops); - playlist :: init(init->playlist_ops); + playlist_init(init->playlist_ops); deck :: init(init->history_ops, init->tempq_ops); audio :: init(); } diff --git a/core/playlist.cpp b/core/playlist.cpp index f274c806..c16099ed 100644 --- a/core/playlist.cpp +++ b/core/playlist.cpp @@ -80,7 +80,7 @@ static PlaylistQueue playlist_q; static std::string cur_plist; -void playlist :: init(struct queue_ops *ops) +void playlist_init(struct queue_ops *ops) { struct set_iter it; @@ -93,7 +93,7 @@ void playlist :: init(struct queue_ops *ops) index_init(&playlist_db, "playlist.db", true); db_load(&playlist_db); - index_entry *ent = get_tracks("Banned"); + index_entry *ent = playlist :: get_tracks("Banned"); if (!ent) return; diff --git a/include/core/playlist.h b/include/core/playlist.h index 9704e6d8..7697aef7 100644 --- a/include/core/playlist.h +++ b/include/core/playlist.h @@ -26,12 +26,6 @@ extern "C" { namespace playlist { - /** - * Read playlist information from disk and removed banned tracks - * from the Library queue. - */ - void init(struct queue_ops *); - /** * Check if a specific track is in a playlist. * @@ -85,4 +79,8 @@ namespace playlist }; + +/* Called to initialize the playlist manager. */ +void playlist_init(struct queue_ops *); + #endif /* OCARINA_CORE_PLAYLIST_H */ diff --git a/tests/core/playlist.cpp b/tests/core/playlist.cpp index 33ae7e88..41c8d2a7 100644 --- a/tests/core/playlist.cpp +++ b/tests/core/playlist.cpp @@ -10,36 +10,36 @@ extern "C" { #include "test.h" static index_entry *IDX_NULL = NULL; -static queue *Q_NULL = NULL; static void test_init() { - index_entry *ent; queue *q = playlist :: get_queue(); + GSList *list; - test_cp_data_dir(); filter_init(); tags_init(); collection_init(NULL); - playlist :: init(NULL); + playlist_init(NULL); - test_not_equal(q, Q_NULL); + test_not_equal(q, NULL); test_equal(queue_has_flag(q, Q_ENABLED), true); test_equal(queue_has_flag(q, Q_REPEAT), true); test_equal(queue_has_flag(q, Q_NO_SORT), true); + test_equal(queue_size(q), 0); - ent = playlist :: get_tracks("Banned"); - test_equal(set_size(&ent->ie_set), (size_t)4); - test_equal(queue_size(collection_get_queue()), (unsigned)20); - ent = playlist :: get_tracks("Favorites"); - test_equal(set_size(&ent->ie_set), (size_t)8); - ent = playlist :: get_tracks("No Such Playlist"); - test_equal(ent, IDX_NULL); + list = q->q_sort; + test_equal(g_slist_length(q->q_sort), 3); + test_equal(GPOINTER_TO_INT(list->data), COMPARE_ARTIST); + list = g_slist_next(list); + test_equal(GPOINTER_TO_INT(list->data), COMPARE_YEAR); + list = g_slist_next(list); + test_equal(GPOINTER_TO_INT(list->data), COMPARE_TRACK); } static void test_queue() { queue *q = playlist :: get_queue(); + test_cp_data_dir(); playlist :: select("Banned"); test_equal(queue_size(q), (unsigned)4); @@ -121,7 +121,7 @@ static void test_has() } DECLARE_UNIT_TESTS( - UNIT_TEST("Playlist Init", test_init), + UNIT_TEST("Playlist Initialization", test_init), UNIT_TEST("Playlist Queue", test_queue), UNIT_TEST("Playlist Add", test_add), UNIT_TEST("Playlist Delete", test_delete),