ocarina/tests/driver.cpp

66 lines
1.3 KiB
C++

/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/driver.h>
#include "test.h"
static TestDriver *DRIVER_NULL = NULL;
static unsigned int eos_count = 0;
static unsigned int error_count = 0;
void on_eos()
{
eos_count++;
}
void on_error()
{
error_count++;
}
void test_driver()
{
TestDriver *driver = (TestDriver *)driver :: get_driver();
const std::string file = "/home/Zelda/Music/Wind Waker/1 - Outset Isle.ogg";
test_not_equal(driver, DRIVER_NULL);
driver->init(0, NULL, on_eos, on_error);
driver->load(file);
test_equal(driver->cur_file, file);
test_equal(driver->play(), true);
test_equal(driver->playing, true);
test_equal(driver->is_playing(), true);
test_equal(driver->pause(), true);
test_equal(driver->playing, false);
test_equal(driver->is_playing(), false);
driver->seek_to(4242);
test_equal(driver->cur_pos, (long)4242);
test_equal(driver->position(), (long)4242);
driver->cur_duration = 424242;
test_equal(driver->duration(), (long)424242);
driver->eos();
test_equal(eos_count, (unsigned)1);
driver->error();
test_equal(error_count, (unsigned)1);
driver->play();
driver->seek_to(4242);
driver->load(file);
test_equal(driver->is_playing(), false);
test_equal(driver->position(), (long)0);
}
int main(int argc, char **argv)
{
run_test("Test Audio Driver", test_driver);
return 0;
}