From 030313d42ec8b0447429788ecb55c36754f7ea77 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Thu, 18 Mar 2021 20:29:55 +0100 Subject: [PATCH] test: Add basic SIP provider tests --- tests/meson.build | 17 +++++++++++++ tests/test-sip.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 tests/test-sip.c diff --git a/tests/meson.build b/tests/meson.build index 8d94c29..678ae47 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -88,4 +88,21 @@ t = executable('plugins', test_sources, ) test('plugins', t, env: test_env) +test_sources = [ 'test-sip.c' ] +t = executable('sip', test_sources, + calls_sources, sip_sources, + calls_enum_sources, calls_resources, + wl_proto_sources, wayland_sources, + c_args : test_cflags_with_test_define, + link_args: test_link_args, + link_with : calls_vala, + dependencies: [calls_deps, sip_deps], + include_directories : [ + calls_includes, + dummy_include, + sip_include, + ] + ) +test('sip', t, env: test_env) + endif diff --git a/tests/test-sip.c b/tests/test-sip.c new file mode 100644 index 0000000..032a19b --- /dev/null +++ b/tests/test-sip.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2018 Purism SPC + * + * SPDX-License-Identifier: GPL-3.0+ + * + * Author: Evangelos Ribeiro Tzaras + */ + +#include "calls-sip-provider.h" +#include "calls-sip-util.h" + +#include +#include + +typedef struct { + CallsSipProvider *provider; +} SipFixture; + +static void +test_sip_provider_object (SipFixture *fixture, + gconstpointer user_data) +{ + SipEngineState state; + + g_assert_true (G_IS_OBJECT (fixture->provider)); + g_assert_true (CALLS_IS_MESSAGE_SOURCE (fixture->provider)); + g_assert_true (CALLS_IS_PROVIDER (fixture->provider)); + g_assert_true (CALLS_IS_SIP_PROVIDER (fixture->provider)); + + g_object_get (fixture->provider, + "sip-state", &state, + NULL); + g_assert_true (state == SIP_ENGINE_READY); +} + +static void +setup_sip (SipFixture *fixture, + gconstpointer user_data) +{ + fixture->provider = calls_sip_provider_new (); +} + +static void +tear_down_sip (SipFixture *fixture, + gconstpointer user_data) +{ + g_clear_object (&fixture->provider); +} + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + + /* this is a workaround for an issue with sofia: https://github.com/freeswitch/sofia-sip/issues/58 */ + su_random64 (); + + g_test_add ("/Calls/SIP/object", SipFixture, NULL, + setup_sip, test_sip_provider_object, tear_down_sip); + + return g_test_run(); +}