diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-03-18 11:54:53 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-03-18 11:54:53 +0100 |
commit | 432e929e644097b25060f85b1e089f2943577bc9 (patch) | |
tree | 9a0cf5abcc77b85ee7aa88f875cb5dc097ab667c /tests | |
parent | 4ad0484b825524bcbb74145ac4e63bdd6274ce6a (diff) | |
parent | 69837e6e04ae125186a8deaac59d82607fcd6d1a (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I21c230900111b4881b40c451bffc3d5c2101111b
Diffstat (limited to 'tests')
6 files changed, 87 insertions, 70 deletions
diff --git a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp index 27fc014aa..068b30653 100644 --- a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp +++ b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp @@ -214,7 +214,7 @@ void tst_QCameraBackend::testCameraStates() QCamera camera; QCameraImageCapture imageCapture(&camera); - QSignalSpy errorSignal(&camera, SIGNAL(error(QCamera::Error))); + QSignalSpy errorSignal(&camera, SIGNAL(errorOccurred(QCamera::Error))); QSignalSpy stateChangedSignal(&camera, SIGNAL(stateChanged(QCamera::State))); QSignalSpy statusChangedSignal(&camera, SIGNAL(statusChanged(QCamera::Status))); @@ -262,8 +262,8 @@ void tst_QCameraBackend::testCameraStartError() { QCamera camera1(QCameraInfo::defaultCamera()); QCamera camera2(QCameraInfo::defaultCamera()); - QSignalSpy errorSpy1(&camera1, QOverload<QCamera::Error>::of(&QCamera::error)); - QSignalSpy errorSpy2(&camera2, QOverload<QCamera::Error>::of(&QCamera::error)); + QSignalSpy errorSpy1(&camera1, &QCamera::errorOccurred); + QSignalSpy errorSpy2(&camera2, &QCamera::errorOccurred); camera1.start(); camera2.start(); @@ -283,7 +283,7 @@ void tst_QCameraBackend::testCaptureMode() { QCamera camera; - QSignalSpy errorSignal(&camera, SIGNAL(error(QCamera::Error))); + QSignalSpy errorSignal(&camera, SIGNAL(errorOccurred(QCamera::Error))); QSignalSpy stateChangedSignal(&camera, SIGNAL(stateChanged(QCamera::State))); QSignalSpy captureModeSignal(&camera, SIGNAL(captureModeChanged(QCamera::CaptureModes))); @@ -631,7 +631,7 @@ void tst_QCameraBackend::testVideoRecording() QMediaRecorder recorder(camera.data()); - QSignalSpy errorSignal(camera.data(), SIGNAL(error(QCamera::Error))); + QSignalSpy errorSignal(camera.data(), SIGNAL(errorOccurred(QCamera::Error))); QSignalSpy recorderErrorSignal(&recorder, SIGNAL(error(QMediaRecorder::Error))); QSignalSpy recorderStatusSignal(&recorder, SIGNAL(statusChanged(QMediaRecorder::Status))); diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp index f1be070e8..a2217afc8 100644 --- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp +++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp @@ -81,6 +81,7 @@ private slots: void multipleSurfaces(); void metadata(); void playerStateAtEOS(); + void playFromBuffer(); private: QMediaContent selectVideoFile(const QStringList& mediaCandidates); @@ -1476,6 +1477,25 @@ void tst_QMediaPlayerBackend::playerStateAtEOS() QVERIFY(endOfMediaReceived); } +void tst_QMediaPlayerBackend::playFromBuffer() +{ + if (localVideoFile.isNull()) + QSKIP("No supported video file"); + + TestVideoSurface surface(false); + QMediaPlayer player; + player.setVideoOutput(&surface); + QFile file(localVideoFile.request().url().toLocalFile()); + if (!file.open(QIODevice::ReadOnly)) + QSKIP("Could not open file"); + player.setMedia(localVideoFile, &file); + player.play(); + QTRY_VERIFY(player.position() >= 1000); + if (surface.error() == QAbstractVideoSurface::UnsupportedFormatError) + QSKIP("None of the pixel formats is supported by the backend"); + QVERIFY2(surface.m_totalFrames >= 25, qPrintable(QString("Expected >= 25, got %1").arg(surface.m_totalFrames))); +} + TestVideoSurface::TestVideoSurface(bool storeFrames): m_totalFrames(0), m_storeFrames(storeFrames) diff --git a/tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp b/tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp index 61299a964..b18dba5f7 100644 --- a/tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp +++ b/tests/auto/unit/qabstractvideosurface/tst_qabstractvideosurface.cpp @@ -58,7 +58,7 @@ private slots: void supportedFormatsChanged(); }; -typedef QMap<QAbstractVideoBuffer::HandleType, QVideoFrame::PixelFormat> SupportedFormatMap; +using SupportedFormatMap = QMultiMap<QAbstractVideoBuffer::HandleType, QVideoFrame::PixelFormat>; Q_DECLARE_METATYPE(SupportedFormatMap) @@ -86,7 +86,7 @@ public: /* fun to generate supportedFormatsChanged signal */ QList<QVideoFrame::PixelFormat> supportedPixelFormatsChange(QList<QVideoFrame::PixelFormat> formats) { - supportedFormats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32); + supportedFormats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32); QList<QVideoFrame::PixelFormat> supportedFormats = supportedPixelFormats(); if (supportedFormats.count() != formats.count()) { emit supportedFormatsChanged(); @@ -189,10 +189,10 @@ void tst_QAbstractVideoSurface::isFormatSupported_data() QAbstractVideoBuffer::GLTextureHandle) << false; - formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32); - formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24); - formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YUV444); - formats.insertMulti(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB32); + formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32); + formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24); + formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YUV444); + formats.insert(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB32); QTest::newRow("supported: rgb32") << formats @@ -228,8 +228,8 @@ void tst_QAbstractVideoSurface::isFormatSupported_data() QAbstractVideoBuffer::GLTextureHandle) << false; - formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YV12); - formats.insertMulti(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB24); + formats.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YV12); + formats.insert(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB24); QTest::newRow("supported: yv12") << formats @@ -377,7 +377,7 @@ void tst_QAbstractVideoSurface::nativeResolution() void tst_QAbstractVideoSurface::supportedFormatsChanged() { SupportedFormatMap formatMap; - formatMap.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24); + formatMap.insert(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24); QtTestVideoSurface surface(formatMap); QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged())); QList<QVideoFrame::PixelFormat> formats = surface.supportedPixelFormats(); diff --git a/tests/auto/unit/qcamera/tst_qcamera.cpp b/tests/auto/unit/qcamera/tst_qcamera.cpp index 4b6202173..643b552f9 100644 --- a/tests/auto/unit/qcamera/tst_qcamera.cpp +++ b/tests/auto/unit/qcamera/tst_qcamera.cpp @@ -2039,7 +2039,7 @@ void tst_QCamera::testErrorSignal() QCamera camera; - QSignalSpy spyError(&camera, SIGNAL(error(QCamera::Error))); + QSignalSpy spyError(&camera, SIGNAL(errorOccurred(QCamera::Error))); /* Set the QCameraControl error and verify if the signal is emitted correctly in QCamera */ service.mockControl->setError(QCamera::CameraError,QString("Camera Error")); diff --git a/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp b/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp index d2b43c56d..bf8704162 100644 --- a/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp +++ b/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp @@ -299,7 +299,7 @@ void tst_QMediaObject::notifySignals() QTRY_COMPARE(spy.count(), count); qint64 elapsed = timer.elapsed(); - int expectedElapsed = count * interval * 1.5; // give it some margin of error + int expectedElapsed = count * interval * 3; // give it some margin of error QVERIFY2(elapsed < expectedElapsed, QString("elapsed: %1, expected: %2").arg(elapsed).arg(expectedElapsed).toLocal8Bit().constData()); } diff --git a/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp b/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp index 6aaeab855..be5c85ab9 100644 --- a/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp +++ b/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp @@ -35,9 +35,9 @@ #include <qvideosurfaceformat.h> #if QT_CONFIG(opengl) -#include <QtOpenGL/qgl.h> -#include <QtOpenGL/qglframebufferobject.h> -#include <QtGui/qopenglfunctions.h> +#include <QOpenGLContext> +#include <QOpenGLFunctions> +#include <QOpenGLWidget> #endif QT_USE_NAMESPACE @@ -559,20 +559,19 @@ void tst_QPainterVideoSurface::presentOpaqueFrame() void tst_QPainterVideoSurface::shaderType() { QPainterVideoSurface surface; - QGLWidget widget; - if (!widget.context() - || !widget.context()->isValid()) { - QSKIP("Platform does not support GLContext"); - } - + QOpenGLWidget widget; widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); - widget.makeCurrent(); + + if (!widget.context() || !widget.context()->isValid()) + QSKIP("Platform does not support OpenGLContext"); QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders); QCOMPARE(surface.supportedShaderTypes(), QPainterVideoSurface::NoShaders); - surface.setGLContext(const_cast<QGLContext *>(widget.context())); + widget.makeCurrent(); + surface.updateGLContext(); QCOMPARE(surface.glContext(), widget.context()); { @@ -612,12 +611,14 @@ void tst_QPainterVideoSurface::shaderType() { QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged())); - surface.setGLContext(const_cast<QGLContext *>(widget.context())); + widget.makeCurrent(); + surface.updateGLContext(); QCOMPARE(surface.glContext(), widget.context()); QCOMPARE(spy.count(), 0); } - surface.setGLContext(0); + widget.doneCurrent(); + surface.updateGLContext(); QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders); QCOMPARE(surface.supportedShaderTypes(), QPainterVideoSurface::NoShaders); @@ -656,19 +657,18 @@ void tst_QPainterVideoSurface::shaderTypeStarted() { QFETCH(QPainterVideoSurface::ShaderType, shaderType); - QGLWidget widget; - if (!widget.context() - || !widget.context()->isValid()) { - QSKIP("Platform does not support GLContext"); - } - + QOpenGLWidget widget; widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); - widget.makeCurrent(); + + if (!widget.context() || !widget.context()->isValid()) + QSKIP("Platform does not support OpenGLContext"); QPainterVideoSurface surface; - surface.setGLContext(const_cast<QGLContext *>(widget.context())); + widget.makeCurrent(); + surface.updateGLContext(); if (!(surface.supportedShaderTypes() & shaderType)) QSKIP("Shader type unsupported on this platform"); @@ -712,7 +712,8 @@ void tst_QPainterVideoSurface::shaderTypeStarted() QCOMPARE(surface.isActive(), true); QCOMPARE(spy.count(), 0); - surface.setGLContext(0); + widget.doneCurrent(); + surface.updateGLContext(); QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders); QCOMPARE(surface.isActive(), false); QCOMPARE(spy.count(), 1); @@ -904,18 +905,17 @@ void tst_QPainterVideoSurface::shaderSupportedFormat() QFETCH(bool, supportedPixelFormat); QFETCH(bool, supportedFormat); - QGLWidget widget; - if (!widget.context() - || !widget.context()->isValid()) { - QSKIP("Platform does not support GLContext"); - } - + QOpenGLWidget widget; widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); - widget.makeCurrent(); + + if (!widget.context() || !widget.context()->isValid()) + QSKIP("Platform does not support GLContext"); QPainterVideoSurface surface; - surface.setGLContext(const_cast<QGLContext *>(widget.context())); + widget.makeCurrent(); + surface.updateGLContext(); if (!(surface.supportedShaderTypes() & shaderType)) @@ -1026,18 +1026,17 @@ void tst_QPainterVideoSurface::shaderPresent() QFETCH(int, bytesB); QFETCH(int, bytesPerLineB); - QGLWidget widget; - if (!widget.context() - || !widget.context()->isValid()) { - QSKIP("Platform does not support GLContext"); - } - + QOpenGLWidget widget; widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); - widget.makeCurrent(); + + if (!widget.context() || !widget.context()->isValid()) + QSKIP("Platform does not support GLContext"); QPainterVideoSurface surface; - surface.setGLContext(const_cast<QGLContext *>(widget.context())); + widget.makeCurrent(); + surface.updateGLContext(); if (!(surface.supportedShaderTypes() & shaderType)) QSKIP("Shader type unsupported on this platform"); @@ -1163,18 +1162,17 @@ void tst_QPainterVideoSurface::shaderPresentOpaqueFrame() { QFETCH(QPainterVideoSurface::ShaderType, shaderType); - QGLWidget widget; - if (!widget.context() - || !widget.context()->isValid()) { - QSKIP("Platform does not support GLContext"); - } - + QOpenGLWidget widget; widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); - widget.makeCurrent(); + + if (!widget.context() || !widget.context()->isValid()) + QSKIP("Platform does not support GLContext"); QPainterVideoSurface surface; - surface.setGLContext(const_cast<QGLContext *>(widget.context())); + widget.makeCurrent(); + surface.updateGLContext(); if (!(surface.supportedShaderTypes() & shaderType)) QSKIP("Shader type unsupported on this platform"); @@ -1217,18 +1215,17 @@ void tst_QPainterVideoSurface::shaderPresentGLFrame() { QFETCH(QPainterVideoSurface::ShaderType, shaderType); - QGLWidget widget; - if (!widget.context() - || !widget.context()->isValid()) { - QSKIP("Platform does not support GLContext"); - } - + QOpenGLWidget widget; widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); - widget.makeCurrent(); + + if (!widget.context() || !widget.context()->isValid()) + QSKIP("Platform does not support GLContext"); QPainterVideoSurface surface; - surface.setGLContext(const_cast<QGLContext *>(widget.context())); + widget.makeCurrent(); + surface.updateGLContext(); if (!(surface.supportedShaderTypes() & shaderType)) QSKIP("Shader type unsupported on this platform"); |