Commit 182b8526 authored by Olivier Crete's avatar Olivier Crete

Make the tests use the gather_candidates() api and make them pass.

darcs-hash:20080426010239-3e2dc-2439c01282eb42a9c545d22bdda11220eac655fe.gz
parent 2a07eb44
...@@ -232,6 +232,9 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress ...@@ -232,6 +232,9 @@ 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);
nice_agent_gather_candidates (lagent, ls_id);
nice_agent_gather_candidates (ragent, rs_id);
/* step: attach to mainloop (needed to register the fds) */ /* step: attach to mainloop (needed to register the fds) */
nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1); g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
...@@ -355,6 +358,7 @@ int main (void) ...@@ -355,6 +358,7 @@ int main (void)
g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_ID19); g_main_loop_get_context (global_mainloop), NICE_COMPATIBILITY_ID19);
/* 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);
......
...@@ -243,6 +243,9 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas ...@@ -243,6 +243,9 @@ 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);
nice_agent_gather_candidates (lagent, ls_id);
nice_agent_gather_candidates (ragent, rs_id);
/* step: attach to mainloop (needed to register the fds) */ /* step: attach to mainloop (needed to register the fds) */
nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1); g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
...@@ -370,6 +373,9 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N ...@@ -370,6 +373,9 @@ 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);
nice_agent_gather_candidates (lagent, ls_id);
nice_agent_gather_candidates (ragent, rs_id);
/* step: attach to mainloop (needed to register the fds) */ /* step: attach to mainloop (needed to register the fds) */
nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1); g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
...@@ -508,6 +514,9 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N ...@@ -508,6 +514,9 @@ 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);
nice_agent_gather_candidates (lagent, ls_id);
nice_agent_gather_candidates (ragent, rs_id);
/* step: attach to mainloop (needed to register the fds) */ /* step: attach to mainloop (needed to register the fds) */
nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1); g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
...@@ -617,6 +626,9 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent, ...@@ -617,6 +626,9 @@ 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);
nice_agent_gather_candidates (lagent, ls_id);
nice_agent_gather_candidates (ragent, rs_id);
/* step: attach to mainloop (needed to register the fds) */ /* step: attach to mainloop (needed to register the fds) */
nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1); g_main_loop_get_context (global_mainloop), cb_nice_recv, (gpointer)1);
......
...@@ -82,6 +82,7 @@ main (void) ...@@ -82,6 +82,7 @@ main (void)
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);
stream = nice_agent_add_stream (agent, 1); stream = nice_agent_add_stream (agent, 1);
nice_agent_gather_candidates (agent, stream);
// attach to default main context // attach to default main context
nice_agent_attach_recv (agent, stream, NICE_COMPONENT_TYPE_RTP, nice_agent_attach_recv (agent, stream, NICE_COMPONENT_TYPE_RTP,
......
...@@ -77,6 +77,7 @@ main (void) ...@@ -77,6 +77,7 @@ main (void)
GSList *fds = NULL; GSList *fds = NULL;
GSList *readable; GSList *readable;
ssize_t w; ssize_t w;
guint stream_id;
nice_address_init (&addr); nice_address_init (&addr);
g_type_init (); g_type_init ();
...@@ -90,13 +91,14 @@ main (void) ...@@ -90,13 +91,14 @@ main (void)
nice_udp_fake_socket_factory_init (&factory); nice_udp_fake_socket_factory_init (&factory);
agent = nice_agent_new (&factory, NULL, NICE_COMPATIBILITY_ID19); 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); stream_id = nice_agent_add_stream (agent, 1);
nice_agent_gather_candidates (agent, stream_id);
{ {
GSList *candidates; GSList *candidates;
NiceCandidate *candidate; NiceCandidate *candidate;
candidates = nice_agent_get_local_candidates (agent, 1, 1); candidates = nice_agent_get_local_candidates (agent, stream_id, 1);
candidate = candidates->data; candidate = candidates->data;
sock = candidate->sockptr; sock = candidate->sockptr;
g_slist_free (candidates); g_slist_free (candidates);
......
...@@ -50,6 +50,7 @@ main (void) ...@@ -50,6 +50,7 @@ main (void)
NiceAgent *agent; NiceAgent *agent;
NiceAddress addr; NiceAddress addr;
NiceUDPSocketFactory factory; NiceUDPSocketFactory factory;
guint stream_id;
nice_address_init (&addr); nice_address_init (&addr);
g_type_init (); g_type_init ();
...@@ -61,7 +62,8 @@ main (void) ...@@ -61,7 +62,8 @@ main (void)
agent = nice_agent_new (&factory, NULL, NICE_COMPATIBILITY_ID19); 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); stream_id = nice_agent_add_stream (agent, 1);
nice_agent_gather_candidates (agent, stream_id);
/* recieve an RTP packet */ /* recieve an RTP packet */
...@@ -72,12 +74,12 @@ main (void) ...@@ -72,12 +74,12 @@ main (void)
gchar buf[1024]; gchar buf[1024];
GSList *candidates; GSList *candidates;
candidates = nice_agent_get_local_candidates (agent, 1, 1); candidates = nice_agent_get_local_candidates (agent, stream_id, 1);
candidate = candidates->data; candidate = candidates->data;
g_slist_free (candidates); g_slist_free (candidates);
sock = candidate->sockptr; sock = candidate->sockptr;
nice_udp_fake_socket_push_recv (sock, &addr, 7, "\x80lalala"); nice_udp_fake_socket_push_recv (sock, &addr, 7, "\x80lalala");
len = nice_agent_recv (agent, candidate->stream_id, len = nice_agent_recv (agent, stream_id,
candidate->component_id, 1024, buf); candidate->component_id, 1024, buf);
g_assert (len == 7); g_assert (len == 7);
g_assert (0 == strncmp (buf, "\x80lalala", 7)); g_assert (0 == strncmp (buf, "\x80lalala", 7));
......
...@@ -231,6 +231,8 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress * ...@@ -231,6 +231,8 @@ 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);
nice_agent_gather_candidates (lagent, ls_id);
nice_agent_gather_candidates (ragent, rs_id);
/* step: attach to mainloop (needed to register the fds) */ /* step: attach to mainloop (needed to register the fds) */
nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, nice_agent_attach_recv (lagent, ls_id, NICE_COMPONENT_TYPE_RTP,
......
...@@ -52,6 +52,7 @@ main (void) ...@@ -52,6 +52,7 @@ main (void)
NiceCandidate *candidate; NiceCandidate *candidate;
NiceUDPSocketFactory factory; NiceUDPSocketFactory factory;
GSList *candidates; GSList *candidates;
guint stream_id;
nice_address_init (&addr_local); nice_address_init (&addr_local);
nice_address_init (&addr_remote); nice_address_init (&addr_remote);
...@@ -76,10 +77,11 @@ main (void) ...@@ -76,10 +77,11 @@ main (void)
g_assert (nice_address_equal (agent->local_addresses->data, &addr_local)); g_assert (nice_address_equal (agent->local_addresses->data, &addr_local));
/* add a stream */ /* add a stream */
nice_agent_add_stream (agent, 1); stream_id = nice_agent_add_stream (agent, 1);
nice_agent_gather_candidates (agent, stream_id);
/* adding a stream should cause host candidates to be generated */ /* adding a stream should cause host candidates to be generated */
candidates = nice_agent_get_local_candidates (agent, 1, 1); candidates = nice_agent_get_local_candidates (agent, stream_id, 1);
g_assert (g_slist_length (candidates) == 1); g_assert (g_slist_length (candidates) == 1);
candidate = candidates->data; candidate = candidates->data;
/* fake socket manager uses incremental port numbers starting at 1 */ /* fake socket manager uses incremental port numbers starting at 1 */
...@@ -89,14 +91,15 @@ main (void) ...@@ -89,14 +91,15 @@ main (void)
g_slist_free (candidates); g_slist_free (candidates);
/* add remote candidate */ /* add remote candidate */
nice_agent_add_remote_candidate (agent, 1, 1, NICE_CANDIDATE_TYPE_HOST, nice_agent_add_remote_candidate (agent, stream_id, 1,
NICE_CANDIDATE_TYPE_HOST,
&addr_remote, "username", "password"); &addr_remote, "username", "password");
candidates = nice_agent_get_remote_candidates (agent, 1, 1); candidates = nice_agent_get_remote_candidates (agent, stream_id, 1);
g_assert (candidates != NULL); g_assert (candidates != NULL);
g_assert (g_slist_length (candidates) == 1); g_assert (g_slist_length (candidates) == 1);
candidate = candidates->data; candidate = candidates->data;
g_assert (nice_address_equal (&(candidate->addr), &addr_remote)); g_assert (nice_address_equal (&(candidate->addr), &addr_remote));
g_assert (candidate->stream_id == 1); g_assert (candidate->stream_id == stream_id);
g_assert (candidate->component_id == 1); g_assert (candidate->component_id == 1);
g_assert (candidate->type == NICE_CANDIDATE_TYPE_HOST); g_assert (candidate->type == NICE_CANDIDATE_TYPE_HOST);
g_assert (0 == strcmp (candidate->username, "username")); g_assert (0 == strcmp (candidate->username, "username"));
......
...@@ -14,8 +14,8 @@ nice_address_to_string ...@@ -14,8 +14,8 @@ nice_address_to_string
nice_agent_add_local_address nice_agent_add_local_address
nice_agent_add_remote_candidate nice_agent_add_remote_candidate
nice_agent_add_stream nice_agent_add_stream
nice_agent_gather_candidates
nice_agent_attach_recv nice_agent_attach_recv
nice_agent_gather_candidates
nice_agent_get_local_candidates nice_agent_get_local_candidates
nice_agent_get_local_credentials nice_agent_get_local_credentials
nice_agent_get_remote_candidates nice_agent_get_remote_candidates
......
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