From 3204fc0e447e126f40db4ed813741523e1301b4d Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sat, 5 Dec 2015 08:55:24 -0500 Subject: [PATCH] core/collection: Move collection_init() out of the collection namespace Signed-off-by: Anna Schumaker --- core/core.cpp | 2 +- core/library.cpp | 2 +- include/core/library.h | 10 ++++------ tests/core/audio.cpp | 2 +- tests/core/deck.cpp | 2 +- tests/core/library.cpp | 33 ++++++++++++++++++++++++--------- tests/core/playlist.cpp | 2 +- 7 files changed, 33 insertions(+), 20 deletions(-) diff --git a/core/core.cpp b/core/core.cpp index ebea4b70..2efc6336 100644 --- a/core/core.cpp +++ b/core/core.cpp @@ -16,7 +16,7 @@ void core :: init(struct core_init_data *init) { filter_init(); tags_init(); - collection :: init(init->collection_ops); + collection_init(init->collection_ops); playlist :: init(init->playlist_ops); deck :: init(init->history_ops, init->tempq_ops); audio :: init(); diff --git a/core/library.cpp b/core/library.cpp index 7ec89c26..260db17a 100644 --- a/core/library.cpp +++ b/core/library.cpp @@ -143,7 +143,7 @@ static void validate_library(void *data) * External API begins here */ -void collection :: init(struct queue_ops *ops) +void collection_init(struct queue_ops *ops) { struct db_entry *track, *next; diff --git a/include/core/library.h b/include/core/library.h index 66232f88..b7e5fbe6 100644 --- a/include/core/library.h +++ b/include/core/library.h @@ -24,12 +24,6 @@ extern "C" { namespace collection { - /** - * Scan over every Track tag and add each enabled Track to the - * library queue. - */ - void init(struct queue_ops *); - void save(struct queue *, enum queue_flags); /** @@ -84,4 +78,8 @@ namespace collection }; + +/* Called to initialize the collection manager. */ +void collection_init(struct queue_ops *); + #endif /* OCARINA_CORE_LIBRARY_H */ diff --git a/tests/core/audio.cpp b/tests/core/audio.cpp index 90af63c5..78f9742d 100644 --- a/tests/core/audio.cpp +++ b/tests/core/audio.cpp @@ -88,7 +88,7 @@ void test_init() filter_init(); tags_init(); - collection :: init(NULL); + collection_init(NULL); deck :: init(NULL, NULL); audio :: init(); diff --git a/tests/core/deck.cpp b/tests/core/deck.cpp index f91b0fc8..a98b1f25 100644 --- a/tests/core/deck.cpp +++ b/tests/core/deck.cpp @@ -23,7 +23,7 @@ static void test_init() test_cp_data_dir(); filter_init(); tags_init(); - collection :: init(NULL); + collection_init(NULL); deck :: init(NULL, NULL); test_equal(queue_has_flag(collection :: get_queue(), Q_RANDOM), true); diff --git a/tests/core/library.cpp b/tests/core/library.cpp index 35bfbdd3..d3277daf 100644 --- a/tests/core/library.cpp +++ b/tests/core/library.cpp @@ -9,26 +9,41 @@ extern "C" { #include #include "test.h" -static queue *Q_NULL = NULL; static struct library *LIB_NULL = NULL; static void test_init() { - queue *q = collection :: get_queue(); + struct queue *q = collection :: get_queue(); + GSList *list; - test_cp_data_dir(); filter_init(); tags_init(); - collection :: init(NULL); + collection_init(NULL); - test_not_equal(q, Q_NULL); - test_equal(queue_has_flag(q, Q_ENABLED), true); - test_equal(queue_has_flag(q, Q_REPEAT), true); - test_equal(queue_size(q), (unsigned)24); + 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_SAVE_SORT), true); + test_equal(queue_has_flag(q, Q_SAVE_FLAGS), true); + test_equal(queue_has_flag(q, Q_ADD_FRONT), false); + test_equal(queue_size(q), 0); + + 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_enable() { + test_cp_data_dir(); + filter_init(); + tags_init(); + collection_init(NULL); + queue *q = collection :: get_queue(); struct library *library = library_get(0); @@ -109,7 +124,7 @@ static void test_update() } DECLARE_UNIT_TESTS( - UNIT_TEST("Library Init", test_init), + UNIT_TEST("Collection Initialization", test_init), UNIT_TEST("Library Enable and Disable", test_enable), UNIT_TEST("Library Delete Path", test_remove), UNIT_TEST("Library Add Path", test_add), diff --git a/tests/core/playlist.cpp b/tests/core/playlist.cpp index a2be8549..377cd264 100644 --- a/tests/core/playlist.cpp +++ b/tests/core/playlist.cpp @@ -20,7 +20,7 @@ static void test_init() test_cp_data_dir(); filter_init(); tags_init(); - collection :: init(NULL); + collection_init(NULL); playlist :: init(NULL); test_not_equal(q, Q_NULL);