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 Lesser 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/Bin>
19 #include <QGst/ElementFactory>
20
21 class ChildProxyTest : public QGstTest
22 {
23 Q_OBJECT
24 private Q_SLOTS:
25 void inspectionTest();
26 void removeTest();
27 void propertiesTest();
28 };
29
inspectionTest()30 void ChildProxyTest::inspectionTest()
31 {
32 QGst::BinPtr bin = QGst::Bin::create();
33 QVERIFY(!bin.isNull());
34 QCOMPARE(bin->childrenCount(), static_cast<uint>(0));
35
36 QGst::ElementPtr tee = QGst::ElementFactory::make("tee", "mytee");
37 QVERIFY(!tee.isNull());
38 QCOMPARE(bin->add(tee), true);
39 QCOMPARE(bin->childrenCount(), static_cast<uint>(1));
40
41 {
42 QGst::ElementPtr tee2 = bin->childByIndex(0).dynamicCast<QGst::Element>();
43 QVERIFY(!tee2.isNull());
44 QCOMPARE(tee2->name(), QString("mytee"));
45 }
46
47 {
48 QGst::ElementPtr tee2 = bin->childByName("mytee").dynamicCast<QGst::Element>();
49 QVERIFY(!tee2.isNull());
50 QCOMPARE(tee2->name(), QString("mytee"));
51 }
52 }
53
removeTest()54 void ChildProxyTest::removeTest()
55 {
56 QGst::BinPtr bin = QGst::Bin::create();
57 QVERIFY(!bin.isNull());
58 QCOMPARE(bin->childrenCount(), static_cast<uint>(0));
59
60 QGst::ElementPtr tee = QGst::ElementFactory::make("tee", "mytee");
61 QVERIFY(!tee.isNull());
62 QCOMPARE(bin->add(tee), true);
63 QCOMPARE(bin->childrenCount(), static_cast<uint>(1));
64
65 QCOMPARE(bin->remove(tee), true);
66 QCOMPARE(bin->childrenCount(), static_cast<uint>(0));
67 }
68
propertiesTest()69 void ChildProxyTest::propertiesTest()
70 {
71 QGst::BinPtr bin = QGst::Bin::create();
72 QVERIFY(!bin.isNull());
73
74 QGst::ElementPtr tee = QGst::ElementFactory::make("tee", "mytee");
75 QVERIFY(!tee.isNull());
76 QCOMPARE(bin->add(tee), true);
77
78 {
79 QGlib::ObjectPtr obj;
80 QGlib::ParamSpecPtr param;
81 QCOMPARE(bin->findChildProperty("mytee::has-chain", &obj, ¶m), true);
82 QVERIFY(!obj.isNull());
83 QVERIFY(!param.isNull());
84 QCOMPARE(obj->property("name").get<QString>(), QString("mytee"));
85 QCOMPARE(param->name(), QString("has-chain"));
86 }
87
88 {
89 QGlib::Value v = bin->childProperty("mytee::has-chain");
90 QVERIFY(v.isValid());
91 QCOMPARE(v.type(), QGlib::Type(QGlib::Type::Boolean));
92 }
93 }
94
95
96 QTEST_APPLESS_MAIN(ChildProxyTest)
97
98 #include "moc_qgsttest.cpp"
99 #include "childproxytest.moc"
100