ocarina/tests/audio/audio.cpp

66 lines
1.2 KiB
C++

/*
* Copyright 2013 (c) Anna Schumaker.
*/
#include <audio.h>
#include <deck.h>
#include <library.h>
#include <print.h>
#include <stdlib.h>
#include <string>
#include <unistd.h>
void gen_library()
{
system("tests/library/gen_library.sh");
print("\n");
}
void check_ret(const std :: string &test, bool ret, bool expected)
{
print("Test %s: ", test.c_str());
if (ret == expected)
print("Success!\n");
else
print("Failed.\n");
}
/* Call various functions without a track loaded */
void test_0()
{
check_ret("0a", audio :: play(), false);
check_ret("0b", audio :: pause(), false);
check_ret("0c", audio :: seek_to(10), false);
check_ret("0d", audio :: next(), false);
print("\n");
}
void test_1()
{
check_ret("1a", audio :: next(), true);
check_ret("1b", audio :: play(), true);
check_ret("1c", audio :: pause(), true);
check_ret("1c", audio :: seek_to(10), true);
}
int main(int argc, char **argv)
{
Playlist *plist;
gen_library();
/* Initialize before testing */
audio :: init(&argc, &argv);
test_0();
/* Read in library, set up a playlist */
library :: add_path("/tmp/library/0");
plist = deck :: create();
for (unsigned int i = 0; i < 150; i++)
plist->add(i);
test_1();
return 0;
}