summaryrefslogtreecommitdiff
path: root/tests/auto/refpointertest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/refpointertest.cpp')
-rw-r--r--tests/auto/refpointertest.cpp112
1 files changed, 110 insertions, 2 deletions
diff --git a/tests/auto/refpointertest.cpp b/tests/auto/refpointertest.cpp
index 206922c..bbb28ff 100644
--- a/tests/auto/refpointertest.cpp
+++ b/tests/auto/refpointertest.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
+ Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
Copyright (C) 2010 Collabora Ltd.
@author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
@@ -18,9 +18,11 @@
*/
#include "qgsttest.h"
#include <QGst/Object>
-#include <QGst/Bin>
#include <QGst/Message>
#include <QGst/Pipeline>
+#include <QGst/ElementFactory>
+#include <QGst/UriHandler>
+#include <QGst/StreamVolume>
class RefPointerTest : public QGstTest
{
@@ -29,6 +31,11 @@ private Q_SLOTS:
void refTest1();
void refTest2();
void dynamicCastTest();
+ void dynamicCastDownObjectTest();
+ void dynamicCastUpObjectTest();
+ void dynamicCastObjectToIfaceTest();
+ void dynamicCastIfaceToObjectTest();
+ void cppWrappersTest();
void messageDynamicCastTest();
void equalityTest();
};
@@ -75,6 +82,107 @@ void RefPointerTest::dynamicCastTest()
gst_object_unref(bin);
}
+void RefPointerTest::dynamicCastDownObjectTest()
+{
+ GstObject *bin = GST_OBJECT(gst_object_ref(gst_bin_new(NULL)));
+ gst_object_sink(bin);
+
+ {
+ QGlib::ObjectPtr object = QGlib::ObjectPtr::wrap(G_OBJECT(bin));
+ QVERIFY(!object.dynamicCast<QGst::Object>().isNull());
+ QVERIFY(!object.dynamicCast<QGst::Bin>().isNull());
+ QVERIFY(object.dynamicCast<QGst::Pipeline>().isNull());
+ }
+
+ gst_object_unref(bin);
+}
+
+void RefPointerTest::dynamicCastUpObjectTest()
+{
+ GstBin *bin = GST_BIN(gst_object_ref(gst_bin_new(NULL)));
+ gst_object_sink(bin);
+
+ {
+ QGst::BinPtr object = QGst::BinPtr::wrap(bin);
+ QVERIFY(!object.dynamicCast<QGst::Element>().isNull());
+ QVERIFY(!object.dynamicCast<QGlib::Object>().isNull());
+ QVERIFY(!object.dynamicCast<QGst::ChildProxy>().isNull());
+ }
+
+ gst_object_unref(bin);
+}
+
+void RefPointerTest::dynamicCastObjectToIfaceTest()
+{
+ QGst::ElementPtr e = QGst::ElementFactory::make("fakesrc");
+ QGst::UriHandlerPtr u = e.dynamicCast<QGst::UriHandler>();
+ QVERIFY(u.isNull());
+
+ e = QGst::ElementFactory::make("filesrc");
+ u = e.dynamicCast<QGst::UriHandler>();
+ QVERIFY(!u.isNull());
+}
+
+void RefPointerTest::dynamicCastIfaceToObjectTest()
+{
+ GstElement *e = gst_element_factory_make("filesrc", NULL);
+ gst_object_ref_sink(e);
+
+ QGst::UriHandlerPtr u = QGst::UriHandlerPtr::wrap(GST_URI_HANDLER(e), false);
+ QVERIFY(!u.isNull());
+ QVERIFY(!u.dynamicCast<QGst::Element>().isNull());
+}
+
+void RefPointerTest::cppWrappersTest()
+{
+ QGst::ElementPtr e = QGst::ElementFactory::make("playbin2");
+ QVERIFY(!e.isNull());
+
+ {
+ QGst::PipelinePtr pipeline = e.dynamicCast<QGst::Pipeline>();
+ QVERIFY(!pipeline.isNull());
+ //the C++ wrappers must be the same
+ QCOMPARE(static_cast<QGlib::RefCountedObject*>(pipeline.operator->()),
+ static_cast<QGlib::RefCountedObject*>(e.operator->()));
+ }
+
+ {
+ QGst::ChildProxyPtr proxy = e.dynamicCast<QGst::ChildProxy>();
+ QVERIFY(!proxy.isNull());
+ //the C++ wrappers must be the same
+ QCOMPARE(static_cast<QGlib::RefCountedObject*>(proxy.operator->()),
+ static_cast<QGlib::RefCountedObject*>(e.operator->()));
+ }
+
+ { //new wrap() should give the same C++ instance
+ GstElement *gobj = e;
+ QGst::ElementPtr e2 = QGst::ElementPtr::wrap(gobj);
+ QCOMPARE(static_cast<QGlib::RefCountedObject*>(e2.operator->()),
+ static_cast<QGlib::RefCountedObject*>(e.operator->()));
+ }
+
+ {
+ QGst::StreamVolumePtr sv = e.dynamicCast<QGst::StreamVolume>();
+ QVERIFY(!sv.isNull());
+ //now the C++ wrapper must not be the same, since Pipeline does not inherit StreamVolume
+ QVERIFY(static_cast<QGlib::RefCountedObject*>(sv.operator->())
+ != static_cast<QGlib::RefCountedObject*>(e.operator->()));
+ }
+
+ {
+ QGst::MessagePtr msg = QGst::ApplicationMessage::create(e);
+ QGst::MessagePtr msg2 = msg;
+ QCOMPARE(static_cast<QGlib::RefCountedObject*>(msg.operator->()),
+ static_cast<QGlib::RefCountedObject*>(msg2.operator->()));
+ QVERIFY(msg2 == msg);
+
+ QGst::MessagePtr msg3 = QGst::MessagePtr::wrap(msg2);
+ QVERIFY(static_cast<QGlib::RefCountedObject*>(msg3.operator->())
+ != static_cast<QGlib::RefCountedObject*>(msg2.operator->()));
+ QVERIFY(msg3 == msg2);
+ }
+}
+
void RefPointerTest::messageDynamicCastTest()
{
QGst::BinPtr bin = QGst::Bin::create();