Remove the headers from the tests and put the class declarations in the cpp files.
[qtgstreamer:qtgstreamer.git] / tests / refpointertest.cpp
1 /*
2     Copyright (C) 2010  George Kiagiadakis <kiagiadakis.george@gmail.com>
3
4     This library is free software; you can redistribute it and/or modify
5     it under the terms of the GNU Lesser General Public License as published
6     by the Free Software Foundation; either version 2.1 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU Lesser General Public License
15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 #include "qgsttest.h"
18 #include <QGst/Object>
19
20 class RefPointerTest : public QGstTest
21 {
22     Q_OBJECT
23 private slots:
24     void refTest1();
25     void refTest2();
26     void dynamicCastTest();
27 };
28
29 void RefPointerTest::refTest1()
30 {
31     GstObject *bin = GST_OBJECT(gst_object_ref(GST_OBJECT(gst_bin_new(NULL))));
32     gst_object_sink(bin);
33     QGst::ObjectPtr object = QGst::ObjectPtr::wrap(bin, false);
34     QCOMPARE(GST_OBJECT_REFCOUNT_VALUE(bin), 1);
35 }
36
37 void RefPointerTest::refTest2()
38 {
39     GstObject *bin = GST_OBJECT(gst_object_ref(GST_OBJECT(gst_bin_new(NULL))));
40     gst_object_sink(bin);
41     {
42         QGst::ObjectPtr object = QGst::ObjectPtr::wrap(bin);
43         QCOMPARE(GST_OBJECT_REFCOUNT_VALUE(bin), 2);
44         {
45             QGst::ObjectPtr object2 = object;
46             QCOMPARE(GST_OBJECT_REFCOUNT_VALUE(bin), 3);
47         }
48     }
49     QCOMPARE(GST_OBJECT_REFCOUNT_VALUE(bin), 1);
50     gst_object_unref(bin);
51 }
52
53 void RefPointerTest::dynamicCastTest()
54 {
55     GstObject *bin = GST_OBJECT(gst_object_ref(GST_OBJECT(gst_bin_new(NULL))));
56     gst_object_sink(bin);
57
58     {
59         QGst::ObjectPtr object = QGst::ObjectPtr::wrap(bin);
60         QVERIFY(!object.dynamicCast<QGlib::Object>().isNull());
61     }
62
63     {
64         QGlib::ObjectPtr object = QGlib::ObjectPtr::wrap(G_OBJECT(bin));
65         QVERIFY(!object.dynamicCast<QGst::Object>().isNull());
66     }
67
68     gst_object_unref(bin);
69 }
70
71 QTEST_APPLESS_MAIN(RefPointerTest)
72
73 #include "moc_qgsttest.cpp"
74 #include "refpointertest.moc"