summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2019-05-08 16:40:10 -0400
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>2019-05-09 01:14:37 +0000
commit6171f2507992792fcee739f751fe469322e5a621 (patch)
treeb9a66d88cfb43faf72695e1e36c73d2ab547c9ca /tests
parente78a492314e4577d33966434708e17eb9e2e52a2 (diff)
downloadlibnice-6171f2507992792fcee739f751fe469322e5a621.tar.gz
agent: Replace closed signal with GASyncResult type function
This makes the API more GIO style
Diffstat (limited to 'tests')
-rw-r--r--tests/test-fullmode.c22
-rw-r--r--tests/test-turn.c24
2 files changed, 20 insertions, 26 deletions
diff --git a/tests/test-fullmode.c b/tests/test-fullmode.c
index d5aedb5..7c38330 100644
--- a/tests/test-fullmode.c
+++ b/tests/test-fullmode.c
@@ -130,8 +130,6 @@ static gboolean global_lagent_gathering_done = FALSE;
static gboolean global_ragent_gathering_done = FALSE;
static gboolean global_lagent_ibr_received = FALSE;
static gboolean global_ragent_ibr_received = FALSE;
-static gboolean global_lagent_closed = FALSE;
-static gboolean global_ragent_closed = FALSE;
static int global_lagent_cands = 0;
static int global_ragent_cands = 0;
static gint global_ragent_read = 0;
@@ -298,8 +296,10 @@ static void cb_initial_binding_request_received(NiceAgent *agent, guint stream_i
(void)agent; (void)stream_id; (void)data;
}
-static void cb_closed (NiceAgent *agent, gpointer data)
+static void cb_closed (GObject *src, GAsyncResult *result, gpointer data)
{
+ NiceAgent *agent = NICE_AGENT (src);
+
g_debug ("test-fullmode:%s: %p", G_STRFUNC, agent);
*((gboolean *)data) = TRUE;
@@ -862,6 +862,8 @@ int main (void)
int result;
guint timer_id;
const char *stun_server = NULL, *stun_server_port = NULL;
+ gboolean lagent_closed = FALSE;
+ gboolean ragent_closed = FALSE;
#ifdef G_OS_WIN32
WSADATA w;
@@ -933,10 +935,6 @@ int main (void)
g_signal_connect (G_OBJECT (ragent), "initial-binding-request-received",
G_CALLBACK (cb_initial_binding_request_received),
GUINT_TO_POINTER (2));
- g_signal_connect (G_OBJECT (lagent), "closed",
- G_CALLBACK (cb_closed), &global_lagent_closed);
- g_signal_connect (G_OBJECT (ragent), "closed",
- G_CALLBACK (cb_closed), &global_ragent_closed);
stun_server = getenv ("NICE_STUN_SERVER");
stun_server_port = getenv ("NICE_STUN_SERVER_PORT");
@@ -1112,15 +1110,15 @@ int main (void)
g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY);
g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY);
- nice_agent_close_async (lagent);
- nice_agent_close_async (ragent);
+ nice_agent_close_async (lagent, cb_closed, &lagent_closed);
+ nice_agent_close_async (ragent, cb_closed, &ragent_closed);
+ g_object_unref (lagent);
+ g_object_unref (ragent);
- while (!global_lagent_closed || !global_ragent_closed) {
+ while (!ragent_closed || !ragent_closed) {
g_main_context_iteration (NULL, TRUE);
}
- g_object_unref (lagent);
- g_object_unref (ragent);
g_main_loop_unref (global_mainloop);
global_mainloop = NULL;
diff --git a/tests/test-turn.c b/tests/test-turn.c
index 9a1e63f..8122d8e 100644
--- a/tests/test-turn.c
+++ b/tests/test-turn.c
@@ -10,8 +10,6 @@ static NiceComponentState global_ragent_state[2] = { NICE_COMPONENT_STATE_LAST,
static guint global_components_ready = 0;
static gboolean global_lagent_gathering_done = FALSE;
static gboolean global_ragent_gathering_done = FALSE;
-static gboolean global_lagent_closed = FALSE;
-static gboolean global_ragent_closed = FALSE;
static int global_lagent_cands = 0;
static int global_ragent_cands = 0;
@@ -103,8 +101,9 @@ static void cb_new_selected_pair(NiceAgent *agent, guint stream_id,
++global_ragent_cands;
}
-static void cb_closed (NiceAgent *agent, gpointer data)
+static void cb_closed (GObject *src, GAsyncResult *res, gpointer data)
{
+ NiceAgent *agent = NICE_AGENT (src);
g_debug ("test-turn:%s: %p", G_STRFUNC, agent);
*((gboolean *)data) = TRUE;
@@ -163,6 +162,8 @@ run_test(guint turn_port, gboolean is_ipv6,
NiceAddress localaddr;
guint ls_id, rs_id;
gulong timer_id;
+ gboolean lagent_closed = FALSE;
+ gboolean ragent_closed = FALSE;
if (is_ipv6)
localhost = "::1";
@@ -173,8 +174,6 @@ run_test(guint turn_port, gboolean is_ipv6,
global_components_ready = 0;
global_lagent_gathering_done = FALSE;
global_ragent_gathering_done = FALSE;
- global_lagent_closed = FALSE;
- global_ragent_closed = FALSE;
global_lagent_cands = global_ragent_cands = 0;
lagent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245);
@@ -210,10 +209,6 @@ run_test(guint turn_port, gboolean is_ipv6,
G_CALLBACK (cb_new_selected_pair), GUINT_TO_POINTER(1));
g_signal_connect (G_OBJECT (ragent), "new-selected-pair",
G_CALLBACK (cb_new_selected_pair), GUINT_TO_POINTER (2));
- g_signal_connect (G_OBJECT (lagent), "closed",
- G_CALLBACK (cb_closed), &global_lagent_closed);
- g_signal_connect (G_OBJECT (ragent), "closed",
- G_CALLBACK (cb_closed), &global_ragent_closed);
g_object_set (G_OBJECT (lagent), "controlling-mode", TRUE, NULL);
g_object_set (G_OBJECT (ragent), "controlling-mode", FALSE, NULL);
@@ -262,17 +257,18 @@ run_test(guint turn_port, gboolean is_ipv6,
nice_agent_remove_stream (lagent, ls_id);
nice_agent_remove_stream (ragent, rs_id);
- nice_agent_close_async (lagent);
- nice_agent_close_async (ragent);
+ nice_agent_close_async (lagent, cb_closed, &lagent_closed);
+ nice_agent_close_async (ragent, cb_closed, &ragent_closed);
- while (!global_lagent_closed || !global_ragent_closed) {
+ g_clear_object(&lagent);
+ g_clear_object(&ragent);
+
+ while (!lagent_closed || !ragent_closed) {
g_main_context_iteration (NULL, TRUE);
}
g_source_remove (timer_id);
- g_clear_object(&lagent);
- g_clear_object(&ragent);
}
guint global_turn_port;