2013-12-22 22:21:19 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#include <deck.h>
|
2014-01-04 11:21:05 -05:00
|
|
|
#include <idle.h>
|
|
|
|
#include <library.h>
|
2013-12-22 22:21:19 -05:00
|
|
|
#include <print.h>
|
|
|
|
|
|
|
|
void test_add_playlist(unsigned int size)
|
|
|
|
{
|
2014-01-30 22:54:15 -05:00
|
|
|
Playqueue *pqueue = deck :: create(false);
|
2013-12-22 22:21:19 -05:00
|
|
|
for (unsigned i = 0; i < size; i++)
|
2014-01-04 11:21:05 -05:00
|
|
|
pqueue->add(i);
|
2013-12-22 22:21:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Test creating a deck of playlists */
|
|
|
|
void test_0()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < 10; i++)
|
|
|
|
test_add_playlist(10 + i);
|
|
|
|
print("Test 0:\n");
|
|
|
|
deck :: print_info();
|
|
|
|
print("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test removing playlists from the deck */
|
|
|
|
void test_1()
|
|
|
|
{
|
|
|
|
print("Test 1:\n");
|
|
|
|
deck :: remove(3);
|
|
|
|
deck :: remove(7);
|
|
|
|
deck :: remove(1);
|
|
|
|
deck :: remove(5);
|
|
|
|
deck :: print_info();
|
|
|
|
print("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get a specific playlist from the deck */
|
|
|
|
void test_2()
|
|
|
|
{
|
2014-01-04 11:21:05 -05:00
|
|
|
Playqueue *pqueue;
|
2013-12-22 22:21:19 -05:00
|
|
|
print("Test 2: ");
|
|
|
|
|
2014-01-04 11:21:05 -05:00
|
|
|
pqueue = deck :: get(3);
|
|
|
|
print("Playqueue { size = %u, flags = %u }", pqueue->size(), pqueue->get_flags());
|
2013-12-22 22:21:19 -05:00
|
|
|
print("\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Move a playlist to a new position in the deck */
|
|
|
|
void test_3()
|
|
|
|
{
|
|
|
|
print("Test 3:\n");
|
|
|
|
deck :: move(4, 0);
|
|
|
|
deck :: print_info();
|
|
|
|
print("\n");
|
|
|
|
deck :: move(5, 1);
|
|
|
|
deck :: print_info();
|
|
|
|
print("\n");
|
|
|
|
deck :: move(2, 5);
|
|
|
|
deck :: print_info();
|
|
|
|
print("\n");
|
|
|
|
deck :: move(3, 4);
|
|
|
|
deck :: print_info();
|
|
|
|
print("\n");
|
|
|
|
deck :: move(4, 3);
|
|
|
|
deck :: print_info();
|
|
|
|
print("\n");
|
|
|
|
deck :: move(4, 4);
|
|
|
|
deck :: print_info();
|
|
|
|
print("\n");
|
|
|
|
}
|
|
|
|
|
2013-12-23 10:22:37 -05:00
|
|
|
/* Test the next() function for playlists */
|
|
|
|
void test_4()
|
|
|
|
{
|
|
|
|
print("Test 4:\n");
|
|
|
|
|
2014-01-04 11:21:05 -05:00
|
|
|
deck :: get(0)->unset_flag(PQ_ENABLED);
|
|
|
|
deck :: get(1)->unset_flag(PQ_ENABLED);
|
|
|
|
deck :: get(4)->unset_flag(PQ_ENABLED);
|
2013-12-23 10:22:37 -05:00
|
|
|
|
2014-01-16 22:25:04 -05:00
|
|
|
for (unsigned int i = 0; i < 40; i++) {
|
|
|
|
print("Playing id: %u\n", deck :: next());
|
|
|
|
if (i == 11 || i == 25)
|
|
|
|
deck :: print_info();
|
2013-12-23 10:22:37 -05:00
|
|
|
}
|
|
|
|
|
2013-12-23 10:37:22 -05:00
|
|
|
deck :: print_info();
|
|
|
|
print("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test load / save functions */
|
|
|
|
void test_5()
|
|
|
|
{
|
|
|
|
print("Test 5:\n");
|
|
|
|
|
2014-01-04 11:21:05 -05:00
|
|
|
deck :: get(1)->set_flag(PQ_ENABLED);
|
|
|
|
deck :: get(2)->set_flag(PQ_ENABLED);
|
|
|
|
deck :: get(2)->set_flag(PQ_RANDOM);
|
2013-12-23 10:37:22 -05:00
|
|
|
|
2014-01-04 11:21:05 -05:00
|
|
|
print("Saving playqueue deck\n");
|
2014-01-24 21:43:18 -05:00
|
|
|
deck :: write();
|
2013-12-23 10:37:22 -05:00
|
|
|
|
|
|
|
print("Clearing deck\n");
|
|
|
|
deck :: reset();
|
|
|
|
deck :: print_info();
|
|
|
|
|
2014-01-04 11:21:05 -05:00
|
|
|
print("Reading back playqueue deck\n");
|
2014-01-29 21:06:24 -05:00
|
|
|
deck :: init();
|
2013-12-23 10:37:22 -05:00
|
|
|
|
2013-12-23 10:22:37 -05:00
|
|
|
deck :: print_info();
|
|
|
|
}
|
|
|
|
|
2013-12-22 22:21:19 -05:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2014-01-04 11:21:05 -05:00
|
|
|
library :: init();
|
2014-01-22 19:35:47 -05:00
|
|
|
deck :: init();
|
2014-01-04 11:21:05 -05:00
|
|
|
library :: reset();
|
|
|
|
library :: add_path("/tmp/library/0");
|
|
|
|
while (idle :: run_task());
|
2014-01-16 22:25:04 -05:00
|
|
|
print("Library size: %u\n", deck :: get_library_pq()->size());
|
2014-01-04 11:21:05 -05:00
|
|
|
|
2013-12-22 22:21:19 -05:00
|
|
|
test_0();
|
|
|
|
test_1();
|
|
|
|
test_2();
|
|
|
|
test_3();
|
2013-12-23 10:22:37 -05:00
|
|
|
test_4();
|
2013-12-23 10:37:22 -05:00
|
|
|
test_5();
|
2014-01-16 22:25:04 -05:00
|
|
|
|
2014-01-18 12:32:41 -05:00
|
|
|
print("Disabling library path\n");
|
|
|
|
library :: set_enabled(0, false);
|
|
|
|
print("Library size: %u\n", deck :: get_library_pq()->size());
|
|
|
|
|
|
|
|
print("Enabling library path\n");
|
|
|
|
library :: set_enabled(0, true);
|
|
|
|
print("Library size: %u\n", deck :: get_library_pq()->size());
|
|
|
|
|
|
|
|
print("Deleting library path\n");
|
2014-01-16 22:25:04 -05:00
|
|
|
library :: del_path(0);
|
|
|
|
while (idle :: run_task());
|
|
|
|
print("Library size: %u\n", deck :: get_library_pq()->size());
|
|
|
|
|
2013-12-22 22:21:19 -05:00
|
|
|
return 0;
|
|
|
|
}
|