2013-12-22 22:21:19 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#include <deck.h>
|
|
|
|
#include <print.h>
|
|
|
|
|
|
|
|
void test_add_playlist(unsigned int size)
|
|
|
|
{
|
|
|
|
Playlist *plist = deck :: create();
|
|
|
|
for (unsigned i = 0; i < size; i++)
|
|
|
|
plist->add(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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()
|
|
|
|
{
|
|
|
|
Playlist *plist;
|
|
|
|
print("Test 2: ");
|
|
|
|
|
|
|
|
plist = deck :: get(3);
|
|
|
|
print("Playlist { size = %u, flags = %u }", plist->size(), plist->get_flags());
|
|
|
|
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");
|
|
|
|
|
|
|
|
deck :: get(0)->unset_flag(PL_ENABLED);
|
|
|
|
deck :: get(1)->unset_flag(PL_ENABLED);
|
|
|
|
deck :: get(4)->unset_flag(PL_ENABLED);
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < 37; i++) {
|
|
|
|
try {
|
|
|
|
print("Playing id: %u\n", deck :: next());
|
|
|
|
if (i == 11 || i == 25)
|
|
|
|
deck :: print_info();
|
|
|
|
} catch (int error) {
|
|
|
|
print("No playable tracks!\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
deck :: print_info();
|
|
|
|
}
|
|
|
|
|
2013-12-22 22:21:19 -05:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
test_0();
|
|
|
|
test_1();
|
|
|
|
test_2();
|
|
|
|
test_3();
|
2013-12-23 10:22:37 -05:00
|
|
|
test_4();
|
2013-12-22 22:21:19 -05:00
|
|
|
return 0;
|
|
|
|
}
|