diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2012-02-14 02:48:39 +1000 |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2012-02-14 02:48:39 +1000 |
commit | fa69d07edaea74fd113ff6122b1e510e22b995a6 (patch) | |
tree | b0d4b76912f239ca7413050801b44eb89a1efd12 /tests | |
parent | 79776f38b7563b4b7b8056f13390d681b14e6115 (diff) | |
parent | e9dce3dae8f08598c53bbc57a1cd70c955ff0115 (diff) |
Merge branch 'master' of scm.dev.nokia.troll.no:qtmobility/qtm-multimedia into master-integration
* 'master' of scm.dev.nokia.troll.no:qtmobility/qtm-multimedia:
Fix tst_QGraphicsVideoItem_symbian
Fix failures in tst_QGraphicsVideoItem on Symbian
Skip some tst_QGraphicsVideoItem steps on Symbian
Fix license header
Backported fixes to video demos from QtMultimedia
Diffstat (limited to 'tests')
4 files changed, 205 insertions, 127 deletions
diff --git a/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro b/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro index 749090e928..b6f3c22a11 100644 --- a/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro +++ b/tests/auto/qgraphicsvideoitem/qgraphicsvideoitem.pro @@ -6,8 +6,14 @@ SOURCES += tst_qgraphicsvideoitem.cpp include (../../../common.pri) -symbian: TARGET.CAPABILITY = ReadDeviceData WriteDeviceData - +symbian { + TARGET.CAPABILITY = ReadDeviceData WriteDeviceData + contains(QT_CONFIG, egl) { + LIBS *= -llibegl + } else { + DEFINES += QT_NO_EGL + } +} CONFIG += mobility MOBILITY = multimedia diff --git a/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp index 7a45325fc0..13a069b0f0 100644 --- a/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp +++ b/tests/auto/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp @@ -56,6 +56,10 @@ #include <QtGui/qgraphicsscene.h> #include <QtGui/qgraphicsview.h> +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_EGL) +#include <egl/egl.h> +#endif + QT_USE_NAMESPACE class tst_QGraphicsVideoItem : public QObject { @@ -83,6 +87,9 @@ private slots: void boundingRect(); void paint(); + +private: + bool m_rendererControlUsed; }; Q_DECLARE_METATYPE(const uchar *) @@ -210,6 +217,14 @@ private: void tst_QGraphicsVideoItem::initTestCase() { qRegisterMetaType<Qt::AspectRatioMode>(); + m_rendererControlUsed = true; +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_EGL) + const EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (display != EGL_NO_DISPLAY) { + if (eglInitialize(display, 0, 0) == EGL_TRUE) + m_rendererControlUsed = (eglGetProcAddress("eglCreateEndpointNOK") != 0); + } +#endif } void tst_QGraphicsVideoItem::nullObject() @@ -265,7 +280,8 @@ void tst_QGraphicsVideoItem::serviceDestroyed() QGraphicsVideoItem item; object.bind(&item); - QCOMPARE(object.testService->rendererRef, 1); + if (m_rendererControlUsed) + QCOMPARE(object.testService->rendererRef, 1); QtTestVideoService *service = object.testService; object.testService = 0; @@ -283,7 +299,8 @@ void tst_QGraphicsVideoItem::mediaObjectDestroyed() QGraphicsVideoItem item; object->bind(&item); - QCOMPARE(object->testService->rendererRef, 1); + if (m_rendererControlUsed) + QCOMPARE(object->testService->rendererRef, 1); delete object; object = 0; @@ -300,67 +317,78 @@ void tst_QGraphicsVideoItem::setMediaObject() QGraphicsVideoItem item; QCOMPARE(item.mediaObject(), nullObject); - QCOMPARE(object.testService->rendererRef, 0); + if (m_rendererControlUsed) + QCOMPARE(object.testService->rendererRef, 0); object.bind(&item); QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object)); - QCOMPARE(object.testService->rendererRef, 1); - QVERIFY(object.testService->rendererControl->surface() == 0); + if (m_rendererControlUsed) { + QCOMPARE(object.testService->rendererRef, 1); + QVERIFY(object.testService->rendererControl->surface() == 0); - { // Surface setup is deferred until after the first paint. - QImage image(320, 240, QImage::Format_RGB32); - QPainter painter(&image); + { // Surface setup is deferred until after the first paint. + QImage image(320, 240, QImage::Format_RGB32); + QPainter painter(&image); - item.paint(&painter, 0); + item.paint(&painter, 0); + } + QVERIFY(object.testService->rendererControl->surface() != 0); } - QVERIFY(object.testService->rendererControl->surface() != 0); object.unbind(&item); QCOMPARE(item.mediaObject(), nullObject); - QCOMPARE(object.testService->rendererRef, 0); - QVERIFY(object.testService->rendererControl->surface() == 0); + if (m_rendererControlUsed) { + QCOMPARE(object.testService->rendererRef, 0); + QVERIFY(object.testService->rendererControl->surface() == 0); + } item.setVisible(false); object.bind(&item); QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object)); - QCOMPARE(object.testService->rendererRef, 1); - QVERIFY(object.testService->rendererControl->surface() != 0); + if (m_rendererControlUsed) { + QCOMPARE(object.testService->rendererRef, 1); + QVERIFY(object.testService->rendererControl->surface() != 0); + } } void tst_QGraphicsVideoItem::show() -{ - QtTestVideoObject object(new QtTestRendererControl); - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - object.bind(item); +{ + if (!m_rendererControlUsed) { + QSKIP("QGraphicsVideoItem does not use QVideoRendererControl", SkipAll); + } else { + QtTestVideoObject object(new QtTestRendererControl); + QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; + object.bind(item); - // Graphics items are visible by default - QCOMPARE(object.testService->rendererRef, 1); - QVERIFY(object.testService->rendererControl->surface() == 0); + // Graphics items are visible by default + QCOMPARE(object.testService->rendererRef, 1); + QVERIFY(object.testService->rendererControl->surface() == 0); - item->hide(); - QCOMPARE(object.testService->rendererRef, 1); + item->hide(); + QCOMPARE(object.testService->rendererRef, 1); - item->show(); - QCOMPARE(object.testService->rendererRef, 1); - QVERIFY(object.testService->rendererControl->surface() == 0); + item->show(); + QCOMPARE(object.testService->rendererRef, 1); + QVERIFY(object.testService->rendererControl->surface() == 0); - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); + QGraphicsScene graphicsScene; + graphicsScene.addItem(item); + QGraphicsView graphicsView(&graphicsScene); + graphicsView.show(); - QVERIFY(item->paintCount() || item->waitForPaint(1)); - QVERIFY(object.testService->rendererControl->surface() != 0); + QVERIFY(item->paintCount() || item->waitForPaint(1)); + QVERIFY(object.testService->rendererControl->surface() != 0); - QVERIFY(item->boundingRect().isEmpty()); + QVERIFY(item->boundingRect().isEmpty()); - QVideoSurfaceFormat format(QSize(320,240),QVideoFrame::Format_RGB32); - QVERIFY(object.testService->rendererControl->surface()->start(format)); + QVideoSurfaceFormat format(QSize(320,240),QVideoFrame::Format_RGB32); + QVERIFY(object.testService->rendererControl->surface()->start(format)); - QCoreApplication::processEvents(); - QVERIFY(!item->boundingRect().isEmpty()); + QCoreApplication::processEvents(); + QVERIFY(!item->boundingRect().isEmpty()); + } } void tst_QGraphicsVideoItem::aspectRatioMode() @@ -459,32 +487,34 @@ void tst_QGraphicsVideoItem::nativeSize() QCOMPARE(item.nativeSize(), QSizeF()); - QSignalSpy spy(&item, SIGNAL(nativeSizeChanged(QSizeF))); + if (m_rendererControlUsed) { + QSignalSpy spy(&item, SIGNAL(nativeSizeChanged(QSizeF))); - QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); - format.setViewport(viewport); - format.setPixelAspectRatio(pixelAspectRatio); + QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); + format.setViewport(viewport); + format.setPixelAspectRatio(pixelAspectRatio); - { // Surface setup is deferred until after the first paint. - QImage image(320, 240, QImage::Format_RGB32); - QPainter painter(&image); + { // Surface setup is deferred until after the first paint. + QImage image(320, 240, QImage::Format_RGB32); + QPainter painter(&image); - item.paint(&painter, 0); - } - QVERIFY(object.testService->rendererControl->surface() != 0); - QVERIFY(object.testService->rendererControl->surface()->start(format)); + item.paint(&painter, 0); + } + QVERIFY(object.testService->rendererControl->surface() != 0); + QVERIFY(object.testService->rendererControl->surface()->start(format)); - QCoreApplication::processEvents(); - QCOMPARE(item.nativeSize(), nativeSize); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.last().first().toSizeF(), nativeSize); + QCoreApplication::processEvents(); + QCOMPARE(item.nativeSize(), nativeSize); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.last().first().toSizeF(), nativeSize); - object.testService->rendererControl->surface()->stop(); + object.testService->rendererControl->surface()->stop(); - QCoreApplication::processEvents(); - QVERIFY(item.nativeSize().isEmpty()); - QCOMPARE(spy.count(), 2); - QVERIFY(spy.last().first().toSizeF().isEmpty()); + QCoreApplication::processEvents(); + QVERIFY(item.nativeSize().isEmpty()); + QCOMPARE(spy.count(), 2); + QVERIFY(spy.last().first().toSizeF().isEmpty()); + } } void tst_QGraphicsVideoItem::boundingRect_data() @@ -590,33 +620,37 @@ void tst_QGraphicsVideoItem::boundingRect_data() void tst_QGraphicsVideoItem::boundingRect() { - QFETCH(QSize, frameSize); - QFETCH(QPointF, offset); - QFETCH(QSizeF, size); - QFETCH(Qt::AspectRatioMode, aspectRatioMode); - QFETCH(QRectF, expectedRect); - - QtTestVideoObject object(new QtTestRendererControl); - QGraphicsVideoItem item; - object.bind(&item); - - item.setOffset(offset); - item.setSize(size); - item.setAspectRatioMode(aspectRatioMode); - - QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); - - { // Surface setup is deferred until after the first paint. - QImage image(320, 240, QImage::Format_RGB32); - QPainter painter(&image); + if (!m_rendererControlUsed) { + QSKIP("QGraphicsVideoItem does not use QVideoRendererControl", SkipAll); + } else { + QFETCH(QSize, frameSize); + QFETCH(QPointF, offset); + QFETCH(QSizeF, size); + QFETCH(Qt::AspectRatioMode, aspectRatioMode); + QFETCH(QRectF, expectedRect); + + QtTestVideoObject object(new QtTestRendererControl); + QGraphicsVideoItem item; + object.bind(&item); + + item.setOffset(offset); + item.setSize(size); + item.setAspectRatioMode(aspectRatioMode); + + QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); + + { // Surface setup is deferred until after the first paint. + QImage image(320, 240, QImage::Format_RGB32); + QPainter painter(&image); + + item.paint(&painter, 0); + } + QVERIFY(object.testService->rendererControl->surface() != 0); + QVERIFY(object.testService->rendererControl->surface()->start(format)); - item.paint(&painter, 0); + QCoreApplication::processEvents(); + QCOMPARE(item.boundingRect(), expectedRect); } - QVERIFY(object.testService->rendererControl->surface() != 0); - QVERIFY(object.testService->rendererControl->surface()->start(format)); - - QCoreApplication::processEvents(); - QCOMPARE(item.boundingRect(), expectedRect); } static const uchar rgb32ImageData[] = @@ -627,48 +661,51 @@ static const uchar rgb32ImageData[] = void tst_QGraphicsVideoItem::paint() { - QtTestVideoObject object(new QtTestRendererControl); - QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; - object.bind(item); - - QGraphicsScene graphicsScene; - graphicsScene.addItem(item); - QGraphicsView graphicsView(&graphicsScene); - graphicsView.show(); - QVERIFY(item->waitForPaint(1)); + if (!m_rendererControlUsed) { + QSKIP("QGraphicsVideoItem does not use QVideoRendererControl", SkipAll); + } else { + QtTestVideoObject object(new QtTestRendererControl); + QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem; + object.bind(item); - QPainterVideoSurface *surface = qobject_cast<QPainterVideoSurface *>( - object.testService->rendererControl->surface()); - if (!surface) - QSKIP("QGraphicsVideoItem is not QPainterVideoSurface based", SkipAll); + QGraphicsScene graphicsScene; + graphicsScene.addItem(item); + QGraphicsView graphicsView(&graphicsScene); + graphicsView.show(); + QVERIFY(item->waitForPaint(1)); - QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32); + QPainterVideoSurface *surface = qobject_cast<QPainterVideoSurface *>( + object.testService->rendererControl->surface()); + if (!surface) + QSKIP("QGraphicsVideoItem is not QPainterVideoSurface based", SkipAll); - QVERIFY(surface->start(format)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); + QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32); - QVERIFY(item->waitForPaint(1)); + QVERIFY(surface->start(format)); + QCOMPARE(surface->isActive(), true); + QCOMPARE(surface->isReady(), true); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); + QVERIFY(item->waitForPaint(1)); - QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32); + QCOMPARE(surface->isActive(), true); + QCOMPARE(surface->isReady(), true); - frame.map(QAbstractVideoBuffer::WriteOnly); - memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes()); - frame.unmap(); + QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32); - QVERIFY(surface->present(frame)); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), false); + frame.map(QAbstractVideoBuffer::WriteOnly); + memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes()); + frame.unmap(); - QVERIFY(item->waitForPaint(1)); + QVERIFY(surface->present(frame)); + QCOMPARE(surface->isActive(), true); + QCOMPARE(surface->isReady(), false); - QCOMPARE(surface->isActive(), true); - QCOMPARE(surface->isReady(), true); -} + QVERIFY(item->waitForPaint(1)); + QCOMPARE(surface->isActive(), true); + QCOMPARE(surface->isReady(), true); + } +} QTEST_MAIN(tst_QGraphicsVideoItem) diff --git a/tests/auto/qgraphicsvideoitem_symbian/qgraphicsvideoitem_symbian.pro b/tests/auto/qgraphicsvideoitem_symbian/qgraphicsvideoitem_symbian.pro index 217fded1cc..04d1ba072d 100644 --- a/tests/auto/qgraphicsvideoitem_symbian/qgraphicsvideoitem_symbian.pro +++ b/tests/auto/qgraphicsvideoitem_symbian/qgraphicsvideoitem_symbian.pro @@ -5,5 +5,10 @@ MOBILITY = multimedia INCLUDEPATH += ../../../src/multimedia SOURCES += tst_qgraphicsvideoitem_symbian.cpp LIBS += -lcone -lavkon +contains(QT_CONFIG, egl) { + LIBS *= -llibegl +} else { + DEFINES += QT_NO_EGL +} include (../../../common.pri) diff --git a/tests/auto/qgraphicsvideoitem_symbian/tst_qgraphicsvideoitem_symbian.cpp b/tests/auto/qgraphicsvideoitem_symbian/tst_qgraphicsvideoitem_symbian.cpp index 8ba74ab796..d9f592a9e3 100644 --- a/tests/auto/qgraphicsvideoitem_symbian/tst_qgraphicsvideoitem_symbian.cpp +++ b/tests/auto/qgraphicsvideoitem_symbian/tst_qgraphicsvideoitem_symbian.cpp @@ -55,6 +55,10 @@ #include <aknenv.h> #include <aknappui.h> +#ifndef QT_NO_EGL +#include <egl/egl.h> +#endif + QT_USE_NAMESPACE static const QString FileName = "e:/test.mp4"; @@ -69,7 +73,15 @@ enum PreferredRenderingPath PreferredRenderingPathDirect }; +enum ActualRenderingPath +{ + ActualRenderingPathNone, + ActualRenderingPathRenderer = PreferredRenderingPathRenderer, + ActualRenderingPathDirect = PreferredRenderingPathDirect +}; + Q_DECLARE_METATYPE(PreferredRenderingPath) +Q_DECLARE_METATYPE(ActualRenderingPath) #define WAIT_FOR_CONDITION(condition, ms) \ { \ @@ -104,12 +116,6 @@ private: void setPreferredRenderingPath(PreferredRenderingPath path); void setFullScreen(bool enabled); - enum ActualRenderingPath - { - ActualRenderingPathNone, - ActualRenderingPathRenderer = PreferredRenderingPathRenderer, - ActualRenderingPathDirect = PreferredRenderingPathDirect - }; ActualRenderingPath actualRenderingPath() const; private slots: @@ -123,6 +129,7 @@ private: QtTestGraphicsView *m_view; QGraphicsScene *m_scene; QtTestGraphicsVideoItem *m_videoItem; + bool m_eglEndpointSupport; }; class QtTestGraphicsView : public QGraphicsView @@ -198,7 +205,16 @@ void tst_QGraphicsVideoItemSymbian::initTestCase() m_view = 0; m_scene = 0; m_videoItem = 0; + m_eglEndpointSupport = false; +#ifndef QT_NO_EGL + const EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (display != EGL_NO_DISPLAY) { + if (eglInitialize(display, 0, 0) == EGL_TRUE) + m_eglEndpointSupport = (eglGetProcAddress("eglCreateEndpointNOK") != 0); + } +#endif qRegisterMetaType<PreferredRenderingPath>(); + qRegisterMetaType<ActualRenderingPath>(); } void tst_QGraphicsVideoItemSymbian::init() @@ -284,7 +300,7 @@ void tst_QGraphicsVideoItemSymbian::setFullScreen(bool enabled) m_videoItem->setAspectRatioMode(mode); } -tst_QGraphicsVideoItemSymbian::ActualRenderingPath tst_QGraphicsVideoItemSymbian::actualRenderingPath() const +ActualRenderingPath tst_QGraphicsVideoItemSymbian::actualRenderingPath() const { ActualRenderingPath path = ActualRenderingPathNone; static const QString property = "_q_currentVideoRenderingPath"; @@ -320,23 +336,34 @@ void tst_QGraphicsVideoItemSymbian::resetInactivityTime() void tst_QGraphicsVideoItemSymbian::specifyPreferredRenderingPath() { QFETCH(PreferredRenderingPath, preferredRenderingPath); + QFETCH(ActualRenderingPath, actualRenderingPath); setPreferredRenderingPath(preferredRenderingPath); play(); - QVERIFY(actualRenderingPath() == preferredRenderingPath); + QVERIFY(this->actualRenderingPath() == actualRenderingPath); } void tst_QGraphicsVideoItemSymbian::specifyPreferredRenderingPath_data() { QTest::addColumn<PreferredRenderingPath>("preferredRenderingPath"); - QTest::newRow("direct") << PreferredRenderingPathDirect; - QTest::newRow("renderer") << PreferredRenderingPathRenderer; + QTest::addColumn<ActualRenderingPath>("actualRenderingPath"); + QTest::newRow("direct") << PreferredRenderingPathDirect + << ActualRenderingPathDirect; + if (m_eglEndpointSupport) + QTest::newRow("renderer") << PreferredRenderingPathRenderer + << ActualRenderingPathRenderer; + else + QTest::newRow("renderer") << PreferredRenderingPathRenderer + << ActualRenderingPathDirect; } void tst_QGraphicsVideoItemSymbian::autoFullScreenIn() { setPreferredRenderingPath(PreferredRenderingPathAuto); play(); - QVERIFY(actualRenderingPath() == ActualRenderingPathRenderer); + if (m_eglEndpointSupport) + QVERIFY(actualRenderingPath() == ActualRenderingPathRenderer); + else + QVERIFY(actualRenderingPath() == ActualRenderingPathDirect); m_videoItem->savePaintCount(); setFullScreen(true); m_videoItem->waitForPaint(); @@ -353,7 +380,10 @@ void tst_QGraphicsVideoItemSymbian::autoFullScreenOut() m_videoItem->savePaintCount(); setFullScreen(false); m_videoItem->waitForPaint(); - QVERIFY(actualRenderingPath() == ActualRenderingPathRenderer); + if (m_eglEndpointSupport) + QVERIFY(actualRenderingPath() == ActualRenderingPathRenderer); + else + QVERIFY(actualRenderingPath() == ActualRenderingPathDirect); } QTEST_MAIN(tst_QGraphicsVideoItemSymbian) |