/* * Copyright 2014 (c) Anna Schumaker. */ #include #include 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() { test_equal(driver :: get_driver(), (Driver *)NULL); TestDriver driver; const std::string file = "/home/Zelda/Music/Wind Waker/1 - Outset Isle.ogg"; test_not_equal(driver :: get_driver(), (Driver *)NULL); test_equal((Driver *)&driver, driver :: get_driver()); 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; }