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 <qt_sanity_bot@ovi.com> Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
461a37b412
commit
d690596868
@@ -22,6 +22,11 @@ SUBDIRS += \
|
|||||||
qvideosurfaceformat \
|
qvideosurfaceformat \
|
||||||
qmetadatareadercontrol \
|
qmetadatareadercontrol \
|
||||||
qmetadatawritercontrol \
|
qmetadatawritercontrol \
|
||||||
|
qmediaplayer \
|
||||||
|
qcameraimagecapture \
|
||||||
|
qmediaobject \
|
||||||
|
qcamera \
|
||||||
|
qcamerabackend \
|
||||||
|
|
||||||
# These is disabled until intent is clearer
|
# These is disabled until intent is clearer
|
||||||
# qvideodevicecontrol \
|
# qvideodevicecontrol \
|
||||||
@@ -38,6 +43,7 @@ contains (QT_CONFIG, private_tests) {
|
|||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
qmediaplaylist \
|
qmediaplaylist \
|
||||||
qmediapluginloader \
|
qmediapluginloader \
|
||||||
|
qmediaimageviewer \
|
||||||
qmediaserviceprovider
|
qmediaserviceprovider
|
||||||
|
|
||||||
contains (QT_CONFIG, declarative) {
|
contains (QT_CONFIG, declarative) {
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
|
|
||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
qcamera \
|
|
||||||
qcamerabackend \
|
|
||||||
qcameraimagecapture \
|
|
||||||
qcameraviewfinder \
|
qcameraviewfinder \
|
||||||
qmediaobject \
|
qcamerawidgets \
|
||||||
qmediaplayer
|
qmediaplayerwidgets \
|
||||||
|
|
||||||
# This is a commment for the mock backend directory so that maketestselftest
|
# This is a commment for the mock backend directory so that maketestselftest
|
||||||
# doesn't believe it's an untested directory
|
# doesn't believe it's an untested directory
|
||||||
@@ -17,8 +14,8 @@ SUBDIRS += \
|
|||||||
contains (QT_CONFIG, private_tests) {
|
contains (QT_CONFIG, private_tests) {
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
qgraphicsvideoitem \
|
qgraphicsvideoitem \
|
||||||
qmediaimageviewer \
|
|
||||||
qpaintervideosurface \
|
qpaintervideosurface \
|
||||||
|
qmediaimageviewerwidgets \
|
||||||
qvideowidget \
|
qvideowidget \
|
||||||
|
|
||||||
contains (QT_CONFIG, declarative) {
|
contains (QT_CONFIG, declarative) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
load(qttest_p4)
|
load(qttest_p4)
|
||||||
|
|
||||||
QT += multimediakit-private multimediakitwidgets-private
|
QT += multimediakit-private
|
||||||
CONFIG += no_private_qt_headers_warning
|
CONFIG += no_private_qt_headers_warning
|
||||||
|
|
||||||
include (../qmultimedia_common/mock.pri)
|
include (../qmultimedia_common/mock.pri)
|
||||||
|
|||||||
@@ -58,10 +58,7 @@
|
|||||||
#include <qmediaservice.h>
|
#include <qmediaservice.h>
|
||||||
#include <qcamera.h>
|
#include <qcamera.h>
|
||||||
#include <qcameraimagecapture.h>
|
#include <qcameraimagecapture.h>
|
||||||
#include <qgraphicsvideoitem.h>
|
|
||||||
#include <qvideorenderercontrol.h>
|
#include <qvideorenderercontrol.h>
|
||||||
#include <qvideowidget.h>
|
|
||||||
#include <qvideowindowcontrol.h>
|
|
||||||
|
|
||||||
#include "mockcameraservice.h"
|
#include "mockcameraservice.h"
|
||||||
|
|
||||||
@@ -1037,39 +1034,10 @@ void tst_QCamera::testCameraEncodingProperyChange()
|
|||||||
QCOMPARE(camera.status(), QCamera::ActiveStatus);
|
QCOMPARE(camera.status(), QCamera::ActiveStatus);
|
||||||
QCOMPARE(stateChangedSignal.count(), 0);
|
QCOMPARE(stateChangedSignal.count(), 0);
|
||||||
QCOMPARE(statusChangedSignal.count(), 1);
|
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()
|
void tst_QCamera::testSetVideoOutput()
|
||||||
{
|
{
|
||||||
QVideoWidget widget;
|
|
||||||
QGraphicsVideoItem item;
|
|
||||||
MockVideoSurface surface;
|
MockVideoSurface surface;
|
||||||
|
|
||||||
MockCameraService service;
|
MockCameraService service;
|
||||||
@@ -1077,21 +1045,9 @@ void tst_QCamera::testSetVideoOutput()
|
|||||||
provider.service = &service;
|
provider.service = &service;
|
||||||
QCamera camera(0, &provider);
|
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<QVideoWidget *>(0));
|
camera.setViewfinder(reinterpret_cast<QVideoWidget *>(0));
|
||||||
QVERIFY(item.mediaObject() == 0);
|
|
||||||
|
|
||||||
camera.setViewfinder(&widget);
|
|
||||||
QVERIFY(widget.mediaObject() == &camera);
|
|
||||||
|
|
||||||
camera.setViewfinder(reinterpret_cast<QGraphicsVideoItem *>(0));
|
camera.setViewfinder(reinterpret_cast<QGraphicsVideoItem *>(0));
|
||||||
QVERIFY(widget.mediaObject() == 0);
|
|
||||||
|
|
||||||
camera.setViewfinder(&surface);
|
camera.setViewfinder(&surface);
|
||||||
QVERIFY(service.rendererControl->surface() == &surface);
|
QVERIFY(service.rendererControl->surface() == &surface);
|
||||||
@@ -1102,56 +1058,37 @@ void tst_QCamera::testSetVideoOutput()
|
|||||||
camera.setViewfinder(&surface);
|
camera.setViewfinder(&surface);
|
||||||
QVERIFY(service.rendererControl->surface() == &surface);
|
QVERIFY(service.rendererControl->surface() == &surface);
|
||||||
|
|
||||||
camera.setViewfinder(&widget);
|
camera.setViewfinder(reinterpret_cast<QVideoWidget *>(0));
|
||||||
QVERIFY(service.rendererControl->surface() == 0);
|
QVERIFY(service.rendererControl->surface() == 0);
|
||||||
QVERIFY(widget.mediaObject() == &camera);
|
|
||||||
|
|
||||||
camera.setViewfinder(&surface);
|
camera.setViewfinder(&surface);
|
||||||
QVERIFY(service.rendererControl->surface() == &surface);
|
QVERIFY(service.rendererControl->surface() == &surface);
|
||||||
QVERIFY(widget.mediaObject() == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void tst_QCamera::testSetVideoOutputNoService()
|
void tst_QCamera::testSetVideoOutputNoService()
|
||||||
{
|
{
|
||||||
QVideoWidget widget;
|
|
||||||
QGraphicsVideoItem item;
|
|
||||||
MockVideoSurface surface;
|
MockVideoSurface surface;
|
||||||
|
|
||||||
MockMediaServiceProvider provider;
|
MockMediaServiceProvider provider;
|
||||||
provider.service = 0;
|
provider.service = 0;
|
||||||
QCamera camera(0, &provider);
|
QCamera camera(0, &provider);
|
||||||
|
|
||||||
camera.setViewfinder(&widget);
|
|
||||||
QVERIFY(widget.mediaObject() == 0);
|
|
||||||
|
|
||||||
camera.setViewfinder(&item);
|
|
||||||
QVERIFY(item.mediaObject() == 0);
|
|
||||||
|
|
||||||
camera.setViewfinder(&surface);
|
camera.setViewfinder(&surface);
|
||||||
// Nothing we can verify here other than it doesn't assert.
|
// Nothing we can verify here other than it doesn't assert.
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QCamera::testSetVideoOutputNoControl()
|
void tst_QCamera::testSetVideoOutputNoControl()
|
||||||
{
|
{
|
||||||
QVideoWidget widget;
|
|
||||||
QGraphicsVideoItem item;
|
|
||||||
MockVideoSurface surface;
|
MockVideoSurface surface;
|
||||||
|
|
||||||
MockCameraService service;
|
MockCameraService service;
|
||||||
service.rendererRef = 1;
|
service.rendererRef = 1;
|
||||||
service.windowRef = 1;
|
|
||||||
|
|
||||||
MockMediaServiceProvider provider;
|
MockMediaServiceProvider provider;
|
||||||
provider.service = &service;
|
provider.service = &service;
|
||||||
QCamera camera(0, &provider);
|
QCamera camera(0, &provider);
|
||||||
|
|
||||||
camera.setViewfinder(&widget);
|
|
||||||
QVERIFY(widget.mediaObject() == 0);
|
|
||||||
|
|
||||||
camera.setViewfinder(&item);
|
|
||||||
QVERIFY(item.mediaObject() == 0);
|
|
||||||
|
|
||||||
camera.setViewfinder(&surface);
|
camera.setViewfinder(&surface);
|
||||||
QVERIFY(service.rendererControl->surface() == 0);
|
QVERIFY(service.rendererControl->surface() == 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
load(qttest_p4)
|
load(qttest_p4)
|
||||||
|
|
||||||
QT += multimediakit-private multimediakitwidgets-private
|
QT += multimediakit-private
|
||||||
CONFIG += no_private_qt_headers_warning
|
CONFIG += no_private_qt_headers_warning
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
|||||||
@@ -63,8 +63,6 @@ Reviewer Name Date Coverage ( Full / Test Case IDs ).
|
|||||||
#include <qmediaservice.h>
|
#include <qmediaservice.h>
|
||||||
#include <qcamera.h>
|
#include <qcamera.h>
|
||||||
#include <qcameraimagecapture.h>
|
#include <qcameraimagecapture.h>
|
||||||
#include <qgraphicsvideoitem.h>
|
|
||||||
#include <qcameraviewfinder.h>
|
|
||||||
|
|
||||||
#include "mockcameraservice.h"
|
#include "mockcameraservice.h"
|
||||||
#include "mockmediaserviceprovider.h"
|
#include "mockmediaserviceprovider.h"
|
||||||
|
|||||||
11
tests/auto/qcamerawidgets/qcamerawidgets.pro
Normal file
11
tests/auto/qcamerawidgets/qcamerawidgets.pro
Normal file
@@ -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
|
||||||
319
tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp
Normal file
319
tests/auto/qcamerawidgets/tst_qcamerawidgets.cpp
Normal file
@@ -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 <QtTest/QtTest>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <qabstractvideosurface.h>
|
||||||
|
#include <qcameracontrol.h>
|
||||||
|
#include <qcameralockscontrol.h>
|
||||||
|
#include <qcameraexposurecontrol.h>
|
||||||
|
#include <qcameraflashcontrol.h>
|
||||||
|
#include <qcamerafocuscontrol.h>
|
||||||
|
#include <qcameraimagecapturecontrol.h>
|
||||||
|
#include <qimageencodercontrol.h>
|
||||||
|
#include <qcameraimageprocessingcontrol.h>
|
||||||
|
#include <qcameracapturebufferformatcontrol.h>
|
||||||
|
#include <qcameracapturedestinationcontrol.h>
|
||||||
|
#include <qmediaservice.h>
|
||||||
|
#include <qcamera.h>
|
||||||
|
#include <qcameraimagecapture.h>
|
||||||
|
#include <qgraphicsvideoitem.h>
|
||||||
|
#include <qvideorenderercontrol.h>
|
||||||
|
#include <qvideowidget.h>
|
||||||
|
#include <qvideowindowcontrol.h>
|
||||||
|
|
||||||
|
#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>("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<QVideoWidget *>(0));
|
||||||
|
QVERIFY(item.mediaObject() == 0);
|
||||||
|
|
||||||
|
camera.setViewfinder(&widget);
|
||||||
|
QVERIFY(widget.mediaObject() == &camera);
|
||||||
|
|
||||||
|
camera.setViewfinder(reinterpret_cast<QGraphicsVideoItem *>(0));
|
||||||
|
QVERIFY(widget.mediaObject() == 0);
|
||||||
|
|
||||||
|
camera.setViewfinder(&surface);
|
||||||
|
QVERIFY(service.rendererControl->surface() == &surface);
|
||||||
|
|
||||||
|
camera.setViewfinder(reinterpret_cast<QAbstractVideoSurface *>(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"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
load(qttest_p4)
|
load(qttest_p4)
|
||||||
|
|
||||||
QT += multimediakit-private multimediakitwidgets-private declarative
|
QT += multimediakit-private declarative
|
||||||
CONFIG += no_private_qt_headers_warning
|
CONFIG += no_private_qt_headers_warning
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
load(qttest_p4)
|
load(qttest_p4)
|
||||||
|
|
||||||
QT += multimediakit-private multimediakitwidgets-private network
|
QT += multimediakit-private network
|
||||||
CONFIG += no_private_qt_headers_warning
|
CONFIG += no_private_qt_headers_warning
|
||||||
|
|
||||||
SOURCES += tst_qmediaimageviewer.cpp
|
SOURCES += tst_qmediaimageviewer.cpp
|
||||||
|
|||||||
@@ -46,14 +46,11 @@
|
|||||||
|
|
||||||
#include <QtCore/qdir.h>
|
#include <QtCore/qdir.h>
|
||||||
|
|
||||||
#include <qgraphicsvideoitem.h>
|
|
||||||
#include <qmediaimageviewer.h>
|
#include <qmediaimageviewer.h>
|
||||||
#include <private/qmediaimageviewerservice_p.h>
|
#include <private/qmediaimageviewerservice_p.h>
|
||||||
#include <qmediaplaylist.h>
|
#include <qmediaplaylist.h>
|
||||||
#include <qmediaservice.h>
|
#include <qmediaservice.h>
|
||||||
#include <qvideorenderercontrol.h>
|
#include <qvideorenderercontrol.h>
|
||||||
#include <qvideowidget.h>
|
|
||||||
#include <qvideowidgetcontrol.h>
|
|
||||||
|
|
||||||
#include <QtCore/qfile.h>
|
#include <QtCore/qfile.h>
|
||||||
#include <QtNetwork/qnetworkaccessmanager.h>
|
#include <QtNetwork/qnetworkaccessmanager.h>
|
||||||
@@ -998,25 +995,11 @@ void tst_QMediaImageViewer::setVideoOutput()
|
|||||||
if (imageViewer.mediaStatus() != QMediaImageViewer::LoadedMedia)
|
if (imageViewer.mediaStatus() != QMediaImageViewer::LoadedMedia)
|
||||||
QSKIP("failed to load test image", SkipSingle);
|
QSKIP("failed to load test image", SkipSingle);
|
||||||
|
|
||||||
QVideoWidget widget;
|
|
||||||
QGraphicsVideoItem item;
|
|
||||||
QtTestVideoSurface surface;
|
QtTestVideoSurface surface;
|
||||||
|
|
||||||
imageViewer.setVideoOutput(&widget);
|
|
||||||
QVERIFY(widget.mediaObject() == &imageViewer);
|
|
||||||
|
|
||||||
imageViewer.setVideoOutput(&item);
|
|
||||||
QVERIFY(widget.mediaObject() == 0);
|
|
||||||
QVERIFY(item.mediaObject() == &imageViewer);
|
|
||||||
|
|
||||||
imageViewer.setVideoOutput(reinterpret_cast<QVideoWidget *>(0));
|
imageViewer.setVideoOutput(reinterpret_cast<QVideoWidget *>(0));
|
||||||
QVERIFY(item.mediaObject() == 0);
|
|
||||||
|
|
||||||
imageViewer.setVideoOutput(&widget);
|
|
||||||
QVERIFY(widget.mediaObject() == &imageViewer);
|
|
||||||
|
|
||||||
imageViewer.setVideoOutput(reinterpret_cast<QGraphicsVideoItem *>(0));
|
imageViewer.setVideoOutput(reinterpret_cast<QGraphicsVideoItem *>(0));
|
||||||
QVERIFY(widget.mediaObject() == 0);
|
|
||||||
|
|
||||||
imageViewer.setVideoOutput(&surface);
|
imageViewer.setVideoOutput(&surface);
|
||||||
QVERIFY(surface.isActive());
|
QVERIFY(surface.isActive());
|
||||||
@@ -1027,13 +1010,11 @@ void tst_QMediaImageViewer::setVideoOutput()
|
|||||||
imageViewer.setVideoOutput(&surface);
|
imageViewer.setVideoOutput(&surface);
|
||||||
QVERIFY(surface.isActive());
|
QVERIFY(surface.isActive());
|
||||||
|
|
||||||
imageViewer.setVideoOutput(&widget);
|
imageViewer.setVideoOutput(reinterpret_cast<QVideoWidget *>(0));
|
||||||
QVERIFY(!surface.isActive());
|
QVERIFY(!surface.isActive());
|
||||||
QVERIFY(widget.mediaObject() == &imageViewer);
|
|
||||||
|
|
||||||
imageViewer.setVideoOutput(&surface);
|
imageViewer.setVideoOutput(&surface);
|
||||||
QVERIFY(surface.isActive());
|
QVERIFY(surface.isActive());
|
||||||
QVERIFY(widget.mediaObject() == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMediaImageViewer::debugEnums()
|
void tst_QMediaImageViewer::debugEnums()
|
||||||
|
|||||||
5
tests/auto/qmediaimageviewerwidgets/images.qrc
Normal file
5
tests/auto/qmediaimageviewerwidgets/images.qrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>images/image.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
BIN
tests/auto/qmediaimageviewerwidgets/images/image.png
Normal file
BIN
tests/auto/qmediaimageviewerwidgets/images/image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 230 B |
@@ -0,0 +1,15 @@
|
|||||||
|
load(qttest_p4)
|
||||||
|
|
||||||
|
QT += multimediakit-private multimediakitwidgets-private network
|
||||||
|
CONFIG += no_private_qt_headers_warning
|
||||||
|
|
||||||
|
SOURCES += tst_qmediaimageviewerwidgets.cpp
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
images.qrc
|
||||||
|
|
||||||
|
!contains(QT_CONFIG, no-jpeg):DEFINES += QTEST_HAVE_JPEG
|
||||||
|
|
||||||
|
wince* {
|
||||||
|
!contains(QT_CONFIG, no-jpeg): DEPLOYMENT_PLUGIN += qjpeg
|
||||||
|
}
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 <qtmultimediakitdefs.h>
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
#include <QtCore/qdir.h>
|
||||||
|
|
||||||
|
#include <qgraphicsvideoitem.h>
|
||||||
|
#include <qmediaimageviewer.h>
|
||||||
|
#include <private/qmediaimageviewerservice_p.h>
|
||||||
|
#include <qmediaplaylist.h>
|
||||||
|
#include <qmediaservice.h>
|
||||||
|
#include <qvideorenderercontrol.h>
|
||||||
|
#include <qvideowidget.h>
|
||||||
|
#include <qvideowidgetcontrol.h>
|
||||||
|
|
||||||
|
#include <qabstractvideosurface.h>
|
||||||
|
#include <qvideosurfaceformat.h>
|
||||||
|
|
||||||
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
|
class tst_QMediaImageViewerWidgets : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private slots:
|
||||||
|
void setVideoOutput();
|
||||||
|
};
|
||||||
|
|
||||||
|
class QtTestVideoSurface : public QAbstractVideoSurface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||||
|
QAbstractVideoBuffer::HandleType handleType) const {
|
||||||
|
QList<QVideoFrame::PixelFormat> 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<QVideoWidget *>(0));
|
||||||
|
QVERIFY(item.mediaObject() == 0);
|
||||||
|
|
||||||
|
imageViewer.setVideoOutput(&widget);
|
||||||
|
QVERIFY(widget.mediaObject() == &imageViewer);
|
||||||
|
|
||||||
|
imageViewer.setVideoOutput(reinterpret_cast<QGraphicsVideoItem *>(0));
|
||||||
|
QVERIFY(widget.mediaObject() == 0);
|
||||||
|
|
||||||
|
imageViewer.setVideoOutput(&surface);
|
||||||
|
QVERIFY(surface.isActive());
|
||||||
|
|
||||||
|
imageViewer.setVideoOutput(reinterpret_cast<QAbstractVideoSurface *>(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"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
load(qttest_p4)
|
load(qttest_p4)
|
||||||
|
|
||||||
QT += multimediakit-private multimediakitwidgets
|
QT += multimediakit-private
|
||||||
CONFIG += no_private_qt_headers_warning
|
CONFIG += no_private_qt_headers_warning
|
||||||
|
|
||||||
include (../qmultimedia_common/mockrecorder.pri)
|
include (../qmultimedia_common/mockrecorder.pri)
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
//TESTED_COMPONENT=src/multimedia
|
//TESTED_COMPONENT=src/multimedia
|
||||||
|
|
||||||
#include "tst_qmediaobject.h"
|
#include "tst_qmediaobject.h"
|
||||||
#include "qvideowidget.h"
|
|
||||||
|
|
||||||
#include "mockmediarecorderservice.h"
|
#include "mockmediarecorderservice.h"
|
||||||
#include "mockmediaserviceprovider.h"
|
#include "mockmediaserviceprovider.h"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
load(qttest_p4)
|
load(qttest_p4)
|
||||||
|
|
||||||
QT += network multimediakit-private multimediakitwidgets-private
|
QT += network multimediakit-private
|
||||||
CONFIG += no_private_qt_headers_warning
|
CONFIG += no_private_qt_headers_warning
|
||||||
|
|
||||||
HEADERS += tst_qmediaplayer.h
|
HEADERS += tst_qmediaplayer.h
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
|
|
||||||
#include "tst_qmediaplayer.h"
|
#include "tst_qmediaplayer.h"
|
||||||
|
|
||||||
#include <qgraphicsvideoitem.h>
|
|
||||||
#include <QtNetwork/qnetworkconfigmanager.h>
|
#include <QtNetwork/qnetworkconfigmanager.h>
|
||||||
|
|
||||||
// Encouraging successful diversity through copy and paste.
|
// Encouraging successful diversity through copy and paste.
|
||||||
@@ -936,29 +935,14 @@ void tst_QMediaPlayer::testNetworkAccess()
|
|||||||
|
|
||||||
void tst_QMediaPlayer::testSetVideoOutput()
|
void tst_QMediaPlayer::testSetVideoOutput()
|
||||||
{
|
{
|
||||||
QVideoWidget widget;
|
|
||||||
QGraphicsVideoItem item;
|
|
||||||
MockVideoSurface surface;
|
MockVideoSurface surface;
|
||||||
|
|
||||||
MockMediaPlayerService service;
|
MockMediaPlayerService service;
|
||||||
MockMediaServiceProvider provider(&service);
|
MockMediaServiceProvider provider(&service);
|
||||||
QMediaPlayer player(0, 0, &provider);
|
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<QVideoWidget *>(0));
|
player.setVideoOutput(reinterpret_cast<QVideoWidget *>(0));
|
||||||
QVERIFY(item.mediaObject() == 0);
|
|
||||||
|
|
||||||
player.setVideoOutput(&widget);
|
|
||||||
QVERIFY(widget.mediaObject() == &player);
|
|
||||||
|
|
||||||
player.setVideoOutput(reinterpret_cast<QGraphicsVideoItem *>(0));
|
player.setVideoOutput(reinterpret_cast<QGraphicsVideoItem *>(0));
|
||||||
QVERIFY(widget.mediaObject() == 0);
|
|
||||||
|
|
||||||
player.setVideoOutput(&surface);
|
player.setVideoOutput(&surface);
|
||||||
QVERIFY(service.rendererControl->surface() == &surface);
|
QVERIFY(service.rendererControl->surface() == &surface);
|
||||||
@@ -969,54 +953,35 @@ void tst_QMediaPlayer::testSetVideoOutput()
|
|||||||
player.setVideoOutput(&surface);
|
player.setVideoOutput(&surface);
|
||||||
QVERIFY(service.rendererControl->surface() == &surface);
|
QVERIFY(service.rendererControl->surface() == &surface);
|
||||||
|
|
||||||
player.setVideoOutput(&widget);
|
player.setVideoOutput(reinterpret_cast<QVideoWidget *>(0));
|
||||||
QVERIFY(service.rendererControl->surface() == 0);
|
QVERIFY(service.rendererControl->surface() == 0);
|
||||||
QVERIFY(widget.mediaObject() == &player);
|
|
||||||
|
|
||||||
player.setVideoOutput(&surface);
|
player.setVideoOutput(&surface);
|
||||||
QVERIFY(service.rendererControl->surface() == &surface);
|
QVERIFY(service.rendererControl->surface() == &surface);
|
||||||
QVERIFY(widget.mediaObject() == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void tst_QMediaPlayer::testSetVideoOutputNoService()
|
void tst_QMediaPlayer::testSetVideoOutputNoService()
|
||||||
{
|
{
|
||||||
QVideoWidget widget;
|
|
||||||
QGraphicsVideoItem item;
|
|
||||||
MockVideoSurface surface;
|
MockVideoSurface surface;
|
||||||
|
|
||||||
MockMediaServiceProvider provider(0, true);
|
MockMediaServiceProvider provider(0, true);
|
||||||
QMediaPlayer player(0, 0, &provider);
|
QMediaPlayer player(0, 0, &provider);
|
||||||
|
|
||||||
player.setVideoOutput(&widget);
|
|
||||||
QVERIFY(widget.mediaObject() == 0);
|
|
||||||
|
|
||||||
player.setVideoOutput(&item);
|
|
||||||
QVERIFY(item.mediaObject() == 0);
|
|
||||||
|
|
||||||
player.setVideoOutput(&surface);
|
player.setVideoOutput(&surface);
|
||||||
// Nothing we can verify here other than it doesn't assert.
|
// Nothing we can verify here other than it doesn't assert.
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMediaPlayer::testSetVideoOutputNoControl()
|
void tst_QMediaPlayer::testSetVideoOutputNoControl()
|
||||||
{
|
{
|
||||||
QVideoWidget widget;
|
|
||||||
QGraphicsVideoItem item;
|
|
||||||
MockVideoSurface surface;
|
MockVideoSurface surface;
|
||||||
|
|
||||||
MockMediaPlayerService service;
|
MockMediaPlayerService service;
|
||||||
service.rendererRef = 1;
|
service.rendererRef = 1;
|
||||||
service.windowRef = 1;
|
|
||||||
|
|
||||||
MockMediaServiceProvider provider(&service);
|
MockMediaServiceProvider provider(&service);
|
||||||
QMediaPlayer player(0, 0, &provider);
|
QMediaPlayer player(0, 0, &provider);
|
||||||
|
|
||||||
player.setVideoOutput(&widget);
|
|
||||||
QVERIFY(widget.mediaObject() == 0);
|
|
||||||
|
|
||||||
player.setVideoOutput(&item);
|
|
||||||
QVERIFY(item.mediaObject() == 0);
|
|
||||||
|
|
||||||
player.setVideoOutput(&surface);
|
player.setVideoOutput(&surface);
|
||||||
QVERIFY(service.rendererControl->surface() == 0);
|
QVERIFY(service.rendererControl->surface() == 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,6 @@
|
|||||||
#include <qmediastreamscontrol.h>
|
#include <qmediastreamscontrol.h>
|
||||||
#include <qmedianetworkaccesscontrol.h>
|
#include <qmedianetworkaccesscontrol.h>
|
||||||
#include <qvideorenderercontrol.h>
|
#include <qvideorenderercontrol.h>
|
||||||
#include <qvideowindowcontrol.h>
|
|
||||||
|
|
||||||
#include "mockmediaserviceprovider.h"
|
#include "mockmediaserviceprovider.h"
|
||||||
#include "mockmediaplayerservice.h"
|
#include "mockmediaplayerservice.h"
|
||||||
|
|||||||
53
tests/auto/qmediaplayerwidgets/main.cpp
Executable file
53
tests/auto/qmediaplayerwidgets/main.cpp
Executable file
@@ -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 <QtCore/qcoreapplication.h>
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
10
tests/auto/qmediaplayerwidgets/qmediaplayerwidgets.pro
Normal file
10
tests/auto/qmediaplayerwidgets/qmediaplayerwidgets.pro
Normal file
@@ -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)
|
||||||
162
tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp
Normal file
162
tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp
Normal file
@@ -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 <qgraphicsvideoitem.h>
|
||||||
|
|
||||||
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
|
void tst_QMediaPlayerWidgets::initTestCase()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<QMediaPlayer::State>("QMediaPlayer::State");
|
||||||
|
qRegisterMetaType<QMediaPlayer::Error>("QMediaPlayer::Error");
|
||||||
|
qRegisterMetaType<QMediaPlayer::MediaStatus>("QMediaPlayer::MediaStatus");
|
||||||
|
qRegisterMetaType<QMediaContent>("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<QVideoWidget *>(0));
|
||||||
|
QVERIFY(item.mediaObject() == 0);
|
||||||
|
|
||||||
|
player.setVideoOutput(&widget);
|
||||||
|
QVERIFY(widget.mediaObject() == &player);
|
||||||
|
|
||||||
|
player.setVideoOutput(reinterpret_cast<QGraphicsVideoItem *>(0));
|
||||||
|
QVERIFY(widget.mediaObject() == 0);
|
||||||
|
|
||||||
|
player.setVideoOutput(&surface);
|
||||||
|
QVERIFY(service.rendererControl->surface() == &surface);
|
||||||
|
|
||||||
|
player.setVideoOutput(reinterpret_cast<QAbstractVideoSurface *>(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);
|
||||||
|
}
|
||||||
|
|
||||||
79
tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.h
Executable file
79
tests/auto/qmediaplayerwidgets/tst_qmediaplayerwidgets.h
Executable file
@@ -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 <QtTest/QtTest>
|
||||||
|
#include <QtCore/qdebug.h>
|
||||||
|
#include <QtCore/qbuffer.h>
|
||||||
|
#include <QtNetwork/qnetworkconfiguration.h>
|
||||||
|
|
||||||
|
#include <qabstractvideosurface.h>
|
||||||
|
#include <qmediaplayer.h>
|
||||||
|
#include <qmediaplayercontrol.h>
|
||||||
|
|
||||||
|
#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
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
load(qttest_p4)
|
load(qttest_p4)
|
||||||
|
|
||||||
QT += multimediakit-private multimediakitwidgets-private
|
QT += multimediakit-private
|
||||||
CONFIG += no_private_qt_headers_warning
|
CONFIG += no_private_qt_headers_warning
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
|||||||
@@ -55,7 +55,10 @@
|
|||||||
#include "../qmultimedia_common/mockcameracontrol.h"
|
#include "../qmultimedia_common/mockcameracontrol.h"
|
||||||
#include "../qmultimedia_common/mockvideosurface.h"
|
#include "../qmultimedia_common/mockvideosurface.h"
|
||||||
#include "../qmultimedia_common/mockvideorenderercontrol.h"
|
#include "../qmultimedia_common/mockvideorenderercontrol.h"
|
||||||
|
|
||||||
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
#include "../qmultimedia_common/mockvideowindowcontrol.h"
|
#include "../qmultimedia_common/mockvideowindowcontrol.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class MockSimpleCameraService : public QMediaService
|
class MockSimpleCameraService : public QMediaService
|
||||||
{
|
{
|
||||||
@@ -102,7 +105,9 @@ public:
|
|||||||
mockImageProcessingControl = new MockImageProcessingControl(this);
|
mockImageProcessingControl = new MockImageProcessingControl(this);
|
||||||
mockImageEncoderControl = new MockImageEncoderControl(this);
|
mockImageEncoderControl = new MockImageEncoderControl(this);
|
||||||
rendererControl = new MockVideoRendererControl(this);
|
rendererControl = new MockVideoRendererControl(this);
|
||||||
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
windowControl = new MockVideoWindowControl(this);
|
windowControl = new MockVideoWindowControl(this);
|
||||||
|
#endif
|
||||||
rendererRef = 0;
|
rendererRef = 0;
|
||||||
windowRef = 0;
|
windowRef = 0;
|
||||||
}
|
}
|
||||||
@@ -148,12 +153,15 @@ public:
|
|||||||
rendererRef += 1;
|
rendererRef += 1;
|
||||||
return rendererControl;
|
return rendererControl;
|
||||||
}
|
}
|
||||||
} else if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
|
}
|
||||||
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
|
if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
|
||||||
if (windowRef == 0) {
|
if (windowRef == 0) {
|
||||||
windowRef += 1;
|
windowRef += 1;
|
||||||
return windowControl;
|
return windowControl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,8 +169,10 @@ public:
|
|||||||
{
|
{
|
||||||
if (control == rendererControl)
|
if (control == rendererControl)
|
||||||
rendererRef -= 1;
|
rendererRef -= 1;
|
||||||
else if (control == windowControl)
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
|
if (control == windowControl)
|
||||||
windowRef -= 1;
|
windowRef -= 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MockCameraControl *mockControl;
|
MockCameraControl *mockControl;
|
||||||
@@ -176,7 +186,9 @@ public:
|
|||||||
MockImageProcessingControl *mockImageProcessingControl;
|
MockImageProcessingControl *mockImageProcessingControl;
|
||||||
MockImageEncoderControl *mockImageEncoderControl;
|
MockImageEncoderControl *mockImageEncoderControl;
|
||||||
MockVideoRendererControl *rendererControl;
|
MockVideoRendererControl *rendererControl;
|
||||||
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
MockVideoWindowControl *windowControl;
|
MockVideoWindowControl *windowControl;
|
||||||
|
#endif
|
||||||
int rendererRef;
|
int rendererRef;
|
||||||
int windowRef;
|
int windowRef;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,7 +48,9 @@
|
|||||||
#include "mockmediastreamscontrol.h"
|
#include "mockmediastreamscontrol.h"
|
||||||
#include "mockmedianetworkaccesscontrol.h"
|
#include "mockmedianetworkaccesscontrol.h"
|
||||||
#include "mockvideorenderercontrol.h"
|
#include "mockvideorenderercontrol.h"
|
||||||
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
#include "mockvideowindowcontrol.h"
|
#include "mockvideowindowcontrol.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class MockMediaPlayerService : public QMediaService
|
class MockMediaPlayerService : public QMediaService
|
||||||
{
|
{
|
||||||
@@ -61,9 +63,11 @@ public:
|
|||||||
mockStreamsControl = new MockStreamsControl;
|
mockStreamsControl = new MockStreamsControl;
|
||||||
mockNetworkControl = new MockNetworkAccessControl;
|
mockNetworkControl = new MockNetworkAccessControl;
|
||||||
rendererControl = new MockVideoRendererControl;
|
rendererControl = new MockVideoRendererControl;
|
||||||
windowControl = new MockVideoWindowControl;
|
|
||||||
rendererRef = 0;
|
rendererRef = 0;
|
||||||
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
|
windowControl = new MockVideoWindowControl;
|
||||||
windowRef = 0;
|
windowRef = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
~MockMediaPlayerService()
|
~MockMediaPlayerService()
|
||||||
@@ -72,7 +76,9 @@ public:
|
|||||||
delete mockStreamsControl;
|
delete mockStreamsControl;
|
||||||
delete mockNetworkControl;
|
delete mockNetworkControl;
|
||||||
delete rendererControl;
|
delete rendererControl;
|
||||||
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
delete windowControl;
|
delete windowControl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QMediaControl* requestControl(const char *iid)
|
QMediaControl* requestControl(const char *iid)
|
||||||
@@ -84,13 +90,15 @@ public:
|
|||||||
rendererRef += 1;
|
rendererRef += 1;
|
||||||
return rendererControl;
|
return rendererControl;
|
||||||
}
|
}
|
||||||
} else if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
|
}
|
||||||
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
|
if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
|
||||||
if (windowRef == 0) {
|
if (windowRef == 0) {
|
||||||
windowRef += 1;
|
windowRef += 1;
|
||||||
return windowControl;
|
return windowControl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (qstrcmp(iid, QMediaNetworkAccessControl_iid) == 0)
|
if (qstrcmp(iid, QMediaNetworkAccessControl_iid) == 0)
|
||||||
return mockNetworkControl;
|
return mockNetworkControl;
|
||||||
@@ -101,8 +109,10 @@ public:
|
|||||||
{
|
{
|
||||||
if (control == rendererControl)
|
if (control == rendererControl)
|
||||||
rendererRef -= 1;
|
rendererRef -= 1;
|
||||||
else if (control == windowControl)
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
|
if (control == windowControl)
|
||||||
windowRef -= 1;
|
windowRef -= 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void setState(QMediaPlayer::State state) { emit mockControl->stateChanged(mockControl->_state = state); }
|
void setState(QMediaPlayer::State state) { emit mockControl->stateChanged(mockControl->_state = state); }
|
||||||
@@ -154,9 +164,11 @@ public:
|
|||||||
MockStreamsControl *mockStreamsControl;
|
MockStreamsControl *mockStreamsControl;
|
||||||
MockNetworkAccessControl *mockNetworkControl;
|
MockNetworkAccessControl *mockNetworkControl;
|
||||||
MockVideoRendererControl *rendererControl;
|
MockVideoRendererControl *rendererControl;
|
||||||
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
MockVideoWindowControl *windowControl;
|
MockVideoWindowControl *windowControl;
|
||||||
int rendererRef;
|
|
||||||
int windowRef;
|
int windowRef;
|
||||||
|
#endif
|
||||||
|
int rendererRef;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#define MOCKMEDIASERVICEPROVIDER_H
|
#define MOCKMEDIASERVICEPROVIDER_H
|
||||||
|
|
||||||
#include "qmediaserviceprovider.h"
|
#include "qmediaserviceprovider.h"
|
||||||
|
#include "qmediaservice.h"
|
||||||
|
|
||||||
// Simple provider that lets you set the service
|
// Simple provider that lets you set the service
|
||||||
class MockMediaServiceProvider : public QMediaServiceProvider
|
class MockMediaServiceProvider : public QMediaServiceProvider
|
||||||
|
|||||||
@@ -3,8 +3,12 @@ INCLUDEPATH += $$PWD \
|
|||||||
../../../src/multimedia \
|
../../../src/multimedia \
|
||||||
../../../src/multimedia/video
|
../../../src/multimedia/video
|
||||||
|
|
||||||
|
contains(QT,multimediakitwidgets)|contains(QT,multimediakitwidgets-private) {
|
||||||
|
HEADERS *= ../qmultimedia_common/mockvideowindowcontrol.h
|
||||||
|
DEFINES *= QT_MULTIMEDIAKIT_MOCK_WIDGETS
|
||||||
|
}
|
||||||
|
|
||||||
HEADERS *= \
|
HEADERS *= \
|
||||||
../qmultimedia_common/mockvideosurface.h \
|
../qmultimedia_common/mockvideosurface.h \
|
||||||
../qmultimedia_common/mockvideorenderercontrol.h \
|
../qmultimedia_common/mockvideorenderercontrol.h
|
||||||
../qmultimedia_common/mockvideowindowcontrol.h
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,8 @@
|
|||||||
#ifndef MOCKVIDEOWINDOWCONTROL_H
|
#ifndef MOCKVIDEOWINDOWCONTROL_H
|
||||||
#define MOCKVIDEOWINDOWCONTROL_H
|
#define MOCKVIDEOWINDOWCONTROL_H
|
||||||
|
|
||||||
|
#if defined(QT_MULTIMEDIAKIT_MOCK_WIDGETS)
|
||||||
|
|
||||||
#include "qvideowindowcontrol.h"
|
#include "qvideowindowcontrol.h"
|
||||||
|
|
||||||
class MockVideoWindowControl : public QVideoWindowControl
|
class MockVideoWindowControl : public QVideoWindowControl
|
||||||
@@ -68,4 +70,5 @@ public:
|
|||||||
void setSaturation(int) {}
|
void setSaturation(int) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // QT_MULTIMEDIAKIT_MOCK_WIDGETS
|
||||||
#endif // MOCKVIDEOWINDOWCONTROL_H
|
#endif // MOCKVIDEOWINDOWCONTROL_H
|
||||||
|
|||||||
Reference in New Issue
Block a user