core/collection: Add collection_deinit()

To clean up the collection queue.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-12-05 12:04:19 -05:00
parent 62f0606cd6
commit 89ce6d725c
4 changed files with 23 additions and 1 deletions

View File

@ -24,6 +24,7 @@ void core :: init(struct core_init_data *init)
void core :: deinit()
{
filter_deinit();
collection_deinit();
tags_deinit();
filter_deinit();
}

View File

@ -166,6 +166,11 @@ void collection_init(struct queue_ops *ops)
queue_set_flag(&library_q, Q_SAVE_FLAGS);
}
void collection_deinit()
{
queue_deinit(&library_q);
}
void collection :: save(struct queue *queue, enum queue_flags flag)
{
library_q.save();

View File

@ -39,6 +39,9 @@ namespace collection
/* Called to initialize the collection manager. */
void collection_init(struct queue_ops *);
/* Called to deinitialize the collection manager. */
void collection_deinit();
/* Called to add a new library directory to the collection manager. */
struct library *collection_add(const gchar *);

View File

@ -146,10 +146,23 @@ static void test_remove()
test_equal(queue_size(q), 0);
}
static void test_deinit()
{
struct queue *q = collection :: get_queue();
collection_deinit();
tags_deinit();
filter_deinit();
test_equal(queue_size(q), 0);
test_equal(g_slist_length(q->q_sort), 0);
}
DECLARE_UNIT_TESTS(
UNIT_TEST("Collection Initialization", test_init),
UNIT_TEST("Collection Add Path", test_add),
UNIT_TEST("Collection Update Path", test_update),
UNIT_TEST("Collection Enable and Disable", test_enable),
UNIT_TEST("Collection Remove Path", test_remove),
UNIT_TEST("Collection De-Initialization", test_deinit),
);