diff options
author | Val Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-01-17 09:15:00 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2019-10-15 09:55:58 +0000 |
commit | d0670f2fd81fb406bd3f33f7faebe6c4a51b0071 (patch) | |
tree | bd9a3321eb9ad81bef4c5dd570e3265af85e5157 | |
parent | 56d430962a50af234902cd799920a5b6df6d80eb (diff) | |
download | qtmultimedia-d0670f2fd81fb406bd3f33f7faebe6c4a51b0071.tar.gz |
Fix tst_qcamerabackend.cpp to pass if capturing to JPEG is not supported
DirectShow capture control supports only RGB32 to capture to buffer,
which fails the test.
Decided to fix the test to avoid checking against Jpeg format and just
make sure that it returns proper QImage.
Change-Id: Ibcd565d6157cf3543eb15d3e1e371df271fc358c
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
-rw-r--r-- | tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp index b8d501c12..80e2e693c 100644 --- a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp +++ b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp @@ -49,6 +49,7 @@ #include <qcameraimagecapture.h> #include <qvideorenderercontrol.h> #include <private/qmediaserviceprovider_p.h> +#include <private/qvideoframe_p.h> QT_USE_NAMESPACE @@ -408,8 +409,6 @@ void tst_QCameraBackend::testCaptureToBuffer() QTRY_COMPARE(camera.status(), QCamera::LoadedStatus); - QCOMPARE(imageCapture.bufferFormat(), QVideoFrame::Format_Jpeg); - QVERIFY(imageCapture.isCaptureDestinationSupported(QCameraImageCapture::CaptureToFile)); QVERIFY(imageCapture.isCaptureDestinationSupported(QCameraImageCapture::CaptureToBuffer)); QVERIFY(imageCapture.isCaptureDestinationSupported( @@ -446,23 +445,9 @@ void tst_QCameraBackend::testCaptureToBuffer() QCOMPARE(imageAvailableSignal.first().first().toInt(), id); QVideoFrame frame = imageAvailableSignal.first().last().value<QVideoFrame>(); - QVERIFY(frame.isValid()); - QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Jpeg); - QVERIFY(!frame.size().isEmpty()); - QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly)); - QByteArray data((const char *)frame.bits(), frame.mappedBytes()); - frame.unmap(); - frame = QVideoFrame(); - - QVERIFY(!data.isEmpty()); - QBuffer buffer; - buffer.setData(data); - buffer.open(QIODevice::ReadOnly); - QImageReader reader(&buffer, "JPG"); - reader.setScaledSize(QSize(640,480)); - QImage img(reader.read()); - QVERIFY(!img.isNull()); + QVERIFY(!qt_imageFromVideoFrame(frame).isNull()); + frame = QVideoFrame(); capturedSignal.clear(); imageAvailableSignal.clear(); savedSignal.clear(); @@ -518,9 +503,7 @@ void tst_QCameraBackend::testCaptureToBuffer() QCOMPARE(imageAvailableSignal.first().first().toInt(), id); frame = imageAvailableSignal.first().last().value<QVideoFrame>(); - QVERIFY(frame.isValid()); - QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Jpeg); - QVERIFY(!frame.size().isEmpty()); + QVERIFY(!qt_imageFromVideoFrame(frame).isNull()); QString fileName = savedSignal.first().last().toString(); QVERIFY(QFileInfo(fileName).exists()); |