2 * This file is part of the Nice GLib ICE library.
4 * (C) 2014 Collabora Ltd.
5 * Contact: Philip Withnall
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
17 * The Original Code is the Nice GLib ICE library.
19 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
20 * Corporation. All Rights Reserved.
23 * Philip Withnall, Collabora Ltd.
25 * Alternatively, the contents of this file may be used under the terms of the
26 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
27 * case the provisions of LGPL are applicable instead of those above. If you
28 * wish to allow use of your version of this file only under the terms of the
29 * LGPL and not to allow others to use your version of this file under the
30 * MPL, indicate your decision by deleting the provisions above and replace
31 * them with the notice and other provisions required by the LGPL. If you do
32 * not delete the provisions above, a recipient may use your version of this
33 * file under either the MPL or the LGPL.
40 #include "test-io-stream-common.h"
48 #define NUM_MESSAGES 10
55 read_thread_cb (GInputStream *input_stream, TestIOStreamThreadData *data)
61 guint8 buf[MESSAGE_SIZE];
63 /* Block on receiving some data. */
64 len = g_input_stream_read (input_stream, buf, sizeof (buf), NULL, &error);
65 g_assert_cmpint (len, ==, sizeof(buf));
67 g_mutex_lock (&count_lock);
69 g_cond_broadcast (&count_cond);
70 if (data->user_data) {
71 g_mutex_unlock (&count_lock);
76 g_cond_wait (&count_cond, &count_lock);
77 g_mutex_unlock (&count_lock);
79 /* Now we remove the stream, lets see how the writer handles that */
81 tmp = g_object_get_data (G_OBJECT (data->other->agent), "stream-id");
82 stream_id = GPOINTER_TO_UINT (tmp);
84 nice_agent_remove_stream (data->other->agent, stream_id);
88 write_thread_cb (GOutputStream *output_stream, TestIOStreamThreadData *data)
90 gchar buf[MESSAGE_SIZE] = {0};
94 g_mutex_lock (&count_lock);
96 g_cond_broadcast (&count_cond);
97 g_mutex_unlock (&count_lock);
100 g_assert_no_error (error);
101 ret = g_output_stream_write (output_stream, buf, sizeof (buf), NULL,
104 if (!data->user_data) {
105 g_assert_cmpint (ret, ==, sizeof (buf));
109 g_assert_cmpint (ret, ==, -1);
111 g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED);
112 g_clear_error (&error);
114 stop_main_loop (data->error_loop);
119 const TestIOStreamCallbacks callbacks = {
128 WSAStartup (0x0202, &w);
131 run_io_stream_test (30, TRUE, &callbacks, (gpointer) TRUE, NULL, NULL, NULL);