52695135e610052baf89e251a942e45f01003dca
[platform/upstream/gstreamer.git] / tests / check / libs / gstnettimeprovider.c
1 /* GStreamer
2  * Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
3  *
4  * gstnettimeprovider.c: Unit test for the network time provider
5  *
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.
10  *
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.
15  *
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.
20  */
21
22 #include <gst/check/gstcheck.h>
23 #include <gst/net/gstnet.h>
24
25 GST_START_TEST (test_refcounts)
26 {
27   GstNetTimeProvider *ntp;
28   GstClock *clock;
29
30   clock = gst_system_clock_obtain ();
31   fail_unless (clock != NULL, "failed to get system clock");
32
33   /* one for gstreamer, one for us */
34   ASSERT_OBJECT_REFCOUNT (clock, "system clock", 2);
35
36   ntp = gst_net_time_provider_new (clock, NULL, -1);
37   fail_unless (ntp != NULL, "failed to create net time provider");
38
39   /* one for ntp, one for gstreamer, one for us */
40   ASSERT_OBJECT_REFCOUNT (clock, "system clock", 3);
41   /* one for us */
42   ASSERT_OBJECT_REFCOUNT (ntp, "net time provider", 1);
43
44   gst_object_unref (ntp);
45   ASSERT_OBJECT_REFCOUNT (clock, "net time provider", 2);
46
47   gst_object_unref (clock);
48 }
49
50 GST_END_TEST;
51
52 #if 0
53 GST_START_TEST (test_functioning)
54 {
55   GstNetTimeProvider *ntp;
56   GstClock *clock;
57
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");
62
63
64
65   gst_object_unref (ntp);
66   gst_object_unref (clock);
67 }
68
69 GST_END_TEST;
70 #endif
71
72 Suite *
73 gst_net_time_provider_suite (void)
74 {
75   Suite *s = suite_create ("GstNetTimeProvider");
76   TCase *tc_chain = tcase_create ("generic tests");
77
78   tcase_set_timeout (tc_chain, 0);
79
80   suite_add_tcase (s, tc_chain);
81   tcase_add_test (tc_chain, test_refcounts);
82
83   return s;
84 }
85
86 int
87 main (int argc, char **argv)
88 {
89   int nf;
90
91   Suite *s = gst_net_time_provider_suite ();
92   SRunner *sr = srunner_create (s);
93
94   gst_check_init (&argc, &argv);
95
96   srunner_run_all (sr, CK_NORMAL);
97   nf = srunner_ntests_failed (sr);
98   srunner_free (sr);
99
100   return nf;
101 }