From d690596868be79fc0212d39707d5bc052700e24c Mon Sep 17 00:00:00 2001 From: Michael Goddard Date: Mon, 5 Sep 2011 16:13:46 +1000 Subject: [PATCH] Split some of the autotests into widget and non widget parts. Since the tests are mostly not widget based. Change-Id: Ic3fa4224b19f2a5c710fd4763b5e645252975c1c Reviewed-on: http://codereview.qt-project.org/4174 Reviewed-by: Qt Sanity Bot Reviewed-by: Dmytro Poplavskiy --- tests/auto/multimedia.pro | 6 + tests/auto/multimediawidgets.pro | 9 +- tests/auto/qcamera/qcamera.pro | 2 +- tests/auto/qcamera/tst_qcamera.cpp | 65 +---- .../qcameraimagecapture/qcameraimagecapture.pro | 2 +- .../tst_qcameraimagecapture.cpp | 2 - tests/auto/qcamerawidgets/qcamerawidgets.pro | 11 + tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp | 319 +++++++++++++++++++++ tests/auto/qdeclarativevideo/qdeclarativevideo.pro | 2 +- tests/auto/qmediaimageviewer/qmediaimageviewer.pro | 2 +- .../qmediaimageviewer/tst_qmediaimageviewer.cpp | 21 +- tests/auto/qmediaimageviewerwidgets/images.qrc | 5 + .../auto/qmediaimageviewerwidgets/images/image.png | Bin 0 -> 230 bytes .../qmediaimageviewerwidgets.pro | 15 + .../tst_qmediaimageviewerwidgets.cpp | 142 +++++++++ tests/auto/qmediaobject/qmediaobject.pro | 2 +- tests/auto/qmediaobject/tst_qmediaobject.cpp | 1 - tests/auto/qmediaplayer/qmediaplayer.pro | 2 +- tests/auto/qmediaplayer/tst_qmediaplayer.cpp | 37 +-- tests/auto/qmediaplayer/tst_qmediaplayer.h | 1 - tests/auto/qmediaplayerwidgets/main.cpp | 53 ++++ .../qmediaplayerwidgets/qmediaplayerwidgets.pro | 10 + .../tst_qmediaplayerwidgets.cpp | 162 +++++++++++ .../qmediaplayerwidgets/tst_qmediaplayerwidgets.h | 79 +++++ .../qmediastreamscontrol/qmediastreamscontrol.pro | 2 +- tests/auto/qmultimedia_common/mockcameraservice.h | 16 +- .../qmultimedia_common/mockmediaplayerservice.h | 22 +- .../qmultimedia_common/mockmediaserviceprovider.h | 1 + tests/auto/qmultimedia_common/mockvideo.pri | 8 +- .../qmultimedia_common/mockvideowindowcontrol.h | 3 + 30 files changed, 856 insertions(+), 146 deletions(-) create mode 100644 tests/auto/qcamerawidgets/qcamerawidgets.pro create mode 100644 tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp create mode 100644 tests/auto/qmediaimageviewerwidgets/images.qrc create mode 100644 tests/auto/qmediaimageviewerwidgets/images/image.png create mode 100644 tests/auto/qmediaimageviewerwidgets/qmediaimageviewerwidgets.pro create mode 100644 tests/auto/qmediaimageviewerwidgets/tst_qmediaimageviewerwidgets.cpp create mode 100755 tests/auto/qmediaplayerwidgets/main.cpp create mode 100644 tests/auto/qmediaplayerwidgets/qmediaplayerwidgets.pro create mode 100644 tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp create mode 100755 tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.h diff --git a/tests/auto/multimedia.pro b/tests/auto/multimedia.pro index d79522d..6a6d08b 100644 --- a/tests/auto/multimedia.pro +++ b/tests/auto/multimedia.pro @@ -22,6 +22,11 @@ SUBDIRS += \ qvideosurfaceformat \ qmetadatareadercontrol \ qmetadatawritercontrol \ + qmediaplayer \ + qcameraimagecapture \ + qmediaobject \ + qcamera \ + qcamerabackend \ # These is disabled until intent is clearer # qvideodevicecontrol \ @@ -38,6 +43,7 @@ contains (QT_CONFIG, private_tests) { SUBDIRS += \ qmediaplaylist \ qmediapluginloader \ + qmediaimageviewer \ qmediaserviceprovider contains (QT_CONFIG, declarative) { diff --git a/tests/auto/multimediawidgets.pro b/tests/auto/multimediawidgets.pro index 1bd2e4e..5a55ecc 100644 --- a/tests/auto/multimediawidgets.pro +++ b/tests/auto/multimediawidgets.pro @@ -1,12 +1,9 @@ TEMPLATE = subdirs SUBDIRS += \ - qcamera \ - qcamerabackend \ - qcameraimagecapture \ qcameraviewfinder \ - qmediaobject \ - qmediaplayer + qcamerawidgets \ + qmediaplayerwidgets \ # This is a commment for the mock backend directory so that maketestselftest # doesn't believe it's an untested directory @@ -17,8 +14,8 @@ SUBDIRS += \ contains (QT_CONFIG, private_tests) { SUBDIRS += \ qgraphicsvideoitem \ - qmediaimageviewer \ qpaintervideosurface \ + qmediaimageviewerwidgets \ qvideowidget \ contains (QT_CONFIG, declarative) { diff --git a/tests/auto/qcamera/qcamera.pro b/tests/auto/qcamera/qcamera.pro index a34e815..9e4a7e8 100644 --- a/tests/auto/qcamera/qcamera.pro +++ b/tests/auto/qcamera/qcamera.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private +QT += multimediakit-private CONFIG += no_private_qt_headers_warning include (../qmultimedia_common/mock.pri) diff --git a/tests/auto/qcamera/tst_qcamera.cpp b/tests/auto/qcamera/tst_qcamera.cpp index 016e738..f096239 100644 --- a/tests/auto/qcamera/tst_qcamera.cpp +++ b/tests/auto/qcamera/tst_qcamera.cpp @@ -58,10 +58,7 @@ #include #include #include -#include #include -#include -#include #include "mockcameraservice.h" @@ -1037,39 +1034,10 @@ void tst_QCamera::testCameraEncodingProperyChange() QCOMPARE(camera.status(), QCamera::ActiveStatus); QCOMPARE(stateChangedSignal.count(), 0); QCOMPARE(statusChangedSignal.count(), 1); - stateChangedSignal.clear(); - statusChangedSignal.clear(); - - //setting the viewfinder should also trigger backend to be restarted: - camera.setViewfinder(new QGraphicsVideoItem()); - QCOMPARE(camera.state(), QCamera::ActiveState); - QCOMPARE(camera.status(), QCamera::LoadedStatus); - - QCOMPARE(stateChangedSignal.count(), 0); - QCOMPARE(statusChangedSignal.count(), 1); - - QTest::qWait(10); - - service.mockControl->m_propertyChangesSupported = true; - //the changes to encoding settings, - //capture mode and encoding parameters should not trigger service restart - stateChangedSignal.clear(); - statusChangedSignal.clear(); - - camera.setCaptureMode(QCamera::CaptureVideo); - camera.setCaptureMode(QCamera::CaptureStillImage); - imageCapture.setEncodingSettings(QImageEncoderSettings()); - imageCapture.setEncodingSettings(QImageEncoderSettings()); - camera.setViewfinder(new QGraphicsVideoItem()); - - QCOMPARE(stateChangedSignal.count(), 0); - QCOMPARE(statusChangedSignal.count(), 0); } void tst_QCamera::testSetVideoOutput() { - QVideoWidget widget; - QGraphicsVideoItem item; MockVideoSurface surface; MockCameraService service; @@ -1077,21 +1045,9 @@ void tst_QCamera::testSetVideoOutput() provider.service = &service; QCamera camera(0, &provider); - camera.setViewfinder(&widget); - QVERIFY(widget.mediaObject() == &camera); - - camera.setViewfinder(&item); - QVERIFY(widget.mediaObject() == 0); - QVERIFY(item.mediaObject() == &camera); - camera.setViewfinder(reinterpret_cast(0)); - QVERIFY(item.mediaObject() == 0); - - camera.setViewfinder(&widget); - QVERIFY(widget.mediaObject() == &camera); camera.setViewfinder(reinterpret_cast(0)); - QVERIFY(widget.mediaObject() == 0); camera.setViewfinder(&surface); QVERIFY(service.rendererControl->surface() == &surface); @@ -1102,56 +1058,37 @@ void tst_QCamera::testSetVideoOutput() camera.setViewfinder(&surface); QVERIFY(service.rendererControl->surface() == &surface); - camera.setViewfinder(&widget); + camera.setViewfinder(reinterpret_cast(0)); QVERIFY(service.rendererControl->surface() == 0); - QVERIFY(widget.mediaObject() == &camera); camera.setViewfinder(&surface); QVERIFY(service.rendererControl->surface() == &surface); - QVERIFY(widget.mediaObject() == 0); } void tst_QCamera::testSetVideoOutputNoService() { - QVideoWidget widget; - QGraphicsVideoItem item; MockVideoSurface surface; MockMediaServiceProvider provider; provider.service = 0; QCamera camera(0, &provider); - camera.setViewfinder(&widget); - QVERIFY(widget.mediaObject() == 0); - - camera.setViewfinder(&item); - QVERIFY(item.mediaObject() == 0); - camera.setViewfinder(&surface); // Nothing we can verify here other than it doesn't assert. } void tst_QCamera::testSetVideoOutputNoControl() { - QVideoWidget widget; - QGraphicsVideoItem item; MockVideoSurface surface; MockCameraService service; service.rendererRef = 1; - service.windowRef = 1; MockMediaServiceProvider provider; provider.service = &service; QCamera camera(0, &provider); - camera.setViewfinder(&widget); - QVERIFY(widget.mediaObject() == 0); - - camera.setViewfinder(&item); - QVERIFY(item.mediaObject() == 0); - camera.setViewfinder(&surface); QVERIFY(service.rendererControl->surface() == 0); } diff --git a/tests/auto/qcameraimagecapture/qcameraimagecapture.pro b/tests/auto/qcameraimagecapture/qcameraimagecapture.pro index 97785dc..a69d2f3 100644 --- a/tests/auto/qcameraimagecapture/qcameraimagecapture.pro +++ b/tests/auto/qcameraimagecapture/qcameraimagecapture.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private +QT += multimediakit-private CONFIG += no_private_qt_headers_warning SOURCES += \ diff --git a/tests/auto/qcameraimagecapture/tst_qcameraimagecapture.cpp b/tests/auto/qcameraimagecapture/tst_qcameraimagecapture.cpp index ab198d5..312def4 100644 --- a/tests/auto/qcameraimagecapture/tst_qcameraimagecapture.cpp +++ b/tests/auto/qcameraimagecapture/tst_qcameraimagecapture.cpp @@ -63,8 +63,6 @@ Reviewer Name Date Coverage ( Full / Test Case IDs ). #include #include #include -#include -#include #include "mockcameraservice.h" #include "mockmediaserviceprovider.h" diff --git a/tests/auto/qcamerawidgets/qcamerawidgets.pro b/tests/auto/qcamerawidgets/qcamerawidgets.pro new file mode 100644 index 0000000..9323543 --- /dev/null +++ b/tests/auto/qcamerawidgets/qcamerawidgets.pro @@ -0,0 +1,11 @@ +load(qttest_p4) + +QT += multimediakit-private multimediakitwidgets-private +CONFIG += no_private_qt_headers_warning + +include (../qmultimedia_common/mock.pri) +include (../qmultimedia_common/mockcamera.pri) + +SOURCES += tst_qcamerawidgets.cpp + +maemo*:CONFIG += insignificant_test diff --git a/tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp b/tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp new file mode 100644 index 0000000..c6b4482 --- /dev/null +++ b/tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp @@ -0,0 +1,319 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//TESTED_COMPONENT=src/multimedia + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mockcameraservice.h" + +#include "mockmediaserviceprovider.h" +#include "mockvideosurface.h" +#include "mockvideorenderercontrol.h" +#include "mockvideowindowcontrol.h" + +QT_USE_NAMESPACE + +Q_DECLARE_METATYPE(QtMultimediaKit::MetaData) + +class tst_QCameraWidgets: public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + void testCameraEncodingProperyChange(); + void testSetVideoOutput(); + void testSetVideoOutputNoService(); + void testSetVideoOutputNoControl(); + +private: + MockSimpleCameraService *mockSimpleCameraService; + MockMediaServiceProvider *provider; +}; + +void tst_QCameraWidgets::initTestCase() +{ + provider = new MockMediaServiceProvider; + mockSimpleCameraService = new MockSimpleCameraService; + provider->service = mockSimpleCameraService; + qRegisterMetaType("QtMultimediaKit::MetaData"); +} + +void tst_QCameraWidgets::cleanupTestCase() +{ + delete mockSimpleCameraService; + delete provider; +} + +void tst_QCameraWidgets::testCameraEncodingProperyChange() +{ + MockCameraService service; + provider->service = &service; + QCamera camera(0, provider); + QCameraImageCapture imageCapture(&camera); + + QSignalSpy stateChangedSignal(&camera, SIGNAL(stateChanged(QCamera::State))); + QSignalSpy statusChangedSignal(&camera, SIGNAL(statusChanged(QCamera::Status))); + + camera.start(); + QCOMPARE(camera.state(), QCamera::ActiveState); + QCOMPARE(camera.status(), QCamera::ActiveStatus); + + QCOMPARE(stateChangedSignal.count(), 1); + QCOMPARE(statusChangedSignal.count(), 1); + stateChangedSignal.clear(); + statusChangedSignal.clear(); + + + camera.setCaptureMode(QCamera::CaptureVideo); + QCOMPARE(camera.state(), QCamera::ActiveState); + QCOMPARE(camera.status(), QCamera::LoadedStatus); + + QCOMPARE(stateChangedSignal.count(), 0); + QCOMPARE(statusChangedSignal.count(), 1); + stateChangedSignal.clear(); + statusChangedSignal.clear(); + + QTest::qWait(10); + + QCOMPARE(camera.state(), QCamera::ActiveState); + QCOMPARE(camera.status(), QCamera::ActiveStatus); + QCOMPARE(stateChangedSignal.count(), 0); + QCOMPARE(statusChangedSignal.count(), 1); + stateChangedSignal.clear(); + statusChangedSignal.clear(); + + //backens should not be stopped since the capture mode is Video + imageCapture.setEncodingSettings(QImageEncoderSettings()); + QCOMPARE(stateChangedSignal.count(), 0); + QCOMPARE(statusChangedSignal.count(), 0); + + camera.setCaptureMode(QCamera::CaptureStillImage); + QTest::qWait(10); + stateChangedSignal.clear(); + statusChangedSignal.clear(); + + //the settings change should trigger camera stop/start + imageCapture.setEncodingSettings(QImageEncoderSettings()); + QCOMPARE(camera.state(), QCamera::ActiveState); + QCOMPARE(camera.status(), QCamera::LoadedStatus); + + QCOMPARE(stateChangedSignal.count(), 0); + QCOMPARE(statusChangedSignal.count(), 1); + stateChangedSignal.clear(); + statusChangedSignal.clear(); + + QTest::qWait(10); + + QCOMPARE(camera.state(), QCamera::ActiveState); + QCOMPARE(camera.status(), QCamera::ActiveStatus); + QCOMPARE(stateChangedSignal.count(), 0); + QCOMPARE(statusChangedSignal.count(), 1); + stateChangedSignal.clear(); + statusChangedSignal.clear(); + + //the settings change should trigger camera stop/start only once + camera.setCaptureMode(QCamera::CaptureVideo); + camera.setCaptureMode(QCamera::CaptureStillImage); + imageCapture.setEncodingSettings(QImageEncoderSettings()); + imageCapture.setEncodingSettings(QImageEncoderSettings()); + + QCOMPARE(camera.state(), QCamera::ActiveState); + QCOMPARE(camera.status(), QCamera::LoadedStatus); + + QCOMPARE(stateChangedSignal.count(), 0); + QCOMPARE(statusChangedSignal.count(), 1); + stateChangedSignal.clear(); + statusChangedSignal.clear(); + + QTest::qWait(10); + + QCOMPARE(camera.state(), QCamera::ActiveState); + QCOMPARE(camera.status(), QCamera::ActiveStatus); + QCOMPARE(stateChangedSignal.count(), 0); + QCOMPARE(statusChangedSignal.count(), 1); + stateChangedSignal.clear(); + statusChangedSignal.clear(); + + //setting the viewfinder should also trigger backend to be restarted: + camera.setViewfinder(new QGraphicsVideoItem()); + QCOMPARE(camera.state(), QCamera::ActiveState); + QCOMPARE(camera.status(), QCamera::LoadedStatus); + + QCOMPARE(stateChangedSignal.count(), 0); + QCOMPARE(statusChangedSignal.count(), 1); + + QTest::qWait(10); + + service.mockControl->m_propertyChangesSupported = true; + //the changes to encoding settings, + //capture mode and encoding parameters should not trigger service restart + stateChangedSignal.clear(); + statusChangedSignal.clear(); + + camera.setCaptureMode(QCamera::CaptureVideo); + camera.setCaptureMode(QCamera::CaptureStillImage); + imageCapture.setEncodingSettings(QImageEncoderSettings()); + imageCapture.setEncodingSettings(QImageEncoderSettings()); + camera.setViewfinder(new QGraphicsVideoItem()); + + QCOMPARE(stateChangedSignal.count(), 0); + QCOMPARE(statusChangedSignal.count(), 0); +} + +void tst_QCameraWidgets::testSetVideoOutput() +{ + QVideoWidget widget; + QGraphicsVideoItem item; + MockVideoSurface surface; + + MockCameraService service; + MockMediaServiceProvider provider; + provider.service = &service; + QCamera camera(0, &provider); + + camera.setViewfinder(&widget); + qDebug() << widget.mediaObject(); + QVERIFY(widget.mediaObject() == &camera); + + camera.setViewfinder(&item); + QVERIFY(widget.mediaObject() == 0); + QVERIFY(item.mediaObject() == &camera); + + camera.setViewfinder(reinterpret_cast(0)); + QVERIFY(item.mediaObject() == 0); + + camera.setViewfinder(&widget); + QVERIFY(widget.mediaObject() == &camera); + + camera.setViewfinder(reinterpret_cast(0)); + QVERIFY(widget.mediaObject() == 0); + + camera.setViewfinder(&surface); + QVERIFY(service.rendererControl->surface() == &surface); + + camera.setViewfinder(reinterpret_cast(0)); + QVERIFY(service.rendererControl->surface() == 0); + + camera.setViewfinder(&surface); + QVERIFY(service.rendererControl->surface() == &surface); + + camera.setViewfinder(&widget); + QVERIFY(service.rendererControl->surface() == 0); + QVERIFY(widget.mediaObject() == &camera); + + camera.setViewfinder(&surface); + QVERIFY(service.rendererControl->surface() == &surface); + QVERIFY(widget.mediaObject() == 0); +} + + +void tst_QCameraWidgets::testSetVideoOutputNoService() +{ + QVideoWidget widget; + QGraphicsVideoItem item; + MockVideoSurface surface; + + MockMediaServiceProvider provider; + provider.service = 0; + QCamera camera(0, &provider); + + camera.setViewfinder(&widget); + QVERIFY(widget.mediaObject() == 0); + + camera.setViewfinder(&item); + QVERIFY(item.mediaObject() == 0); + + camera.setViewfinder(&surface); + // Nothing we can verify here other than it doesn't assert. +} + +void tst_QCameraWidgets::testSetVideoOutputNoControl() +{ + QVideoWidget widget; + QGraphicsVideoItem item; + MockVideoSurface surface; + + MockCameraService service; + service.rendererRef = 1; + service.windowRef = 1; + + MockMediaServiceProvider provider; + provider.service = &service; + QCamera camera(0, &provider); + + camera.setViewfinder(&widget); + QVERIFY(widget.mediaObject() == 0); + + camera.setViewfinder(&item); + QVERIFY(item.mediaObject() == 0); + + camera.setViewfinder(&surface); + QVERIFY(service.rendererControl->surface() == 0); +} + +QTEST_MAIN(tst_QCameraWidgets) + +#include "tst_qcamerawidgets.moc" diff --git a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro b/tests/auto/qdeclarativevideo/qdeclarativevideo.pro index 3abe939..3faeb32 100644 --- a/tests/auto/qdeclarativevideo/qdeclarativevideo.pro +++ b/tests/auto/qdeclarativevideo/qdeclarativevideo.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private declarative +QT += multimediakit-private declarative CONFIG += no_private_qt_headers_warning HEADERS += \ diff --git a/tests/auto/qmediaimageviewer/qmediaimageviewer.pro b/tests/auto/qmediaimageviewer/qmediaimageviewer.pro index 50991fa..5372a19 100644 --- a/tests/auto/qmediaimageviewer/qmediaimageviewer.pro +++ b/tests/auto/qmediaimageviewer/qmediaimageviewer.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private network +QT += multimediakit-private network CONFIG += no_private_qt_headers_warning SOURCES += tst_qmediaimageviewer.cpp diff --git a/tests/auto/qmediaimageviewer/tst_qmediaimageviewer.cpp b/tests/auto/qmediaimageviewer/tst_qmediaimageviewer.cpp index ff88b9c..e1de92a 100644 --- a/tests/auto/qmediaimageviewer/tst_qmediaimageviewer.cpp +++ b/tests/auto/qmediaimageviewer/tst_qmediaimageviewer.cpp @@ -46,14 +46,11 @@ #include -#include #include #include #include #include #include -#include -#include #include #include @@ -998,25 +995,11 @@ void tst_QMediaImageViewer::setVideoOutput() if (imageViewer.mediaStatus() != QMediaImageViewer::LoadedMedia) QSKIP("failed to load test image", SkipSingle); - QVideoWidget widget; - QGraphicsVideoItem item; QtTestVideoSurface surface; - imageViewer.setVideoOutput(&widget); - QVERIFY(widget.mediaObject() == &imageViewer); - - imageViewer.setVideoOutput(&item); - QVERIFY(widget.mediaObject() == 0); - QVERIFY(item.mediaObject() == &imageViewer); - imageViewer.setVideoOutput(reinterpret_cast(0)); - QVERIFY(item.mediaObject() == 0); - - imageViewer.setVideoOutput(&widget); - QVERIFY(widget.mediaObject() == &imageViewer); imageViewer.setVideoOutput(reinterpret_cast(0)); - QVERIFY(widget.mediaObject() == 0); imageViewer.setVideoOutput(&surface); QVERIFY(surface.isActive()); @@ -1027,13 +1010,11 @@ void tst_QMediaImageViewer::setVideoOutput() imageViewer.setVideoOutput(&surface); QVERIFY(surface.isActive()); - imageViewer.setVideoOutput(&widget); + imageViewer.setVideoOutput(reinterpret_cast(0)); QVERIFY(!surface.isActive()); - QVERIFY(widget.mediaObject() == &imageViewer); imageViewer.setVideoOutput(&surface); QVERIFY(surface.isActive()); - QVERIFY(widget.mediaObject() == 0); } void tst_QMediaImageViewer::debugEnums() diff --git a/tests/auto/qmediaimageviewerwidgets/images.qrc b/tests/auto/qmediaimageviewerwidgets/images.qrc new file mode 100644 index 0000000..1d4edce --- /dev/null +++ b/tests/auto/qmediaimageviewerwidgets/images.qrc @@ -0,0 +1,5 @@ + + + images/image.png + + diff --git a/tests/auto/qmediaimageviewerwidgets/images/image.png b/tests/auto/qmediaimageviewerwidgets/images/image.png new file mode 100644 index 0000000000000000000000000000000000000000..a24db1b13fd4d5f2bdca117131d12ebf4e2ee1ea GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^-au@`!2~2{Gj7}hq}F=6IEH9Ue0%;NCzGRq%f(kO zuTB;9Jr(0~LB;1l$duCbWj5S=6}l_R^=AD$cp#tgi;LM7m8dB@llF#vIk=DUcbl&F zhV+E29kIU(duKKOKG0Y(sr1>;P`UCaVfS}u+DC2P%p9pz86`HU +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +QT_USE_NAMESPACE + +class tst_QMediaImageViewerWidgets : public QObject +{ + Q_OBJECT +private slots: + void setVideoOutput(); +}; + +class QtTestVideoSurface : public QAbstractVideoSurface +{ +public: + QList supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const { + QList formats; + if (handleType == QAbstractVideoBuffer::NoHandle) { + formats << QVideoFrame::Format_RGB32; + } + return formats; + } + + QVideoFrame frame() const { return m_frame; } + + bool present(const QVideoFrame &frame) { m_frame = frame; return true; } + +private: + QVideoFrame m_frame; +}; + +void tst_QMediaImageViewerWidgets::setVideoOutput() +{ + QMediaImageViewer imageViewer; + imageViewer.setMedia(QMediaContent(QUrl("qrc:///images/image.png"))); + + connect(&imageViewer, SIGNAL(mediaStatusChanged(QMediaImageViewer::MediaStatus)), + &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(2); + + if (imageViewer.mediaStatus() != QMediaImageViewer::LoadedMedia) + QSKIP("failed to load test image", SkipSingle); + + QVideoWidget widget; + QGraphicsVideoItem item; + QtTestVideoSurface surface; + + imageViewer.setVideoOutput(&widget); + QVERIFY(widget.mediaObject() == &imageViewer); + + imageViewer.setVideoOutput(&item); + QVERIFY(widget.mediaObject() == 0); + QVERIFY(item.mediaObject() == &imageViewer); + + imageViewer.setVideoOutput(reinterpret_cast(0)); + QVERIFY(item.mediaObject() == 0); + + imageViewer.setVideoOutput(&widget); + QVERIFY(widget.mediaObject() == &imageViewer); + + imageViewer.setVideoOutput(reinterpret_cast(0)); + QVERIFY(widget.mediaObject() == 0); + + imageViewer.setVideoOutput(&surface); + QVERIFY(surface.isActive()); + + imageViewer.setVideoOutput(reinterpret_cast(0)); + QVERIFY(!surface.isActive()); + + imageViewer.setVideoOutput(&surface); + QVERIFY(surface.isActive()); + + imageViewer.setVideoOutput(&widget); + QVERIFY(!surface.isActive()); + QVERIFY(widget.mediaObject() == &imageViewer); + + imageViewer.setVideoOutput(&surface); + QVERIFY(surface.isActive()); + QVERIFY(widget.mediaObject() == 0); +} + +QTEST_MAIN(tst_QMediaImageViewerWidgets) + +#include "tst_qmediaimageviewerwidgets.moc" diff --git a/tests/auto/qmediaobject/qmediaobject.pro b/tests/auto/qmediaobject/qmediaobject.pro index 091222c..66f60e1 100644 --- a/tests/auto/qmediaobject/qmediaobject.pro +++ b/tests/auto/qmediaobject/qmediaobject.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets +QT += multimediakit-private CONFIG += no_private_qt_headers_warning include (../qmultimedia_common/mockrecorder.pri) diff --git a/tests/auto/qmediaobject/tst_qmediaobject.cpp b/tests/auto/qmediaobject/tst_qmediaobject.cpp index 2c96a39..6a337ac 100644 --- a/tests/auto/qmediaobject/tst_qmediaobject.cpp +++ b/tests/auto/qmediaobject/tst_qmediaobject.cpp @@ -42,7 +42,6 @@ //TESTED_COMPONENT=src/multimedia #include "tst_qmediaobject.h" -#include "qvideowidget.h" #include "mockmediarecorderservice.h" #include "mockmediaserviceprovider.h" diff --git a/tests/auto/qmediaplayer/qmediaplayer.pro b/tests/auto/qmediaplayer/qmediaplayer.pro index 7d6dab9..bdb616a 100644 --- a/tests/auto/qmediaplayer/qmediaplayer.pro +++ b/tests/auto/qmediaplayer/qmediaplayer.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += network multimediakit-private multimediakitwidgets-private +QT += network multimediakit-private CONFIG += no_private_qt_headers_warning HEADERS += tst_qmediaplayer.h diff --git a/tests/auto/qmediaplayer/tst_qmediaplayer.cpp b/tests/auto/qmediaplayer/tst_qmediaplayer.cpp index fb438f6..8117ae1 100644 --- a/tests/auto/qmediaplayer/tst_qmediaplayer.cpp +++ b/tests/auto/qmediaplayer/tst_qmediaplayer.cpp @@ -43,7 +43,6 @@ #include "tst_qmediaplayer.h" -#include #include // Encouraging successful diversity through copy and paste. @@ -936,29 +935,14 @@ void tst_QMediaPlayer::testNetworkAccess() void tst_QMediaPlayer::testSetVideoOutput() { - QVideoWidget widget; - QGraphicsVideoItem item; MockVideoSurface surface; MockMediaPlayerService service; MockMediaServiceProvider provider(&service); QMediaPlayer player(0, 0, &provider); - player.setVideoOutput(&widget); - QVERIFY(widget.mediaObject() == &player); - - player.setVideoOutput(&item); - QVERIFY(widget.mediaObject() == 0); - QVERIFY(item.mediaObject() == &player); - player.setVideoOutput(reinterpret_cast(0)); - QVERIFY(item.mediaObject() == 0); - - player.setVideoOutput(&widget); - QVERIFY(widget.mediaObject() == &player); - player.setVideoOutput(reinterpret_cast(0)); - QVERIFY(widget.mediaObject() == 0); player.setVideoOutput(&surface); QVERIFY(service.rendererControl->surface() == &surface); @@ -969,54 +953,35 @@ void tst_QMediaPlayer::testSetVideoOutput() player.setVideoOutput(&surface); QVERIFY(service.rendererControl->surface() == &surface); - player.setVideoOutput(&widget); + player.setVideoOutput(reinterpret_cast(0)); QVERIFY(service.rendererControl->surface() == 0); - QVERIFY(widget.mediaObject() == &player); player.setVideoOutput(&surface); QVERIFY(service.rendererControl->surface() == &surface); - QVERIFY(widget.mediaObject() == 0); } void tst_QMediaPlayer::testSetVideoOutputNoService() { - QVideoWidget widget; - QGraphicsVideoItem item; MockVideoSurface surface; MockMediaServiceProvider provider(0, true); QMediaPlayer player(0, 0, &provider); - player.setVideoOutput(&widget); - QVERIFY(widget.mediaObject() == 0); - - player.setVideoOutput(&item); - QVERIFY(item.mediaObject() == 0); - player.setVideoOutput(&surface); // Nothing we can verify here other than it doesn't assert. } void tst_QMediaPlayer::testSetVideoOutputNoControl() { - QVideoWidget widget; - QGraphicsVideoItem item; MockVideoSurface surface; MockMediaPlayerService service; service.rendererRef = 1; - service.windowRef = 1; MockMediaServiceProvider provider(&service); QMediaPlayer player(0, 0, &provider); - player.setVideoOutput(&widget); - QVERIFY(widget.mediaObject() == 0); - - player.setVideoOutput(&item); - QVERIFY(item.mediaObject() == 0); - player.setVideoOutput(&surface); QVERIFY(service.rendererControl->surface() == 0); } diff --git a/tests/auto/qmediaplayer/tst_qmediaplayer.h b/tests/auto/qmediaplayer/tst_qmediaplayer.h index c87c65a..76a94cc 100755 --- a/tests/auto/qmediaplayer/tst_qmediaplayer.h +++ b/tests/auto/qmediaplayer/tst_qmediaplayer.h @@ -54,7 +54,6 @@ #include #include #include -#include #include "mockmediaserviceprovider.h" #include "mockmediaplayerservice.h" diff --git a/tests/auto/qmediaplayerwidgets/main.cpp b/tests/auto/qmediaplayerwidgets/main.cpp new file mode 100755 index 0000000..95903a5 --- /dev/null +++ b/tests/auto/qmediaplayerwidgets/main.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include "tst_qmediaplayerwidgets.h" + +int main(int argc, char**argv) +{ + QApplication app(argc,argv); + int ret; + tst_QMediaPlayerWidgets test_api; + ret = QTest::qExec(&test_api, argc, argv); + return ret; +} diff --git a/tests/auto/qmediaplayerwidgets/qmediaplayerwidgets.pro b/tests/auto/qmediaplayerwidgets/qmediaplayerwidgets.pro new file mode 100644 index 0000000..a750ca9 --- /dev/null +++ b/tests/auto/qmediaplayerwidgets/qmediaplayerwidgets.pro @@ -0,0 +1,10 @@ +load(qttest_p4) + +QT += network multimediakit-private multimediakitwidgets-private +CONFIG += no_private_qt_headers_warning + +HEADERS += tst_qmediaplayerwidgets.h +SOURCES += main.cpp tst_qmediaplayerwidgets.cpp + +include (../qmultimedia_common/mock.pri) +include (../qmultimedia_common/mockplayer.pri) diff --git a/tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp b/tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp new file mode 100644 index 0000000..ac9ffa0 --- /dev/null +++ b/tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//TESTED_COMPONENT=src/multimedia + +#include "tst_qmediaplayerwidgets.h" +#include "mockvideosurface.h" +#include + +QT_USE_NAMESPACE + +void tst_QMediaPlayerWidgets::initTestCase() +{ + qRegisterMetaType("QMediaPlayer::State"); + qRegisterMetaType("QMediaPlayer::Error"); + qRegisterMetaType("QMediaPlayer::MediaStatus"); + qRegisterMetaType("QMediaContent"); + + mockService = new MockMediaPlayerService; + mockProvider = new MockMediaServiceProvider(mockService, true); + player = new QMediaPlayer(0, 0, mockProvider); +} + +void tst_QMediaPlayerWidgets::cleanupTestCase() +{ + delete player; +} + +void tst_QMediaPlayerWidgets::init() +{ + mockService->reset(); +} + +void tst_QMediaPlayerWidgets::cleanup() +{ +} + +void tst_QMediaPlayerWidgets::testSetVideoOutput() +{ + QVideoWidget widget; + QGraphicsVideoItem item; + MockVideoSurface surface; + + MockMediaPlayerService service; + MockMediaServiceProvider provider(&service); + QMediaPlayer player(0, 0, &provider); + + player.setVideoOutput(&widget); + QVERIFY(widget.mediaObject() == &player); + + player.setVideoOutput(&item); + QVERIFY(widget.mediaObject() == 0); + QVERIFY(item.mediaObject() == &player); + + player.setVideoOutput(reinterpret_cast(0)); + QVERIFY(item.mediaObject() == 0); + + player.setVideoOutput(&widget); + QVERIFY(widget.mediaObject() == &player); + + player.setVideoOutput(reinterpret_cast(0)); + QVERIFY(widget.mediaObject() == 0); + + player.setVideoOutput(&surface); + QVERIFY(service.rendererControl->surface() == &surface); + + player.setVideoOutput(reinterpret_cast(0)); + QVERIFY(service.rendererControl->surface() == 0); + + player.setVideoOutput(&surface); + QVERIFY(service.rendererControl->surface() == &surface); + + player.setVideoOutput(&widget); + QVERIFY(service.rendererControl->surface() == 0); + QVERIFY(widget.mediaObject() == &player); + + player.setVideoOutput(&surface); + QVERIFY(service.rendererControl->surface() == &surface); + QVERIFY(widget.mediaObject() == 0); +} + + +void tst_QMediaPlayerWidgets::testSetVideoOutputNoService() +{ + QVideoWidget widget; + QGraphicsVideoItem item; + MockVideoSurface surface; + + MockMediaServiceProvider provider(0, true); + QMediaPlayer player(0, 0, &provider); + + player.setVideoOutput(&widget); + QVERIFY(widget.mediaObject() == 0); + + player.setVideoOutput(&item); + QVERIFY(item.mediaObject() == 0); + + player.setVideoOutput(&surface); + // Nothing we can verify here other than it doesn't assert. +} + +void tst_QMediaPlayerWidgets::testSetVideoOutputNoControl() +{ + QVideoWidget widget; + QGraphicsVideoItem item; + MockVideoSurface surface; + + MockMediaPlayerService service; + service.rendererRef = 1; + service.windowRef = 1; + + MockMediaServiceProvider provider(&service); + QMediaPlayer player(0, 0, &provider); + + player.setVideoOutput(&widget); + QVERIFY(widget.mediaObject() == 0); + + player.setVideoOutput(&item); + QVERIFY(item.mediaObject() == 0); + + player.setVideoOutput(&surface); + QVERIFY(service.rendererControl->surface() == 0); +} + diff --git a/tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.h b/tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.h new file mode 100755 index 0000000..e5f9b67 --- /dev/null +++ b/tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TST_QMEDIAPLAYER_H +#define TST_QMEDIAPLAYER_H + +#include +#include +#include +#include + +#include +#include +#include + +#include "mockmediaserviceprovider.h" +#include "mockmediaplayerservice.h" + +QT_USE_NAMESPACE + +class tst_QMediaPlayerWidgets: public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + +private slots: + void testSetVideoOutput(); + void testSetVideoOutputNoService(); + void testSetVideoOutputNoControl(); + +private: + MockMediaServiceProvider *mockProvider; + MockMediaPlayerService *mockService; + QMediaPlayer *player; +}; + +#endif //TST_QMEDIAPLAYER_H diff --git a/tests/auto/qmediastreamscontrol/qmediastreamscontrol.pro b/tests/auto/qmediastreamscontrol/qmediastreamscontrol.pro index 1672413..3ee3311 100644 --- a/tests/auto/qmediastreamscontrol/qmediastreamscontrol.pro +++ b/tests/auto/qmediastreamscontrol/qmediastreamscontrol.pro @@ -1,6 +1,6 @@ load(qttest_p4) -QT += multimediakit-private multimediakitwidgets-private +QT += multimediakit-private CONFIG += no_private_qt_headers_warning SOURCES += \ diff --git a/tests/auto/qmultimedia_common/mockcameraservice.h b/tests/auto/qmultimedia_common/mockcameraservice.h index 591745b..c51f75f 100644 --- a/tests/auto/qmultimedia_common/mockcameraservice.h +++ b/tests/auto/qmultimedia_common/mockcameraservice.h @@ -55,7 +55,10 @@ #include "../qmultimedia_common/mockcameracontrol.h" #include "../qmultimedia_common/mockvideosurface.h" #include "../qmultimedia_common/mockvideorenderercontrol.h" + +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) #include "../qmultimedia_common/mockvideowindowcontrol.h" +#endif class MockSimpleCameraService : public QMediaService { @@ -102,7 +105,9 @@ public: mockImageProcessingControl = new MockImageProcessingControl(this); mockImageEncoderControl = new MockImageEncoderControl(this); rendererControl = new MockVideoRendererControl(this); +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) windowControl = new MockVideoWindowControl(this); +#endif rendererRef = 0; windowRef = 0; } @@ -148,12 +153,15 @@ public: rendererRef += 1; return rendererControl; } - } else if (qstrcmp(iid, QVideoWindowControl_iid) == 0) { + } +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) + if (qstrcmp(iid, QVideoWindowControl_iid) == 0) { if (windowRef == 0) { windowRef += 1; return windowControl; } } +#endif return 0; } @@ -161,8 +169,10 @@ public: { if (control == rendererControl) rendererRef -= 1; - else if (control == windowControl) +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) + if (control == windowControl) windowRef -= 1; +#endif } MockCameraControl *mockControl; @@ -176,7 +186,9 @@ public: MockImageProcessingControl *mockImageProcessingControl; MockImageEncoderControl *mockImageEncoderControl; MockVideoRendererControl *rendererControl; +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) MockVideoWindowControl *windowControl; +#endif int rendererRef; int windowRef; }; diff --git a/tests/auto/qmultimedia_common/mockmediaplayerservice.h b/tests/auto/qmultimedia_common/mockmediaplayerservice.h index ac1e32b..5769722 100644 --- a/tests/auto/qmultimedia_common/mockmediaplayerservice.h +++ b/tests/auto/qmultimedia_common/mockmediaplayerservice.h @@ -48,7 +48,9 @@ #include "mockmediastreamscontrol.h" #include "mockmedianetworkaccesscontrol.h" #include "mockvideorenderercontrol.h" +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) #include "mockvideowindowcontrol.h" +#endif class MockMediaPlayerService : public QMediaService { @@ -61,9 +63,11 @@ public: mockStreamsControl = new MockStreamsControl; mockNetworkControl = new MockNetworkAccessControl; rendererControl = new MockVideoRendererControl; - windowControl = new MockVideoWindowControl; rendererRef = 0; +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) + windowControl = new MockVideoWindowControl; windowRef = 0; +#endif } ~MockMediaPlayerService() @@ -72,7 +76,9 @@ public: delete mockStreamsControl; delete mockNetworkControl; delete rendererControl; +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) delete windowControl; +#endif } QMediaControl* requestControl(const char *iid) @@ -84,13 +90,15 @@ public: rendererRef += 1; return rendererControl; } - } else if (qstrcmp(iid, QVideoWindowControl_iid) == 0) { + } +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) + if (qstrcmp(iid, QVideoWindowControl_iid) == 0) { if (windowRef == 0) { windowRef += 1; return windowControl; } } - +#endif if (qstrcmp(iid, QMediaNetworkAccessControl_iid) == 0) return mockNetworkControl; @@ -101,8 +109,10 @@ public: { if (control == rendererControl) rendererRef -= 1; - else if (control == windowControl) +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) + if (control == windowControl) windowRef -= 1; +#endif } void setState(QMediaPlayer::State state) { emit mockControl->stateChanged(mockControl->_state = state); } @@ -154,9 +164,11 @@ public: MockStreamsControl *mockStreamsControl; MockNetworkAccessControl *mockNetworkControl; MockVideoRendererControl *rendererControl; +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) MockVideoWindowControl *windowControl; - int rendererRef; int windowRef; +#endif + int rendererRef; }; diff --git a/tests/auto/qmultimedia_common/mockmediaserviceprovider.h b/tests/auto/qmultimedia_common/mockmediaserviceprovider.h index 3509fea..4573d7f 100644 --- a/tests/auto/qmultimedia_common/mockmediaserviceprovider.h +++ b/tests/auto/qmultimedia_common/mockmediaserviceprovider.h @@ -43,6 +43,7 @@ #define MOCKMEDIASERVICEPROVIDER_H #include "qmediaserviceprovider.h" +#include "qmediaservice.h" // Simple provider that lets you set the service class MockMediaServiceProvider : public QMediaServiceProvider diff --git a/tests/auto/qmultimedia_common/mockvideo.pri b/tests/auto/qmultimedia_common/mockvideo.pri index a249229..6ffa036 100644 --- a/tests/auto/qmultimedia_common/mockvideo.pri +++ b/tests/auto/qmultimedia_common/mockvideo.pri @@ -3,8 +3,12 @@ INCLUDEPATH += $$PWD \ ../../../src/multimedia \ ../../../src/multimedia/video +contains(QT,multimediakitwidgets)|contains(QT,multimediakitwidgets-private) { + HEADERS *= ../qmultimedia_common/mockvideowindowcontrol.h + DEFINES *= QT_MULTIMEDIAKIT_MOCK_WIDGETS +} + HEADERS *= \ ../qmultimedia_common/mockvideosurface.h \ - ../qmultimedia_common/mockvideorenderercontrol.h \ - ../qmultimedia_common/mockvideowindowcontrol.h + ../qmultimedia_common/mockvideorenderercontrol.h diff --git a/tests/auto/qmultimedia_common/mockvideowindowcontrol.h b/tests/auto/qmultimedia_common/mockvideowindowcontrol.h index ef8c41d..981e266 100644 --- a/tests/auto/qmultimedia_common/mockvideowindowcontrol.h +++ b/tests/auto/qmultimedia_common/mockvideowindowcontrol.h @@ -42,6 +42,8 @@ #ifndef MOCKVIDEOWINDOWCONTROL_H #define MOCKVIDEOWINDOWCONTROL_H +#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS) + #include "qvideowindowcontrol.h" class MockVideoWindowControl : public QVideoWindowControl @@ -68,4 +70,5 @@ public: void setSaturation(int) {} }; +#endif // QT_MULTIMEDIAKIT_MOCK_WIDGETS #endif // MOCKVIDEOWINDOWCONTROL_H -- 2.7.4