core/collection: Move collection_add() out of the collection namespace
This patch breaks later tests, since I needed to remove the old ogg files. This will be fixed in a few more patches. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
3204fc0e44
commit
6e39e17060
|
@ -171,16 +171,16 @@ void collection :: save(struct queue *queue, enum queue_flags flag)
|
|||
library_q.save();
|
||||
}
|
||||
|
||||
struct library *collection :: add(const std::string &dir)
|
||||
struct library *collection_add(const gchar *path)
|
||||
{
|
||||
struct library *library = NULL;
|
||||
|
||||
if (g_file_test(dir.c_str(), G_FILE_TEST_IS_DIR) == false)
|
||||
if (g_file_test(path, G_FILE_TEST_IS_DIR) == false)
|
||||
return library;
|
||||
|
||||
library = library_find(dir.c_str());
|
||||
library = library_find(path);
|
||||
if (library)
|
||||
update(library);
|
||||
collection :: update(library);
|
||||
return library;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ static void idle_enable()
|
|||
|
||||
static void on_add()
|
||||
{
|
||||
list_path(collection :: add(c_chooser->get_filename()));
|
||||
list_path(collection_add(c_chooser->get_filename().c_str()));
|
||||
idle_enable();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,15 +26,6 @@ namespace collection
|
|||
|
||||
void save(struct queue *, enum queue_flags);
|
||||
|
||||
/**
|
||||
* Add a new directory to the library.
|
||||
*
|
||||
* @param dir The directory that should be scanned.
|
||||
* @return The newly created Library tag or NULL if a
|
||||
* tag could not be created.
|
||||
*/
|
||||
struct library *add(const std::string &);
|
||||
|
||||
/**
|
||||
* Remove a Library tag from the database along with every
|
||||
* Track associated with this library.
|
||||
|
@ -82,4 +73,8 @@ namespace collection
|
|||
/* Called to initialize the collection manager. */
|
||||
void collection_init(struct queue_ops *);
|
||||
|
||||
|
||||
/* Called to add a new library directory to the collection manager. */
|
||||
struct library *collection_add(const gchar *);
|
||||
|
||||
#endif /* OCARINA_CORE_LIBRARY_H */
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -37,6 +37,31 @@ static void test_init()
|
|||
test_equal(GPOINTER_TO_INT(list->data), COMPARE_TRACK);
|
||||
}
|
||||
|
||||
static void test_add()
|
||||
{
|
||||
struct queue *q = collection :: get_queue();
|
||||
struct library *lib;
|
||||
|
||||
test_equal(collection_add("tests/Invalid"), NULL);
|
||||
|
||||
lib = collection_add("tests/Music");
|
||||
test_not_equal(lib, NULL);
|
||||
test_equal(lib->li_size, 0);
|
||||
test_equal(lib->li_enabled, true);
|
||||
test_equal(lib->li_path, "tests/Music");
|
||||
|
||||
test_equal(queue_size(q), 0);
|
||||
test_equal(idle_run_task(), true); /* collection validation */
|
||||
test_equal(idle_run_task(), true); /* tests/Music/ */
|
||||
test_equal(idle_run_task(), true); /* tests/Music/Hyrule Symphony/ */
|
||||
test_equal(idle_run_task(), false); /* tests/Music/Ocarina of Time/ */
|
||||
|
||||
test_equal(track_db_get()->db_size, 48);
|
||||
test_equal(lib->li_size, 48);
|
||||
test_equal(queue_size(q), 48);
|
||||
}
|
||||
|
||||
|
||||
static void test_enable()
|
||||
{
|
||||
test_cp_data_dir();
|
||||
|
@ -81,23 +106,6 @@ static void test_remove()
|
|||
test_equal(queue_size(q), (unsigned)0);
|
||||
}
|
||||
|
||||
static void test_add()
|
||||
{
|
||||
queue *q = collection :: get_queue();
|
||||
|
||||
test_generate_library();
|
||||
collection :: add("/tmp/ocarina/");
|
||||
|
||||
test_equal(queue_size(q), (unsigned)0);
|
||||
test_equal(idle_run_task(), true);
|
||||
test_equal(queue_size(q), (unsigned)0);
|
||||
|
||||
for (unsigned int i = 0; i < 6; i++) {
|
||||
test_equal(idle_run_task(), (i < 5) ? true : false);
|
||||
test_equal(queue_size(q), i * 7);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_update()
|
||||
{
|
||||
queue *q = collection :: get_queue();
|
||||
|
@ -125,8 +133,8 @@ static void test_update()
|
|||
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("Collection Initialization", test_init),
|
||||
UNIT_TEST("Collection Add Path", test_add),
|
||||
UNIT_TEST("Library Enable and Disable", test_enable),
|
||||
UNIT_TEST("Library Delete Path", test_remove),
|
||||
UNIT_TEST("Library Add Path", test_add),
|
||||
UNIT_TEST("Library Update Path", test_update),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue