2 * This file is part of the Nice GLib ICE library.
4 * (C) 2016 Jakub Adam <jakub.adam@ktknet.cz>
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is the Nice GLib ICE library.
18 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
19 * Corporation. All Rights Reserved.
21 * Alternatively, the contents of this file may be used under the terms of the
22 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
23 * case the provisions of LGPL are applicable instead of those above. If you
24 * wish to allow use of your version of this file only under the terms of the
25 * LGPL and not to allow others to use your version of this file under the
26 * MPL, indicate your decision by deleting the provisions above and replace
27 * them with the notice and other provisions required by the LGPL. If you do
28 * not delete the provisions above, a recipient may use your version of this
29 * file under either the MPL or the LGPL.
36 #include <gio/gnetworking.h>
40 static NiceSocket *udp_bsd;
41 static NiceSocket *tcp_active;
42 static NiceSocket *pseudossl;
43 static NiceSocket *udp_turn_over_tcp;
46 socket_base_udp_bsd (void)
48 g_assert (nice_socket_is_based_on (udp_bsd, udp_bsd));
49 g_assert (!nice_socket_is_based_on (udp_bsd, tcp_active));
50 g_assert (!nice_socket_is_based_on (udp_bsd, pseudossl));
51 g_assert (!nice_socket_is_based_on (udp_bsd, udp_turn_over_tcp));
55 socket_base_tcp_active (void)
57 g_assert (!nice_socket_is_based_on (tcp_active, udp_bsd));
58 g_assert (nice_socket_is_based_on (tcp_active, tcp_active));
59 g_assert (!nice_socket_is_based_on (tcp_active, pseudossl));
60 g_assert (!nice_socket_is_based_on (tcp_active, udp_turn_over_tcp));
64 socket_base_pseudossl (void)
66 g_assert (!nice_socket_is_based_on (pseudossl, udp_bsd));
67 g_assert (nice_socket_is_based_on (pseudossl, tcp_active));
68 g_assert (nice_socket_is_based_on (pseudossl, pseudossl));
69 g_assert (!nice_socket_is_based_on (pseudossl, udp_turn_over_tcp));
73 socket_base_udp_turn_over_tcp (void)
75 g_assert (!nice_socket_is_based_on (udp_turn_over_tcp, udp_bsd));
76 g_assert (nice_socket_is_based_on (udp_turn_over_tcp, tcp_active));
77 g_assert (nice_socket_is_based_on (udp_turn_over_tcp, pseudossl));
78 g_assert (nice_socket_is_based_on (udp_turn_over_tcp, udp_turn_over_tcp));
82 main (int argc, char *argv[])
84 GMainLoop *mainloop = NULL;
90 setlocale (LC_ALL, "");
91 g_test_init (&argc, &argv, NULL);
93 mainloop = g_main_loop_new (NULL, TRUE);
95 nice_address_set_from_string (&addr, "127.0.0.1");
97 /* Standalone socket */
98 udp_bsd = nice_udp_bsd_socket_new (&addr);
100 /* tcp_passive -> pseudossl -> udp_turn_over_tcp */
101 tcp_active = nice_tcp_active_socket_new (g_main_loop_get_context (mainloop),
103 pseudossl = nice_pseudossl_socket_new (tcp_active,
104 NICE_PSEUDOSSL_SOCKET_COMPATIBILITY_GOOGLE);
105 udp_turn_over_tcp = nice_udp_turn_over_tcp_socket_new (pseudossl,
106 NICE_TURN_SOCKET_COMPATIBILITY_GOOGLE);
108 g_test_add_func ("/socket/is-base-of/udp-bsd",
109 socket_base_udp_bsd);
110 g_test_add_func ("/socket/is-base-of/tcp-active",
111 socket_base_tcp_active);
112 g_test_add_func ("/socket/is-base-of/pseudossl",
113 socket_base_pseudossl);
114 g_test_add_func ("/socket/is-base-of/udp-turn-over-tcp",
115 socket_base_udp_turn_over_tcp);
119 nice_socket_free (udp_bsd);
120 nice_socket_free (udp_turn_over_tcp);
122 g_main_loop_unref (mainloop);