diff --git a/core/library.cpp b/core/library.cpp index 260db17a..cc7532db 100644 --- a/core/library.cpp +++ b/core/library.cpp @@ -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; } diff --git a/gui/manager.cpp b/gui/manager.cpp index ab4820a2..643382bb 100644 --- a/gui/manager.cpp +++ b/gui/manager.cpp @@ -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(); } diff --git a/include/core/library.h b/include/core/library.h index b7e5fbe6..13265d2a 100644 --- a/include/core/library.h +++ b/include/core/library.h @@ -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 */ diff --git a/tests/Music/1.ogg b/tests/Music/1.ogg deleted file mode 100644 index 5e94d369..00000000 Binary files a/tests/Music/1.ogg and /dev/null differ diff --git a/tests/Music/10.ogg b/tests/Music/10.ogg deleted file mode 100644 index 6f2e4fcd..00000000 Binary files a/tests/Music/10.ogg and /dev/null differ diff --git a/tests/Music/15.ogg b/tests/Music/15.ogg deleted file mode 100644 index 99bb15b7..00000000 Binary files a/tests/Music/15.ogg and /dev/null differ diff --git a/tests/Music/60.ogg b/tests/Music/60.ogg deleted file mode 100644 index 16b85beb..00000000 Binary files a/tests/Music/60.ogg and /dev/null differ diff --git a/tests/Music/600.ogg b/tests/Music/600.ogg deleted file mode 100644 index c7e36082..00000000 Binary files a/tests/Music/600.ogg and /dev/null differ diff --git a/tests/Music/666.ogg b/tests/Music/666.ogg deleted file mode 100644 index 3586665e..00000000 Binary files a/tests/Music/666.ogg and /dev/null differ diff --git a/tests/Music/90.ogg b/tests/Music/90.ogg deleted file mode 100644 index abeceb9a..00000000 Binary files a/tests/Music/90.ogg and /dev/null differ diff --git a/tests/core/library.cpp b/tests/core/library.cpp index d3277daf..426e8882 100644 --- a/tests/core/library.cpp +++ b/tests/core/library.cpp @@ -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), );