static void lomo_state_change_cb(LomoPlayer *lomo) { LomoState state = lomo_player_get_state(lomo); switch (state) { case LOMO_STATE_PLAY: // Set checkpoint without acumulate set_checkpoint(lomo_player_get_position(lomo), FALSE); break; case LOMO_STATE_STOP: debug("stop signal, position may be 0"); case LOMO_STATE_PAUSE: // Add to counter secs from the last checkpoint set_checkpoint(lomo_player_get_position(lomo), TRUE); break; default: // Do nothing? debug("Unknow state. Be careful"); break; } }
static void lomo_seek_cb(LomoPlayer *lomo, gint64 from, gint64 to) { // Count from checkpoint to 'from' // Move checkpoint to 'to' without adding set_checkpoint(from, TRUE); set_checkpoint(to, FALSE); }
int run() { // for each testcase for (test_suite::const_iterator b = m_ts.begin(), e = m_ts.end(); b != e; ++b) { test_case const& tc = *b; set_checkpoint(tc.file, tc.func, tc.line); get_reporter().test_case_begin(); #ifndef TEST_HAS_NO_EXCEPTIONS try { #endif tc.invoke(); #ifndef TEST_HAS_NO_EXCEPTIONS } catch (...) { test_outcome o; o.type = failure_type::uncaught_exception; o.file = get_checkpoint().file; o.func = get_checkpoint().func; o.line = get_checkpoint().line; o.expression = ""; o.message = ""; get_reporter().report(o); } #endif get_reporter().test_case_end(); } auto exit_code = get_reporter().failure_count() ? EXIT_FAILURE : EXIT_SUCCESS; if (exit_code == EXIT_FAILURE) get_reporter().print_summary(m_ts.name()); return exit_code; }
static void lomo_eos_cb(LomoPlayer *lomo, EinaAdb *adb) { debug("Got EOS/PRE_CHANGE"); set_checkpoint(lomo_player_get_position(lomo), TRUE); if ((__markers.played >= 30) && (__markers.played >= (lomo_player_get_length(lomo) / 2)) && !__markers.submited) { debug("Submit to lastfm"); gint sid = eina_adb_lomo_stream_get_sid(adb, lomo_player_get_current_stream(lomo)); g_return_if_fail(sid >= 0); eina_adb_query_exec(adb, "UPDATE streams SET played = STRFTIME('%%s', 'NOW'), count = (count + 1) WHERE sid=%d;", sid); eina_adb_query_exec(adb, "INSERT INTO recent_plays (sid,timestamp) VALUES(%d,STRFTIME('%%s', 'NOW'))", sid); __markers.submited = TRUE; } else debug("Not enought to submit to lastfm"); }
int run() { // for each testcase for (auto & tc : m_ts) { set_checkpoint(tc.file, tc.func, tc.line); get_reporter().test_case_begin(); try { tc.invoke(); } catch (...) { test_outcome o; o.type = failure_type::uncaught_exception; o.file = get_checkpoint().file; o.func = get_checkpoint().func; o.line = get_checkpoint().line; o.expression = ""; o.message = ""; get_reporter().report(o); } get_reporter().test_case_end(); } get_reporter().print_summary(m_ts.name()); // return 0 if no failures, 1 otherwise. return get_reporter().failure_count() ? EXIT_FAILURE : EXIT_SUCCESS; }