Commit 0b5045ed authored by Val Doroshchuk's avatar Val Doroshchuk

tests

parent a9d2faf9
......@@ -163,7 +163,7 @@ void QGstreamerPipeline::setPipeline(const QString &desc)
QString pl = QLatin1String("gst-pipeline:") + desc;
if (d->source)
d->source->setProperty("source", QVariant::fromValue<QUrl>(QUrl(pl)));
d->source->setProperty("source", QVariant::fromValue<QUrl>(pl));
else
d->mediaPlayer->setMedia(QMediaContent(pl));
......
......@@ -26,11 +26,11 @@
**
****************************************************************************/
#include <QtTest/QtTest>
#include <QMediaPlayer>
#include <QGstreamerPipeline>
#include <QMediaPlayer>
#include <QAbstractVideoSurface>
#include <QVideoWidget>
#include <QtTest/QtTest>
QT_USE_NAMESPACE
......@@ -40,6 +40,8 @@ class tst_QGstreamerPipeline: public QObject
private slots:
void testMediaPlayer();
void testPipeline();
void testPipelineSurface();
void testPipelineWidget();
void testSetProperty();
private:
......@@ -47,6 +49,25 @@ private:
QGstreamerPipeline *control = nullptr;
};
struct Surface : QAbstractVideoSurface
{
Surface(QObject *parent = nullptr)
: QAbstractVideoSurface(parent)
{
}
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
QAbstractVideoBuffer::HandleType) const override
{
return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_ARGB32;
}
bool isFormatSupported(const QVideoSurfaceFormat &) const override { return true; }
bool start(const QVideoSurfaceFormat &) override { return true; }
void stop() override { }
bool present(const QVideoFrame &) override { return true; }
};
void tst_QGstreamerPipeline::testMediaPlayer()
{
QMediaPlayer mediaPlayer;
......@@ -69,6 +90,42 @@ void tst_QGstreamerPipeline::testPipeline()
QCOMPARE(p.pipeline(), pl);
}
void tst_QGstreamerPipeline::testPipelineSurface()
{
QMediaPlayer mediaPlayer;
Surface *s = new Surface(this);
mediaPlayer.setVideoOutput(s);
QGstreamerPipeline p(&mediaPlayer);
QSignalSpy spy(&p, &QGstreamerPipeline::pipelineChanged);
QString pl = "videotestsrc ! xvimagesink name=qtvideosink";
p.setPipeline(pl);
mediaPlayer.play();
QTRY_COMPARE(spy.count(), 1);
QCOMPARE(mediaPlayer.error(), QMediaPlayer::NoError);
QCOMPARE(p.pipeline(), pl);
}
void tst_QGstreamerPipeline::testPipelineWidget()
{
QMediaPlayer mediaPlayer;
QVideoWidget w;
mediaPlayer.setVideoOutput(&w);
QGstreamerPipeline p(&mediaPlayer);
QSignalSpy spy(&p, &QGstreamerPipeline::pipelineChanged);
QString pl = "videotestsrc ! xvimagesink name=qtvideosink";
p.setPipeline(pl);
mediaPlayer.play();
QTRY_COMPARE(spy.count(), 1);
QCOMPARE(mediaPlayer.error(), QMediaPlayer::NoError);
QCOMPARE(p.pipeline(), pl);
}
void tst_QGstreamerPipeline::testSetProperty()
{
QMediaPlayer mediaPlayer;
......@@ -81,5 +138,5 @@ void tst_QGstreamerPipeline::testSetProperty()
QCOMPARE(mediaPlayer.error(), QMediaPlayer::NoError);
}
QTEST_GUILESS_MAIN(tst_QGstreamerPipeline)
QTEST_MAIN(tst_QGstreamerPipeline)
#include "tst_qgstreamerpipeline.moc"
......@@ -26,11 +26,10 @@
**
****************************************************************************/
#include <QtTest/QtTest>
#include <QMediaPlayer>
#include <QGstreamerPlaybin>
#include <QMediaPlayer>
#include <QAbstractVideoSurface>
#include <QtTest/QtTest>
QT_USE_NAMESPACE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment