core/collection: move collection_set_enabled() out of the collection
namespace Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
8a1f5403d0
commit
62f0606cd6
|
@ -187,7 +187,7 @@ struct library *collection_add(const gchar *path)
|
|||
void collection_remove(struct library *library)
|
||||
{
|
||||
if (library) {
|
||||
collection :: set_enabled(library, false);
|
||||
collection_set_enabled(library, false);
|
||||
track_remove_all(library);
|
||||
library_remove(library);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ void collection_update_all()
|
|||
collection_update(LIBRARY(library));
|
||||
}
|
||||
|
||||
void collection :: set_enabled(struct library *library, bool enabled)
|
||||
void collection_set_enabled(struct library *library, bool enabled)
|
||||
{
|
||||
struct db_entry *dbe, *next;
|
||||
struct track *track;
|
||||
|
|
|
@ -167,7 +167,7 @@ static void on_toggled(const Glib::ustring &str)
|
|||
Gtk::TreeModel::Row row;
|
||||
struct library *lib = get_library_and_row(Gtk::TreePath(str), row);
|
||||
|
||||
collection :: set_enabled(lib, !lib->li_enabled);
|
||||
collection_set_enabled(lib, !lib->li_enabled);
|
||||
row[c_cols.c_enabled] = lib->li_enabled;
|
||||
if (lib->li_enabled)
|
||||
remove_banned_tracks();
|
||||
|
|
|
@ -26,16 +26,6 @@ namespace collection
|
|||
|
||||
void save(struct queue *, enum queue_flags);
|
||||
|
||||
/**
|
||||
* Use to enable or disable a library path. When a Library path
|
||||
* is disabled, its tracks will be removed from the Library queue.
|
||||
*
|
||||
* @param library The library to be enabled or disabled.
|
||||
* @param enabled Set to true if the library should be enabled,
|
||||
* and false to disable it.
|
||||
*/
|
||||
void set_enabled(struct library *, bool);
|
||||
|
||||
/**
|
||||
* Use to access the library queue.
|
||||
*
|
||||
|
@ -62,4 +52,8 @@ void collection_update(struct library *);
|
|||
/* Called to update all library paths. */
|
||||
void collection_update_all();
|
||||
|
||||
|
||||
/* Called to enable or disable a library directory. */
|
||||
void collection_set_enabled(struct library *, bool);
|
||||
|
||||
#endif /* OCARINA_CORE_LIBRARY_H */
|
||||
|
|
|
@ -9,8 +9,6 @@ extern "C" {
|
|||
#include <core/library.h>
|
||||
#include "test.h"
|
||||
|
||||
static struct library *LIB_NULL = NULL;
|
||||
|
||||
static void test_init()
|
||||
{
|
||||
struct queue *q = collection :: get_queue();
|
||||
|
@ -114,6 +112,27 @@ static void test_update()
|
|||
test_equal(queue_size(q), 48);
|
||||
}
|
||||
|
||||
static void test_enable()
|
||||
{
|
||||
struct queue *q = collection :: get_queue();
|
||||
struct library *lib = library_get(0);
|
||||
|
||||
collection_set_enabled(NULL, true);
|
||||
test_equal(queue_size(q), 48);
|
||||
|
||||
collection_set_enabled(lib, false);
|
||||
test_equal(queue_size(q), 0);
|
||||
|
||||
collection_set_enabled(lib, false);
|
||||
test_equal(queue_size(q), 0);
|
||||
|
||||
collection_set_enabled(lib, true);
|
||||
test_equal(queue_size(q), 48);
|
||||
|
||||
collection_set_enabled(lib, true);
|
||||
test_equal(queue_size(q), 48);
|
||||
}
|
||||
|
||||
static void test_remove()
|
||||
{
|
||||
struct queue *q = collection :: get_queue();
|
||||
|
@ -127,39 +146,10 @@ static void test_remove()
|
|||
test_equal(queue_size(q), 0);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
collection :: set_enabled(LIB_NULL, true);
|
||||
test_equal(queue_size(q), (unsigned)24);
|
||||
|
||||
collection :: set_enabled(library, false);
|
||||
test_equal(queue_size(q), (unsigned)0);
|
||||
|
||||
collection :: set_enabled(library, true);
|
||||
test_equal(queue_size(q), (unsigned)24);
|
||||
|
||||
collection :: set_enabled(library, true);
|
||||
test_equal(queue_size(q), (unsigned)24);
|
||||
|
||||
collection :: set_enabled(library, false);
|
||||
test_equal(queue_size(q), (unsigned)0);
|
||||
|
||||
collection :: set_enabled(library, true);
|
||||
test_equal(queue_size(q), (unsigned)24);
|
||||
}
|
||||
|
||||
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("Library Enable and Disable", test_enable),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue