2 * Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
4 * gstnettimeprovider.c: Unit test for the network time provider
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include <gst/check/gstcheck.h>
23 #include <gst/net/gstnet.h>
25 GST_START_TEST (test_refcounts)
27 GstNetTimeProvider *ntp;
30 clock = gst_system_clock_obtain ();
31 fail_unless (clock != NULL, "failed to get system clock");
33 /* one for gstreamer, one for us */
34 ASSERT_OBJECT_REFCOUNT (clock, "system clock", 2);
36 ntp = gst_net_time_provider_new (clock, NULL, -1);
37 fail_unless (ntp != NULL, "failed to create net time provider");
39 /* one for ntp, one for gstreamer, one for us */
40 ASSERT_OBJECT_REFCOUNT (clock, "system clock", 3);
42 ASSERT_OBJECT_REFCOUNT (ntp, "net time provider", 1);
44 gst_object_unref (ntp);
45 ASSERT_OBJECT_REFCOUNT (clock, "net time provider", 2);
47 gst_object_unref (clock);
53 GST_START_TEST (test_functioning)
55 GstNetTimeProvider *ntp;
58 clock = gst_system_clock_obtain ();
59 fail_unless (clock != NULL, "failed to get system clock");
60 ntp = gst_net_time_provider_new (clock, NULL, -1);
61 fail_unless (ntp != NULL, "failed to create net time provider");
65 gst_object_unref (ntp);
66 gst_object_unref (clock);
73 gst_net_time_provider_suite (void)
75 Suite *s = suite_create ("GstNetTimeProvider");
76 TCase *tc_chain = tcase_create ("generic tests");
78 tcase_set_timeout (tc_chain, 0);
80 suite_add_tcase (s, tc_chain);
81 tcase_add_test (tc_chain, test_refcounts);
87 main (int argc, char **argv)
91 Suite *s = gst_net_time_provider_suite ();
92 SRunner *sr = srunner_create (s);
94 gst_check_init (&argc, &argv);
96 srunner_run_all (sr, CK_NORMAL);
97 nf = srunner_ntests_failed (sr);