aboutsummaryrefslogtreecommitdiff
path: root/plugins/simtech/tests/test-modem-helpers-simtech.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2019-10-15 10:30:00 +0200
committerAleksander Morgado <aleksander@aleksander.es>2019-10-15 10:30:00 +0200
commit395b22178c4f6dd24d552e82d2d46dfb24c65297 (patch)
treeb2bfd84ac1fc1f23bf3c2455000d29a7b28ed236 /plugins/simtech/tests/test-modem-helpers-simtech.c
parent1a17996ccb3560c29e2a27c596ad0e9c7bbaaa61 (diff)
simtech: handle 'VOICE CALL' URCs
Just processing and parsing them for now, so that they don't interfere with other commands: $ sudo mmcli --call 1 --accept error: couldn't accept the call: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Failed: Couldn't accept the call: Unhandled response ' VOICE CALL: BEGIN''
Diffstat (limited to 'plugins/simtech/tests/test-modem-helpers-simtech.c')
-rw-r--r--plugins/simtech/tests/test-modem-helpers-simtech.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/simtech/tests/test-modem-helpers-simtech.c b/plugins/simtech/tests/test-modem-helpers-simtech.c
index a93d903a..3092e936 100644
--- a/plugins/simtech/tests/test-modem-helpers-simtech.c
+++ b/plugins/simtech/tests/test-modem-helpers-simtech.c
@@ -143,6 +143,56 @@ test_clcc_urc_complex (void)
/*****************************************************************************/
+static void
+common_test_voice_call_urc (const gchar *urc,
+ gboolean expected_start_or_stop,
+ guint expected_duration)
+{
+ GError *error = NULL;
+ gboolean start_or_stop = FALSE; /* start = TRUE, stop = FALSE */
+ guint duration = 0;
+ GRegex *voice_call_regex = NULL;
+ gboolean result;
+ GMatchInfo *match_info = NULL;
+
+ voice_call_regex = mm_simtech_get_voice_call_urc_regex ();
+
+ /* Same matching logic as done in MMSerialPortAt when processing URCs! */
+ result = g_regex_match_full (voice_call_regex, urc, -1, 0, 0, &match_info, &error);
+ g_assert_no_error (error);
+ g_assert (result);
+
+ result = mm_simtech_parse_voice_call_urc (match_info, &start_or_stop, &duration, &error);
+ g_assert_no_error (error);
+ g_assert (result);
+
+ g_assert_cmpuint (expected_start_or_stop, ==, start_or_stop);
+ g_assert_cmpuint (expected_duration, ==, duration);
+
+ g_match_info_free (match_info);
+ g_regex_unref (voice_call_regex);
+}
+
+static void
+test_voice_call_begin_urc (void)
+{
+ common_test_voice_call_urc ("\r\nVOICE CALL: BEGIN\r\n", TRUE, 0);
+}
+
+static void
+test_voice_call_end_urc (void)
+{
+ common_test_voice_call_urc ("\r\nVOICE CALL: END\r\n", FALSE, 0);
+}
+
+static void
+test_voice_call_end_duration_urc (void)
+{
+ common_test_voice_call_urc ("\r\nVOICE CALL: END: 000041\r\n", FALSE, 41);
+}
+
+/*****************************************************************************/
+
void
_mm_log (const char *loc,
const char *func,
@@ -173,5 +223,9 @@ int main (int argc, char **argv)
g_test_add_func ("/MM/simtech/clcc/urc/multiple", test_clcc_urc_multiple);
g_test_add_func ("/MM/simtech/clcc/urc/complex", test_clcc_urc_complex);
+ g_test_add_func ("/MM/simtech/voicecall/urc/begin", test_voice_call_begin_urc);
+ g_test_add_func ("/MM/simtech/voicecall/urc/end", test_voice_call_end_urc);
+ g_test_add_func ("/MM/simtech/voicecall/urc/end-duration", test_voice_call_end_duration_urc);
+
return g_test_run ();
}