tests: Move sample files into the Data/ directory
Keeping separate directories for all of these files isn't the most obvious way to do things. Instead, move everything into the same directory. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
a96e6f6f2d
commit
a385727206
|
@ -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()
|
||||
|
|
|
@ -9,3 +9,4 @@ random
|
|||
queue
|
||||
library
|
||||
playlist
|
||||
deck
|
||||
|
|
|
@ -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, [], []),
|
||||
|
||||
]
|
||||
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
/*
|
||||
* Copyright 2013 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <deck.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*#include <deck.h>
|
||||
#include <idle.h>
|
||||
#include <library.h>
|
||||
#include <print.h>
|
||||
|
@ -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;
|
||||
}
|
||||
}*/
|
|
@ -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 <callback.h>
|
||||
#include <idle.h>
|
||||
#include <library.h>
|
||||
#include <print.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
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;
|
||||
}*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
11
tests/test.h
11
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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue