[Nice] [nice/master] Adapt the tests to the new API
Youness Alaoui
youness.alaoui at collabora.co.uk
Wed Nov 5 14:01:00 PST 2008
darcs-hash:20080422163406-4f0f6-f7918de91cf672838ed1b700ea2507d62e898b54.gz
---
agent/test-add-remove-stream.c | 2 +-
agent/test-fallback.c | 19 ++++++++++----
agent/test-fullmode.c | 52 +++++++++++++++++++++++++++++++--------
agent/test-mainloop.c | 12 ++++++---
agent/test-poll.c | 2 +-
agent/test-recv.c | 2 +-
agent/test-restart.c | 20 +++++++++++----
agent/test.c | 2 +-
8 files changed, 82 insertions(+), 29 deletions(-)
diff --git a/agent/test-add-remove-stream.c b/agent/test-add-remove-stream.c
index ff06c2a..c716921 100644
--- a/agent/test-add-remove-stream.c
+++ b/agent/test-add-remove-stream.c
@@ -60,7 +60,7 @@ main (void)
if (!nice_address_set_from_string (&addr, "127.0.0.1"))
g_assert_not_reached ();
- agent = nice_agent_new (&factory);
+ agent = nice_agent_new (&factory, NULL, NICE_COMPATIBILITY_ID19);
nice_agent_add_local_address (agent, &addr);
g_assert (nice_agent_add_stream (agent, 1) == 1);
diff --git a/agent/test-fallback.c b/agent/test-fallback.c
index 4b1366a..1b2018a 100644
--- a/agent/test-fallback.c
+++ b/agent/test-fallback.c
@@ -236,6 +236,16 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress
g_assert (ls_id > 0);
g_assert (rs_id > 0);
+ /* step: attach to mainloop (needed to register the fds) */
+ nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
+ nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
+ nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
+ nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
+
/* step: run mainloop until local candidates are ready
* (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE ||
@@ -343,12 +353,11 @@ int main (void)
nice_udp_bsd_socket_factory_init (&udpfactory);
/* step: create the agents L and R */
- lagent = nice_agent_new (&udpfactory);
- ragent = nice_agent_new (&udpfactory);
+ lagent = nice_agent_new (&udpfactory,
+ g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_ID19);
+ ragent = nice_agent_new (&udpfactory,
+ g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_ID19);
- /* step: attach to mainloop (needed to register the fds) */
- nice_agent_main_context_attach (lagent, g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
- nice_agent_main_context_attach (ragent, g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
/* step: add a timer to catch state changes triggered by signals */
timer_id = g_timeout_add (30000, timer_cb, NULL);
diff --git a/agent/test-fullmode.c b/agent/test-fullmode.c
index 241335d..e4e7241 100644
--- a/agent/test-fullmode.c
+++ b/agent/test-fullmode.c
@@ -225,7 +225,7 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
global_ragent_gathering_done = FALSE;
global_lagent_ibr_received =
global_ragent_ibr_received = FALSE;
- global_lagent_cands =
+ global_lagent_cands =
global_ragent_cands = 0;
g_object_set (G_OBJECT (lagent), "controlling-mode", TRUE, NULL);
@@ -237,7 +237,17 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
g_assert (ls_id > 0);
g_assert (rs_id > 0);
- /* step: run mainloop until local candidates are ready
+ /* step: attach to mainloop (needed to register the fds) */
+ nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
+ nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
+ nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
+ nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
+
+ /* step: run mainloop until local candidates are ready
* (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE ||
global_ragent_gathering_done != TRUE) {
@@ -279,19 +289,19 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
cdes.component_id = NICE_COMPONENT_TYPE_RTP;
cdes.addr = &raddr;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
- cdes.addr = &laddr;
+ cdes.addr = &laddr;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.component_id = NICE_COMPONENT_TYPE_RTCP;
cdes.addr = &raddr_rtcp;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands);
- cdes.addr = &laddr_rtcp;
+ cdes.addr = &laddr_rtcp;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands);
g_slist_free (cands);
g_debug ("test-fullmode: Set properties, next running mainloop until connectivity checks succeed...");
- /* step: run the mainloop until connectivity checks succeed
+ /* step: run the mainloop until connectivity checks succeed
* (see timer_cb() above) */
g_main_loop_run (global_mainloop);
@@ -360,6 +370,16 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N
g_assert (ls_id > 0);
g_assert (rs_id > 0);
+ /* step: attach to mainloop (needed to register the fds) */
+ nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
+ nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
+ nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
+ nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
+
/* step: run mainloop until local candidates are ready
* (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE ||
@@ -494,6 +514,12 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N
g_assert (ls_id > 0);
g_assert (rs_id > 0);
+ /* step: attach to mainloop (needed to register the fds) */
+ nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
+ nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
+
/* step: run mainloop until local candidates are ready
* (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE ||
@@ -603,6 +629,12 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent,
g_assert (ls_id > 0);
g_assert (rs_id > 0);
+ /* step: attach to mainloop (needed to register the fds) */
+ nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
+ nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
+
/* step: run mainloop until local candidates are ready
* (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE ||
@@ -695,12 +727,10 @@ int main (void)
nice_udp_bsd_socket_factory_init (&udpfactory);
/* step: create the agents L and R */
- lagent = nice_agent_new (&udpfactory);
- ragent = nice_agent_new (&udpfactory);
-
- /* step: attach to mainloop (needed to register the fds) */
- nice_agent_main_context_attach (lagent, g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
- nice_agent_main_context_attach (ragent, g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
+ lagent = nice_agent_new (&udpfactory,
+ g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_ID19);
+ ragent = nice_agent_new (&udpfactory,
+ g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_ID19);
/* step: add a timer to catch state changes triggered by signals */
timer_id = g_timeout_add (30000, timer_cb, NULL);
diff --git a/agent/test-mainloop.c b/agent/test-mainloop.c
index 827db76..679958e 100644
--- a/agent/test-mainloop.c
+++ b/agent/test-mainloop.c
@@ -69,18 +69,23 @@ main (void)
NiceAgent *agent;
NiceAddress addr;
NiceUDPSocketFactory factory;
+ guint stream;
nice_address_init (&addr);
g_type_init ();
g_thread_init (NULL);
+ loop = g_main_loop_new (NULL, FALSE);
nice_udp_fake_socket_factory_init (&factory);
- agent = nice_agent_new (&factory);
+ agent = nice_agent_new (&factory,
+ g_main_loop_get_context (loop), NICE_COMPATIBILITY_ID19);
nice_address_set_ipv4 (&addr, 0x7f000001);
nice_agent_add_local_address (agent, &addr);
- nice_agent_add_stream (agent, 1);
+ stream = nice_agent_add_stream (agent, 1);
+
// attach to default main context
- nice_agent_main_context_attach (agent, NULL, recv_cb, GUINT_TO_POINTER (42));
+ nice_agent_attach_recv (agent, stream, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (loop), recv_cb, GUINT_TO_POINTER (42));
{
NiceUDPSocket *sock;
@@ -95,7 +100,6 @@ main (void)
nice_udp_fake_socket_push_recv (sock, &addr, 6, "\x80hello");
}
- loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
g_object_unref (agent);
diff --git a/agent/test-poll.c b/agent/test-poll.c
index be5fd39..e791bcc 100644
--- a/agent/test-poll.c
+++ b/agent/test-poll.c
@@ -88,7 +88,7 @@ main (void)
g_assert_not_reached ();
nice_udp_fake_socket_factory_init (&factory);
- agent = nice_agent_new (&factory);
+ agent = nice_agent_new (&factory, NULL, NICE_COMPATIBILITY_ID19);
nice_agent_add_local_address (agent, &addr);
nice_agent_add_stream (agent, 1);
diff --git a/agent/test-recv.c b/agent/test-recv.c
index 7636bf5..f3ece08 100644
--- a/agent/test-recv.c
+++ b/agent/test-recv.c
@@ -58,7 +58,7 @@ main (void)
nice_udp_fake_socket_factory_init (&factory);
/* set up agent */
- agent = nice_agent_new (&factory);
+ agent = nice_agent_new (&factory, NULL, NICE_COMPATIBILITY_ID19);
g_assert (nice_address_set_from_string (&addr, "192.168.0.1"));
nice_agent_add_local_address (agent, &addr);
nice_agent_add_stream (agent, 1);
diff --git a/agent/test-restart.c b/agent/test-restart.c
index 821a366..acb801e 100644
--- a/agent/test-restart.c
+++ b/agent/test-restart.c
@@ -233,6 +233,17 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
g_assert (ls_id > 0);
g_assert (rs_id > 0);
+
+ /* step: attach to mainloop (needed to register the fds) */
+ nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
+ nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
+ nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
+ nice_agent_attach_recv (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP,
+ g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
+
/* step: run mainloop until local candidates are ready
* (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE ||
@@ -386,12 +397,11 @@ int main (void)
nice_udp_bsd_socket_factory_init (&udpfactory);
/* step: create the agents L and R */
- lagent = nice_agent_new (&udpfactory);
- ragent = nice_agent_new (&udpfactory);
+ lagent = nice_agent_new (&udpfactory,
+ g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_ID19);
+ ragent = nice_agent_new (&udpfactory,
+ g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_ID19);
- /* step: attach to mainloop (needed to register the fds) */
- nice_agent_main_context_attach (lagent, g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
- nice_agent_main_context_attach (ragent, g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)2);
/* step: add a timer to catch state changes triggered by signals */
timer_id = g_timeout_add (30000, timer_cb, NULL);
diff --git a/agent/test.c b/agent/test.c
index dd5eb2f..171faad 100644
--- a/agent/test.c
+++ b/agent/test.c
@@ -64,7 +64,7 @@ main (void)
g_assert (nice_address_set_from_string (&addr_remote, "192.168.0.2"));
nice_address_set_port (&addr_remote, 2345);
- agent = nice_agent_new (&factory);
+ agent = nice_agent_new (&factory, NULL, NICE_COMPATIBILITY_ID19);
g_assert (agent->local_addresses == NULL);
--
1.5.6.5
More information about the Nice
mailing list