Commit 360e6b9b authored by Youness Alaoui's avatar Youness Alaoui

Adapt the tests to the new API

darcs-hash:20080422163406-4f0f6-f7918de91cf672838ed1b700ea2507d62e898b54.gz
parent c92139c8
...@@ -60,7 +60,7 @@ main (void) ...@@ -60,7 +60,7 @@ main (void)
if (!nice_address_set_from_string (&addr, "127.0.0.1")) if (!nice_address_set_from_string (&addr, "127.0.0.1"))
g_assert_not_reached (); 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); nice_agent_add_local_address (agent, &addr);
g_assert (nice_agent_add_stream (agent, 1) == 1); g_assert (nice_agent_add_stream (agent, 1) == 1);
......
...@@ -236,6 +236,16 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress ...@@ -236,6 +236,16 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress
g_assert (ls_id > 0); g_assert (ls_id > 0);
g_assert (rs_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 /* step: run mainloop until local candidates are ready
* (see timer_cb() above) */ * (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE || if (global_lagent_gathering_done != TRUE ||
...@@ -343,12 +353,11 @@ int main (void) ...@@ -343,12 +353,11 @@ int main (void)
nice_udp_bsd_socket_factory_init (&udpfactory); nice_udp_bsd_socket_factory_init (&udpfactory);
/* step: create the agents L and R */ /* step: create the agents L and R */
lagent = nice_agent_new (&udpfactory); lagent = nice_agent_new (&udpfactory,
ragent = 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 */ /* step: add a timer to catch state changes triggered by signals */
timer_id = g_timeout_add (30000, timer_cb, NULL); timer_id = g_timeout_add (30000, timer_cb, NULL);
......
...@@ -225,7 +225,7 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas ...@@ -225,7 +225,7 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
global_ragent_gathering_done = FALSE; global_ragent_gathering_done = FALSE;
global_lagent_ibr_received = global_lagent_ibr_received =
global_ragent_ibr_received = FALSE; global_ragent_ibr_received = FALSE;
global_lagent_cands = global_lagent_cands =
global_ragent_cands = 0; global_ragent_cands = 0;
g_object_set (G_OBJECT (lagent), "controlling-mode", TRUE, NULL); 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 ...@@ -237,7 +237,17 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
g_assert (ls_id > 0); g_assert (ls_id > 0);
g_assert (rs_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) */ * (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE || if (global_lagent_gathering_done != TRUE ||
global_ragent_gathering_done != TRUE) { global_ragent_gathering_done != TRUE) {
...@@ -279,19 +289,19 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas ...@@ -279,19 +289,19 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
cdes.component_id = NICE_COMPONENT_TYPE_RTP; cdes.component_id = NICE_COMPONENT_TYPE_RTP;
cdes.addr = &raddr; cdes.addr = &raddr;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands); 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); nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.component_id = NICE_COMPONENT_TYPE_RTCP; cdes.component_id = NICE_COMPONENT_TYPE_RTCP;
cdes.addr = &raddr_rtcp; cdes.addr = &raddr_rtcp;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands); 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); nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands);
g_slist_free (cands); g_slist_free (cands);
g_debug ("test-fullmode: Set properties, next running mainloop until connectivity checks succeed..."); 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) */ * (see timer_cb() above) */
g_main_loop_run (global_mainloop); g_main_loop_run (global_mainloop);
...@@ -360,6 +370,16 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N ...@@ -360,6 +370,16 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N
g_assert (ls_id > 0); g_assert (ls_id > 0);
g_assert (rs_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 /* step: run mainloop until local candidates are ready
* (see timer_cb() above) */ * (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE || if (global_lagent_gathering_done != TRUE ||
...@@ -494,6 +514,12 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N ...@@ -494,6 +514,12 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N
g_assert (ls_id > 0); g_assert (ls_id > 0);
g_assert (rs_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 /* step: run mainloop until local candidates are ready
* (see timer_cb() above) */ * (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE || if (global_lagent_gathering_done != TRUE ||
...@@ -603,6 +629,12 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent, ...@@ -603,6 +629,12 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent,
g_assert (ls_id > 0); g_assert (ls_id > 0);
g_assert (rs_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 /* step: run mainloop until local candidates are ready
* (see timer_cb() above) */ * (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE || if (global_lagent_gathering_done != TRUE ||
...@@ -695,12 +727,10 @@ int main (void) ...@@ -695,12 +727,10 @@ int main (void)
nice_udp_bsd_socket_factory_init (&udpfactory); nice_udp_bsd_socket_factory_init (&udpfactory);
/* step: create the agents L and R */ /* step: create the agents L and R */
lagent = nice_agent_new (&udpfactory); lagent = nice_agent_new (&udpfactory,
ragent = nice_agent_new (&udpfactory); g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_ID19);
ragent = nice_agent_new (&udpfactory,
/* step: attach to mainloop (needed to register the fds) */ g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_ID19);
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 */ /* step: add a timer to catch state changes triggered by signals */
timer_id = g_timeout_add (30000, timer_cb, NULL); timer_id = g_timeout_add (30000, timer_cb, NULL);
......
...@@ -69,18 +69,23 @@ main (void) ...@@ -69,18 +69,23 @@ main (void)
NiceAgent *agent; NiceAgent *agent;
NiceAddress addr; NiceAddress addr;
NiceUDPSocketFactory factory; NiceUDPSocketFactory factory;
guint stream;
nice_address_init (&addr); nice_address_init (&addr);
g_type_init (); g_type_init ();
g_thread_init (NULL); g_thread_init (NULL);
loop = g_main_loop_new (NULL, FALSE);
nice_udp_fake_socket_factory_init (&factory); 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_address_set_ipv4 (&addr, 0x7f000001);
nice_agent_add_local_address (agent, &addr); 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 // 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; NiceUDPSocket *sock;
...@@ -95,7 +100,6 @@ main (void) ...@@ -95,7 +100,6 @@ main (void)
nice_udp_fake_socket_push_recv (sock, &addr, 6, "\x80hello"); nice_udp_fake_socket_push_recv (sock, &addr, 6, "\x80hello");
} }
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop); g_main_loop_run (loop);
g_object_unref (agent); g_object_unref (agent);
......
...@@ -88,7 +88,7 @@ main (void) ...@@ -88,7 +88,7 @@ main (void)
g_assert_not_reached (); g_assert_not_reached ();
nice_udp_fake_socket_factory_init (&factory); 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_local_address (agent, &addr);
nice_agent_add_stream (agent, 1); nice_agent_add_stream (agent, 1);
......
...@@ -58,7 +58,7 @@ main (void) ...@@ -58,7 +58,7 @@ main (void)
nice_udp_fake_socket_factory_init (&factory); nice_udp_fake_socket_factory_init (&factory);
/* set up agent */ /* 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")); g_assert (nice_address_set_from_string (&addr, "192.168.0.1"));
nice_agent_add_local_address (agent, &addr); nice_agent_add_local_address (agent, &addr);
nice_agent_add_stream (agent, 1); nice_agent_add_stream (agent, 1);
......
...@@ -233,6 +233,17 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress * ...@@ -233,6 +233,17 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
g_assert (ls_id > 0); g_assert (ls_id > 0);
g_assert (rs_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 /* step: run mainloop until local candidates are ready
* (see timer_cb() above) */ * (see timer_cb() above) */
if (global_lagent_gathering_done != TRUE || if (global_lagent_gathering_done != TRUE ||
...@@ -386,12 +397,11 @@ int main (void) ...@@ -386,12 +397,11 @@ int main (void)
nice_udp_bsd_socket_factory_init (&udpfactory); nice_udp_bsd_socket_factory_init (&udpfactory);
/* step: create the agents L and R */ /* step: create the agents L and R */
lagent = nice_agent_new (&udpfactory); lagent = nice_agent_new (&udpfactory,
ragent = 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 */ /* step: add a timer to catch state changes triggered by signals */
timer_id = g_timeout_add (30000, timer_cb, NULL); timer_id = g_timeout_add (30000, timer_cb, NULL);
......
...@@ -64,7 +64,7 @@ main (void) ...@@ -64,7 +64,7 @@ main (void)
g_assert (nice_address_set_from_string (&addr_remote, "192.168.0.2")); g_assert (nice_address_set_from_string (&addr_remote, "192.168.0.2"));
nice_address_set_port (&addr_remote, 2345); 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); g_assert (agent->local_addresses == NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment