diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/call.c | 64 | ||||
-rw-r--r-- | test/main.c | 1 | ||||
-rw-r--r-- | test/test.h | 1 |
3 files changed, 66 insertions, 0 deletions
diff --git a/test/call.c b/test/call.c index f3881c6..60af1b2 100644 --- a/test/call.c +++ b/test/call.c @@ -703,3 +703,67 @@ int test_call_video(void) return err; } #endif + + +static void mock_sample_handler(const int16_t *sampv, size_t sampc, void *arg) +{ + struct fixture *fix = arg; + bool got_aulevel; + (void)sampv; + (void)sampc; + + got_aulevel = + 0 == audio_level_get(call_audio(ua_call(fix->a.ua)), NULL) && + 0 == audio_level_get(call_audio(ua_call(fix->b.ua)), NULL); + + if (got_aulevel) + re_cancel(); +} + + +int test_call_aulevel(void) +{ + struct fixture fix, *f = &fix; + struct ausrc *ausrc = NULL; + struct auplay *auplay = NULL; + double lvl; + int err = 0; + + /* Use a low packet time, so the test completes quickly */ + fixture_init_prm(f, ";ptime=1"); + + conf_config()->audio.level = true; + + err = mock_ausrc_register(&ausrc); + TEST_ERR(err); + err = mock_auplay_register(&auplay, mock_sample_handler, f); + TEST_ERR(err); + + f->estab_action = ACTION_NOTHING; + + /* Make a call from A to B */ + err = ua_connect(f->a.ua, 0, NULL, f->buri, NULL, VIDMODE_OFF); + TEST_ERR(err); + + /* run main-loop with timeout, wait for events */ + err = re_main_timeout(5000); + TEST_ERR(err); + TEST_ERR(fix.err); + + /* verify audio silence */ + err = audio_level_get(call_audio(ua_call(f->a.ua)), &lvl); + TEST_ERR(err); + ASSERT_EQ(-96, lvl); + err = audio_level_get(call_audio(ua_call(f->b.ua)), &lvl); + TEST_ERR(err); + ASSERT_EQ(-96, lvl); + + out: + conf_config()->audio.level = false; + + fixture_close(f); + mem_deref(auplay); + mem_deref(ausrc); + + return err; +} diff --git a/test/main.c b/test/main.c index f443dcb..aa56420 100644 --- a/test/main.c +++ b/test/main.c @@ -33,6 +33,7 @@ static const struct test tests[] = { TEST(test_call_multiple), TEST(test_call_max), TEST(test_call_dtmf), + TEST(test_call_aulevel), #ifdef USE_VIDEO TEST(test_call_video), #endif diff --git a/test/test.h b/test/test.h index a68d61d..355d698 100644 --- a/test/test.h +++ b/test/test.h @@ -204,6 +204,7 @@ int test_call_multiple(void); int test_call_max(void); int test_call_dtmf(void); int test_call_video(void); +int test_call_aulevel(void); #ifdef __cplusplus |