2014-05-31 10:25:25 -04:00
|
|
|
/*
|
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
2014-06-05 10:19:22 -04:00
|
|
|
#include <core/driver.h>
|
2014-06-14 10:50:18 -04:00
|
|
|
#include <tests/test.h>
|
2014-05-31 10:25:25 -04:00
|
|
|
|
|
|
|
static unsigned int eos_count = 0;
|
2014-05-31 20:52:40 -04:00
|
|
|
static unsigned int error_count = 0;
|
2014-05-31 10:25:25 -04:00
|
|
|
|
|
|
|
void on_eos()
|
|
|
|
{
|
|
|
|
eos_count++;
|
|
|
|
}
|
|
|
|
|
2014-05-31 20:52:40 -04:00
|
|
|
void on_error()
|
|
|
|
{
|
|
|
|
error_count++;
|
|
|
|
}
|
|
|
|
|
2014-05-31 10:25:25 -04:00
|
|
|
void test_driver()
|
|
|
|
{
|
2014-12-19 14:19:18 -05:00
|
|
|
test_equal(driver :: get_driver(), (Driver *)NULL);
|
|
|
|
TestDriver driver;
|
|
|
|
|
2014-05-31 10:25:25 -04:00
|
|
|
const std::string file = "/home/Zelda/Music/Wind Waker/1 - Outset Isle.ogg";
|
|
|
|
|
2014-12-19 14:19:18 -05:00
|
|
|
test_not_equal(driver :: get_driver(), (Driver *)NULL);
|
|
|
|
test_equal((Driver *)&driver, driver :: get_driver());
|
2014-05-31 10:25:25 -04:00
|
|
|
|
2014-12-19 14:19:18 -05:00
|
|
|
driver.init(0, NULL, on_eos, on_error);
|
2014-05-31 10:25:25 -04:00
|
|
|
|
2014-12-19 14:19:18 -05:00
|
|
|
driver.load(file);
|
|
|
|
test_equal(driver.cur_file, file);
|
2014-05-31 10:25:25 -04:00
|
|
|
|
2014-12-19 14:19:18 -05:00
|
|
|
test_equal(driver.play(), true);
|
|
|
|
test_equal(driver.playing, true);
|
|
|
|
test_equal(driver.is_playing(), true);
|
2014-05-31 20:52:40 -04:00
|
|
|
|
2014-12-19 14:19:18 -05:00
|
|
|
test_equal(driver.pause(), true);
|
|
|
|
test_equal(driver.playing, false);
|
|
|
|
test_equal(driver.is_playing(), false);
|
2014-05-31 10:25:25 -04:00
|
|
|
|
2014-12-19 14:19:18 -05:00
|
|
|
driver.seek_to(4242);
|
|
|
|
test_equal(driver.cur_pos, (long)4242);
|
|
|
|
test_equal(driver.position(), (long)4242);
|
2014-05-31 10:25:25 -04:00
|
|
|
|
2014-12-19 14:19:18 -05:00
|
|
|
driver.cur_duration = 424242;
|
|
|
|
test_equal(driver.duration(), (long)424242);
|
2014-05-31 10:25:25 -04:00
|
|
|
|
2014-12-19 14:19:18 -05:00
|
|
|
driver.eos();
|
2014-05-31 10:25:25 -04:00
|
|
|
test_equal(eos_count, (unsigned)1);
|
2014-05-31 20:52:40 -04:00
|
|
|
|
2014-12-19 14:19:18 -05:00
|
|
|
driver.error();
|
2014-05-31 20:52:40 -04:00
|
|
|
test_equal(error_count, (unsigned)1);
|
2014-06-01 17:52:49 -04:00
|
|
|
|
2014-12-19 14:19:18 -05:00
|
|
|
driver.play();
|
|
|
|
driver.seek_to(4242);
|
|
|
|
driver.load(file);
|
|
|
|
test_equal(driver.is_playing(), false);
|
|
|
|
test_equal(driver.position(), (long)0);
|
2014-05-31 10:25:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
run_test("Test Audio Driver", test_driver);
|
|
|
|
return 0;
|
|
|
|
}
|