diff --git a/lib/deck.cpp b/lib/deck.cpp index ebf6b70e..daa92a5e 100644 --- a/lib/deck.cpp +++ b/lib/deck.cpp @@ -178,7 +178,7 @@ void deck :: reset() { get_callbacks()->on_queue_changed = no_op; playqueue_deck.clear(); - library_playqueue.reset(); + //library_playqueue.reset(); } void deck :: print_info() diff --git a/tests/.gitignore b/tests/.gitignore index fa59425a..f30eb57c 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -9,3 +9,4 @@ random queue library playlist +deck diff --git a/tests/Library/album.db b/tests/Data/album.db similarity index 100% rename from tests/Library/album.db rename to tests/Data/album.db diff --git a/tests/Library/artist.db b/tests/Data/artist.db similarity index 100% rename from tests/Library/artist.db rename to tests/Data/artist.db diff --git a/tests/Library/genre.db b/tests/Data/genre.db similarity index 100% rename from tests/Library/genre.db rename to tests/Data/genre.db diff --git a/tests/Library/library.db b/tests/Data/library.db similarity index 100% rename from tests/Library/library.db rename to tests/Data/library.db diff --git a/tests/Playlist/playlist.db b/tests/Data/playlist.db similarity index 100% rename from tests/Playlist/playlist.db rename to tests/Data/playlist.db diff --git a/tests/Library/track.db b/tests/Data/track.db similarity index 100% rename from tests/Library/track.db rename to tests/Data/track.db diff --git a/tests/Sconscript b/tests/Sconscript index e6e9976c..eede98a3 100644 --- a/tests/Sconscript +++ b/tests/Sconscript @@ -6,7 +6,7 @@ tests = [ ### # -# (source.cpp, use collected lib_files?, [ other files ]) +# (source.cpp, use collected lib_files?, [ other files ], [ other packages ]) # ("version.cpp", False, [], [ "glib-2.0" ]), @@ -20,6 +20,7 @@ tests = [ ("queue.cpp", True, [ "callback.cpp", "random.cpp" ], []), ("library.cpp", True, [ "idle.cpp" ], []), ("playlist.cpp", True, [], []), + ("deck.cpp", True, [], []), ] diff --git a/tests/deck/deck.cpp b/tests/deck.cpp similarity index 93% rename from tests/deck/deck.cpp rename to tests/deck.cpp index da208c8e..0fb83d4a 100644 --- a/tests/deck/deck.cpp +++ b/tests/deck.cpp @@ -1,7 +1,16 @@ /* * Copyright 2013 (c) Anna Schumaker. */ -#include + + + +int main(int argc, char **argv) +{ + return 0; +} + + +/*#include #include #include #include @@ -12,9 +21,9 @@ void test_add_playlist(unsigned int size) for (unsigned i = 0; i < size; i++) pqueue->add(i); } - +*/ /* Test creating a deck of playlists */ -void test_0() +/*void test_0() { for (unsigned int i = 0; i < 10; i++) test_add_playlist(10 + i); @@ -22,9 +31,9 @@ void test_0() deck :: print_info(); print("\n"); } - +*/ /* Test removing playlists from the deck */ -void test_1() +/*void test_1() { print("Test 1:\n"); deck :: remove(3); @@ -34,9 +43,9 @@ void test_1() deck :: print_info(); print("\n"); } - +*/ /* Get a specific playlist from the deck */ -void test_2() +/*void test_2() { Playqueue *pqueue; print("Test 2: "); @@ -44,10 +53,10 @@ void test_2() pqueue = deck :: get(3); print("Playqueue { size = %u, flags = %u }", pqueue->size(), pqueue->get_flags()); print("\n\n"); -} +}*/ /* Move a playlist to a new position in the deck */ -void test_3() +/*void test_3() { print("Test 3:\n"); deck :: move(4, 0); @@ -68,10 +77,10 @@ void test_3() deck :: move(4, 4); deck :: print_info(); print("\n"); -} +}*/ /* Test the next() function for playlists */ -void test_4() +/*void test_4() { print("Test 4:\n"); @@ -87,10 +96,10 @@ void test_4() deck :: print_info(); print("\n"); -} +}*/ /* Test load / save functions */ -void test_5() +/*void test_5() { print("Test 5:\n"); @@ -141,4 +150,4 @@ int main(int argc, char **argv) print("Library size: %u\n", deck :: get_library_pq()->size()); return 0; -} +}*/ diff --git a/tests/deck/Sconscript b/tests/deck.old/Sconscript similarity index 100% rename from tests/deck/Sconscript rename to tests/deck.old/Sconscript diff --git a/tests/deck/deck.good b/tests/deck.old/deck.good similarity index 100% rename from tests/deck/deck.good rename to tests/deck.old/deck.good diff --git a/tests/library.cpp b/tests/library.cpp index d52e3810..0838dd9c 100644 --- a/tests/library.cpp +++ b/tests/library.cpp @@ -105,7 +105,7 @@ static void test_update() int main(int argc, char **argv) { - test :: cp_library(); + test :: cp_data_dir(); run_test("Library Init Test", test_init); run_test("Library Enable and Disable Test", test_enable); @@ -113,305 +113,3 @@ int main(int argc, char **argv) run_test("Library Add Path Test", test_add); run_test("Library Update Path Test", test_update); } -/*#include -#include -#include -#include - -#include - -void gen_library() -{ - system("tests/library/gen_library.sh"); - print("\n"); -} - -void run_idle_tasks() -{ - while (idle :: run_task()); -} - -bool check_add_dir(const std::string &dir) -{ - try { - library :: add_path(dir.c_str()); - return true; - } catch (int error) { - return false; - } -} - -void library_added(unsigned int id, library :: Library *path) -{ - print("Added library %u: %s\n", id, path->root_path.c_str()); -} - -void library_updated(unsigned int id, library :: Library *path) -{ - print("Updated library %u: %s (size: %u)\n", - id, path->root_path.c_str(), path->size); -} - -void test_add_dir(const std::string &test, const std::string &dir, bool expected) -{ - print("Test %s: ", test.c_str()); - if (check_add_dir(dir.c_str()) == expected) - print("PASSED\n"); - else - print("FAILED\n"); - - run_idle_tasks(); - library :: print_db(library :: DB_LIBRARY); -} - -void test_del_dir(const std::string &test, const unsigned int path_id) -{ - print("Test %s\n", test.c_str()); - library :: del_path(path_id); - library :: print_db(library :: DB_LIBRARY); -} - -bool check_lookup(const unsigned int track_id, library :: Song *song) -{ - try { - library :: lookup(track_id, song); - return true; - } catch (int error) { - return false; - } -} - -void test_lookup(const std::string &test, const unsigned int track_id, bool expected) -{ - library :: Song song; - bool res; - - print("Test %s (track_id == %u): ", test.c_str(), track_id); - - res = check_lookup(track_id, &song); - if (res == expected) - print("PASSED\n"); - else - print("FAILED\n"); - - if (res == true) { - print(" %s (%s) by %s (%s) from %s (%s) Length: %s\n", - song.track->title.c_str(), - song.track->title_lower.c_str(), - song.artist->primary_key.c_str(), - song.artist->key_lower.c_str(), - song.album->name.c_str(), - song.album->name_lower.c_str(), - song.track->length_str.c_str()); - print(" Genre: %s (%s), Library: %s\n", - song.genre->primary_key.c_str(), - song.genre->key_lower.c_str(), - song.library->root_path.c_str()); - } -} - -void test_path_lookup(const std::string &test, unsigned int lib_id, bool expected) -{ - library :: Library *lib; - - print("Test %s (lib_id == %u): ", test.c_str(), lib_id); - - try { - lib = library :: lookup_path(lib_id); - if (expected == true) - print("PASSED\n"); - else - print("FAILED, no error produced\n"); - - print("%s (", lib->root_path.c_str()); - if (lib->enabled) - print("enabled"); - else - print("disabled"); - print(") size = %u\n", lib->size); - } catch (int error) { - if (expected == true) - print("FAILED, unexpected error %d\n", error); - else - print("PASSED\n"); - } -} - -void test_print_dbs(const std::string &test) -{ - print("Test %s\n", test.c_str()); - library :: print_db(library :: DB_GENRE); - print("\n"); -}*/ - - -/* Add paths library that SHOULD fail */ -/*void test_0() -{ - test_add_dir("0a", "/tmp/library/error", false); - test_add_dir("0b", "/tmp/library/file", false); - print("\n"); -}*/ - -/* Simple library path operations */ -/*void test_1() -{ - test_add_dir("1a", "/tmp/library/0", true); - test_del_dir("1b", 0); - print("\n"); -}*/ - -/* Test multiple paths */ -/*void test_2() -{ - library :: reset(); - test_add_dir("2a", "/tmp/library/0", true); - test_add_dir("2b", "/tmp/library/1", true); - test_add_dir("2c", "/tmp/library/2", true); - - test_del_dir("2d", 1); - test_del_dir("2e", 0); - test_del_dir("2f", 2); - print("\n"); -}*/ - -/* Test load and save of library db */ -/*void test_3() -{ - library :: reset(); - test_add_dir("3a", "/tmp/library/0", true); - test_add_dir("3b", "/tmp/library/1", true); - test_add_dir("3c", "/tmp/library/2", true); - - print("Test 3d\n"); - library :: reset(); - library :: print_db(library :: DB_LIBRARY); - - print("Test 3e\n"); - library :: init(); - library :: print_db(library :: DB_LIBRARY); - print("\n"); -}*/ - -/* Test scanning a single path */ -/*void test_4() -{ - library :: reset(); - test_add_dir("4a", "/tmp/library/0", true); - - library :: print_db(library :: DB_ARTIST); - print("\n"); - library :: print_db(library :: DB_ALBUM); - print("\n"); - library :: print_db(library :: DB_GENRE); - print("\n"); - library :: print_db(library :: DB_TRACK); - print("\n"); -}*/ - -/* Test lookup() */ -/*void test_5() -{ - library :: reset(); -*/ - /* Lookup on empty DB */ -// test_lookup("5a", 0, false); -// test_add_dir("5b", "/tmp/library/0", true); - /* Lookup on DB[0] */ -// test_lookup("5c", 0, true); - /* Lookup on DB[10] */ -// test_lookup("5d", 42, true); - /* Lookup beyond db */ -// test_lookup("5e", 100000, false); - - /* Lookup path id = 0 */ -// test_path_lookup("5f", 0, true); - /* Lookup path id that doesn't exist */ -// test_path_lookup("5g", 1, false); -// print("\n"); -//} - -/* Test validation code */ -/*void test_6() -{ - library :: reset(); - - test_add_dir("6a", "/tmp/library/0", true); - print("\n"); - - print("6b: Updating library 0 (nothing should change)\n"); - library :: update_path(0); - run_idle_tasks(); - library :: print_db(library :: DB_TRACK); - print("\n"); - - print("6c: Delete /tmp/library/0/Artist 2\n"); - system("rm -rf /tmp/library/0/Artist\\ 2/"); - library :: update_path(0); - run_idle_tasks(); - library :: print_db(library :: DB_LIBRARY); - library :: print_db(library :: DB_TRACK); - print("\n"); - - print("6d: Regenerate Artist 2\n"); - fflush(stdout); - gen_library(); - fflush(stdout); - library :: update_all(); - run_idle_tasks(); - library :: print_db(library :: DB_TRACK); - print("\n"); -}*/ - -/* Test importing Ocarina 5.11 libraries */ -/*void test_7() -{ - library :: reset(); - - test_add_dir("7a", "/tmp/library/2", true); - - print("\n"); - library :: import(); - run_idle_tasks(); - library :: print_db(library :: DB_LIBRARY); - print("\n"); -}*/ - -/* Test disabling libraries */ -/*void test_8() -{ - library :: reset(); - - test_add_dir("8a", "/tmp/library/0", true); - print("\n"); - library :: set_enabled(0, false); - library :: print_db(library :: DB_LIBRARY); - library :: set_enabled(0, true); - library :: print_db(library :: DB_LIBRARY); - library :: set_enabled(0, false); - library :: print_db(library :: DB_LIBRARY); - library :: set_enabled(0, true); - library :: print_db(library :: DB_LIBRARY); -} - - -int main(int argc, char **argv) -{ - struct Callbacks *cb; - gen_library(); - - cb = get_callbacks(); - cb->on_library_add = library_added; - cb->on_library_update = library_updated; - - test_0(); - test_1(); - test_2(); - test_3(); - test_4(); - test_5(); - test_6(); - test_7(); - test_8(); - return 0; -}*/ diff --git a/tests/playlist.cpp b/tests/playlist.cpp index e81c59fb..c8763aa0 100644 --- a/tests/playlist.cpp +++ b/tests/playlist.cpp @@ -110,7 +110,7 @@ static void test_has() int main(int argc, char **argv) { - test :: cp_playlist(); + test :: cp_data_dir(); run_test("Playlist Initialization Test", test_init); run_test("Playlist Queue Test", test_queue); diff --git a/tests/queue.cpp b/tests/queue.cpp index 4bbb56c7..59da0f69 100644 --- a/tests/queue.cpp +++ b/tests/queue.cpp @@ -344,7 +344,7 @@ void test_saving() { TestQueue q(Q_RANDOM); TestQueue r(0); - File f("test.q"); + File f("test.q", 0); test_fill_q(&q); @@ -373,7 +373,7 @@ void test_saving() int main(int argc, char **argv) { - test :: cp_library(); + test :: cp_data_dir(); tagdb :: init(); run_test("Queue Default Constructor Test", test_default); diff --git a/tests/test.h b/tests/test.h index b37583f4..ea9dbd42 100644 --- a/tests/test.h +++ b/tests/test.h @@ -118,17 +118,10 @@ namespace test system(cmd.c_str()); } - void cp_library() + void cp_data_dir() { reset_data_dir(); - std::string cmd = "cp -r tests/Library/* " + data_dir(); - system(cmd.c_str()); - } - - void cp_playlist() - { - cp_library(); - std::string cmd = "cp -r tests/Playlist/* " + data_dir(); + std::string cmd = "cp -r tests/Data/* " + data_dir(); system(cmd.c_str()); }