Rearrange the automatic tests.
Split them into unit and integration tests. Integration tests really need to be run on the real platform (not in a VM etc) since they are somewhat unstable or nonfunctional otherwise. A few tests were previously broken by QUrl changes and they were repaired. Removed one test since it was not providing a lot of value. There are still a number of tests that rely on Q_AUTOTEST_EXPORT symbols. Change-Id: Ic402abf0af946baa5945075d975b3f584f9ef280 Reviewed-by: Kalle Lehtonen <kalle.ju.lehtonen@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
7dfb883df6
commit
e3a8c165ea
41
tests/auto/unit/multimedia.pro
Normal file
41
tests/auto/unit/multimedia.pro
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS += \
|
||||
qabstractvideobuffer \
|
||||
qabstractvideosurface \
|
||||
qaudiocapturesource \
|
||||
qaudiodeviceinfo \
|
||||
qaudioformat \
|
||||
qaudionamespace \
|
||||
qcamera \
|
||||
qcameraimagecapture \
|
||||
qmediabindableinterface \
|
||||
qmediacontainercontrol \
|
||||
qmediacontent \
|
||||
qmediaobject \
|
||||
qmediaplayer \
|
||||
qmediaplaylistnavigator \
|
||||
qmediarecorder \
|
||||
qmediaresource \
|
||||
qmediaservice \
|
||||
qmediatimerange \
|
||||
qmetadatareadercontrol \
|
||||
qmetadatawritercontrol \
|
||||
qradiodata \
|
||||
qradiotuner \
|
||||
qvideoencodercontrol \
|
||||
qvideoframe \
|
||||
qvideosurfaceformat \
|
||||
qwavedecoder
|
||||
|
||||
# Tests depending on private interfaces should only be built if
|
||||
# these interfaces are exported.
|
||||
contains (QT_CONFIG, private_tests) {
|
||||
# These depend on controlling the set of plugins loaded (in qmediapluginloader)
|
||||
SUBDIRS += \
|
||||
qdeclarativeaudio \
|
||||
qmediaplaylist \
|
||||
qmediapluginloader \
|
||||
qmediaimageviewer \
|
||||
qmediaserviceprovider
|
||||
}
|
||||
17
tests/auto/unit/multimediawidgets.pro
Normal file
17
tests/auto/unit/multimediawidgets.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS += \
|
||||
qcameraviewfinder \
|
||||
qcamerawidgets \
|
||||
qmediaplayerwidgets \
|
||||
|
||||
# Tests depending on private interfaces should only be built if
|
||||
# these interfaces are exported.
|
||||
contains (QT_CONFIG, private_tests) {
|
||||
SUBDIRS += \
|
||||
qgraphicsvideoitem \
|
||||
qpaintervideosurface \
|
||||
qmediaimageviewerwidgets \
|
||||
qvideowidget \
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qabstractvideobuffer
|
||||
|
||||
QT += core multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qabstractvideobuffer.cpp
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 <qabstractvideobuffer.h>
|
||||
|
||||
// Adds an enum, and the stringized version
|
||||
#define ADD_ENUM_TEST(x) \
|
||||
QTest::newRow(#x) \
|
||||
<< QAbstractVideoBuffer::x \
|
||||
<< QString(QLatin1String(#x));
|
||||
|
||||
class tst_QAbstractVideoBuffer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_QAbstractVideoBuffer();
|
||||
~tst_QAbstractVideoBuffer();
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
private slots:
|
||||
void handleType_data();
|
||||
void handleType();
|
||||
void handle();
|
||||
void mapMode();
|
||||
void mapModeDebug_data();
|
||||
void mapModeDebug();
|
||||
};
|
||||
|
||||
class QtTestVideoBuffer : public QAbstractVideoBuffer
|
||||
{
|
||||
public:
|
||||
QtTestVideoBuffer(QAbstractVideoBuffer::HandleType type) : QAbstractVideoBuffer(type) {}
|
||||
|
||||
MapMode mapMode() const { return QAbstractVideoBuffer::ReadWrite; }
|
||||
|
||||
uchar *map(MapMode, int *, int *) { return 0; }
|
||||
void unmap() {}
|
||||
};
|
||||
|
||||
tst_QAbstractVideoBuffer::tst_QAbstractVideoBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
tst_QAbstractVideoBuffer::~tst_QAbstractVideoBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::cleanupTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::init()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::handleType_data()
|
||||
{
|
||||
QTest::addColumn<QAbstractVideoBuffer::HandleType>("type");
|
||||
QTest::addColumn<QString>("stringized");
|
||||
|
||||
ADD_ENUM_TEST(NoHandle);
|
||||
ADD_ENUM_TEST(GLTextureHandle);
|
||||
ADD_ENUM_TEST(XvShmImageHandle);
|
||||
ADD_ENUM_TEST(QPixmapHandle);
|
||||
ADD_ENUM_TEST(CoreImageHandle);
|
||||
|
||||
// User handles are different
|
||||
|
||||
QTest::newRow("user1")
|
||||
<< QAbstractVideoBuffer::UserHandle << QString::fromAscii("UserHandle(1000)");
|
||||
QTest::newRow("user2")
|
||||
<< QAbstractVideoBuffer::HandleType(QAbstractVideoBuffer::UserHandle + 1) << QString::fromAscii("UserHandle(1001)");
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::handleType()
|
||||
{
|
||||
QFETCH(QAbstractVideoBuffer::HandleType, type);
|
||||
QFETCH(QString, stringized);
|
||||
|
||||
QtTestVideoBuffer buffer(type);
|
||||
|
||||
QCOMPARE(buffer.handleType(), type);
|
||||
|
||||
QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
|
||||
qDebug() << type;
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::handle()
|
||||
{
|
||||
QtTestVideoBuffer buffer(QAbstractVideoBuffer::NoHandle);
|
||||
|
||||
QVERIFY(buffer.handle().isNull());
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::mapMode()
|
||||
{
|
||||
QtTestVideoBuffer maptest(QAbstractVideoBuffer::NoHandle);
|
||||
QVERIFY2(maptest.mapMode() == QAbstractVideoBuffer::ReadWrite, "ReadWrite Failed");
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::mapModeDebug_data()
|
||||
{
|
||||
QTest::addColumn<QAbstractVideoBuffer::MapMode>("mapMode");
|
||||
QTest::addColumn<QString>("stringized");
|
||||
|
||||
ADD_ENUM_TEST(NotMapped);
|
||||
ADD_ENUM_TEST(ReadOnly);
|
||||
ADD_ENUM_TEST(WriteOnly);
|
||||
ADD_ENUM_TEST(ReadWrite);
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoBuffer::mapModeDebug()
|
||||
{
|
||||
QFETCH(QAbstractVideoBuffer::MapMode, mapMode);
|
||||
QFETCH(QString, stringized);
|
||||
|
||||
QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
|
||||
qDebug() << mapMode;
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAbstractVideoBuffer)
|
||||
|
||||
#include "tst_qabstractvideobuffer.moc"
|
||||
@@ -0,0 +1,8 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qabstractvideosurface
|
||||
|
||||
QT += core multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qabstractvideosurface.cpp
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 <qabstractvideosurface.h>
|
||||
#include <qvideosurfaceformat.h>
|
||||
|
||||
class tst_QAbstractVideoSurface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_QAbstractVideoSurface();
|
||||
~tst_QAbstractVideoSurface();
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
private slots:
|
||||
void setError();
|
||||
void isFormatSupported_data();
|
||||
void isFormatSupported();
|
||||
void nearestFormat_data();
|
||||
void nearestFormat();
|
||||
void start_data();
|
||||
void start();
|
||||
void nativeResolution();
|
||||
void supportedFormatsChanged();
|
||||
};
|
||||
|
||||
typedef QMap<QAbstractVideoBuffer::HandleType, QVideoFrame::PixelFormat> SupportedFormatMap;
|
||||
|
||||
Q_DECLARE_METATYPE(SupportedFormatMap)
|
||||
|
||||
class QtTestVideoSurface : public QAbstractVideoSurface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QtTestVideoSurface(QObject *parent = 0) : QAbstractVideoSurface(parent) {}
|
||||
explicit QtTestVideoSurface(SupportedFormatMap formats, QObject *parent = 0)
|
||||
: QAbstractVideoSurface(parent), supportedFormats(formats) {}
|
||||
|
||||
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const
|
||||
{
|
||||
return supportedFormats.values(handleType);
|
||||
}
|
||||
|
||||
bool present(const QVideoFrame &) { return false; }
|
||||
|
||||
using QAbstractVideoSurface::setError;
|
||||
|
||||
/* adding protected setNativeResolution*/
|
||||
using QAbstractVideoSurface::setNativeResolution;
|
||||
|
||||
/* fun to generate supportedFormatsChanged signal */
|
||||
QList<QVideoFrame::PixelFormat> supportedPixelFormatsChange(QList<QVideoFrame::PixelFormat> formats)
|
||||
{
|
||||
supportedFormats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32);
|
||||
QList<QVideoFrame::PixelFormat> supportedFormats = supportedPixelFormats();
|
||||
if (supportedFormats.count() != formats.count()) {
|
||||
emit supportedFormatsChanged();
|
||||
}
|
||||
return supportedFormats;
|
||||
}
|
||||
|
||||
private:
|
||||
SupportedFormatMap supportedFormats;
|
||||
};
|
||||
|
||||
tst_QAbstractVideoSurface::tst_QAbstractVideoSurface()
|
||||
{
|
||||
}
|
||||
|
||||
tst_QAbstractVideoSurface::~tst_QAbstractVideoSurface()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::cleanupTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::init()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::setError()
|
||||
{
|
||||
qRegisterMetaType<QAbstractVideoSurface::Error>();
|
||||
|
||||
QtTestVideoSurface surface;
|
||||
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
|
||||
QTest::ignoreMessage(QtDebugMsg, "NoError");
|
||||
qDebug() << QAbstractVideoSurface::NoError;
|
||||
|
||||
surface.setError(QAbstractVideoSurface::StoppedError);
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::StoppedError);
|
||||
QTest::ignoreMessage(QtDebugMsg, "StoppedError");
|
||||
qDebug() << QAbstractVideoSurface::StoppedError;
|
||||
|
||||
surface.setError(QAbstractVideoSurface::ResourceError);
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::ResourceError);
|
||||
QTest::ignoreMessage(QtDebugMsg, "ResourceError");
|
||||
qDebug() << QAbstractVideoSurface::ResourceError;
|
||||
|
||||
surface.setError(QAbstractVideoSurface::NoError);
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
|
||||
QTest::ignoreMessage(QtDebugMsg, "NoError");
|
||||
qDebug() << QAbstractVideoSurface::NoError;
|
||||
|
||||
surface.setError(QAbstractVideoSurface::UnsupportedFormatError);
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::UnsupportedFormatError);
|
||||
QTest::ignoreMessage(QtDebugMsg, "UnsupportedFormatError");
|
||||
qDebug() << QAbstractVideoSurface::UnsupportedFormatError;
|
||||
|
||||
surface.setError(QAbstractVideoSurface::IncorrectFormatError);
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::IncorrectFormatError);
|
||||
QTest::ignoreMessage(QtDebugMsg, "IncorrectFormatError");
|
||||
qDebug() << QAbstractVideoSurface::IncorrectFormatError;
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::isFormatSupported_data()
|
||||
{
|
||||
QTest::addColumn<SupportedFormatMap>("supportedFormats");
|
||||
QTest::addColumn<QVideoSurfaceFormat>("format");
|
||||
QTest::addColumn<bool>("supported");
|
||||
|
||||
SupportedFormatMap formats;
|
||||
|
||||
QTest::newRow("no formats: rgb32")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB32)
|
||||
<< false;
|
||||
QTest::newRow("no formats: yv12")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12)
|
||||
<< false;
|
||||
QTest::newRow("no formats: rgb32 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB32,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< false;
|
||||
QTest::newRow("no formats: rgb24 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB24,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< false;
|
||||
|
||||
formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32);
|
||||
formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24);
|
||||
formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YUV444);
|
||||
formats.insertMulti(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB32);
|
||||
|
||||
QTest::newRow("supported: rgb32")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB32)
|
||||
<< true;
|
||||
QTest::newRow("supported: rgb24")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB24)
|
||||
<< true;
|
||||
QTest::newRow("unsupported: yv12")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12)
|
||||
<< false;
|
||||
QTest::newRow("supported: rgb32 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB32,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< true;
|
||||
QTest::newRow("unsupported: rgb24 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB24,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< false;
|
||||
QTest::newRow("unsupported: yv12 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_YV12,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< false;
|
||||
|
||||
formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YV12);
|
||||
formats.insertMulti(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB24);
|
||||
|
||||
QTest::newRow("supported: yv12")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12)
|
||||
<< true;
|
||||
QTest::newRow("supported: rgb24 gl")
|
||||
<< formats
|
||||
<< QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB24,
|
||||
QAbstractVideoBuffer::GLTextureHandle)
|
||||
<< true;
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::isFormatSupported()
|
||||
{
|
||||
QFETCH(SupportedFormatMap, supportedFormats);
|
||||
QFETCH(QVideoSurfaceFormat, format);
|
||||
QFETCH(bool, supported);
|
||||
|
||||
QtTestVideoSurface surface(supportedFormats);
|
||||
|
||||
QCOMPARE(surface.isFormatSupported(format), supported);
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::nearestFormat_data()
|
||||
{
|
||||
isFormatSupported_data();
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::nearestFormat()
|
||||
{
|
||||
QFETCH(SupportedFormatMap, supportedFormats);
|
||||
QFETCH(QVideoSurfaceFormat, format);
|
||||
QFETCH(bool, supported);
|
||||
|
||||
QtTestVideoSurface surface(supportedFormats);
|
||||
|
||||
QCOMPARE(surface.nearestFormat(format) == format, supported);
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::start_data()
|
||||
{
|
||||
QTest::addColumn<QVideoSurfaceFormat>("format");
|
||||
|
||||
QTest::newRow("rgb32") << QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB32);
|
||||
QTest::newRow("yv12") << QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_YV12);
|
||||
QTest::newRow("rgb32 gl") << QVideoSurfaceFormat(
|
||||
QSize(800, 600),
|
||||
QVideoFrame::Format_RGB32,
|
||||
QAbstractVideoBuffer::GLTextureHandle);
|
||||
}
|
||||
|
||||
void tst_QAbstractVideoSurface::start()
|
||||
{
|
||||
QFETCH(QVideoSurfaceFormat, format);
|
||||
|
||||
QtTestVideoSurface surface;
|
||||
surface.setError(QAbstractVideoSurface::ResourceError);
|
||||
|
||||
QSignalSpy formatSpy(&surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)));
|
||||
QSignalSpy activeSpy(&surface, SIGNAL(activeChanged(bool)));
|
||||
|
||||
QVERIFY(!surface.isActive());
|
||||
QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
|
||||
|
||||
QVERIFY(surface.start(format));
|
||||
|
||||
QVERIFY(surface.isActive());
|
||||
QCOMPARE(surface.surfaceFormat(), format);
|
||||
|
||||
QCOMPARE(formatSpy.count(), 1);
|
||||
QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), format);
|
||||
|
||||
QCOMPARE(activeSpy.count(), 1);
|
||||
QCOMPARE(activeSpy.last().at(0).toBool(), true);
|
||||
|
||||
// Starting twice won't change active
|
||||
// XXX should this also not emit surfaceFormatChanged?
|
||||
QVERIFY(surface.start(format));
|
||||
QCOMPARE(activeSpy.count(), 1);
|
||||
QVERIFY(surface.isActive());
|
||||
|
||||
// error() is reset on a successful start.
|
||||
QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
|
||||
|
||||
surface.stop();
|
||||
|
||||
QVERIFY(!surface.isActive());
|
||||
QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
|
||||
|
||||
QCOMPARE(formatSpy.count(), 3);
|
||||
QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), QVideoSurfaceFormat());
|
||||
|
||||
QCOMPARE(activeSpy.count(), 2);
|
||||
QCOMPARE(activeSpy.last().at(0).toBool(), false);
|
||||
|
||||
// Stopping a stopped surface shouldn't hurt
|
||||
surface.stop();
|
||||
|
||||
QVERIFY(!surface.isActive());
|
||||
QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
|
||||
|
||||
QCOMPARE(formatSpy.count(), 3);
|
||||
QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), QVideoSurfaceFormat());
|
||||
|
||||
QCOMPARE(activeSpy.count(), 2);
|
||||
QCOMPARE(activeSpy.last().at(0).toBool(), false);
|
||||
}
|
||||
|
||||
// Test nativeResolution property
|
||||
void tst_QAbstractVideoSurface::nativeResolution()
|
||||
{
|
||||
QtTestVideoSurface surface;
|
||||
QSignalSpy spy(&surface, SIGNAL(nativeResolutionChanged(QSize)));
|
||||
QSize size1 = surface.nativeResolution();
|
||||
QVERIFY(size1.width() == -1);
|
||||
QVERIFY(size1.height() == -1);
|
||||
QVERIFY(spy.count() == 0);
|
||||
|
||||
QSize res(100,150);
|
||||
surface.setNativeResolution(res);
|
||||
QVERIFY(spy.count() == 1);
|
||||
|
||||
QSize size2 = qvariant_cast<QSize>(spy.at(0).at(0));
|
||||
QVERIFY(size2.width() == 100);
|
||||
QVERIFY(size2.height() == 150);
|
||||
|
||||
// Setting again should not emit
|
||||
surface.setNativeResolution(res);
|
||||
QVERIFY(spy.count() == 1);
|
||||
|
||||
size2 = qvariant_cast<QSize>(spy.at(0).at(0));
|
||||
QVERIFY(size2.width() == 100);
|
||||
QVERIFY(size2.height() == 150);
|
||||
|
||||
spy.clear();
|
||||
}
|
||||
|
||||
// QAbstractVideoSurface's supported Formats Changed Signal
|
||||
void tst_QAbstractVideoSurface::supportedFormatsChanged()
|
||||
{
|
||||
SupportedFormatMap formatMap;
|
||||
formatMap.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24);
|
||||
QtTestVideoSurface surface(formatMap);
|
||||
QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged()));
|
||||
QList<QVideoFrame::PixelFormat> formats = surface.supportedPixelFormats();
|
||||
QVERIFY(formats.count() == 1);
|
||||
QVERIFY(spy.count() == 0);
|
||||
|
||||
// user defined implementation for generation of supportedFormatsChanged signal
|
||||
QList<QVideoFrame::PixelFormat> newFormats = surface.supportedPixelFormatsChange(formats);
|
||||
QVERIFY(newFormats.count() == (formats.count() + 1));
|
||||
QVERIFY(spy.count() == 1);
|
||||
spy.clear();
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAbstractVideoSurface)
|
||||
|
||||
#include "tst_qabstractvideosurface.moc"
|
||||
11
tests/auto/unit/qaudiocapturesource/qaudiocapturesource.pro
Normal file
11
tests/auto/unit/qaudiocapturesource/qaudiocapturesource.pro
Normal file
@@ -0,0 +1,11 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qaudiocapturesource
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qaudiocapturesource.cpp
|
||||
|
||||
include (../qmultimedia_common/mockrecorder.pri)
|
||||
include (../qmultimedia_common/mock.pri)
|
||||
|
||||
204
tests/auto/unit/qaudiocapturesource/tst_qaudiocapturesource.cpp
Normal file
204
tests/auto/unit/qaudiocapturesource/tst_qaudiocapturesource.cpp
Normal file
@@ -0,0 +1,204 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtTest/QtTest>
|
||||
#include <QDebug>
|
||||
|
||||
#include <qaudioformat.h>
|
||||
|
||||
#include <qaudiocapturesource.h>
|
||||
#include <qaudioencodercontrol.h>
|
||||
#include <qmediarecordercontrol.h>
|
||||
#include <qaudioendpointselector.h>
|
||||
#include <qaudiodeviceinfo.h>
|
||||
#include <qaudioinput.h>
|
||||
#include <qmediaobject.h>
|
||||
|
||||
//TESTED_COMPONENT=src/multimedia
|
||||
|
||||
#include "mockmediaserviceprovider.h"
|
||||
#include "mockmediarecorderservice.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class tst_QAudioCaptureSource: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
//void testNullService();
|
||||
//void testNullControl();
|
||||
void testAudioSource();
|
||||
void testOptions();
|
||||
void testDevices();
|
||||
void testAvailability();
|
||||
void testAvailableAudioInputChangedSignal();
|
||||
|
||||
private:
|
||||
QAudioCaptureSource *audiosource;
|
||||
MockMediaRecorderService *mockMediaRecorderService;
|
||||
MockMediaServiceProvider *mockProvider;
|
||||
};
|
||||
|
||||
void tst_QAudioCaptureSource::initTestCase()
|
||||
{
|
||||
mockMediaRecorderService = new MockMediaRecorderService;
|
||||
mockProvider = new MockMediaServiceProvider(mockMediaRecorderService);
|
||||
}
|
||||
|
||||
void tst_QAudioCaptureSource::cleanupTestCase()
|
||||
{
|
||||
delete audiosource;
|
||||
delete mockProvider;
|
||||
audiosource = 0;
|
||||
}
|
||||
/*
|
||||
void tst_QAudioCaptureSource::testNullService()
|
||||
{
|
||||
MockProvider provider(0);
|
||||
QAudioCaptureSource source(0, &provider);
|
||||
|
||||
QCOMPARE(source.audioInputs().size(), 0);
|
||||
QCOMPARE(source.defaultAudioInput(), QString());
|
||||
QCOMPARE(source.activeAudioInput(), QString());
|
||||
}
|
||||
*/
|
||||
/*
|
||||
void tst_QAudioCaptureSource::testNullControl()
|
||||
{
|
||||
MockRecorderService service;
|
||||
service.hasAudioDeviceControl = false;
|
||||
MockProvider provider(&service);
|
||||
QAudioCaptureSource source(0, &provider);
|
||||
|
||||
QCOMPARE(source.audioInputs().size(), 0);
|
||||
QCOMPARE(source.defaultAudioInput(), QString());
|
||||
QCOMPARE(source.activeAudioInput(), QString());
|
||||
|
||||
QCOMPARE(source.audioDescription("blah"), QString());
|
||||
|
||||
QSignalSpy deviceNameSpy(&source, SIGNAL(activeAudioInputChanged(QString)));
|
||||
|
||||
source.setAudioInput("blah");
|
||||
QCOMPARE(deviceNameSpy.count(), 0);
|
||||
}
|
||||
*/
|
||||
void tst_QAudioCaptureSource::testAudioSource()
|
||||
{
|
||||
audiosource = new QAudioCaptureSource(0, mockProvider);
|
||||
|
||||
QCOMPARE(audiosource->service(),(QMediaService *) mockMediaRecorderService);
|
||||
}
|
||||
|
||||
void tst_QAudioCaptureSource::testOptions()
|
||||
{
|
||||
const QString codec(QLatin1String("audio/mpeg"));
|
||||
|
||||
QStringList options = mockMediaRecorderService->mockAudioEncoderControl->supportedEncodingOptions(codec);
|
||||
QCOMPARE(options.count(), 4);
|
||||
mockMediaRecorderService->mockAudioEncoderControl->setEncodingOption(codec, options.first(),8000);
|
||||
QVERIFY(mockMediaRecorderService->mockAudioEncoderControl->encodingOption(codec, options.first()).toInt() == 8000);
|
||||
}
|
||||
|
||||
void tst_QAudioCaptureSource::testDevices()
|
||||
{
|
||||
audiosource = new QAudioCaptureSource(0,mockProvider);
|
||||
QList<QString> devices = audiosource->audioInputs();
|
||||
QVERIFY(devices.size() > 0);
|
||||
QVERIFY(devices.at(0).compare("device1") == 0);
|
||||
QVERIFY(audiosource->audioDescription("device1").compare("dev1 comment") == 0);
|
||||
QVERIFY(audiosource->defaultAudioInput() == "device1");
|
||||
QVERIFY(audiosource->isAvailable() == true);
|
||||
|
||||
QSignalSpy checkSignal(audiosource, SIGNAL(activeAudioInputChanged(QString)));
|
||||
audiosource->setAudioInput("device2");
|
||||
QVERIFY(audiosource->activeAudioInput().compare("device2") == 0);
|
||||
QVERIFY(checkSignal.count() == 1);
|
||||
QVERIFY(audiosource->isAvailable() == true);
|
||||
}
|
||||
|
||||
void tst_QAudioCaptureSource::testAvailability()
|
||||
{
|
||||
MockMediaRecorderService service;
|
||||
service.hasControls = false;
|
||||
MockMediaServiceProvider provider(&service);
|
||||
QAudioCaptureSource source(0, &provider);
|
||||
|
||||
QVERIFY(source.isAvailable() == false);
|
||||
QVERIFY(source.availabilityError() == QtMultimedia::ServiceMissingError);
|
||||
|
||||
service.hasControls = true;
|
||||
MockMediaServiceProvider provider2(&service);
|
||||
QAudioCaptureSource source2(0, &provider2);
|
||||
|
||||
QVERIFY(source2.isAvailable() == true);
|
||||
QVERIFY(source2.availabilityError() == QtMultimedia::NoError);
|
||||
}
|
||||
|
||||
void tst_QAudioCaptureSource::testAvailableAudioInputChangedSignal()
|
||||
{
|
||||
// The availabilityChangedSignal is implemented in QAudioCaptureSource. SO using it to test the signal.
|
||||
audiosource = new QAudioCaptureSource(0, mockProvider);
|
||||
|
||||
/* Spy the signal availableEndpointChanged and audioInputchanged */
|
||||
QSignalSpy changed(mockMediaRecorderService->mockAudioEndpointSelector, SIGNAL(availableEndpointsChanged()));
|
||||
QSignalSpy audioInputchange(audiosource, SIGNAL(availableAudioInputsChanged()));
|
||||
|
||||
/* Add the end points and verify if the available end point changed signal is emitted. */
|
||||
QMetaObject::invokeMethod(mockMediaRecorderService->mockAudioEndpointSelector, "addEndpoints");
|
||||
QVERIFY(changed.count() == 1);
|
||||
QVERIFY(audioInputchange.count() == 1);
|
||||
|
||||
/* Now try removes */
|
||||
changed.clear();
|
||||
audioInputchange.clear();
|
||||
QMetaObject::invokeMethod(mockMediaRecorderService->mockAudioEndpointSelector, "removeEndpoints");
|
||||
QVERIFY(changed.count() == 1);
|
||||
QVERIFY(audioInputchange.count() == 1);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAudioCaptureSource)
|
||||
|
||||
#include "tst_qaudiocapturesource.moc"
|
||||
10
tests/auto/unit/qaudiodeviceinfo/qaudiodeviceinfo.pro
Normal file
10
tests/auto/unit/qaudiodeviceinfo/qaudiodeviceinfo.pro
Normal file
@@ -0,0 +1,10 @@
|
||||
TARGET = tst_qaudiodeviceinfo
|
||||
|
||||
QT += core multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
# This is more of a system test
|
||||
# CONFIG += testcase
|
||||
|
||||
SOURCES += tst_qaudiodeviceinfo.cpp
|
||||
|
||||
277
tests/auto/unit/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
Normal file
277
tests/auto/unit/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
Normal file
@@ -0,0 +1,277 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 <QtTest/QtTest>
|
||||
#include <QtCore/qlocale.h>
|
||||
#include <qaudiodeviceinfo.h>
|
||||
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
|
||||
//TESTED_COMPONENT=src/multimedia
|
||||
|
||||
class tst_QAudioDeviceInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
tst_QAudioDeviceInfo(QObject* parent=0) : QObject(parent) {}
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void checkAvailableDefaultInput();
|
||||
void checkAvailableDefaultOutput();
|
||||
void outputList();
|
||||
void codecs();
|
||||
void channels();
|
||||
void sampleSizes();
|
||||
void byteOrders();
|
||||
void sampleTypes();
|
||||
void frequencies();
|
||||
void isFormatSupported();
|
||||
void preferred();
|
||||
void nearest();
|
||||
void supportedChannelCounts();
|
||||
void supportedSampleRates();
|
||||
void assignOperator();
|
||||
void deviceName();
|
||||
void defaultConstructor();
|
||||
|
||||
private:
|
||||
bool available;
|
||||
QAudioDeviceInfo* device;
|
||||
};
|
||||
|
||||
void tst_QAudioDeviceInfo::initTestCase()
|
||||
{
|
||||
// Only perform tests if audio output device exists!
|
||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
if (devices.size() > 0)
|
||||
available = true;
|
||||
else {
|
||||
qWarning()<<"NOTE: no audio output device found, no test will be performed";
|
||||
available = false;
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::checkAvailableDefaultInput()
|
||||
{
|
||||
// Only perform tests if audio input device exists!
|
||||
bool storeAvailable = available;
|
||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
||||
if (devices.size() > 0)
|
||||
available = true;
|
||||
else {
|
||||
qWarning()<<"NOTE: no audio input device found, no test will be performed";
|
||||
available = false;
|
||||
}
|
||||
if (available)
|
||||
QVERIFY(!QAudioDeviceInfo::defaultInputDevice().isNull());
|
||||
available = storeAvailable;
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::checkAvailableDefaultOutput()
|
||||
{
|
||||
if (available)
|
||||
QVERIFY(!QAudioDeviceInfo::defaultOutputDevice().isNull());
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::outputList()
|
||||
{
|
||||
if (available) {
|
||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
QVERIFY(devices.size() > 0);
|
||||
device = new QAudioDeviceInfo(devices.at(0));
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::codecs()
|
||||
{
|
||||
if (available) {
|
||||
QStringList avail = device->supportedCodecs();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::channels()
|
||||
{
|
||||
if (available) {
|
||||
QList<int> avail = device->supportedChannels();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::sampleSizes()
|
||||
{
|
||||
if (available) {
|
||||
QList<int> avail = device->supportedSampleSizes();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::byteOrders()
|
||||
{
|
||||
if (available) {
|
||||
QList<QAudioFormat::Endian> avail = device->supportedByteOrders();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::sampleTypes()
|
||||
{
|
||||
if (available) {
|
||||
QList<QAudioFormat::SampleType> avail = device->supportedSampleTypes();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::frequencies()
|
||||
{
|
||||
if (available) {
|
||||
QList<int> avail = device->supportedFrequencies();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::isFormatSupported()
|
||||
{
|
||||
if (available) {
|
||||
QAudioFormat format;
|
||||
format.setFrequency(44100);
|
||||
format.setChannels(2);
|
||||
format.setSampleType(QAudioFormat::SignedInt);
|
||||
format.setByteOrder(QAudioFormat::LittleEndian);
|
||||
format.setSampleSize(16);
|
||||
format.setCodec("audio/pcm");
|
||||
|
||||
// Should always be true for these format
|
||||
QVERIFY(device->isFormatSupported(format));
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAudioDeviceInfo::preferred()
|
||||
{
|
||||
if (available) {
|
||||
QAudioFormat format = device->preferredFormat();
|
||||
QVERIFY(format.isValid());
|
||||
}
|
||||
}
|
||||
|
||||
// Returns closest QAudioFormat to settings that system audio supports.
|
||||
void tst_QAudioDeviceInfo::nearest()
|
||||
{
|
||||
if (available) {
|
||||
/*
|
||||
QAudioFormat format1, format2;
|
||||
format1.setFrequency(8000);
|
||||
format2 = device->nearestFormat(format1);
|
||||
QVERIFY(format2.frequency() == 44100);
|
||||
*/
|
||||
QAudioFormat format;
|
||||
format.setFrequency(44100);
|
||||
format.setChannels(2);
|
||||
format.setSampleType(QAudioFormat::SignedInt);
|
||||
format.setByteOrder(QAudioFormat::LittleEndian);
|
||||
format.setSampleSize(16);
|
||||
format.setCodec("audio/pcm");
|
||||
|
||||
QAudioFormat format2 = device->nearestFormat(format);
|
||||
|
||||
// This is definitely dependent on platform support (but isFormatSupported tests that above)
|
||||
QVERIFY(format2.frequency() == 44100);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a list of supported channel counts.
|
||||
void tst_QAudioDeviceInfo::supportedChannelCounts()
|
||||
{
|
||||
if (available) {
|
||||
QList<int> avail = device->supportedChannelCounts();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a list of supported sample rates.
|
||||
void tst_QAudioDeviceInfo::supportedSampleRates()
|
||||
{
|
||||
if (available) {
|
||||
QList<int> avail = device->supportedSampleRates();
|
||||
QVERIFY(avail.size() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
// QAudioDeviceInfo's assignOperator method
|
||||
void tst_QAudioDeviceInfo::assignOperator()
|
||||
{
|
||||
QAudioDeviceInfo dev;
|
||||
QVERIFY(dev.deviceName() == NULL);
|
||||
QVERIFY(dev.isNull() == true);
|
||||
|
||||
if (available) {
|
||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||
QVERIFY(devices.size() > 0);
|
||||
QAudioDeviceInfo dev1(devices.at(0));
|
||||
dev = dev1;
|
||||
QVERIFY(dev.isNull() == false);
|
||||
QVERIFY(dev.deviceName() == dev1.deviceName());
|
||||
}
|
||||
}
|
||||
|
||||
// Returns human readable name of audio device
|
||||
void tst_QAudioDeviceInfo::deviceName()
|
||||
{
|
||||
if (available) {
|
||||
QVERIFY(device->deviceName() != NULL);
|
||||
QVERIFY(device->deviceName() == QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).at(0).deviceName());
|
||||
}
|
||||
}
|
||||
|
||||
// QAudioDeviceInfo's defaultConstructor method
|
||||
void tst_QAudioDeviceInfo::defaultConstructor()
|
||||
{
|
||||
QAudioDeviceInfo dev;
|
||||
QVERIFY(dev.isNull() == true);
|
||||
QVERIFY(dev.deviceName() == NULL);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAudioDeviceInfo)
|
||||
|
||||
#include "tst_qaudiodeviceinfo.moc"
|
||||
8
tests/auto/unit/qaudioformat/qaudioformat.pro
Normal file
8
tests/auto/unit/qaudioformat/qaudioformat.pro
Normal file
@@ -0,0 +1,8 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qaudioformat
|
||||
|
||||
QT += core multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qaudioformat.cpp
|
||||
|
||||
271
tests/auto/unit/qaudioformat/tst_qaudioformat.cpp
Normal file
271
tests/auto/unit/qaudioformat/tst_qaudioformat.cpp
Normal file
@@ -0,0 +1,271 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 <QtTest/QtTest>
|
||||
#include <QtCore/qlocale.h>
|
||||
#include <qaudioformat.h>
|
||||
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
|
||||
//TESTED_COMPONENT=src/multimedia
|
||||
|
||||
class tst_QAudioFormat : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tst_QAudioFormat(QObject* parent=0) : QObject(parent) {}
|
||||
|
||||
private slots:
|
||||
void checkNull();
|
||||
void checkFrequency();
|
||||
void checkSampleSize();
|
||||
void checkCodec();
|
||||
void checkByteOrder();
|
||||
void checkSampleType();
|
||||
void checkEquality();
|
||||
void checkAssignment();
|
||||
void checkSampleRate();
|
||||
void checkChannelCount();
|
||||
|
||||
void debugOperator();
|
||||
void debugOperator_data();
|
||||
};
|
||||
|
||||
void tst_QAudioFormat::checkNull()
|
||||
{
|
||||
// Default constructed QAudioFormat is invalid.
|
||||
QAudioFormat audioFormat0;
|
||||
QVERIFY(!audioFormat0.isValid());
|
||||
|
||||
// validity is transferred
|
||||
QAudioFormat audioFormat1(audioFormat0);
|
||||
QVERIFY(!audioFormat1.isValid());
|
||||
|
||||
audioFormat0.setFrequency(44100);
|
||||
audioFormat0.setChannels(2);
|
||||
audioFormat0.setSampleSize(16);
|
||||
audioFormat0.setCodec("audio/pcm");
|
||||
audioFormat0.setSampleType(QAudioFormat::SignedInt);
|
||||
QVERIFY(audioFormat0.isValid());
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkFrequency()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setFrequency(44100);
|
||||
QVERIFY(audioFormat.frequency() == 44100);
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkSampleSize()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setSampleSize(16);
|
||||
QVERIFY(audioFormat.sampleSize() == 16);
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkCodec()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setCodec(QString::fromLatin1("audio/pcm"));
|
||||
QVERIFY(audioFormat.codec() == QString::fromLatin1("audio/pcm"));
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkByteOrder()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setByteOrder(QAudioFormat::LittleEndian);
|
||||
QVERIFY(audioFormat.byteOrder() == QAudioFormat::LittleEndian);
|
||||
|
||||
QTest::ignoreMessage(QtDebugMsg, "LittleEndian");
|
||||
qDebug() << QAudioFormat::LittleEndian;
|
||||
|
||||
audioFormat.setByteOrder(QAudioFormat::BigEndian);
|
||||
QVERIFY(audioFormat.byteOrder() == QAudioFormat::BigEndian);
|
||||
|
||||
QTest::ignoreMessage(QtDebugMsg, "BigEndian");
|
||||
qDebug() << QAudioFormat::BigEndian;
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkSampleType()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
audioFormat.setSampleType(QAudioFormat::SignedInt);
|
||||
QVERIFY(audioFormat.sampleType() == QAudioFormat::SignedInt);
|
||||
QTest::ignoreMessage(QtDebugMsg, "SignedInt");
|
||||
qDebug() << QAudioFormat::SignedInt;
|
||||
|
||||
audioFormat.setSampleType(QAudioFormat::Unknown);
|
||||
QVERIFY(audioFormat.sampleType() == QAudioFormat::Unknown);
|
||||
QTest::ignoreMessage(QtDebugMsg, "Unknown");
|
||||
qDebug() << QAudioFormat::Unknown;
|
||||
|
||||
audioFormat.setSampleType(QAudioFormat::UnSignedInt);
|
||||
QVERIFY(audioFormat.sampleType() == QAudioFormat::UnSignedInt);
|
||||
QTest::ignoreMessage(QtDebugMsg, "UnSignedInt");
|
||||
qDebug() << QAudioFormat::UnSignedInt;
|
||||
|
||||
audioFormat.setSampleType(QAudioFormat::Float);
|
||||
QVERIFY(audioFormat.sampleType() == QAudioFormat::Float);
|
||||
QTest::ignoreMessage(QtDebugMsg, "Float");
|
||||
qDebug() << QAudioFormat::Float;
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkEquality()
|
||||
{
|
||||
QAudioFormat audioFormat0;
|
||||
QAudioFormat audioFormat1;
|
||||
|
||||
// Null formats are equivalent
|
||||
QVERIFY(audioFormat0 == audioFormat1);
|
||||
QVERIFY(!(audioFormat0 != audioFormat1));
|
||||
|
||||
// on filled formats
|
||||
audioFormat0.setFrequency(8000);
|
||||
audioFormat0.setChannels(1);
|
||||
audioFormat0.setSampleSize(8);
|
||||
audioFormat0.setCodec("audio/pcm");
|
||||
audioFormat0.setByteOrder(QAudioFormat::LittleEndian);
|
||||
audioFormat0.setSampleType(QAudioFormat::UnSignedInt);
|
||||
|
||||
audioFormat1.setFrequency(8000);
|
||||
audioFormat1.setChannels(1);
|
||||
audioFormat1.setSampleSize(8);
|
||||
audioFormat1.setCodec("audio/pcm");
|
||||
audioFormat1.setByteOrder(QAudioFormat::LittleEndian);
|
||||
audioFormat1.setSampleType(QAudioFormat::UnSignedInt);
|
||||
|
||||
QVERIFY(audioFormat0 == audioFormat1);
|
||||
QVERIFY(!(audioFormat0 != audioFormat1));
|
||||
|
||||
audioFormat0.setFrequency(44100);
|
||||
QVERIFY(audioFormat0 != audioFormat1);
|
||||
QVERIFY(!(audioFormat0 == audioFormat1));
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::checkAssignment()
|
||||
{
|
||||
QAudioFormat audioFormat0;
|
||||
QAudioFormat audioFormat1;
|
||||
|
||||
audioFormat0.setFrequency(8000);
|
||||
audioFormat0.setChannels(1);
|
||||
audioFormat0.setSampleSize(8);
|
||||
audioFormat0.setCodec("audio/pcm");
|
||||
audioFormat0.setByteOrder(QAudioFormat::LittleEndian);
|
||||
audioFormat0.setSampleType(QAudioFormat::UnSignedInt);
|
||||
|
||||
audioFormat1 = audioFormat0;
|
||||
QVERIFY(audioFormat1 == audioFormat0);
|
||||
|
||||
QAudioFormat audioFormat2(audioFormat0);
|
||||
QVERIFY(audioFormat2 == audioFormat0);
|
||||
}
|
||||
|
||||
/* sampleRate() API property test. */
|
||||
void tst_QAudioFormat::checkSampleRate()
|
||||
{
|
||||
QAudioFormat audioFormat;
|
||||
QVERIFY(audioFormat.sampleRate() == -1);
|
||||
|
||||
audioFormat.setSampleRate(123);
|
||||
QVERIFY(audioFormat.sampleRate() == 123);
|
||||
}
|
||||
|
||||
/* channelCount() API property test. */
|
||||
void tst_QAudioFormat::checkChannelCount()
|
||||
{
|
||||
// channels is the old name for channelCount, so
|
||||
// they should always be equal
|
||||
QAudioFormat audioFormat;
|
||||
QVERIFY(audioFormat.channelCount() == -1);
|
||||
QVERIFY(audioFormat.channels() == -1);
|
||||
|
||||
audioFormat.setChannelCount(123);
|
||||
QVERIFY(audioFormat.channelCount() == 123);
|
||||
QVERIFY(audioFormat.channels() == 123);
|
||||
|
||||
audioFormat.setChannels(5);
|
||||
QVERIFY(audioFormat.channelCount() == 5);
|
||||
QVERIFY(audioFormat.channels() == 5);
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::debugOperator_data()
|
||||
{
|
||||
QTest::addColumn<QAudioFormat>("format");
|
||||
QTest::addColumn<QString>("stringized");
|
||||
|
||||
// A small sampling
|
||||
QAudioFormat f;
|
||||
QTest::newRow("plain") << f << QString::fromLatin1("QAudioFormat(-1Hz, -1bit, channelCount=-1, sampleType=Unknown, byteOrder=LittleEndian, codec=\"\") ");
|
||||
|
||||
f.setSampleRate(22050);
|
||||
f.setByteOrder(QAudioFormat::LittleEndian);
|
||||
f.setChannelCount(4);
|
||||
f.setCodec("audio/pcm");
|
||||
f.setSampleType(QAudioFormat::Float);
|
||||
|
||||
QTest::newRow("float") << f << QString::fromLatin1("QAudioFormat(22050Hz, -1bit, channelCount=4, sampleType=Float, byteOrder=LittleEndian, codec=\"audio/pcm\") ");
|
||||
|
||||
f.setSampleType(QAudioFormat::UnSignedInt);
|
||||
QTest::newRow("unsigned") << f << QString::fromLatin1("QAudioFormat(22050Hz, -1bit, channelCount=4, sampleType=UnSignedInt, byteOrder=LittleEndian, codec=\"audio/pcm\") ");
|
||||
|
||||
f.setSampleRate(44100);
|
||||
QTest::newRow("44.1 unsigned") << f << QString::fromLatin1("QAudioFormat(44100Hz, -1bit, channelCount=4, sampleType=UnSignedInt, byteOrder=LittleEndian, codec=\"audio/pcm\") ");
|
||||
|
||||
f.setByteOrder(QAudioFormat::BigEndian);
|
||||
QTest::newRow("44.1 big unsigned") << f << QString::fromLatin1("QAudioFormat(44100Hz, -1bit, channelCount=4, sampleType=UnSignedInt, byteOrder=BigEndian, codec=\"audio/pcm\") ");
|
||||
}
|
||||
|
||||
void tst_QAudioFormat::debugOperator()
|
||||
{
|
||||
QFETCH(QAudioFormat, format);
|
||||
QFETCH(QString, stringized);
|
||||
|
||||
QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
|
||||
qDebug() << format;
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAudioFormat)
|
||||
|
||||
#include "tst_qaudioformat.moc"
|
||||
8
tests/auto/unit/qaudionamespace/qaudionamespace.pro
Normal file
8
tests/auto/unit/qaudionamespace/qaudionamespace.pro
Normal file
@@ -0,0 +1,8 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qaudionamespace
|
||||
|
||||
QT += core multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qaudionamespace.cpp
|
||||
|
||||
127
tests/auto/unit/qaudionamespace/tst_qaudionamespace.cpp
Normal file
127
tests/auto/unit/qaudionamespace/tst_qaudionamespace.cpp
Normal file
@@ -0,0 +1,127 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 "qaudio.h"
|
||||
|
||||
// Adds an enum, and the stringized version
|
||||
#define ADD_ENUM_TEST(x) \
|
||||
QTest::newRow(#x) \
|
||||
<< QAudio::x \
|
||||
<< QString(QLatin1String(#x));
|
||||
|
||||
class tst_QAudioNamespace : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void debugError();
|
||||
void debugError_data();
|
||||
void debugState();
|
||||
void debugState_data();
|
||||
void debugMode();
|
||||
void debugMode_data();
|
||||
};
|
||||
|
||||
void tst_QAudioNamespace::debugError_data()
|
||||
{
|
||||
QTest::addColumn<QAudio::Error>("error");
|
||||
QTest::addColumn<QString>("stringized");
|
||||
|
||||
ADD_ENUM_TEST(NoError);
|
||||
ADD_ENUM_TEST(OpenError);
|
||||
ADD_ENUM_TEST(IOError);
|
||||
ADD_ENUM_TEST(UnderrunError);
|
||||
ADD_ENUM_TEST(FatalError);
|
||||
}
|
||||
|
||||
void tst_QAudioNamespace::debugError()
|
||||
{
|
||||
QFETCH(QAudio::Error, error);
|
||||
QFETCH(QString, stringized);
|
||||
|
||||
QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
|
||||
qDebug() << error;
|
||||
}
|
||||
|
||||
void tst_QAudioNamespace::debugState_data()
|
||||
{
|
||||
QTest::addColumn<QAudio::State>("state");
|
||||
QTest::addColumn<QString>("stringized");
|
||||
|
||||
ADD_ENUM_TEST(ActiveState);
|
||||
ADD_ENUM_TEST(SuspendedState);
|
||||
ADD_ENUM_TEST(StoppedState);
|
||||
ADD_ENUM_TEST(IdleState);
|
||||
}
|
||||
|
||||
void tst_QAudioNamespace::debugState()
|
||||
{
|
||||
QFETCH(QAudio::State, state);
|
||||
QFETCH(QString, stringized);
|
||||
|
||||
QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
|
||||
qDebug() << state;
|
||||
}
|
||||
|
||||
void tst_QAudioNamespace::debugMode_data()
|
||||
{
|
||||
QTest::addColumn<QAudio::Mode>("mode");
|
||||
QTest::addColumn<QString>("stringized");
|
||||
|
||||
ADD_ENUM_TEST(AudioInput);
|
||||
ADD_ENUM_TEST(AudioOutput);
|
||||
}
|
||||
|
||||
void tst_QAudioNamespace::debugMode()
|
||||
{
|
||||
QFETCH(QAudio::Mode, mode);
|
||||
QFETCH(QString, stringized);
|
||||
|
||||
QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
|
||||
qDebug() << mode;
|
||||
}
|
||||
QTEST_MAIN(tst_QAudioNamespace)
|
||||
|
||||
#include "tst_qaudionamespace.moc"
|
||||
10
tests/auto/unit/qcamera/qcamera.pro
Normal file
10
tests/auto/unit/qcamera/qcamera.pro
Normal file
@@ -0,0 +1,10 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qcamera
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
include (../qmultimedia_common/mock.pri)
|
||||
include (../qmultimedia_common/mockcamera.pri)
|
||||
|
||||
SOURCES += tst_qcamera.cpp
|
||||
1956
tests/auto/unit/qcamera/tst_qcamera.cpp
Normal file
1956
tests/auto/unit/qcamera/tst_qcamera.cpp
Normal file
File diff suppressed because it is too large
Load Diff
11
tests/auto/unit/qcameraimagecapture/qcameraimagecapture.pro
Normal file
11
tests/auto/unit/qcameraimagecapture/qcameraimagecapture.pro
Normal file
@@ -0,0 +1,11 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qcameraimagecapture
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += \
|
||||
tst_qcameraimagecapture.cpp
|
||||
|
||||
include (../qmultimedia_common/mock.pri)
|
||||
include (../qmultimedia_common/mockcamera.pri)
|
||||
432
tests/auto/unit/qcameraimagecapture/tst_qcameraimagecapture.cpp
Normal file
432
tests/auto/unit/qcameraimagecapture/tst_qcameraimagecapture.cpp
Normal file
@@ -0,0 +1,432 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
Author : Vijay/Avinash
|
||||
|
||||
Reviewer Name Date Coverage ( Full / Test Case IDs ).
|
||||
---------------------------------------------------------------------------
|
||||
Initial review of test cases.
|
||||
****************************************************************************/
|
||||
|
||||
//TESTED_COMPONENT=src/multimedia
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDebug>
|
||||
|
||||
#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 <qmediaservice.h>
|
||||
#include <qcamera.h>
|
||||
#include <qcameraimagecapture.h>
|
||||
|
||||
#include "mockcameraservice.h"
|
||||
#include "mockmediaserviceprovider.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class NullService: public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NullService(): QMediaService(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~NullService()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QMediaControl* requestControl(const char *iid)
|
||||
{
|
||||
Q_UNUSED(iid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void releaseControl(QMediaControl*) {}
|
||||
|
||||
};
|
||||
|
||||
class tst_QCameraImageCapture: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
void constructor();
|
||||
void mediaObject();
|
||||
void deleteMediaObject();
|
||||
void isReadyForCapture();
|
||||
void capture();
|
||||
void cancelCapture();
|
||||
void encodingSettings();
|
||||
void errors();
|
||||
void error();
|
||||
void imageCaptured();
|
||||
void imageExposed();
|
||||
void imageSaved();
|
||||
void readyForCaptureChanged();
|
||||
void supportedResolutions();
|
||||
void imageCodecDescription();
|
||||
void supportedImageCodecs();
|
||||
void cameraImageCaptureControl();
|
||||
|
||||
private:
|
||||
MockCameraService *mockcameraservice;
|
||||
MockMediaServiceProvider *provider;
|
||||
};
|
||||
|
||||
void tst_QCameraImageCapture::initTestCase()
|
||||
{
|
||||
provider = new MockMediaServiceProvider;
|
||||
mockcameraservice = new MockCameraService;
|
||||
provider->service = mockcameraservice;
|
||||
}
|
||||
|
||||
void tst_QCameraImageCapture::cleanupTestCase()
|
||||
{
|
||||
delete mockcameraservice;
|
||||
delete provider;
|
||||
}
|
||||
|
||||
//MaemoAPI-1823:test QCameraImageCapture Constructor
|
||||
void tst_QCameraImageCapture::constructor()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
}
|
||||
|
||||
//MaemoAPI-1824:test mediaObject
|
||||
void tst_QCameraImageCapture::mediaObject()
|
||||
{
|
||||
MockMediaServiceProvider provider1;
|
||||
NullService mymockcameraservice ;
|
||||
provider1.service = &mymockcameraservice;
|
||||
QCamera camera(0, &provider1);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QMediaObject *medobj = imageCapture.mediaObject();
|
||||
QVERIFY(medobj == NULL);
|
||||
|
||||
QCamera camera1(0, provider);
|
||||
QCameraImageCapture imageCapture1(&camera1);
|
||||
QMediaObject *medobj1 = imageCapture1.mediaObject();
|
||||
QCOMPARE(medobj1, &camera1);
|
||||
}
|
||||
|
||||
void tst_QCameraImageCapture::deleteMediaObject()
|
||||
{
|
||||
MockMediaServiceProvider *provider = new MockMediaServiceProvider;
|
||||
provider->service = new MockCameraService;
|
||||
|
||||
QCamera *camera = new QCamera(0, provider);
|
||||
QCameraImageCapture *capture = new QCameraImageCapture(camera);
|
||||
|
||||
QVERIFY(capture->mediaObject() == camera);
|
||||
QVERIFY(capture->isAvailable());
|
||||
|
||||
delete camera;
|
||||
delete provider->service;
|
||||
delete provider;
|
||||
|
||||
//capture should detach from camera
|
||||
QVERIFY(capture->mediaObject() == 0);
|
||||
QVERIFY(!capture->isAvailable());
|
||||
|
||||
capture->capture();
|
||||
delete capture;
|
||||
}
|
||||
|
||||
//MaemoAPI-1825:test isReadyForCapture
|
||||
void tst_QCameraImageCapture::isReadyForCapture()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == false);
|
||||
camera.start();
|
||||
imageCapture.capture();
|
||||
QTest::qWait(300);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == true);
|
||||
camera.stop();
|
||||
}
|
||||
|
||||
//MaemoAPI-1826:test capture
|
||||
void tst_QCameraImageCapture::capture()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == false);
|
||||
QVERIFY(imageCapture.capture() == -1);
|
||||
camera.start();
|
||||
QVERIFY(imageCapture.isReadyForCapture() == true);
|
||||
QTest::qWait(300);
|
||||
QVERIFY(imageCapture.capture() != -1);
|
||||
camera.stop();
|
||||
}
|
||||
|
||||
//MaemoAPI-1827:test cancelCapture
|
||||
void tst_QCameraImageCapture::cancelCapture()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QSignalSpy spy(&imageCapture, SIGNAL(imageCaptured(int,QImage)));
|
||||
QSignalSpy spy1(&imageCapture, SIGNAL(imageSaved(int,QString)));
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == false);
|
||||
camera.start();
|
||||
imageCapture.capture();
|
||||
QTest::qWait(300);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == true);
|
||||
QVERIFY(spy.count() == 1 && spy1.count() == 1);
|
||||
spy.clear();
|
||||
spy1.clear();
|
||||
camera.stop();
|
||||
|
||||
QVERIFY(imageCapture.isReadyForCapture() == false);
|
||||
camera.start();
|
||||
imageCapture.capture();
|
||||
imageCapture.cancelCapture();
|
||||
QTest::qWait(300);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == true);
|
||||
QVERIFY(spy.count() == 0 && spy1.count() == 0);
|
||||
camera.stop();
|
||||
}
|
||||
|
||||
//MaemoAPI-1828:test encodingSettings
|
||||
//MaemoAPI-1829:test set encodingSettings
|
||||
void tst_QCameraImageCapture::encodingSettings()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
QVERIFY(imageCapture.encodingSettings() == QImageEncoderSettings());
|
||||
QImageEncoderSettings settings;
|
||||
settings.setCodec("JPEG");
|
||||
settings.setQuality(QtMultimedia::NormalQuality);
|
||||
imageCapture.setEncodingSettings(settings);
|
||||
QVERIFY(!imageCapture.encodingSettings().isNull());
|
||||
QVERIFY(imageCapture.encodingSettings().codec() == "JPEG");
|
||||
QVERIFY(imageCapture.encodingSettings().quality() == QtMultimedia::NormalQuality);
|
||||
}
|
||||
|
||||
//MaemoAPI-1838:test supportedImageCodecs
|
||||
void tst_QCameraImageCapture::supportedImageCodecs()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
QVERIFY(!imageCapture.supportedImageCodecs().isEmpty());
|
||||
}
|
||||
|
||||
//MaemoAPI-1836:test supportedResolutions
|
||||
void tst_QCameraImageCapture::supportedResolutions()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
QVERIFY(imageCapture.supportedResolutions().count() == 2);
|
||||
QImageEncoderSettings settings1;
|
||||
settings1.setCodec("PNG");;
|
||||
settings1.setResolution(320, 240);
|
||||
int result = imageCapture.supportedResolutions(settings1).count();
|
||||
QVERIFY(result == 1);
|
||||
}
|
||||
|
||||
//MaemoAPI-1837:test imageCodecDescription
|
||||
void tst_QCameraImageCapture::imageCodecDescription()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
QVERIFY(imageCapture.imageCodecDescription(" ").isNull());
|
||||
QVERIFY(imageCapture.imageCodecDescription("PNG").isNull() == false);
|
||||
}
|
||||
|
||||
//MaemoAPI-1830:test errors
|
||||
void tst_QCameraImageCapture::errors()
|
||||
{
|
||||
MockMediaServiceProvider provider1 ;
|
||||
MockSimpleCameraService mockSimpleCameraService ;
|
||||
provider1.service = &mockSimpleCameraService;
|
||||
|
||||
QCamera camera1(0, &provider1);
|
||||
QCameraImageCapture imageCapture1(&camera1);
|
||||
QVERIFY(imageCapture1.isAvailable() == false);
|
||||
imageCapture1.capture(QString::fromLatin1("/dev/null"));
|
||||
QVERIFY(imageCapture1.error() == QCameraImageCapture::NotSupportedFeatureError);
|
||||
QVERIFY2(!imageCapture1.errorString().isEmpty(), "Device does not support images capture");
|
||||
QVERIFY(imageCapture1.availabilityError() == QtMultimedia::ServiceMissingError);
|
||||
|
||||
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
QVERIFY(imageCapture.error() == QCameraImageCapture::NoError);
|
||||
QVERIFY(imageCapture.errorString().isEmpty());
|
||||
QVERIFY(imageCapture.availabilityError() == QtMultimedia::NoError);
|
||||
|
||||
imageCapture.capture();
|
||||
QVERIFY(imageCapture.error() == QCameraImageCapture::NotReadyError);
|
||||
QVERIFY2(!imageCapture.errorString().isEmpty(), "Could not capture in stopped state");
|
||||
QVERIFY(imageCapture.availabilityError() == QtMultimedia::NoError);
|
||||
}
|
||||
|
||||
//MaemoAPI-1831:test error
|
||||
void tst_QCameraImageCapture::error()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QSignalSpy spy(&imageCapture, SIGNAL(error(int,QCameraImageCapture::Error,QString)));
|
||||
imageCapture.capture();
|
||||
QTest::qWait(30);
|
||||
QVERIFY(spy.count() == 1);
|
||||
QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) == -1);
|
||||
QVERIFY(qvariant_cast<QCameraImageCapture::Error>(spy.at(0).at(1)) == QCameraImageCapture::NotReadyError);
|
||||
QVERIFY(qvariant_cast<QString>(spy.at(0).at(2)) == "Could not capture in stopped state");
|
||||
spy.clear();
|
||||
}
|
||||
|
||||
//MaemoAPI-1832:test imageCaptured
|
||||
void tst_QCameraImageCapture::imageCaptured()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QSignalSpy spy(&imageCapture, SIGNAL(imageCaptured(int,QImage)));
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == false);
|
||||
camera.start();
|
||||
imageCapture.capture();
|
||||
QTest::qWait(300);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == true);
|
||||
|
||||
QVERIFY(spy.count() == 1);
|
||||
QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) > 0);
|
||||
QImage image = qvariant_cast<QImage>(spy.at(0).at(1));
|
||||
QVERIFY(image.isNull() == true);
|
||||
spy.clear();
|
||||
camera.stop();
|
||||
}
|
||||
|
||||
//MaemoAPI-1833:test imageExposed
|
||||
void tst_QCameraImageCapture::imageExposed()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QSignalSpy spy(&imageCapture, SIGNAL(imageExposed(int)));
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == false);
|
||||
camera.start();
|
||||
imageCapture.capture();
|
||||
QTest::qWait(300);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == true);
|
||||
|
||||
QVERIFY(spy.count() == 1);
|
||||
QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) > 0);
|
||||
spy.clear();
|
||||
camera.stop();
|
||||
}
|
||||
|
||||
//MaemoAPI-1834:test imageSaved
|
||||
void tst_QCameraImageCapture::imageSaved()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QSignalSpy spy(&imageCapture, SIGNAL(imageSaved(int,QString)));
|
||||
QVERIFY(imageCapture.isAvailable() == true);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == false);
|
||||
camera.start();
|
||||
imageCapture.capture(QString::fromLatin1("/usr/share"));
|
||||
QTest::qWait(300);
|
||||
QVERIFY(imageCapture.isReadyForCapture() == true);
|
||||
|
||||
QVERIFY(spy.count() == 1);
|
||||
QVERIFY(qvariant_cast<int>(spy.at(0).at(0)) > 0);
|
||||
QVERIFY(qvariant_cast<QString>(spy.at(0).at(1)) == "/usr/share");
|
||||
spy.clear();
|
||||
camera.stop();
|
||||
}
|
||||
|
||||
//MaemoAPI-1835:test readyForCaptureChanged
|
||||
void tst_QCameraImageCapture::readyForCaptureChanged()
|
||||
{
|
||||
QCamera camera(0, provider);
|
||||
QCameraImageCapture imageCapture(&camera);
|
||||
QSignalSpy spy(&imageCapture, SIGNAL(readyForCaptureChanged(bool)));
|
||||
QVERIFY(imageCapture.isReadyForCapture() == false);
|
||||
imageCapture.capture();
|
||||
QTest::qWait(100);
|
||||
QVERIFY(spy.count() == 0);
|
||||
QVERIFY2(!imageCapture.errorString().isEmpty(),"Could not capture in stopped state" );
|
||||
camera.start();
|
||||
QTest::qWait(100);
|
||||
imageCapture.capture();
|
||||
QTest::qWait(100);
|
||||
QVERIFY(spy.count() == 2);
|
||||
QVERIFY(spy.at(0).at(0).toBool() == false);
|
||||
QVERIFY(spy.at(1).at(0).toBool() == true);
|
||||
camera.stop();
|
||||
spy.clear();
|
||||
}
|
||||
|
||||
//MaemoAPI-1853:test cameraImageCapture control constructor
|
||||
void tst_QCameraImageCapture::cameraImageCaptureControl()
|
||||
{
|
||||
MockCameraControl ctrl;
|
||||
MockCaptureControl capctrl(&ctrl);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QCameraImageCapture)
|
||||
|
||||
#include "tst_qcameraimagecapture.moc"
|
||||
11
tests/auto/unit/qcameraviewfinder/qcameraviewfinder.pro
Normal file
11
tests/auto/unit/qcameraviewfinder/qcameraviewfinder.pro
Normal file
@@ -0,0 +1,11 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qcameraviewfinder
|
||||
|
||||
QT += multimedia-private multimediawidgets-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
include (../qmultimedia_common/mock.pri)
|
||||
include (../qmultimedia_common/mockcamera.pri)
|
||||
|
||||
SOURCES += tst_qcameraviewfinder.cpp
|
||||
QT+=widgets
|
||||
113
tests/auto/unit/qcameraviewfinder/tst_qcameraviewfinder.cpp
Normal file
113
tests/auto/unit/qcameraviewfinder/tst_qcameraviewfinder.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 <QtTest/QtTest>
|
||||
#include <QDebug>
|
||||
|
||||
#include "qcameraviewfinder.h"
|
||||
#include "qcamera.h"
|
||||
#include "qmediaobject.h"
|
||||
|
||||
#include "mockcameraservice.h"
|
||||
#include "mockmediaserviceprovider.h"
|
||||
|
||||
class tst_QCameraViewFinder : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
void testConstructor();
|
||||
void testMediaObject();
|
||||
|
||||
private:
|
||||
MockCameraService *mockcameraservice;
|
||||
MockMediaServiceProvider *provider;
|
||||
QCamera *camera;
|
||||
QCameraViewfinder *viewFinder;
|
||||
};
|
||||
|
||||
void tst_QCameraViewFinder::initTestCase()
|
||||
{
|
||||
provider = new MockMediaServiceProvider;
|
||||
mockcameraservice = new MockCameraService;
|
||||
provider->service = mockcameraservice;
|
||||
|
||||
camera = new QCamera(0, provider);
|
||||
viewFinder = new QCameraViewfinder();
|
||||
}
|
||||
|
||||
void tst_QCameraViewFinder::cleanupTestCase()
|
||||
{
|
||||
delete mockcameraservice;
|
||||
delete provider;
|
||||
}
|
||||
|
||||
void tst_QCameraViewFinder::testConstructor()
|
||||
{
|
||||
/* Verify whether the object is created or not */
|
||||
QVERIFY(viewFinder != NULL);
|
||||
QCOMPARE(viewFinder->isVisible(),false);
|
||||
QCOMPARE(viewFinder->isEnabled(),true);
|
||||
viewFinder->show();
|
||||
}
|
||||
|
||||
void tst_QCameraViewFinder::testMediaObject()
|
||||
{
|
||||
QVERIFY(viewFinder != NULL);
|
||||
viewFinder->show();
|
||||
/* Sets the QVideoWidget based camera viewfinder.*/
|
||||
camera->setViewfinder(viewFinder);
|
||||
QCOMPARE(viewFinder->isVisible(),true);
|
||||
|
||||
/* Return the currently attached media object.*/
|
||||
QMediaObject *media = viewFinder->mediaObject();
|
||||
|
||||
/* Verifying the object */
|
||||
QCOMPARE(media, camera);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QCameraViewFinder)
|
||||
#include "tst_qcameraviewfinder.moc"
|
||||
13
tests/auto/unit/qcamerawidgets/qcamerawidgets.pro
Normal file
13
tests/auto/unit/qcamerawidgets/qcamerawidgets.pro
Normal file
@@ -0,0 +1,13 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qcamerawidgets
|
||||
|
||||
QT += multimedia-private multimediawidgets-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
include (../qmultimedia_common/mock.pri)
|
||||
include (../qmultimedia_common/mockcamera.pri)
|
||||
|
||||
SOURCES += tst_qcamerawidgets.cpp
|
||||
|
||||
maemo*:CONFIG += insignificant_test
|
||||
QT+=widgets
|
||||
318
tests/auto/unit/qcamerawidgets/tst_qcamerawidgets.cpp
Normal file
318
tests/auto/unit/qcamerawidgets/tst_qcamerawidgets.cpp
Normal file
@@ -0,0 +1,318 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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
|
||||
|
||||
|
||||
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<QtMultimedia::MetaData>("QtMultimedia::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"
|
||||
17
tests/auto/unit/qdeclarativeaudio/qdeclarativeaudio.pro
Normal file
17
tests/auto/unit/qdeclarativeaudio/qdeclarativeaudio.pro
Normal file
@@ -0,0 +1,17 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qdeclarativeaudio
|
||||
|
||||
QT += multimedia-private declarative testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
HEADERS += \
|
||||
$$QT.multimedia.sources/../imports/multimedia/qdeclarativeaudio_p.h \
|
||||
$$QT.multimedia.sources/../imports/multimedia/qdeclarativemediabase_p.h \
|
||||
$$QT.multimedia.sources/../imports/multimedia/qdeclarativemediametadata_p.h
|
||||
|
||||
SOURCES += \
|
||||
tst_qdeclarativeaudio.cpp \
|
||||
$$QT.multimedia.sources/../imports/multimedia/qdeclarativeaudio.cpp \
|
||||
$$QT.multimedia.sources/../imports/multimedia/qdeclarativemediabase.cpp
|
||||
|
||||
INCLUDEPATH += $$QT.multimedia.sources/../imports/multimedia
|
||||
1301
tests/auto/unit/qdeclarativeaudio/tst_qdeclarativeaudio.cpp
Normal file
1301
tests/auto/unit/qdeclarativeaudio/tst_qdeclarativeaudio.cpp
Normal file
File diff suppressed because it is too large
Load Diff
18
tests/auto/unit/qdeclarativevideo/qdeclarativevideo.pro
Normal file
18
tests/auto/unit/qdeclarativevideo/qdeclarativevideo.pro
Normal file
@@ -0,0 +1,18 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qdeclarativevideo
|
||||
|
||||
QT += multimedia-private declarative testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
HEADERS += \
|
||||
$$QT.multimedia.sources/../imports/multimedia/qdeclarativevideo_p.h \
|
||||
$$QT.multimedia.sources/../imports/multimedia/qdeclarativemediabase_p.h \
|
||||
$$QT.multimedia.sources/../imports/multimedia/qdeclarativemediametadata_p.h
|
||||
|
||||
SOURCES += \
|
||||
tst_qdeclarativevideo.cpp \
|
||||
$$QT.multimedia.sources/../imports/multimedia/qdeclarativevideo.cpp \
|
||||
$$QT.multimedia.sources/../imports/multimedia/qdeclarativemediabase.cpp
|
||||
|
||||
INCLUDEPATH += $$QT.multimedia.sources/../imports/multimedia
|
||||
QT+=widgets
|
||||
991
tests/auto/unit/qdeclarativevideo/tst_qdeclarativevideo.cpp
Normal file
991
tests/auto/unit/qdeclarativevideo/tst_qdeclarativevideo.cpp
Normal file
@@ -0,0 +1,991 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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=plugins/declarative/multimedia
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include "qdeclarativevideo_p.h"
|
||||
|
||||
|
||||
#include <qabstractvideosurface.h>
|
||||
#include <qgraphicsvideoitem.h>
|
||||
#include <qmediaplayercontrol.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediaserviceprovider.h>
|
||||
#include <qvideorenderercontrol.h>
|
||||
#include <qvideowindowcontrol.h>
|
||||
#include <qvideosurfaceformat.h>
|
||||
|
||||
#include <QtWidgets/qapplication.h>
|
||||
#include <QtGui/qpainter.h>
|
||||
|
||||
class tst_QDeclarativeVideo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
void initTestCase();
|
||||
|
||||
private slots:
|
||||
void nullPlayerControl();
|
||||
void nullService();
|
||||
|
||||
void playing();
|
||||
void paused();
|
||||
void error();
|
||||
|
||||
void hasAudio();
|
||||
void hasVideo();
|
||||
void fillMode();
|
||||
void geometry();
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(QDeclarativeVideo::Error);
|
||||
|
||||
class QtTestMediaPlayerControl : public QMediaPlayerControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtTestMediaPlayerControl(QObject *parent = 0)
|
||||
: QMediaPlayerControl(parent)
|
||||
, m_state(QMediaPlayer::StoppedState)
|
||||
, m_mediaStatus(QMediaPlayer::NoMedia)
|
||||
, m_duration(0)
|
||||
, m_position(0)
|
||||
, m_playbackRate(1.0)
|
||||
, m_volume(50)
|
||||
, m_bufferStatus(0)
|
||||
, m_muted(false)
|
||||
, m_audioAvailable(false)
|
||||
, m_videoAvailable(false)
|
||||
, m_seekable(false)
|
||||
{
|
||||
}
|
||||
|
||||
QMediaPlayer::State state() const { return m_state; }
|
||||
void updateState(QMediaPlayer::State state) { emit stateChanged(m_state = state); }
|
||||
|
||||
QMediaPlayer::MediaStatus mediaStatus() const { return m_mediaStatus; }
|
||||
void updateMediaStatus(QMediaPlayer::MediaStatus status) {
|
||||
emit mediaStatusChanged(m_mediaStatus = status); }
|
||||
void updateMediaStatus(QMediaPlayer::MediaStatus status, QMediaPlayer::State state)
|
||||
{
|
||||
m_mediaStatus = status;
|
||||
m_state = state;
|
||||
|
||||
emit mediaStatusChanged(m_mediaStatus);
|
||||
emit stateChanged(m_state);
|
||||
}
|
||||
|
||||
qint64 duration() const { return m_duration; }
|
||||
void setDuration(qint64 duration) { emit durationChanged(m_duration = duration); }
|
||||
|
||||
qint64 position() const { return m_position; }
|
||||
void setPosition(qint64 position) { emit positionChanged(m_position = position); }
|
||||
|
||||
int volume() const { return m_volume; }
|
||||
void setVolume(int volume) { emit volumeChanged(m_volume = volume); }
|
||||
|
||||
bool isMuted() const { return m_muted; }
|
||||
void setMuted(bool muted) { emit mutedChanged(m_muted = muted); }
|
||||
|
||||
int bufferStatus() const { return m_bufferStatus; }
|
||||
void setBufferStatus(int status) { emit bufferStatusChanged(m_bufferStatus = status); }
|
||||
|
||||
bool isAudioAvailable() const { return m_audioAvailable; }
|
||||
void setAudioAvailable(bool available) {
|
||||
emit audioAvailableChanged(m_audioAvailable = available); }
|
||||
bool isVideoAvailable() const { return m_videoAvailable; }
|
||||
void setVideoAvailable(bool available) {
|
||||
emit videoAvailableChanged(m_videoAvailable = available); }
|
||||
|
||||
bool isSeekable() const { return m_seekable; }
|
||||
void setSeekable(bool seekable) { emit seekableChanged(m_seekable = seekable); }
|
||||
|
||||
QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
|
||||
|
||||
qreal playbackRate() const { return m_playbackRate; }
|
||||
void setPlaybackRate(qreal rate) { emit playbackRateChanged(m_playbackRate = rate); }
|
||||
|
||||
QMediaContent media() const { return m_media; }
|
||||
const QIODevice *mediaStream() const { return 0; }
|
||||
void setMedia(const QMediaContent &media, QIODevice *)
|
||||
{
|
||||
m_media = media;
|
||||
|
||||
m_mediaStatus = m_media.isNull()
|
||||
? QMediaPlayer::NoMedia
|
||||
: QMediaPlayer::LoadingMedia;
|
||||
|
||||
emit mediaChanged(m_media);
|
||||
emit mediaStatusChanged(m_mediaStatus);
|
||||
}
|
||||
|
||||
void play() { emit stateChanged(m_state = QMediaPlayer::PlayingState); }
|
||||
void pause() { emit stateChanged(m_state = QMediaPlayer::PausedState); }
|
||||
void stop() { emit stateChanged(m_state = QMediaPlayer::StoppedState); }
|
||||
|
||||
void emitError(QMediaPlayer::Error err, const QString &errorString) {
|
||||
emit error(err, errorString); }
|
||||
|
||||
private:
|
||||
QMediaPlayer::State m_state;
|
||||
QMediaPlayer::MediaStatus m_mediaStatus;
|
||||
qint64 m_duration;
|
||||
qint64 m_position;
|
||||
qreal m_playbackRate;
|
||||
int m_volume;
|
||||
int m_bufferStatus;
|
||||
bool m_muted;
|
||||
bool m_audioAvailable;
|
||||
bool m_videoAvailable;
|
||||
bool m_seekable;
|
||||
QMediaContent m_media;
|
||||
};
|
||||
|
||||
class QtTestRendererControl : public QVideoRendererControl
|
||||
{
|
||||
public:
|
||||
QtTestRendererControl(QObject *parent ) : QVideoRendererControl(parent), m_surface(0) {}
|
||||
|
||||
QAbstractVideoSurface *surface() const { return m_surface; }
|
||||
void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
|
||||
|
||||
private:
|
||||
QAbstractVideoSurface *m_surface;
|
||||
};
|
||||
|
||||
class QtTestWindowControl : public QVideoWindowControl
|
||||
{
|
||||
public:
|
||||
QtTestWindowControl(QObject *parent)
|
||||
: QVideoWindowControl(parent)
|
||||
, m_winId(0)
|
||||
, m_repaintCount(0)
|
||||
, m_brightness(0)
|
||||
, m_contrast(0)
|
||||
, m_saturation(0)
|
||||
, m_aspectRatioMode(Qt::KeepAspectRatio)
|
||||
, m_fullScreen(0)
|
||||
{
|
||||
}
|
||||
|
||||
WId winId() const { return m_winId; }
|
||||
void setWinId(WId id) { m_winId = id; }
|
||||
|
||||
QRect displayRect() const { return m_displayRect; }
|
||||
void setDisplayRect(const QRect &rect) { m_displayRect = rect; }
|
||||
|
||||
bool isFullScreen() const { return m_fullScreen; }
|
||||
void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); }
|
||||
|
||||
int repaintCount() const { return m_repaintCount; }
|
||||
void setRepaintCount(int count) { m_repaintCount = count; }
|
||||
void repaint() { ++m_repaintCount; }
|
||||
|
||||
QSize nativeSize() const { return m_nativeSize; }
|
||||
void setNativeSize(const QSize &size) { m_nativeSize = size; emit nativeSizeChanged(); }
|
||||
|
||||
Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; }
|
||||
void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; }
|
||||
|
||||
int brightness() const { return m_brightness; }
|
||||
void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); }
|
||||
|
||||
int contrast() const { return m_contrast; }
|
||||
void setContrast(int contrast) { emit contrastChanged(m_contrast = contrast); }
|
||||
|
||||
int hue() const { return m_hue; }
|
||||
void setHue(int hue) { emit hueChanged(m_hue = hue); }
|
||||
|
||||
int saturation() const { return m_saturation; }
|
||||
void setSaturation(int saturation) { emit saturationChanged(m_saturation = saturation); }
|
||||
|
||||
private:
|
||||
WId m_winId;
|
||||
int m_repaintCount;
|
||||
int m_brightness;
|
||||
int m_contrast;
|
||||
int m_hue;
|
||||
int m_saturation;
|
||||
Qt::AspectRatioMode m_aspectRatioMode;
|
||||
QRect m_displayRect;
|
||||
QSize m_nativeSize;
|
||||
bool m_fullScreen;
|
||||
};
|
||||
|
||||
class QtTestMediaService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtTestMediaService(
|
||||
QtTestMediaPlayerControl *playerControl,
|
||||
QtTestRendererControl *rendererControl,
|
||||
QtTestWindowControl *windowControl,
|
||||
QObject *parent)
|
||||
: QMediaService(parent)
|
||||
, playerControl(playerControl)
|
||||
, rendererControl(rendererControl)
|
||||
, windowControl(windowControl)
|
||||
{
|
||||
}
|
||||
|
||||
QMediaControl *requestControl(const char *name)
|
||||
{
|
||||
if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
|
||||
return playerControl;
|
||||
else if (qstrcmp(name, QVideoRendererControl_iid) == 0)
|
||||
return rendererControl;
|
||||
else if (qstrcmp(name, QVideoWindowControl_iid) == 0)
|
||||
return windowControl;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void releaseControl(QMediaControl *) {}
|
||||
|
||||
QtTestMediaPlayerControl *playerControl;
|
||||
QtTestRendererControl *rendererControl;
|
||||
QtTestWindowControl *windowControl;
|
||||
};
|
||||
|
||||
class QtTestMediaServiceProvider : public QMediaServiceProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtTestMediaServiceProvider()
|
||||
: service(
|
||||
new QtTestMediaService(
|
||||
new QtTestMediaPlayerControl(this),
|
||||
new QtTestRendererControl(this),
|
||||
new QtTestWindowControl(this),
|
||||
this))
|
||||
{
|
||||
setDefaultServiceProvider(this);
|
||||
}
|
||||
|
||||
QtTestMediaServiceProvider(QtTestMediaService *service)
|
||||
: service(service)
|
||||
{
|
||||
setDefaultServiceProvider(this);
|
||||
}
|
||||
|
||||
QtTestMediaServiceProvider(
|
||||
QtTestMediaPlayerControl *playerControl,
|
||||
QtTestRendererControl *rendererControl,
|
||||
QtTestWindowControl *windowControl)
|
||||
: service(new QtTestMediaService(playerControl, rendererControl, windowControl, this))
|
||||
{
|
||||
setDefaultServiceProvider(this);
|
||||
}
|
||||
|
||||
~QtTestMediaServiceProvider()
|
||||
{
|
||||
setDefaultServiceProvider(0);
|
||||
}
|
||||
|
||||
QMediaService *requestService(
|
||||
const QByteArray &type,
|
||||
const QMediaServiceProviderHint & = QMediaServiceProviderHint())
|
||||
{
|
||||
requestedService = type;
|
||||
|
||||
return service;
|
||||
}
|
||||
|
||||
void releaseService(QMediaService *) {}
|
||||
|
||||
inline QtTestMediaPlayerControl *playerControl() { return service->playerControl; }
|
||||
inline QtTestRendererControl *rendererControl() { return service->rendererControl; }
|
||||
|
||||
QtTestMediaService *service;
|
||||
QByteArray requestedService;
|
||||
};
|
||||
|
||||
|
||||
void tst_QDeclarativeVideo::initTestCase()
|
||||
{
|
||||
qRegisterMetaType<QDeclarativeVideo::Error>();
|
||||
}
|
||||
|
||||
void tst_QDeclarativeVideo::nullPlayerControl()
|
||||
{
|
||||
QtTestMediaServiceProvider provider(0, 0, 0);
|
||||
|
||||
QDeclarativeVideo video;
|
||||
video.classBegin();
|
||||
|
||||
QCOMPARE(video.source(), QUrl());
|
||||
video.setSource(QUrl("http://example.com"));
|
||||
QCOMPARE(video.source(), QUrl("http://example.com"));
|
||||
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
video.setPlaying(true);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
video.setPlaying(false);
|
||||
video.play();
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
video.pause();
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
video.setPaused(true);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
|
||||
QCOMPARE(video.duration(), 0);
|
||||
|
||||
QCOMPARE(video.position(), 0);
|
||||
video.setPosition(10000);
|
||||
QCOMPARE(video.position(), 10000);
|
||||
|
||||
QCOMPARE(video.volume(), qreal(1.0));
|
||||
video.setVolume(0.5);
|
||||
QCOMPARE(video.volume(), qreal(0.5));
|
||||
|
||||
QCOMPARE(video.isMuted(), false);
|
||||
video.setMuted(true);
|
||||
QCOMPARE(video.isMuted(), true);
|
||||
|
||||
QCOMPARE(video.bufferProgress(), qreal(0));
|
||||
|
||||
QCOMPARE(video.isSeekable(), false);
|
||||
|
||||
QCOMPARE(video.playbackRate(), qreal(1.0));
|
||||
|
||||
QCOMPARE(video.hasAudio(), false);
|
||||
QCOMPARE(video.hasVideo(), false);
|
||||
|
||||
QCOMPARE(video.status(), QDeclarativeVideo::NoMedia);
|
||||
|
||||
QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing);
|
||||
}
|
||||
|
||||
void tst_QDeclarativeVideo::nullService()
|
||||
{
|
||||
QtTestMediaServiceProvider provider(0);
|
||||
|
||||
QDeclarativeVideo video;
|
||||
video.classBegin();
|
||||
|
||||
QCOMPARE(video.source(), QUrl());
|
||||
video.setSource(QUrl("http://example.com"));
|
||||
QCOMPARE(video.source(), QUrl("http://example.com"));
|
||||
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
video.setPlaying(true);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
video.setPlaying(false);
|
||||
video.play();
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
video.pause();
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
video.setPaused(true);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
|
||||
QCOMPARE(video.duration(), 0);
|
||||
|
||||
QCOMPARE(video.position(), 0);
|
||||
video.setPosition(10000);
|
||||
QCOMPARE(video.position(), 10000);
|
||||
|
||||
QCOMPARE(video.volume(), qreal(1.0));
|
||||
video.setVolume(0.5);
|
||||
QCOMPARE(video.volume(), qreal(0.5));
|
||||
|
||||
QCOMPARE(video.isMuted(), false);
|
||||
video.setMuted(true);
|
||||
QCOMPARE(video.isMuted(), true);
|
||||
|
||||
QCOMPARE(video.bufferProgress(), qreal(0));
|
||||
|
||||
QCOMPARE(video.isSeekable(), false);
|
||||
|
||||
QCOMPARE(video.playbackRate(), qreal(1.0));
|
||||
|
||||
QCOMPARE(video.hasAudio(), false);
|
||||
QCOMPARE(video.hasVideo(), false);
|
||||
|
||||
QCOMPARE(video.status(), QDeclarativeVideo::NoMedia);
|
||||
|
||||
QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing);
|
||||
|
||||
QCOMPARE(video.metaObject()->indexOfProperty("title"), -1);
|
||||
QCOMPARE(video.metaObject()->indexOfProperty("genre"), -1);
|
||||
QCOMPARE(video.metaObject()->indexOfProperty("description"), -1);
|
||||
}
|
||||
|
||||
void tst_QDeclarativeVideo::playing()
|
||||
{
|
||||
QtTestMediaServiceProvider provider;
|
||||
QDeclarativeVideo video;
|
||||
video.classBegin();
|
||||
video.componentComplete();
|
||||
video.setSource(QUrl("http://example.com"));
|
||||
|
||||
QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
|
||||
QSignalSpy startedSpy(&video, SIGNAL(started()));
|
||||
QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
|
||||
|
||||
int playingChanged = 0;
|
||||
int started = 0;
|
||||
int stopped = 0;
|
||||
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
|
||||
// setPlaying(true) when stopped.
|
||||
video.setPlaying(true);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(startedSpy.count(), ++started);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPlaying(false) when playing.
|
||||
video.setPlaying(false);
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(stoppedSpy.count(), ++stopped);
|
||||
|
||||
// play() when stopped.
|
||||
video.play();
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(startedSpy.count(), ++started);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// stop() when playing.
|
||||
video.stop();
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(stoppedSpy.count(), ++stopped);
|
||||
|
||||
// stop() when stopped.
|
||||
video.stop();
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPlaying(false) when stopped.
|
||||
video.setPlaying(false);
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
video.setPlaying(true);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(startedSpy.count(), ++started);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPlaying(true) when playing.
|
||||
video.setPlaying(true);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// play() when playing.
|
||||
video.play();
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
}
|
||||
|
||||
void tst_QDeclarativeVideo::paused()
|
||||
{
|
||||
QtTestMediaServiceProvider provider;
|
||||
QDeclarativeVideo video;
|
||||
video.classBegin();
|
||||
video.componentComplete();
|
||||
video.setSource(QUrl("http://example.com"));
|
||||
|
||||
QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged()));
|
||||
QSignalSpy pausedChangedSpy(&video, SIGNAL(pausedChanged()));
|
||||
QSignalSpy startedSpy(&video, SIGNAL(started()));
|
||||
QSignalSpy pausedSpy(&video, SIGNAL(paused()));
|
||||
QSignalSpy resumedSpy(&video, SIGNAL(resumed()));
|
||||
QSignalSpy stoppedSpy(&video, SIGNAL(stopped()));
|
||||
|
||||
int playingChanged = 0;
|
||||
int pausedChanged = 0;
|
||||
int started = 0;
|
||||
int paused = 0;
|
||||
int resumed = 0;
|
||||
int stopped = 0;
|
||||
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
|
||||
// setPlaying(true) when stopped.
|
||||
video.setPlaying(true);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), ++started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPaused(true) when playing.
|
||||
video.setPaused(true);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), ++paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPaused(true) when paused.
|
||||
video.setPaused(true);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// pause() when paused.
|
||||
video.pause();
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPaused(false) when paused.
|
||||
video.setPaused(false);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), ++resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPaused(false) when playing.
|
||||
video.setPaused(false);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// pause() when playing.
|
||||
video.pause();
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), ++paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPlaying(false) when paused.
|
||||
video.setPlaying(false);
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), ++stopped);
|
||||
|
||||
// setPaused(true) when stopped and paused.
|
||||
video.setPaused(true);
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPaused(false) when stopped and paused.
|
||||
video.setPaused(false);
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPaused(true) when stopped.
|
||||
video.setPaused(true);
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPlaying(true) when stopped and paused.
|
||||
video.setPlaying(true);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), ++started);
|
||||
QCOMPARE(pausedSpy.count(), ++paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// play() when paused.
|
||||
video.play();
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), ++resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPaused(true) when playing.
|
||||
video.setPaused(true);
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), ++paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// stop() when paused.
|
||||
video.stop();
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), ++stopped);
|
||||
|
||||
// setPaused(true) when stopped.
|
||||
video.setPaused(true);
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// stop() when stopped and paused.
|
||||
video.stop();
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// pause() when stopped.
|
||||
video.pause();
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), ++started);
|
||||
QCOMPARE(pausedSpy.count(), ++paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPlaying(false) when paused.
|
||||
video.setPlaying(false);
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), ++stopped);
|
||||
|
||||
// pause() when stopped and paused.
|
||||
video.pause();
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PausedState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), ++started);
|
||||
QCOMPARE(pausedSpy.count(), ++paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
|
||||
// setPlaying(false) when paused.
|
||||
video.setPlaying(false);
|
||||
QCOMPARE(video.isPlaying(), false);
|
||||
QCOMPARE(video.isPaused(), true);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::StoppedState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), ++stopped);
|
||||
|
||||
// play() when stopped and paused.
|
||||
video.play();
|
||||
QCOMPARE(video.isPlaying(), true);
|
||||
QCOMPARE(video.isPaused(), false);
|
||||
QCOMPARE(provider.playerControl()->state(), QMediaPlayer::PlayingState);
|
||||
QCOMPARE(playingChangedSpy.count(), ++playingChanged);
|
||||
QCOMPARE(pausedChangedSpy.count(), ++pausedChanged);
|
||||
QCOMPARE(startedSpy.count(), ++started);
|
||||
QCOMPARE(pausedSpy.count(), paused);
|
||||
QCOMPARE(resumedSpy.count(), resumed);
|
||||
QCOMPARE(stoppedSpy.count(), stopped);
|
||||
}
|
||||
|
||||
void tst_QDeclarativeVideo::error()
|
||||
{
|
||||
const QString errorString = QLatin1String("Failed to open device.");
|
||||
|
||||
QtTestMediaServiceProvider provider;
|
||||
QDeclarativeVideo video;
|
||||
video.classBegin();
|
||||
video.componentComplete();
|
||||
|
||||
QSignalSpy errorSpy(&video, SIGNAL(error(QDeclarativeVideo::Error,QString)));
|
||||
QSignalSpy errorChangedSpy(&video, SIGNAL(errorChanged()));
|
||||
|
||||
QCOMPARE(video.error(), QDeclarativeVideo::NoError);
|
||||
QCOMPARE(video.errorString(), QString());
|
||||
|
||||
provider.playerControl()->emitError(QMediaPlayer::ResourceError, errorString);
|
||||
|
||||
QCOMPARE(video.error(), QDeclarativeVideo::ResourceError);
|
||||
QCOMPARE(video.errorString(), errorString);
|
||||
QCOMPARE(errorSpy.count(), 1);
|
||||
QCOMPARE(errorChangedSpy.count(), 1);
|
||||
|
||||
// Changing the source resets the error properties.
|
||||
video.setSource(QUrl("http://example.com"));
|
||||
QCOMPARE(video.error(), QDeclarativeVideo::NoError);
|
||||
QCOMPARE(video.errorString(), QString());
|
||||
QCOMPARE(errorSpy.count(), 1);
|
||||
QCOMPARE(errorChangedSpy.count(), 2);
|
||||
|
||||
// But isn't noisy.
|
||||
video.setSource(QUrl("file:///file/path"));
|
||||
QCOMPARE(video.error(), QDeclarativeVideo::NoError);
|
||||
QCOMPARE(video.errorString(), QString());
|
||||
QCOMPARE(errorSpy.count(), 1);
|
||||
QCOMPARE(errorChangedSpy.count(), 2);
|
||||
}
|
||||
|
||||
|
||||
void tst_QDeclarativeVideo::hasAudio()
|
||||
{
|
||||
QtTestMediaServiceProvider provider;
|
||||
QDeclarativeVideo video;
|
||||
video.classBegin();
|
||||
video.componentComplete();
|
||||
|
||||
QSignalSpy spy(&video, SIGNAL(hasAudioChanged()));
|
||||
|
||||
QCOMPARE(video.hasAudio(), false);
|
||||
|
||||
provider.playerControl()->setAudioAvailable(true);
|
||||
QCOMPARE(video.hasAudio(), true);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
|
||||
provider.playerControl()->setAudioAvailable(true);
|
||||
QCOMPARE(video.hasAudio(), true);
|
||||
QCOMPARE(spy.count(), 2);
|
||||
|
||||
provider.playerControl()->setAudioAvailable(false);
|
||||
QCOMPARE(video.hasAudio(), false);
|
||||
QCOMPARE(spy.count(), 3);
|
||||
}
|
||||
|
||||
void tst_QDeclarativeVideo::hasVideo()
|
||||
{
|
||||
QtTestMediaServiceProvider provider;
|
||||
QDeclarativeVideo video;
|
||||
video.classBegin();
|
||||
video.componentComplete();
|
||||
|
||||
QSignalSpy spy(&video, SIGNAL(hasVideoChanged()));
|
||||
|
||||
QCOMPARE(video.hasVideo(), false);
|
||||
|
||||
provider.playerControl()->setVideoAvailable(true);
|
||||
QCOMPARE(video.hasVideo(), true);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
|
||||
provider.playerControl()->setVideoAvailable(true);
|
||||
QCOMPARE(video.hasVideo(), true);
|
||||
QCOMPARE(spy.count(), 2);
|
||||
|
||||
provider.playerControl()->setVideoAvailable(false);
|
||||
QCOMPARE(video.hasVideo(), false);
|
||||
QCOMPARE(spy.count(), 3);
|
||||
}
|
||||
|
||||
void tst_QDeclarativeVideo::fillMode()
|
||||
{
|
||||
QtTestMediaServiceProvider provider;
|
||||
QDeclarativeVideo video;
|
||||
video.classBegin();
|
||||
video.componentComplete();
|
||||
|
||||
QList<QGraphicsItem *> children = video.childItems();
|
||||
QCOMPARE(children.count(), 1);
|
||||
QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
|
||||
QVERIFY(videoItem != 0);
|
||||
|
||||
QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit);
|
||||
|
||||
video.setFillMode(QDeclarativeVideo::PreserveAspectCrop);
|
||||
QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectCrop);
|
||||
QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatioByExpanding);
|
||||
|
||||
video.setFillMode(QDeclarativeVideo::Stretch);
|
||||
QCOMPARE(video.fillMode(), QDeclarativeVideo::Stretch);
|
||||
QCOMPARE(videoItem->aspectRatioMode(), Qt::IgnoreAspectRatio);
|
||||
|
||||
video.setFillMode(QDeclarativeVideo::PreserveAspectFit);
|
||||
QCOMPARE(video.fillMode(), QDeclarativeVideo::PreserveAspectFit);
|
||||
QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
void tst_QDeclarativeVideo::geometry()
|
||||
{
|
||||
QtTestMediaServiceProvider provider;
|
||||
QDeclarativeVideo video;
|
||||
video.classBegin();
|
||||
video.componentComplete();
|
||||
|
||||
QList<QGraphicsItem *> children = video.childItems();
|
||||
QCOMPARE(children.count(), 1);
|
||||
QGraphicsVideoItem *videoItem = qgraphicsitem_cast<QGraphicsVideoItem *>(children.first());
|
||||
QVERIFY(videoItem != 0);
|
||||
|
||||
{ // Surface setup is deferred until after the first paint.
|
||||
QImage image(320, 240, QImage::Format_RGB32);
|
||||
QPainter painter(&image);
|
||||
|
||||
videoItem->paint(&painter, 0);
|
||||
}
|
||||
|
||||
QAbstractVideoSurface *surface = provider.rendererControl()->surface();
|
||||
|
||||
//video item can use overlay, QAbstractVideoSurface is not used than.
|
||||
if (surface) {
|
||||
QVideoSurfaceFormat format(QSize(640, 480), QVideoFrame::Format_RGB32);
|
||||
|
||||
QVERIFY(surface->start(format));
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
QCOMPARE(video.implicitWidth(), qreal(640));
|
||||
QCOMPARE(video.implicitHeight(), qreal(480));
|
||||
}
|
||||
|
||||
video.setWidth(560);
|
||||
video.setHeight(328);
|
||||
|
||||
QCOMPARE(videoItem->size().width(), qreal(560));
|
||||
QCOMPARE(videoItem->size().height(), qreal(328));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QDeclarativeVideo)
|
||||
|
||||
#include "tst_qdeclarativevideo.moc"
|
||||
11
tests/auto/unit/qgraphicsvideoitem/qgraphicsvideoitem.pro
Normal file
11
tests/auto/unit/qgraphicsvideoitem/qgraphicsvideoitem.pro
Normal file
@@ -0,0 +1,11 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qgraphicsvideoitem
|
||||
|
||||
QT += multimedia-private multimediawidgets-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qgraphicsvideoitem.cpp
|
||||
|
||||
# QPA minimal crashes with this test in QBackingStore
|
||||
CONFIG += insignificant_test
|
||||
QT+=widgets
|
||||
675
tests/auto/unit/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
Normal file
675
tests/auto/unit/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
Normal file
@@ -0,0 +1,675 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <qtmultimediadefs.h>
|
||||
#include "qgraphicsvideoitem.h"
|
||||
#include <QtTest/QtTest>
|
||||
#include "qmediaobject.h"
|
||||
#include "qmediaservice.h"
|
||||
#include <private/qpaintervideosurface_p.h>
|
||||
#include "qvideorenderercontrol.h"
|
||||
|
||||
#include <qabstractvideosurface.h>
|
||||
#include <qvideosurfaceformat.h>
|
||||
|
||||
#include <QtWidgets/qapplication.h>
|
||||
#include <QtWidgets/qgraphicsscene.h>
|
||||
#include <QtWidgets/qgraphicsview.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
class tst_QGraphicsVideoItem : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
void initTestCase();
|
||||
|
||||
private slots:
|
||||
void nullObject();
|
||||
void nullService();
|
||||
void noOutputs();
|
||||
void serviceDestroyed();
|
||||
void mediaObjectDestroyed();
|
||||
void setMediaObject();
|
||||
|
||||
void show();
|
||||
|
||||
void aspectRatioMode();
|
||||
void offset();
|
||||
void size();
|
||||
void nativeSize_data();
|
||||
void nativeSize();
|
||||
|
||||
void boundingRect_data();
|
||||
void boundingRect();
|
||||
|
||||
void paint();
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(const uchar *)
|
||||
Q_DECLARE_METATYPE(Qt::AspectRatioMode)
|
||||
|
||||
class QtTestRendererControl : public QVideoRendererControl
|
||||
{
|
||||
public:
|
||||
QtTestRendererControl()
|
||||
: m_surface(0)
|
||||
{
|
||||
}
|
||||
|
||||
QAbstractVideoSurface *surface() const { return m_surface; }
|
||||
void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
|
||||
|
||||
private:
|
||||
QAbstractVideoSurface *m_surface;
|
||||
};
|
||||
|
||||
class QtTestVideoService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtTestVideoService(
|
||||
QtTestRendererControl *renderer)
|
||||
: QMediaService(0)
|
||||
, rendererRef(0)
|
||||
, rendererControl(renderer)
|
||||
{
|
||||
}
|
||||
|
||||
~QtTestVideoService()
|
||||
{
|
||||
delete rendererControl;
|
||||
}
|
||||
|
||||
QMediaControl *requestControl(const char *name)
|
||||
{
|
||||
if (qstrcmp(name, QVideoRendererControl_iid) == 0 && rendererControl) {
|
||||
rendererRef += 1;
|
||||
|
||||
return rendererControl;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void releaseControl(QMediaControl *control)
|
||||
{
|
||||
Q_ASSERT(control);
|
||||
|
||||
if (control == rendererControl) {
|
||||
rendererRef -= 1;
|
||||
|
||||
if (rendererRef == 0)
|
||||
rendererControl->setSurface(0);
|
||||
}
|
||||
}
|
||||
|
||||
int rendererRef;
|
||||
QtTestRendererControl *rendererControl;
|
||||
};
|
||||
|
||||
class QtTestVideoObject : public QMediaObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtTestVideoObject(QtTestRendererControl *renderer)
|
||||
: QMediaObject(0, new QtTestVideoService(renderer))
|
||||
{
|
||||
testService = qobject_cast<QtTestVideoService*>(service());
|
||||
}
|
||||
|
||||
QtTestVideoObject(QtTestVideoService *service):
|
||||
QMediaObject(0, service),
|
||||
testService(service)
|
||||
{
|
||||
}
|
||||
|
||||
~QtTestVideoObject()
|
||||
{
|
||||
delete testService;
|
||||
}
|
||||
|
||||
QtTestVideoService *testService;
|
||||
};
|
||||
|
||||
class QtTestGraphicsVideoItem : public QGraphicsVideoItem
|
||||
{
|
||||
public:
|
||||
QtTestGraphicsVideoItem(QGraphicsItem *parent = 0)
|
||||
: QGraphicsVideoItem(parent)
|
||||
, m_paintCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
++m_paintCount;
|
||||
|
||||
QTestEventLoop::instance().exitLoop();
|
||||
|
||||
QGraphicsVideoItem::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
bool waitForPaint(int secs)
|
||||
{
|
||||
const int paintCount = m_paintCount;
|
||||
|
||||
QTestEventLoop::instance().enterLoop(secs);
|
||||
|
||||
return m_paintCount != paintCount;
|
||||
}
|
||||
|
||||
int paintCount() const
|
||||
{
|
||||
return m_paintCount;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_paintCount;
|
||||
};
|
||||
|
||||
void tst_QGraphicsVideoItem::initTestCase()
|
||||
{
|
||||
qRegisterMetaType<Qt::AspectRatioMode>();
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::nullObject()
|
||||
{
|
||||
QGraphicsVideoItem item(0);
|
||||
|
||||
QVERIFY(item.boundingRect().isEmpty());
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::nullService()
|
||||
{
|
||||
QtTestVideoService *service = 0;
|
||||
|
||||
QtTestVideoObject object(service);
|
||||
|
||||
QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem;
|
||||
object.bind(item);
|
||||
|
||||
QVERIFY(item->boundingRect().isEmpty());
|
||||
|
||||
item->hide();
|
||||
item->show();
|
||||
|
||||
QGraphicsScene graphicsScene;
|
||||
graphicsScene.addItem(item);
|
||||
QGraphicsView graphicsView(&graphicsScene);
|
||||
graphicsView.show();
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::noOutputs()
|
||||
{
|
||||
QtTestRendererControl *control = 0;
|
||||
QtTestVideoObject object(control);
|
||||
|
||||
QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem;
|
||||
object.bind(item);
|
||||
|
||||
QVERIFY(item->boundingRect().isEmpty());
|
||||
|
||||
item->hide();
|
||||
item->show();
|
||||
|
||||
QGraphicsScene graphicsScene;
|
||||
graphicsScene.addItem(item);
|
||||
QGraphicsView graphicsView(&graphicsScene);
|
||||
graphicsView.show();
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::serviceDestroyed()
|
||||
{
|
||||
QtTestVideoObject object(new QtTestRendererControl);
|
||||
|
||||
QGraphicsVideoItem item;
|
||||
object.bind(&item);
|
||||
|
||||
QCOMPARE(object.testService->rendererRef, 1);
|
||||
|
||||
QtTestVideoService *service = object.testService;
|
||||
object.testService = 0;
|
||||
|
||||
delete service;
|
||||
|
||||
QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object));
|
||||
QVERIFY(item.boundingRect().isEmpty());
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::mediaObjectDestroyed()
|
||||
{
|
||||
QtTestVideoObject *object = new QtTestVideoObject(new QtTestRendererControl);
|
||||
|
||||
QGraphicsVideoItem item;
|
||||
object->bind(&item);
|
||||
|
||||
QCOMPARE(object->testService->rendererRef, 1);
|
||||
|
||||
delete object;
|
||||
object = 0;
|
||||
|
||||
QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(object));
|
||||
QVERIFY(item.boundingRect().isEmpty());
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::setMediaObject()
|
||||
{
|
||||
QMediaObject *nullObject = 0;
|
||||
QtTestVideoObject object(new QtTestRendererControl);
|
||||
|
||||
QGraphicsVideoItem item;
|
||||
|
||||
QCOMPARE(item.mediaObject(), nullObject);
|
||||
QCOMPARE(object.testService->rendererRef, 0);
|
||||
|
||||
object.bind(&item);
|
||||
QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object));
|
||||
QCOMPARE(object.testService->rendererRef, 1);
|
||||
QVERIFY(object.testService->rendererControl->surface() == 0);
|
||||
|
||||
{ // Surface setup is deferred until after the first paint.
|
||||
QImage image(320, 240, QImage::Format_RGB32);
|
||||
QPainter painter(&image);
|
||||
|
||||
item.paint(&painter, 0);
|
||||
}
|
||||
QVERIFY(object.testService->rendererControl->surface() != 0);
|
||||
|
||||
object.unbind(&item);
|
||||
QCOMPARE(item.mediaObject(), nullObject);
|
||||
|
||||
QCOMPARE(object.testService->rendererRef, 0);
|
||||
QVERIFY(object.testService->rendererControl->surface() == 0);
|
||||
|
||||
item.setVisible(false);
|
||||
|
||||
object.bind(&item);
|
||||
QCOMPARE(item.mediaObject(), static_cast<QMediaObject *>(&object));
|
||||
QCOMPARE(object.testService->rendererRef, 1);
|
||||
QVERIFY(object.testService->rendererControl->surface() != 0);
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::show()
|
||||
{
|
||||
QtTestVideoObject object(new QtTestRendererControl);
|
||||
QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem;
|
||||
object.bind(item);
|
||||
|
||||
// Graphics items are visible by default
|
||||
QCOMPARE(object.testService->rendererRef, 1);
|
||||
QVERIFY(object.testService->rendererControl->surface() == 0);
|
||||
|
||||
item->hide();
|
||||
QCOMPARE(object.testService->rendererRef, 1);
|
||||
|
||||
item->show();
|
||||
QCOMPARE(object.testService->rendererRef, 1);
|
||||
QVERIFY(object.testService->rendererControl->surface() == 0);
|
||||
|
||||
QGraphicsScene graphicsScene;
|
||||
graphicsScene.addItem(item);
|
||||
QGraphicsView graphicsView(&graphicsScene);
|
||||
graphicsView.show();
|
||||
|
||||
QVERIFY(item->paintCount() || item->waitForPaint(1));
|
||||
QVERIFY(object.testService->rendererControl->surface() != 0);
|
||||
|
||||
QVERIFY(item->boundingRect().isEmpty());
|
||||
|
||||
QVideoSurfaceFormat format(QSize(320,240),QVideoFrame::Format_RGB32);
|
||||
QVERIFY(object.testService->rendererControl->surface()->start(format));
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
QVERIFY(!item->boundingRect().isEmpty());
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::aspectRatioMode()
|
||||
{
|
||||
QGraphicsVideoItem item;
|
||||
|
||||
QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio);
|
||||
|
||||
item.setAspectRatioMode(Qt::IgnoreAspectRatio);
|
||||
QCOMPARE(item.aspectRatioMode(), Qt::IgnoreAspectRatio);
|
||||
|
||||
item.setAspectRatioMode(Qt::KeepAspectRatioByExpanding);
|
||||
QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatioByExpanding);
|
||||
|
||||
item.setAspectRatioMode(Qt::KeepAspectRatio);
|
||||
QCOMPARE(item.aspectRatioMode(), Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::offset()
|
||||
{
|
||||
QGraphicsVideoItem item;
|
||||
|
||||
QCOMPARE(item.offset(), QPointF(0, 0));
|
||||
|
||||
item.setOffset(QPointF(-32.4, 43.0));
|
||||
QCOMPARE(item.offset(), QPointF(-32.4, 43.0));
|
||||
|
||||
item.setOffset(QPointF(1, 1));
|
||||
QCOMPARE(item.offset(), QPointF(1, 1));
|
||||
|
||||
item.setOffset(QPointF(12, -30.4));
|
||||
QCOMPARE(item.offset(), QPointF(12, -30.4));
|
||||
|
||||
item.setOffset(QPointF(-90.4, -75));
|
||||
QCOMPARE(item.offset(), QPointF(-90.4, -75));
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::size()
|
||||
{
|
||||
QGraphicsVideoItem item;
|
||||
|
||||
QCOMPARE(item.size(), QSizeF(320, 240));
|
||||
|
||||
item.setSize(QSizeF(542.5, 436.3));
|
||||
QCOMPARE(item.size(), QSizeF(542.5, 436.3));
|
||||
|
||||
item.setSize(QSizeF(-43, 12));
|
||||
QCOMPARE(item.size(), QSizeF(0, 0));
|
||||
|
||||
item.setSize(QSizeF(54, -9));
|
||||
QCOMPARE(item.size(), QSizeF(0, 0));
|
||||
|
||||
item.setSize(QSizeF(-90, -65));
|
||||
QCOMPARE(item.size(), QSizeF(0, 0));
|
||||
|
||||
item.setSize(QSizeF(1000, 1000));
|
||||
QCOMPARE(item.size(), QSizeF(1000, 1000));
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::nativeSize_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("frameSize");
|
||||
QTest::addColumn<QRect>("viewport");
|
||||
QTest::addColumn<QSize>("pixelAspectRatio");
|
||||
QTest::addColumn<QSizeF>("nativeSize");
|
||||
|
||||
QTest::newRow("640x480")
|
||||
<< QSize(640, 480)
|
||||
<< QRect(0, 0, 640, 480)
|
||||
<< QSize(1, 1)
|
||||
<< QSizeF(640, 480);
|
||||
|
||||
QTest::newRow("800x600, (80,60, 640x480) viewport")
|
||||
<< QSize(800, 600)
|
||||
<< QRect(80, 60, 640, 480)
|
||||
<< QSize(1, 1)
|
||||
<< QSizeF(640, 480);
|
||||
|
||||
QTest::newRow("800x600, (80,60, 640x480) viewport, 4:3")
|
||||
<< QSize(800, 600)
|
||||
<< QRect(80, 60, 640, 480)
|
||||
<< QSize(4, 3)
|
||||
<< QSizeF(853, 480);
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::nativeSize()
|
||||
{
|
||||
QFETCH(QSize, frameSize);
|
||||
QFETCH(QRect, viewport);
|
||||
QFETCH(QSize, pixelAspectRatio);
|
||||
QFETCH(QSizeF, nativeSize);
|
||||
|
||||
QtTestVideoObject object(new QtTestRendererControl);
|
||||
QGraphicsVideoItem item;
|
||||
object.bind(&item);
|
||||
|
||||
QCOMPARE(item.nativeSize(), QSizeF());
|
||||
|
||||
QSignalSpy spy(&item, SIGNAL(nativeSizeChanged(QSizeF)));
|
||||
|
||||
QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32);
|
||||
format.setViewport(viewport);
|
||||
format.setPixelAspectRatio(pixelAspectRatio);
|
||||
|
||||
{ // Surface setup is deferred until after the first paint.
|
||||
QImage image(320, 240, QImage::Format_RGB32);
|
||||
QPainter painter(&image);
|
||||
|
||||
item.paint(&painter, 0);
|
||||
}
|
||||
QVERIFY(object.testService->rendererControl->surface() != 0);
|
||||
QVERIFY(object.testService->rendererControl->surface()->start(format));
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
QCOMPARE(item.nativeSize(), nativeSize);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(spy.last().first().toSizeF(), nativeSize);
|
||||
|
||||
object.testService->rendererControl->surface()->stop();
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
QVERIFY(item.nativeSize().isEmpty());
|
||||
QCOMPARE(spy.count(), 2);
|
||||
QVERIFY(spy.last().first().toSizeF().isEmpty());
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::boundingRect_data()
|
||||
{
|
||||
QTest::addColumn<QSize>("frameSize");
|
||||
QTest::addColumn<QPointF>("offset");
|
||||
QTest::addColumn<QSizeF>("size");
|
||||
QTest::addColumn<Qt::AspectRatioMode>("aspectRatioMode");
|
||||
QTest::addColumn<QRectF>("expectedRect");
|
||||
|
||||
|
||||
QTest::newRow("640x480: (0,0 640x480), Keep")
|
||||
<< QSize(640, 480)
|
||||
<< QPointF(0, 0)
|
||||
<< QSizeF(640, 480)
|
||||
<< Qt::KeepAspectRatio
|
||||
<< QRectF(0, 0, 640, 480);
|
||||
|
||||
QTest::newRow("800x600, (0,0, 640x480), Keep")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(0, 0)
|
||||
<< QSizeF(640, 480)
|
||||
<< Qt::KeepAspectRatio
|
||||
<< QRectF(0, 0, 640, 480);
|
||||
|
||||
QTest::newRow("800x600, (0,0, 640x480), KeepByExpanding")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(0, 0)
|
||||
<< QSizeF(640, 480)
|
||||
<< Qt::KeepAspectRatioByExpanding
|
||||
<< QRectF(0, 0, 640, 480);
|
||||
|
||||
QTest::newRow("800x600, (0,0, 640x480), Ignore")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(0, 0)
|
||||
<< QSizeF(640, 480)
|
||||
<< Qt::IgnoreAspectRatio
|
||||
<< QRectF(0, 0, 640, 480);
|
||||
|
||||
QTest::newRow("800x600, (100,100, 640x480), Keep")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(100, 100)
|
||||
<< QSizeF(640, 480)
|
||||
<< Qt::KeepAspectRatio
|
||||
<< QRectF(100, 100, 640, 480);
|
||||
|
||||
QTest::newRow("800x600, (100,-100, 640x480), KeepByExpanding")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(100, -100)
|
||||
<< QSizeF(640, 480)
|
||||
<< Qt::KeepAspectRatioByExpanding
|
||||
<< QRectF(100, -100, 640, 480);
|
||||
|
||||
QTest::newRow("800x600, (-100,-100, 640x480), Ignore")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(-100, -100)
|
||||
<< QSizeF(640, 480)
|
||||
<< Qt::IgnoreAspectRatio
|
||||
<< QRectF(-100, -100, 640, 480);
|
||||
|
||||
QTest::newRow("800x600, (0,0, 1920x1024), Keep")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(0, 0)
|
||||
<< QSizeF(1920, 1024)
|
||||
<< Qt::KeepAspectRatio
|
||||
<< QRectF(832.0 / 3, 0, 4096.0 / 3, 1024);
|
||||
|
||||
QTest::newRow("800x600, (0,0, 1920x1024), KeepByExpanding")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(0, 0)
|
||||
<< QSizeF(1920, 1024)
|
||||
<< Qt::KeepAspectRatioByExpanding
|
||||
<< QRectF(0, 0, 1920, 1024);
|
||||
|
||||
QTest::newRow("800x600, (0,0, 1920x1024), Ignore")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(0, 0)
|
||||
<< QSizeF(1920, 1024)
|
||||
<< Qt::IgnoreAspectRatio
|
||||
<< QRectF(0, 0, 1920, 1024);
|
||||
|
||||
QTest::newRow("800x600, (100,100, 1920x1024), Keep")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(100, 100)
|
||||
<< QSizeF(1920, 1024)
|
||||
<< Qt::KeepAspectRatio
|
||||
<< QRectF(100 + 832.0 / 3, 100, 4096.0 / 3, 1024);
|
||||
|
||||
QTest::newRow("800x600, (100,-100, 1920x1024), KeepByExpanding")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(100, -100)
|
||||
<< QSizeF(1920, 1024)
|
||||
<< Qt::KeepAspectRatioByExpanding
|
||||
<< QRectF(100, -100, 1920, 1024);
|
||||
|
||||
QTest::newRow("800x600, (-100,-100, 1920x1024), Ignore")
|
||||
<< QSize(800, 600)
|
||||
<< QPointF(-100, -100)
|
||||
<< QSizeF(1920, 1024)
|
||||
<< Qt::IgnoreAspectRatio
|
||||
<< QRectF(-100, -100, 1920, 1024);
|
||||
}
|
||||
|
||||
void tst_QGraphicsVideoItem::boundingRect()
|
||||
{
|
||||
QFETCH(QSize, frameSize);
|
||||
QFETCH(QPointF, offset);
|
||||
QFETCH(QSizeF, size);
|
||||
QFETCH(Qt::AspectRatioMode, aspectRatioMode);
|
||||
QFETCH(QRectF, expectedRect);
|
||||
|
||||
QtTestVideoObject object(new QtTestRendererControl);
|
||||
QGraphicsVideoItem item;
|
||||
object.bind(&item);
|
||||
|
||||
item.setOffset(offset);
|
||||
item.setSize(size);
|
||||
item.setAspectRatioMode(aspectRatioMode);
|
||||
|
||||
QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32);
|
||||
|
||||
{ // Surface setup is deferred until after the first paint.
|
||||
QImage image(320, 240, QImage::Format_RGB32);
|
||||
QPainter painter(&image);
|
||||
|
||||
item.paint(&painter, 0);
|
||||
}
|
||||
QVERIFY(object.testService->rendererControl->surface() != 0);
|
||||
QVERIFY(object.testService->rendererControl->surface()->start(format));
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
QCOMPARE(item.boundingRect(), expectedRect);
|
||||
}
|
||||
|
||||
static const uchar rgb32ImageData[] =
|
||||
{
|
||||
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00
|
||||
};
|
||||
|
||||
void tst_QGraphicsVideoItem::paint()
|
||||
{
|
||||
QtTestVideoObject object(new QtTestRendererControl);
|
||||
QtTestGraphicsVideoItem *item = new QtTestGraphicsVideoItem;
|
||||
object.bind(item);
|
||||
|
||||
QGraphicsScene graphicsScene;
|
||||
graphicsScene.addItem(item);
|
||||
QGraphicsView graphicsView(&graphicsScene);
|
||||
graphicsView.show();
|
||||
QVERIFY(item->waitForPaint(1));
|
||||
|
||||
QPainterVideoSurface *surface = qobject_cast<QPainterVideoSurface *>(
|
||||
object.testService->rendererControl->surface());
|
||||
if (!surface)
|
||||
QSKIP("QGraphicsVideoItem is not QPainterVideoSurface based", SkipAll);
|
||||
|
||||
QVideoSurfaceFormat format(QSize(2, 2), QVideoFrame::Format_RGB32);
|
||||
|
||||
QVERIFY(surface->start(format));
|
||||
QCOMPARE(surface->isActive(), true);
|
||||
QCOMPARE(surface->isReady(), true);
|
||||
|
||||
QVERIFY(item->waitForPaint(1));
|
||||
|
||||
QCOMPARE(surface->isActive(), true);
|
||||
QCOMPARE(surface->isReady(), true);
|
||||
|
||||
QVideoFrame frame(sizeof(rgb32ImageData), QSize(2, 2), 8, QVideoFrame::Format_RGB32);
|
||||
|
||||
frame.map(QAbstractVideoBuffer::WriteOnly);
|
||||
memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes());
|
||||
frame.unmap();
|
||||
|
||||
QVERIFY(surface->present(frame));
|
||||
QCOMPARE(surface->isActive(), true);
|
||||
QCOMPARE(surface->isReady(), false);
|
||||
|
||||
QVERIFY(item->waitForPaint(1));
|
||||
|
||||
QCOMPARE(surface->isActive(), true);
|
||||
QCOMPARE(surface->isReady(), true);
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(tst_QGraphicsVideoItem)
|
||||
|
||||
#include "tst_qgraphicsvideoitem.moc"
|
||||
@@ -0,0 +1,11 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediabindableinterface
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += \
|
||||
tst_qmediabindableinterface.cpp
|
||||
|
||||
include (../qmultimedia_common/mock.pri)
|
||||
include (../qmultimedia_common/mockrecorder.pri)
|
||||
@@ -0,0 +1,137 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 <qmediaobject.h>
|
||||
#include <qmediacontrol.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediarecordercontrol.h>
|
||||
#include <qmediarecorder.h>
|
||||
#include <qmetadatawritercontrol.h>
|
||||
#include <qaudioendpointselector.h>
|
||||
#include <qaudioencodercontrol.h>
|
||||
#include <qmediacontainercontrol.h>
|
||||
#include <qvideoencodercontrol.h>
|
||||
#include <qaudioformat.h>
|
||||
|
||||
#include "mockmediacontainercontrol.h"
|
||||
#include "mockmetadatawritercontrol.h"
|
||||
#include "mockmediarecordercontrol.h"
|
||||
#include "mockmediaobject.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class TestBindableService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestBindableService(QObject *parent, QMediaControl *control):
|
||||
QMediaService(parent),
|
||||
mockControl(control),
|
||||
hasControls(true)
|
||||
{
|
||||
mockContainerControl = new MockMediaContainerControl(parent); //Creating the object for Media
|
||||
mockMetaDataControl = new MockMetaDataWriterControl(parent); //Creating the object for MetaData
|
||||
}
|
||||
|
||||
QMediaControl* requestControl(const char *name)
|
||||
{
|
||||
if (hasControls && qstrcmp(name,QMediaRecorderControl_iid) == 0)
|
||||
return mockControl;
|
||||
if (hasControls && qstrcmp(name,QMediaContainerControl_iid) == 0)
|
||||
return mockContainerControl;
|
||||
if (hasControls && qstrcmp(name, QMetaDataWriterControl_iid) == 0)
|
||||
return mockMetaDataControl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void releaseControl(QMediaControl*) {}
|
||||
//Initialising the objects for the media
|
||||
QMediaControl *mockControl;
|
||||
QMediaContainerControl *mockContainerControl;
|
||||
MockMetaDataWriterControl *mockMetaDataControl;
|
||||
bool hasControls;
|
||||
};
|
||||
|
||||
class tst_QMediaBindableInterface:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void cleanup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void testMediaObject() //Verifying the mediaobject api
|
||||
{
|
||||
MockMediaRecorderControl recorderControl(0);
|
||||
TestBindableService service(0, &recorderControl);
|
||||
service.mockMetaDataControl->populateMetaData();
|
||||
MockMediaObject object(0, &service);
|
||||
QMediaRecorder recorder(&object);
|
||||
QMediaObject *obj = recorder.mediaObject();
|
||||
QVERIFY(obj != NULL);
|
||||
QVERIFY(obj->isAvailable());
|
||||
}
|
||||
|
||||
void testDestructor() //Invoking the destructor
|
||||
{
|
||||
MockMediaRecorderControl recorderControl(0);
|
||||
TestBindableService service(0, &recorderControl);
|
||||
service.mockMetaDataControl->populateMetaData();
|
||||
MockMediaObject object(0, &service);
|
||||
QMediaRecorder *recorder = new QMediaRecorder(&object);
|
||||
QVERIFY(recorder->isAvailable());
|
||||
delete recorder;
|
||||
recorder = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(tst_QMediaBindableInterface)
|
||||
#include "tst_qmediabindableinterface.moc"
|
||||
@@ -0,0 +1,10 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediacontainercontrol
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qmediacontainercontrol.cpp
|
||||
|
||||
include (../qmultimedia_common/mockcontainer.pri)
|
||||
|
||||
@@ -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 test suite 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 "qmediacontainercontrol.h"
|
||||
#include "qmediarecorder.h"
|
||||
|
||||
#include "../qmultimedia_common/mockmediacontainercontrol.h"
|
||||
|
||||
//MaemoAPI-
|
||||
class tst_QMediaContainerControl :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
//to test the constructor
|
||||
void tst_mediacontainercontrol()
|
||||
{
|
||||
|
||||
QObject obj;
|
||||
MockMediaContainerControl control(&obj);
|
||||
QStringList strlist=control.supportedContainers();
|
||||
QStringList strlist1;
|
||||
strlist1 << "wav" << "mp3" << "mov";
|
||||
QVERIFY(strlist[0]==strlist1[0]); //checking with "wav" mime type
|
||||
QVERIFY(strlist[1]==strlist1[1]); //checking with "mp3" mime type
|
||||
QVERIFY(strlist[2]==strlist1[2]); //checking with "mov" mime type
|
||||
|
||||
control.setContainerMimeType("wav");
|
||||
const QString str("wav");
|
||||
QVERIFY2(control.containerMimeType() == str,"Failed");
|
||||
|
||||
const QString str1("WAV format");
|
||||
QVERIFY2(control.containerDescription("wav") == str1,"FAILED");
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(tst_QMediaContainerControl);
|
||||
#include "tst_qmediacontainercontrol.moc"
|
||||
7
tests/auto/unit/qmediacontent/qmediacontent.pro
Normal file
7
tests/auto/unit/qmediacontent/qmediacontent.pro
Normal file
@@ -0,0 +1,7 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediacontent
|
||||
|
||||
QT += multimedia-private network testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qmediacontent.cpp
|
||||
177
tests/auto/unit/qmediacontent/tst_qmediacontent.cpp
Normal file
177
tests/auto/unit/qmediacontent/tst_qmediacontent.cpp
Normal file
@@ -0,0 +1,177 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtTest/QtTest>
|
||||
#include <QtNetwork/qnetworkrequest.h>
|
||||
|
||||
#include <qmediacontent.h>
|
||||
|
||||
//TESTED_COMPONENT=src/multimedia
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
class tst_QMediaContent : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testNull();
|
||||
void testUrlCtor();
|
||||
void testRequestCtor();
|
||||
void testResourceCtor();
|
||||
void testResourceListCtor();
|
||||
void testCopy();
|
||||
void testAssignment();
|
||||
void testEquality();
|
||||
void testResources();
|
||||
};
|
||||
|
||||
void tst_QMediaContent::testNull()
|
||||
{
|
||||
QMediaContent media;
|
||||
|
||||
QCOMPARE(media.isNull(), true);
|
||||
QCOMPARE(media.canonicalUrl(), QUrl());
|
||||
QCOMPARE(media.canonicalResource(), QMediaResource());
|
||||
QCOMPARE(media.resources(), QMediaResourceList());
|
||||
}
|
||||
|
||||
void tst_QMediaContent::testUrlCtor()
|
||||
{
|
||||
QMediaContent media(QUrl("http://example.com/movie.mov"));
|
||||
|
||||
QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov"));
|
||||
QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov"));
|
||||
}
|
||||
|
||||
void tst_QMediaContent::testRequestCtor()
|
||||
{
|
||||
QNetworkRequest request(QUrl("http://example.com/movie.mov"));
|
||||
request.setAttribute(QNetworkRequest::User, QVariant(1234));
|
||||
|
||||
QMediaContent media(request);
|
||||
|
||||
QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov"));
|
||||
QCOMPARE(media.canonicalRequest(),request);
|
||||
QCOMPARE(media.canonicalResource().request(), request);
|
||||
QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov"));
|
||||
}
|
||||
|
||||
void tst_QMediaContent::testResourceCtor()
|
||||
{
|
||||
QMediaContent media(QMediaResource(QUrl("http://example.com/movie.mov")));
|
||||
|
||||
QCOMPARE(media.canonicalResource(), QMediaResource(QUrl("http://example.com/movie.mov")));
|
||||
}
|
||||
|
||||
void tst_QMediaContent::testResourceListCtor()
|
||||
{
|
||||
QMediaResourceList resourceList;
|
||||
resourceList << QMediaResource(QUrl("http://example.com/movie.mov"));
|
||||
|
||||
QMediaContent media(resourceList);
|
||||
|
||||
QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov"));
|
||||
QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov"));
|
||||
}
|
||||
|
||||
void tst_QMediaContent::testCopy()
|
||||
{
|
||||
QMediaContent media1(QMediaResource(QUrl("http://example.com/movie.mov")));
|
||||
QMediaContent media2(media1);
|
||||
|
||||
QVERIFY(media1 == media2);
|
||||
}
|
||||
|
||||
void tst_QMediaContent::testAssignment()
|
||||
{
|
||||
QMediaContent media1(QMediaResource(QUrl("http://example.com/movie.mov")));
|
||||
QMediaContent media2;
|
||||
QMediaContent media3;
|
||||
|
||||
media2 = media1;
|
||||
QVERIFY(media2 == media1);
|
||||
|
||||
media2 = media3;
|
||||
QVERIFY(media2 == media3);
|
||||
}
|
||||
|
||||
void tst_QMediaContent::testEquality()
|
||||
{
|
||||
QMediaContent media1;
|
||||
QMediaContent media2;
|
||||
QMediaContent media3(QMediaResource(QUrl("http://example.com/movie.mov")));
|
||||
QMediaContent media4(QMediaResource(QUrl("http://example.com/movie.mov")));
|
||||
QMediaContent media5(QMediaResource(QUrl("file:///some/where/over/the/rainbow.mp3")));
|
||||
|
||||
// null == null
|
||||
QCOMPARE(media1 == media2, true);
|
||||
QCOMPARE(media1 != media2, false);
|
||||
|
||||
// null != something
|
||||
QCOMPARE(media1 == media3, false);
|
||||
QCOMPARE(media1 != media3, true);
|
||||
|
||||
// equiv
|
||||
QCOMPARE(media3 == media4, true);
|
||||
QCOMPARE(media3 != media4, false);
|
||||
|
||||
// not equiv
|
||||
QCOMPARE(media4 == media5, false);
|
||||
QCOMPARE(media4 != media5, true);
|
||||
}
|
||||
|
||||
void tst_QMediaContent::testResources()
|
||||
{
|
||||
QMediaResourceList resourceList;
|
||||
|
||||
resourceList << QMediaResource(QUrl("http://example.com/movie-main.mov"));
|
||||
resourceList << QMediaResource(QUrl("http://example.com/movie-big.mov"));
|
||||
QMediaContent media(resourceList);
|
||||
|
||||
QMediaResourceList res = media.resources();
|
||||
QCOMPARE(res.size(), 2);
|
||||
QCOMPARE(res[0], QMediaResource(QUrl("http://example.com/movie-main.mov")));
|
||||
QCOMPARE(res[1], QMediaResource(QUrl("http://example.com/movie-big.mov")));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMediaContent)
|
||||
|
||||
#include "tst_qmediacontent.moc"
|
||||
9
tests/auto/unit/qmediaimageviewer/images.qrc
Normal file
9
tests/auto/unit/qmediaimageviewer/images.qrc
Normal file
@@ -0,0 +1,9 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>images/coverart.png</file>
|
||||
<file>images/image.jpg</file>
|
||||
<file>images/image.png</file>
|
||||
<file>images/invalid.png</file>
|
||||
<file>images/poster.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
BIN
tests/auto/unit/qmediaimageviewer/images/coverart.png
Normal file
BIN
tests/auto/unit/qmediaimageviewer/images/coverart.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 230 B |
BIN
tests/auto/unit/qmediaimageviewer/images/image.jpg
Normal file
BIN
tests/auto/unit/qmediaimageviewer/images/image.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
tests/auto/unit/qmediaimageviewer/images/image.png
Normal file
BIN
tests/auto/unit/qmediaimageviewer/images/image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 230 B |
2
tests/auto/unit/qmediaimageviewer/images/invalid.png
Normal file
2
tests/auto/unit/qmediaimageviewer/images/invalid.png
Normal file
@@ -0,0 +1,2 @@
|
||||
This is not really a PNG file.
|
||||
|
||||
BIN
tests/auto/unit/qmediaimageviewer/images/poster.png
Normal file
BIN
tests/auto/unit/qmediaimageviewer/images/poster.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 230 B |
16
tests/auto/unit/qmediaimageviewer/qmediaimageviewer.pro
Normal file
16
tests/auto/unit/qmediaimageviewer/qmediaimageviewer.pro
Normal file
@@ -0,0 +1,16 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediaimageviewer
|
||||
|
||||
QT += multimedia-private network testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qmediaimageviewer.cpp
|
||||
|
||||
RESOURCES += \
|
||||
images.qrc
|
||||
|
||||
!contains(QT_CONFIG, no-jpeg):DEFINES += QTEST_HAVE_JPEG
|
||||
|
||||
wince* {
|
||||
!contains(QT_CONFIG, no-jpeg): DEPLOYMENT_PLUGIN += qjpeg
|
||||
}
|
||||
1044
tests/auto/unit/qmediaimageviewer/tst_qmediaimageviewer.cpp
Normal file
1044
tests/auto/unit/qmediaimageviewer/tst_qmediaimageviewer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
5
tests/auto/unit/qmediaimageviewerwidgets/images.qrc
Normal file
5
tests/auto/unit/qmediaimageviewerwidgets/images.qrc
Normal file
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>images/image.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
BIN
tests/auto/unit/qmediaimageviewerwidgets/images/image.png
Normal file
BIN
tests/auto/unit/qmediaimageviewerwidgets/images/image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 230 B |
@@ -0,0 +1,17 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediaimageviewerwidgets
|
||||
|
||||
QT += multimedia-private multimediawidgets-private network testlib
|
||||
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
|
||||
}
|
||||
QT+=widgets
|
||||
@@ -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 <qtmultimediadefs.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"
|
||||
53
tests/auto/unit/qmediaobject/main.cpp
Normal file
53
tests/auto/unit/qmediaobject/main.cpp
Normal 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_qmediaobject.h"
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
QCoreApplication app(argc,argv);
|
||||
int ret;
|
||||
tst_QMediaObject test_api;
|
||||
ret = QTest::qExec(&test_api, argc, argv);
|
||||
return ret;
|
||||
}
|
||||
11
tests/auto/unit/qmediaobject/qmediaobject.pro
Normal file
11
tests/auto/unit/qmediaobject/qmediaobject.pro
Normal file
@@ -0,0 +1,11 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediaobject
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
include (../qmultimedia_common/mockrecorder.pri)
|
||||
|
||||
HEADERS+= tst_qmediaobject.h
|
||||
SOURCES += main.cpp tst_qmediaobject.cpp
|
||||
|
||||
403
tests/auto/unit/qmediaobject/tst_qmediaobject.cpp
Normal file
403
tests/auto/unit/qmediaobject/tst_qmediaobject.cpp
Normal file
@@ -0,0 +1,403 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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_qmediaobject.h"
|
||||
|
||||
#include "mockmediarecorderservice.h"
|
||||
#include "mockmediaserviceprovider.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
void tst_QMediaObject::propertyWatch()
|
||||
{
|
||||
QtTestMediaObject object;
|
||||
object.setNotifyInterval(0);
|
||||
|
||||
QEventLoop loop;
|
||||
connect(&object, SIGNAL(aChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
connect(&object, SIGNAL(bChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
connect(&object, SIGNAL(cChanged(int)), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
|
||||
QSignalSpy aSpy(&object, SIGNAL(aChanged(int)));
|
||||
QSignalSpy bSpy(&object, SIGNAL(bChanged(int)));
|
||||
QSignalSpy cSpy(&object, SIGNAL(cChanged(int)));
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(aSpy.count(), 0);
|
||||
QCOMPARE(bSpy.count(), 0);
|
||||
QCOMPARE(cSpy.count(), 0);
|
||||
|
||||
int aCount = 0;
|
||||
int bCount = 0;
|
||||
int cCount = 0;
|
||||
|
||||
object.addPropertyWatch("a");
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QVERIFY(aSpy.count() > aCount);
|
||||
QCOMPARE(bSpy.count(), 0);
|
||||
QCOMPARE(cSpy.count(), 0);
|
||||
QCOMPARE(aSpy.last().value(0).toInt(), 0);
|
||||
|
||||
aCount = aSpy.count();
|
||||
|
||||
object.setA(54);
|
||||
object.setB(342);
|
||||
object.setC(233);
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QVERIFY(aSpy.count() > aCount);
|
||||
QCOMPARE(bSpy.count(), 0);
|
||||
QCOMPARE(cSpy.count(), 0);
|
||||
QCOMPARE(aSpy.last().value(0).toInt(), 54);
|
||||
|
||||
aCount = aSpy.count();
|
||||
|
||||
object.addPropertyWatch("b");
|
||||
object.addPropertyWatch("d");
|
||||
object.removePropertyWatch("e");
|
||||
object.setA(43);
|
||||
object.setB(235);
|
||||
object.setC(90);
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QVERIFY(aSpy.count() > aCount);
|
||||
QVERIFY(bSpy.count() > bCount);
|
||||
QCOMPARE(cSpy.count(), 0);
|
||||
QCOMPARE(aSpy.last().value(0).toInt(), 43);
|
||||
QCOMPARE(bSpy.last().value(0).toInt(), 235);
|
||||
|
||||
aCount = aSpy.count();
|
||||
bCount = bSpy.count();
|
||||
|
||||
object.removePropertyWatch("a");
|
||||
object.addPropertyWatch("c");
|
||||
object.addPropertyWatch("e");
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(aSpy.count(), aCount);
|
||||
QVERIFY(bSpy.count() > bCount);
|
||||
QVERIFY(cSpy.count() > cCount);
|
||||
QCOMPARE(bSpy.last().value(0).toInt(), 235);
|
||||
QCOMPARE(cSpy.last().value(0).toInt(), 90);
|
||||
|
||||
bCount = bSpy.count();
|
||||
cCount = cSpy.count();
|
||||
|
||||
object.setA(435);
|
||||
object.setC(9845);
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(aSpy.count(), aCount);
|
||||
QVERIFY(bSpy.count() > bCount);
|
||||
QVERIFY(cSpy.count() > cCount);
|
||||
QCOMPARE(bSpy.last().value(0).toInt(), 235);
|
||||
QCOMPARE(cSpy.last().value(0).toInt(), 9845);
|
||||
|
||||
bCount = bSpy.count();
|
||||
cCount = cSpy.count();
|
||||
|
||||
object.setA(8432);
|
||||
object.setB(324);
|
||||
object.setC(443);
|
||||
object.removePropertyWatch("c");
|
||||
object.removePropertyWatch("d");
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(aSpy.count(), aCount);
|
||||
QVERIFY(bSpy.count() > bCount);
|
||||
QCOMPARE(cSpy.count(), cCount);
|
||||
QCOMPARE(bSpy.last().value(0).toInt(), 324);
|
||||
QCOMPARE(cSpy.last().value(0).toInt(), 9845);
|
||||
|
||||
bCount = bSpy.count();
|
||||
|
||||
object.removePropertyWatch("b");
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(aSpy.count(), aCount);
|
||||
QCOMPARE(bSpy.count(), bCount);
|
||||
QCOMPARE(cSpy.count(), cCount);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::setupNotifyTests()
|
||||
{
|
||||
QTest::addColumn<int>("interval");
|
||||
QTest::addColumn<int>("count");
|
||||
|
||||
QTest::newRow("single 750ms")
|
||||
<< 750
|
||||
<< 1;
|
||||
QTest::newRow("single 600ms")
|
||||
<< 600
|
||||
<< 1;
|
||||
QTest::newRow("x3 300ms")
|
||||
<< 300
|
||||
<< 3;
|
||||
QTest::newRow("x5 180ms")
|
||||
<< 180
|
||||
<< 5;
|
||||
}
|
||||
|
||||
void tst_QMediaObject::notifySignals_data()
|
||||
{
|
||||
setupNotifyTests();
|
||||
}
|
||||
|
||||
void tst_QMediaObject::notifySignals()
|
||||
{
|
||||
QFETCH(int, interval);
|
||||
QFETCH(int, count);
|
||||
|
||||
QtTestMediaObject object;
|
||||
object.setNotifyInterval(interval);
|
||||
object.addPropertyWatch("a");
|
||||
|
||||
QSignalSpy spy(&object, SIGNAL(aChanged(int)));
|
||||
|
||||
QTestEventLoop::instance().enterLoop(1);
|
||||
|
||||
QCOMPARE(spy.count(), count);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::notifyInterval_data()
|
||||
{
|
||||
setupNotifyTests();
|
||||
}
|
||||
|
||||
void tst_QMediaObject::notifyInterval()
|
||||
{
|
||||
QFETCH(int, interval);
|
||||
|
||||
QtTestMediaObject object;
|
||||
QSignalSpy spy(&object, SIGNAL(notifyIntervalChanged(int)));
|
||||
|
||||
object.setNotifyInterval(interval);
|
||||
QCOMPARE(object.notifyInterval(), interval);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(spy.last().value(0).toInt(), interval);
|
||||
|
||||
object.setNotifyInterval(interval);
|
||||
QCOMPARE(object.notifyInterval(), interval);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::nullMetaDataControl()
|
||||
{
|
||||
const QString titleKey(QLatin1String("Title"));
|
||||
const QString title(QLatin1String("Host of Seraphim"));
|
||||
|
||||
QtTestMetaDataService service;
|
||||
service.hasMetaData = false;
|
||||
|
||||
QtTestMediaObject object(&service);
|
||||
|
||||
QSignalSpy spy(&object, SIGNAL(metaDataChanged()));
|
||||
|
||||
QCOMPARE(object.isMetaDataAvailable(), false);
|
||||
|
||||
QCOMPARE(object.metaData(QtMultimedia::Title).toString(), QString());
|
||||
QCOMPARE(object.extendedMetaData(titleKey).toString(), QString());
|
||||
QCOMPARE(object.availableMetaData(), QList<QtMultimedia::MetaData>());
|
||||
QCOMPARE(object.availableExtendedMetaData(), QStringList());
|
||||
QCOMPARE(spy.count(), 0);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::isMetaDataAvailable()
|
||||
{
|
||||
QtTestMetaDataService service;
|
||||
service.metaData.setMetaDataAvailable(false);
|
||||
|
||||
QtTestMediaObject object(&service);
|
||||
QCOMPARE(object.isMetaDataAvailable(), false);
|
||||
|
||||
QSignalSpy spy(&object, SIGNAL(metaDataAvailableChanged(bool)));
|
||||
service.metaData.setMetaDataAvailable(true);
|
||||
|
||||
QCOMPARE(object.isMetaDataAvailable(), true);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(spy.at(0).at(0).toBool(), true);
|
||||
|
||||
service.metaData.setMetaDataAvailable(false);
|
||||
|
||||
QCOMPARE(object.isMetaDataAvailable(), false);
|
||||
QCOMPARE(spy.count(), 2);
|
||||
QCOMPARE(spy.at(1).at(0).toBool(), false);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::metaDataChanged()
|
||||
{
|
||||
QtTestMetaDataService service;
|
||||
QtTestMediaObject object(&service);
|
||||
|
||||
QSignalSpy spy(&object, SIGNAL(metaDataChanged()));
|
||||
|
||||
service.metaData.metaDataChanged();
|
||||
QCOMPARE(spy.count(), 1);
|
||||
|
||||
service.metaData.metaDataChanged();
|
||||
QCOMPARE(spy.count(), 2);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::metaData_data()
|
||||
{
|
||||
QTest::addColumn<QString>("artist");
|
||||
QTest::addColumn<QString>("title");
|
||||
QTest::addColumn<QString>("genre");
|
||||
|
||||
QTest::newRow("")
|
||||
<< QString::fromLatin1("Dead Can Dance")
|
||||
<< QString::fromLatin1("Host of Seraphim")
|
||||
<< QString::fromLatin1("Awesome");
|
||||
}
|
||||
|
||||
void tst_QMediaObject::metaData()
|
||||
{
|
||||
QFETCH(QString, artist);
|
||||
QFETCH(QString, title);
|
||||
QFETCH(QString, genre);
|
||||
|
||||
QtTestMetaDataService service;
|
||||
service.metaData.populateMetaData();
|
||||
|
||||
QtTestMediaObject object(&service);
|
||||
QVERIFY(object.availableMetaData().isEmpty());
|
||||
|
||||
service.metaData.m_data.insert(QtMultimedia::AlbumArtist, artist);
|
||||
service.metaData.m_data.insert(QtMultimedia::Title, title);
|
||||
service.metaData.m_data.insert(QtMultimedia::Genre, genre);
|
||||
|
||||
QCOMPARE(object.metaData(QtMultimedia::AlbumArtist).toString(), artist);
|
||||
QCOMPARE(object.metaData(QtMultimedia::Title).toString(), title);
|
||||
|
||||
QList<QtMultimedia::MetaData> metaDataKeys = object.availableMetaData();
|
||||
QCOMPARE(metaDataKeys.size(), 3);
|
||||
QVERIFY(metaDataKeys.contains(QtMultimedia::AlbumArtist));
|
||||
QVERIFY(metaDataKeys.contains(QtMultimedia::Title));
|
||||
QVERIFY(metaDataKeys.contains(QtMultimedia::Genre));
|
||||
}
|
||||
|
||||
void tst_QMediaObject::extendedMetaData()
|
||||
{
|
||||
QFETCH(QString, artist);
|
||||
QFETCH(QString, title);
|
||||
QFETCH(QString, genre);
|
||||
|
||||
QtTestMetaDataService service;
|
||||
QtTestMediaObject object(&service);
|
||||
QVERIFY(object.availableExtendedMetaData().isEmpty());
|
||||
|
||||
service.metaData.m_extendedData.insert(QLatin1String("Artist"), artist);
|
||||
service.metaData.m_extendedData.insert(QLatin1String("Title"), title);
|
||||
service.metaData.m_extendedData.insert(QLatin1String("Genre"), genre);
|
||||
|
||||
QCOMPARE(object.extendedMetaData(QLatin1String("Artist")).toString(), artist);
|
||||
QCOMPARE(object.extendedMetaData(QLatin1String("Title")).toString(), title);
|
||||
|
||||
QStringList extendedKeys = object.availableExtendedMetaData();
|
||||
QCOMPARE(extendedKeys.size(), 3);
|
||||
QVERIFY(extendedKeys.contains(QLatin1String("Artist")));
|
||||
QVERIFY(extendedKeys.contains(QLatin1String("Title")));
|
||||
QVERIFY(extendedKeys.contains(QLatin1String("Genre")));
|
||||
}
|
||||
|
||||
void tst_QMediaObject::availability()
|
||||
{
|
||||
QtTestMediaObject nullObject(0);
|
||||
QCOMPARE(nullObject.isAvailable(), false);
|
||||
QCOMPARE(nullObject.availabilityError(), QtMultimedia::ServiceMissingError);
|
||||
|
||||
QtTestMetaDataService service;
|
||||
QtTestMediaObject object(&service);
|
||||
QCOMPARE(object.isAvailable(), true);
|
||||
QCOMPARE(object.availabilityError(), QtMultimedia::NoError);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::service()
|
||||
{
|
||||
// Create the mediaobject with service.
|
||||
QtTestMetaDataService service;
|
||||
QtTestMediaObject mediaObject1(&service);
|
||||
|
||||
// Get service and Compare if it equal to the service passed as an argument in mediaObject1.
|
||||
QMediaService *service1 = mediaObject1.service();
|
||||
QVERIFY(service1 != NULL);
|
||||
QCOMPARE(service1,&service);
|
||||
|
||||
// Create the mediaobject with empty service and verify that service() returns NULL.
|
||||
QtTestMediaObject mediaObject2;
|
||||
QMediaService *service2 = mediaObject2.service();
|
||||
QVERIFY(service2 == NULL);
|
||||
}
|
||||
|
||||
void tst_QMediaObject::availabilityChangedSignal()
|
||||
{
|
||||
// The availabilityChangedSignal is implemented in QAudioCaptureSource. So using it to test the signal.
|
||||
MockMediaRecorderService *mockAudioSourceService = new MockMediaRecorderService;
|
||||
MockMediaServiceProvider *mockProvider = new MockMediaServiceProvider(mockAudioSourceService);
|
||||
QAudioCaptureSource *audiosource = new QAudioCaptureSource(0, mockProvider);
|
||||
|
||||
QSignalSpy spy(audiosource, SIGNAL(availabilityChanged(bool)));
|
||||
|
||||
// Add the end points and verify if the availablity changed signal emitted with argument true.
|
||||
QMetaObject::invokeMethod(mockAudioSourceService->mockAudioEndpointSelector, "addEndpoints");
|
||||
QVERIFY(spy.count() == 1);
|
||||
bool available = qvariant_cast<bool>(spy.at(0).at(0));
|
||||
QVERIFY(available == true);
|
||||
|
||||
spy.clear();
|
||||
|
||||
// Remove all endpoints and verify if the signal is emitted with argument false.
|
||||
QMetaObject::invokeMethod(mockAudioSourceService->mockAudioEndpointSelector, "removeEndpoints");
|
||||
QVERIFY(spy.count() == 1);
|
||||
available = qvariant_cast<bool>(spy.at(0).at(0));
|
||||
QVERIFY(available == false);
|
||||
}
|
||||
147
tests/auto/unit/qmediaobject/tst_qmediaobject.h
Normal file
147
tests/auto/unit/qmediaobject/tst_qmediaobject.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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_QMEDIAOBJECT_H
|
||||
#define TST_QMEDIAOBJECT_H
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include <QtCore/qtimer.h>
|
||||
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qmetadatareadercontrol.h>
|
||||
#include <qaudiocapturesource.h>
|
||||
#include <qaudioendpointselector.h>
|
||||
|
||||
//TESTED_COMPONENT=src/multimedia
|
||||
|
||||
#include "mockmetadatareadercontrol.h"
|
||||
|
||||
class QtTestMetaDataService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtTestMetaDataService(QObject *parent = 0):QMediaService(parent), metaDataRef(0), hasMetaData(true)
|
||||
{
|
||||
}
|
||||
|
||||
QMediaControl *requestControl(const char *iid)
|
||||
{
|
||||
if (hasMetaData && qstrcmp(iid, QMetaDataReaderControl_iid) == 0)
|
||||
return &metaData;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void releaseControl(QMediaControl *)
|
||||
{
|
||||
}
|
||||
|
||||
MockMetaDataReaderControl metaData;
|
||||
int metaDataRef;
|
||||
bool hasMetaData;
|
||||
};
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
class tst_QMediaObject : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void propertyWatch();
|
||||
void notifySignals_data();
|
||||
void notifySignals();
|
||||
void notifyInterval_data();
|
||||
void notifyInterval();
|
||||
|
||||
void nullMetaDataControl();
|
||||
void isMetaDataAvailable();
|
||||
void metaDataChanged();
|
||||
void metaData_data();
|
||||
void metaData();
|
||||
void availability();
|
||||
void extendedMetaData_data() { metaData_data(); }
|
||||
void extendedMetaData();
|
||||
|
||||
void service();
|
||||
void availabilityChangedSignal();
|
||||
|
||||
private:
|
||||
void setupNotifyTests();
|
||||
};
|
||||
|
||||
class QtTestMediaObject : public QMediaObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int a READ a WRITE setA NOTIFY aChanged)
|
||||
Q_PROPERTY(int b READ b WRITE setB NOTIFY bChanged)
|
||||
Q_PROPERTY(int c READ c WRITE setC NOTIFY cChanged)
|
||||
Q_PROPERTY(int d READ d WRITE setD)
|
||||
public:
|
||||
QtTestMediaObject(QMediaService *service = 0): QMediaObject(0, service), m_a(0), m_b(0), m_c(0), m_d(0) {}
|
||||
|
||||
using QMediaObject::addPropertyWatch;
|
||||
using QMediaObject::removePropertyWatch;
|
||||
|
||||
int a() const { return m_a; }
|
||||
void setA(int a) { m_a = a; }
|
||||
|
||||
int b() const { return m_b; }
|
||||
void setB(int b) { m_b = b; }
|
||||
|
||||
int c() const { return m_c; }
|
||||
void setC(int c) { m_c = c; }
|
||||
|
||||
int d() const { return m_d; }
|
||||
void setD(int d) { m_d = d; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void aChanged(int a);
|
||||
void bChanged(int b);
|
||||
void cChanged(int c);
|
||||
|
||||
private:
|
||||
int m_a;
|
||||
int m_b;
|
||||
int m_c;
|
||||
int m_d;
|
||||
};
|
||||
#endif //TST_QMEDIAOBJECT_H
|
||||
53
tests/auto/unit/qmediaplayer/main.cpp
Executable file
53
tests/auto/unit/qmediaplayer/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_qmediaplayer.h"
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
QCoreApplication app(argc,argv);
|
||||
int ret;
|
||||
tst_QMediaPlayer test_api;
|
||||
ret = QTest::qExec(&test_api, argc, argv);
|
||||
return ret;
|
||||
}
|
||||
11
tests/auto/unit/qmediaplayer/qmediaplayer.pro
Normal file
11
tests/auto/unit/qmediaplayer/qmediaplayer.pro
Normal file
@@ -0,0 +1,11 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediaplayer
|
||||
|
||||
QT += network multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
HEADERS += tst_qmediaplayer.h
|
||||
SOURCES += main.cpp tst_qmediaplayer.cpp
|
||||
|
||||
include (../qmultimedia_common/mock.pri)
|
||||
include (../qmultimedia_common/mockplayer.pri)
|
||||
1050
tests/auto/unit/qmediaplayer/tst_qmediaplayer.cpp
Normal file
1050
tests/auto/unit/qmediaplayer/tst_qmediaplayer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
133
tests/auto/unit/qmediaplayer/tst_qmediaplayer.h
Executable file
133
tests/auto/unit/qmediaplayer/tst_qmediaplayer.h
Executable file
@@ -0,0 +1,133 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <qmediaplaylist.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediastreamscontrol.h>
|
||||
#include <qmedianetworkaccesscontrol.h>
|
||||
#include <qvideorenderercontrol.h>
|
||||
|
||||
#include "mockmediaserviceprovider.h"
|
||||
#include "mockmediaplayerservice.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class AutoConnection
|
||||
{
|
||||
public:
|
||||
AutoConnection(QObject *sender, const char *signal, QObject *receiver, const char *method)
|
||||
: sender(sender), signal(signal), receiver(receiver), method(method)
|
||||
{
|
||||
QObject::connect(sender, signal, receiver, method);
|
||||
}
|
||||
|
||||
~AutoConnection()
|
||||
{
|
||||
QObject::disconnect(sender, signal, receiver, method);
|
||||
}
|
||||
|
||||
private:
|
||||
QObject *sender;
|
||||
const char *signal;
|
||||
QObject *receiver;
|
||||
const char *method;
|
||||
};
|
||||
|
||||
class tst_QMediaPlayer: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase_data();
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
private slots:
|
||||
void testNullService();
|
||||
void testValid();
|
||||
void testMedia();
|
||||
void testDuration();
|
||||
void testPosition();
|
||||
void testVolume();
|
||||
void testMuted();
|
||||
void testIsAvailable();
|
||||
void testVideoAvailable();
|
||||
void testBufferStatus();
|
||||
void testSeekable();
|
||||
void testPlaybackRate();
|
||||
void testError();
|
||||
void testErrorString();
|
||||
void testService();
|
||||
void testPlay();
|
||||
void testPause();
|
||||
void testStop();
|
||||
void testMediaStatus();
|
||||
void testPlaylist();
|
||||
void testNetworkAccess();
|
||||
void testSetVideoOutput();
|
||||
void testSetVideoOutputNoService();
|
||||
void testSetVideoOutputNoControl();
|
||||
void testSetVideoOutputDestruction();
|
||||
void testPositionPropertyWatch();
|
||||
void debugEnums();
|
||||
void testPlayerFlags();
|
||||
void testDestructor();
|
||||
void testSupportedMimeTypes();
|
||||
|
||||
private:
|
||||
MockMediaServiceProvider *mockProvider;
|
||||
MockMediaPlayerService *mockService;
|
||||
QMediaPlayer *player;
|
||||
};
|
||||
|
||||
#endif //TST_QMEDIAPLAYER_H
|
||||
53
tests/auto/unit/qmediaplayerwidgets/main.cpp
Executable file
53
tests/auto/unit/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 <QtWidgets/QApplication>
|
||||
#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;
|
||||
}
|
||||
11
tests/auto/unit/qmediaplayerwidgets/qmediaplayerwidgets.pro
Normal file
11
tests/auto/unit/qmediaplayerwidgets/qmediaplayerwidgets.pro
Normal file
@@ -0,0 +1,11 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediaplayerwidgets
|
||||
|
||||
QT += network multimedia-private multimediawidgets-private testlib widgets
|
||||
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/unit/qmediaplayerwidgets/tst_qmediaplayerwidgets.cpp
Normal file
162
tests/auto/unit/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/unit/qmediaplayerwidgets/tst_qmediaplayerwidgets.h
Executable file
79
tests/auto/unit/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
|
||||
18
tests/auto/unit/qmediaplaylist/qmediaplaylist.pro
Normal file
18
tests/auto/unit/qmediaplaylist/qmediaplaylist.pro
Normal file
@@ -0,0 +1,18 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediaplaylist
|
||||
|
||||
include (../qmultimedia_common/mockplaylist.pri)
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
DEFINES += TESTDATA_DIR=\\\"$$PWD/\\\"
|
||||
|
||||
HEADERS += \
|
||||
$$QT.multimedia.sources/../plugins/m3u/qm3uhandler.h
|
||||
|
||||
SOURCES += \
|
||||
tst_qmediaplaylist.cpp \
|
||||
$$QT.multimedia.sources/../plugins/m3u/qm3uhandler.cpp
|
||||
|
||||
INCLUDEPATH += $$QT.multimedia.sources/../plugins/m3u
|
||||
11
tests/auto/unit/qmediaplaylist/testdata/test.m3u
vendored
Normal file
11
tests/auto/unit/qmediaplaylist/testdata/test.m3u
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#comment
|
||||
|
||||
http://test.host/path
|
||||
http://test.host/path
|
||||
testfile
|
||||
|
||||
|
||||
testdir/testfile
|
||||
/testdir/testfile
|
||||
file://path/name#suffix
|
||||
testfile2#suffix
|
||||
0
tests/auto/unit/qmediaplaylist/testdata/testfile
vendored
Normal file
0
tests/auto/unit/qmediaplaylist/testdata/testfile
vendored
Normal file
0
tests/auto/unit/qmediaplaylist/testdata/testfile2#suffix
vendored
Normal file
0
tests/auto/unit/qmediaplaylist/testdata/testfile2#suffix
vendored
Normal file
783
tests/auto/unit/qmediaplaylist/tst_qmediaplaylist.cpp
Normal file
783
tests/auto/unit/qmediaplaylist/tst_qmediaplaylist.cpp
Normal file
@@ -0,0 +1,783 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDebug>
|
||||
#include "qmediaservice.h"
|
||||
#include "qmediaplaylist.h"
|
||||
#include "qmediaplaylistcontrol.h"
|
||||
#include "qmediaplaylistsourcecontrol.h"
|
||||
#include "qmediaplaylistnavigator.h"
|
||||
#include <private/qmediapluginloader_p.h>
|
||||
|
||||
#include "qm3uhandler.h"
|
||||
|
||||
//TESTED_COMPONENT=src/multimedia
|
||||
|
||||
#include "mockplaylistservice.h"
|
||||
#include "mockmediaplaylistcontrol.h"
|
||||
#include "mockmediaplaylistsourcecontrol.h"
|
||||
#include "mockreadonlyplaylistprovider.h"
|
||||
|
||||
#ifndef TESTDATA_DIR
|
||||
#define TESTDATA_DIR "./"
|
||||
#endif
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class MockReadOnlyPlaylistObject : public QMediaObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockReadOnlyPlaylistObject(QObject *parent = 0)
|
||||
:QMediaObject(parent, new MockPlaylistService)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class tst_QMediaPlaylist : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
void init();
|
||||
void cleanup();
|
||||
void initTestCase();
|
||||
|
||||
private slots:
|
||||
void construction();
|
||||
void append();
|
||||
void insert();
|
||||
void clear();
|
||||
void removeMedia();
|
||||
void currentItem();
|
||||
void saveAndLoad();
|
||||
void loadM3uFile();
|
||||
void playbackMode();
|
||||
void playbackMode_data();
|
||||
void shuffle();
|
||||
void readOnlyPlaylist();
|
||||
void setMediaObject();
|
||||
|
||||
void testCurrentIndexChanged_signal();
|
||||
void testCurrentMediaChanged_signal();
|
||||
void testLoaded_signal();
|
||||
void testMediaChanged_signal();
|
||||
void testPlaybackModeChanged_signal();
|
||||
void testEnums();
|
||||
|
||||
void mediaPlayListProvider();
|
||||
// TC for Abstract control classes
|
||||
void mediaPlayListControl();
|
||||
void mediaPlayListSourceControl();
|
||||
|
||||
|
||||
private:
|
||||
QMediaContent content1;
|
||||
QMediaContent content2;
|
||||
QMediaContent content3;
|
||||
};
|
||||
|
||||
void tst_QMediaPlaylist::init()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::initTestCase()
|
||||
{
|
||||
qRegisterMetaType<QMediaContent>();
|
||||
content1 = QMediaContent(QUrl(QLatin1String("file:///1")));
|
||||
content2 = QMediaContent(QUrl(QLatin1String("file:///2")));
|
||||
content3 = QMediaContent(QUrl(QLatin1String("file:///3")));
|
||||
|
||||
QMediaPluginLoader::setStaticPlugins(QLatin1String("playlistformats"), QObjectList() << new QM3uPlaylistPlugin(this));
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::construction()
|
||||
{
|
||||
QMediaPlaylist playlist;
|
||||
QCOMPARE(playlist.mediaCount(), 0);
|
||||
QVERIFY(playlist.isEmpty());
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::append()
|
||||
{
|
||||
QMediaPlaylist playlist;
|
||||
QVERIFY(!playlist.isReadOnly());
|
||||
|
||||
playlist.addMedia(content1);
|
||||
QCOMPARE(playlist.mediaCount(), 1);
|
||||
QCOMPARE(playlist.media(0), content1);
|
||||
|
||||
QSignalSpy aboutToBeInsertedSignalSpy(&playlist, SIGNAL(mediaAboutToBeInserted(int,int)));
|
||||
QSignalSpy insertedSignalSpy(&playlist, SIGNAL(mediaInserted(int,int)));
|
||||
playlist.addMedia(content2);
|
||||
QCOMPARE(playlist.mediaCount(), 2);
|
||||
QCOMPARE(playlist.media(1), content2);
|
||||
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1);
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy.first()[0].toInt(), 1);
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy.first()[1].toInt(), 1);
|
||||
|
||||
QCOMPARE(insertedSignalSpy.count(), 1);
|
||||
QCOMPARE(insertedSignalSpy.first()[0].toInt(), 1);
|
||||
QCOMPARE(insertedSignalSpy.first()[1].toInt(), 1);
|
||||
|
||||
aboutToBeInsertedSignalSpy.clear();
|
||||
insertedSignalSpy.clear();
|
||||
|
||||
QMediaContent content4(QUrl(QLatin1String("file:///4")));
|
||||
QMediaContent content5(QUrl(QLatin1String("file:///5")));
|
||||
playlist.addMedia(QList<QMediaContent>() << content3 << content4 << content5);
|
||||
QCOMPARE(playlist.mediaCount(), 5);
|
||||
QCOMPARE(playlist.media(2), content3);
|
||||
QCOMPARE(playlist.media(3), content4);
|
||||
QCOMPARE(playlist.media(4), content5);
|
||||
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1);
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy[0][0].toInt(), 2);
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy[0][1].toInt(), 4);
|
||||
|
||||
QCOMPARE(insertedSignalSpy.count(), 1);
|
||||
QCOMPARE(insertedSignalSpy[0][0].toInt(), 2);
|
||||
QCOMPARE(insertedSignalSpy[0][1].toInt(), 4);
|
||||
|
||||
aboutToBeInsertedSignalSpy.clear();
|
||||
insertedSignalSpy.clear();
|
||||
|
||||
playlist.addMedia(QList<QMediaContent>());
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy.count(), 0);
|
||||
QCOMPARE(insertedSignalSpy.count(), 0);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::insert()
|
||||
{
|
||||
QMediaPlaylist playlist;
|
||||
QVERIFY(!playlist.isReadOnly());
|
||||
|
||||
playlist.addMedia(content1);
|
||||
QCOMPARE(playlist.mediaCount(), 1);
|
||||
QCOMPARE(playlist.media(0), content1);
|
||||
|
||||
playlist.addMedia(content2);
|
||||
QCOMPARE(playlist.mediaCount(), 2);
|
||||
QCOMPARE(playlist.media(1), content2);
|
||||
|
||||
QSignalSpy aboutToBeInsertedSignalSpy(&playlist, SIGNAL(mediaAboutToBeInserted(int,int)));
|
||||
QSignalSpy insertedSignalSpy(&playlist, SIGNAL(mediaInserted(int,int)));
|
||||
|
||||
playlist.insertMedia(1, content3);
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
QCOMPARE(playlist.media(0), content1);
|
||||
QCOMPARE(playlist.media(1), content3);
|
||||
QCOMPARE(playlist.media(2), content2);
|
||||
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1);
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy.first()[0].toInt(), 1);
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy.first()[1].toInt(), 1);
|
||||
|
||||
QCOMPARE(insertedSignalSpy.count(), 1);
|
||||
QCOMPARE(insertedSignalSpy.first()[0].toInt(), 1);
|
||||
QCOMPARE(insertedSignalSpy.first()[1].toInt(), 1);
|
||||
|
||||
aboutToBeInsertedSignalSpy.clear();
|
||||
insertedSignalSpy.clear();
|
||||
|
||||
QMediaContent content4(QUrl(QLatin1String("file:///4")));
|
||||
QMediaContent content5(QUrl(QLatin1String("file:///5")));
|
||||
playlist.insertMedia(1, QList<QMediaContent>() << content4 << content5);
|
||||
|
||||
QCOMPARE(playlist.media(0), content1);
|
||||
QCOMPARE(playlist.media(1), content4);
|
||||
QCOMPARE(playlist.media(2), content5);
|
||||
QCOMPARE(playlist.media(3), content3);
|
||||
QCOMPARE(playlist.media(4), content2);
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy.count(), 1);
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy[0][0].toInt(), 1);
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy[0][1].toInt(), 2);
|
||||
|
||||
QCOMPARE(insertedSignalSpy.count(), 1);
|
||||
QCOMPARE(insertedSignalSpy[0][0].toInt(), 1);
|
||||
QCOMPARE(insertedSignalSpy[0][1].toInt(), 2);
|
||||
|
||||
aboutToBeInsertedSignalSpy.clear();
|
||||
insertedSignalSpy.clear();
|
||||
|
||||
playlist.insertMedia(1, QList<QMediaContent>());
|
||||
QCOMPARE(aboutToBeInsertedSignalSpy.count(), 0);
|
||||
QCOMPARE(insertedSignalSpy.count(), 0);
|
||||
}
|
||||
|
||||
|
||||
void tst_QMediaPlaylist::currentItem()
|
||||
{
|
||||
QMediaPlaylist playlist;
|
||||
playlist.addMedia(content1);
|
||||
playlist.addMedia(content2);
|
||||
|
||||
QCOMPARE(playlist.currentIndex(), -1);
|
||||
QCOMPARE(playlist.currentMedia(), QMediaContent());
|
||||
|
||||
QCOMPARE(playlist.nextIndex(), 0);
|
||||
QCOMPARE(playlist.nextIndex(2), 1);
|
||||
QCOMPARE(playlist.previousIndex(), 1);
|
||||
QCOMPARE(playlist.previousIndex(2), 0);
|
||||
|
||||
playlist.setCurrentIndex(0);
|
||||
QCOMPARE(playlist.currentIndex(), 0);
|
||||
QCOMPARE(playlist.currentMedia(), content1);
|
||||
|
||||
QCOMPARE(playlist.nextIndex(), 1);
|
||||
QCOMPARE(playlist.nextIndex(2), -1);
|
||||
QCOMPARE(playlist.previousIndex(), -1);
|
||||
QCOMPARE(playlist.previousIndex(2), -1);
|
||||
|
||||
playlist.setCurrentIndex(1);
|
||||
QCOMPARE(playlist.currentIndex(), 1);
|
||||
QCOMPARE(playlist.currentMedia(), content2);
|
||||
|
||||
QCOMPARE(playlist.nextIndex(), -1);
|
||||
QCOMPARE(playlist.nextIndex(2), -1);
|
||||
QCOMPARE(playlist.previousIndex(), 0);
|
||||
QCOMPARE(playlist.previousIndex(2), -1);
|
||||
|
||||
QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range ");
|
||||
playlist.setCurrentIndex(2);
|
||||
|
||||
QCOMPARE(playlist.currentIndex(), -1);
|
||||
QCOMPARE(playlist.currentMedia(), QMediaContent());
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::clear()
|
||||
{
|
||||
QMediaPlaylist playlist;
|
||||
playlist.addMedia(content1);
|
||||
playlist.addMedia(content2);
|
||||
|
||||
playlist.clear();
|
||||
QVERIFY(playlist.isEmpty());
|
||||
QCOMPARE(playlist.mediaCount(), 0);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::removeMedia()
|
||||
{
|
||||
QMediaPlaylist playlist;
|
||||
playlist.addMedia(content1);
|
||||
playlist.addMedia(content2);
|
||||
playlist.addMedia(content3);
|
||||
|
||||
QSignalSpy aboutToBeRemovedSignalSpy(&playlist, SIGNAL(mediaAboutToBeRemoved(int,int)));
|
||||
QSignalSpy removedSignalSpy(&playlist, SIGNAL(mediaRemoved(int,int)));
|
||||
playlist.removeMedia(1);
|
||||
QCOMPARE(playlist.mediaCount(), 2);
|
||||
QCOMPARE(playlist.media(1), content3);
|
||||
|
||||
QCOMPARE(aboutToBeRemovedSignalSpy.count(), 1);
|
||||
QCOMPARE(aboutToBeRemovedSignalSpy.first()[0].toInt(), 1);
|
||||
QCOMPARE(aboutToBeRemovedSignalSpy.first()[1].toInt(), 1);
|
||||
|
||||
QCOMPARE(removedSignalSpy.count(), 1);
|
||||
QCOMPARE(removedSignalSpy.first()[0].toInt(), 1);
|
||||
QCOMPARE(removedSignalSpy.first()[1].toInt(), 1);
|
||||
|
||||
aboutToBeRemovedSignalSpy.clear();
|
||||
removedSignalSpy.clear();
|
||||
|
||||
playlist.removeMedia(0,1);
|
||||
QVERIFY(playlist.isEmpty());
|
||||
|
||||
QCOMPARE(aboutToBeRemovedSignalSpy.count(), 1);
|
||||
QCOMPARE(aboutToBeRemovedSignalSpy.first()[0].toInt(), 0);
|
||||
QCOMPARE(aboutToBeRemovedSignalSpy.first()[1].toInt(), 1);
|
||||
|
||||
QCOMPARE(removedSignalSpy.count(), 1);
|
||||
QCOMPARE(removedSignalSpy.first()[0].toInt(), 0);
|
||||
QCOMPARE(removedSignalSpy.first()[1].toInt(), 1);
|
||||
|
||||
|
||||
playlist.addMedia(content1);
|
||||
playlist.addMedia(content2);
|
||||
playlist.addMedia(content3);
|
||||
|
||||
playlist.removeMedia(0,1);
|
||||
QCOMPARE(playlist.mediaCount(), 1);
|
||||
QCOMPARE(playlist.media(0), content3);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::saveAndLoad()
|
||||
{
|
||||
QMediaPlaylist playlist;
|
||||
playlist.addMedia(content1);
|
||||
playlist.addMedia(content2);
|
||||
playlist.addMedia(content3);
|
||||
|
||||
QCOMPARE(playlist.error(), QMediaPlaylist::NoError);
|
||||
QVERIFY(playlist.errorString().isEmpty());
|
||||
|
||||
QBuffer buffer;
|
||||
buffer.open(QBuffer::ReadWrite);
|
||||
|
||||
bool res = playlist.save(&buffer, "unsupported_format");
|
||||
QVERIFY(!res);
|
||||
QVERIFY(playlist.error() == QMediaPlaylist::FormatNotSupportedError);
|
||||
QVERIFY(!playlist.errorString().isEmpty());
|
||||
|
||||
QSignalSpy errorSignal(&playlist, SIGNAL(loadFailed()));
|
||||
playlist.load(&buffer, "unsupported_format");
|
||||
QCOMPARE(errorSignal.size(), 1);
|
||||
QVERIFY(playlist.error() != QMediaPlaylist::NoError);
|
||||
QVERIFY(!playlist.errorString().isEmpty());
|
||||
|
||||
res = playlist.save(QUrl::fromLocalFile(QLatin1String("tmp.unsupported_format")), "unsupported_format");
|
||||
QVERIFY(!res);
|
||||
QVERIFY(playlist.error() != QMediaPlaylist::NoError);
|
||||
QVERIFY(!playlist.errorString().isEmpty());
|
||||
|
||||
errorSignal.clear();
|
||||
playlist.load(QUrl::fromLocalFile(QLatin1String("tmp.unsupported_format")), "unsupported_format");
|
||||
QCOMPARE(errorSignal.size(), 1);
|
||||
QVERIFY(playlist.error() == QMediaPlaylist::FormatNotSupportedError);
|
||||
QVERIFY(!playlist.errorString().isEmpty());
|
||||
|
||||
res = playlist.save(&buffer, "m3u");
|
||||
|
||||
QVERIFY(res);
|
||||
QVERIFY(buffer.pos() > 0);
|
||||
buffer.seek(0);
|
||||
|
||||
QMediaPlaylist playlist2;
|
||||
playlist2.load(&buffer, "m3u");
|
||||
QCOMPARE(playlist.error(), QMediaPlaylist::NoError);
|
||||
|
||||
QCOMPARE(playlist.mediaCount(), playlist2.mediaCount());
|
||||
QCOMPARE(playlist.media(0), playlist2.media(0));
|
||||
QCOMPARE(playlist.media(1), playlist2.media(1));
|
||||
QCOMPARE(playlist.media(3), playlist2.media(3));
|
||||
res = playlist.save(QUrl::fromLocalFile(QLatin1String("tmp.m3u")), "m3u");
|
||||
QVERIFY(res);
|
||||
|
||||
playlist2.clear();
|
||||
QVERIFY(playlist2.isEmpty());
|
||||
playlist2.load(QUrl::fromLocalFile(QLatin1String("tmp.m3u")), "m3u");
|
||||
QCOMPARE(playlist.error(), QMediaPlaylist::NoError);
|
||||
|
||||
QCOMPARE(playlist.mediaCount(), playlist2.mediaCount());
|
||||
QCOMPARE(playlist.media(0), playlist2.media(0));
|
||||
QCOMPARE(playlist.media(1), playlist2.media(1));
|
||||
QCOMPARE(playlist.media(3), playlist2.media(3));
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::loadM3uFile()
|
||||
{
|
||||
QMediaPlaylist playlist;
|
||||
|
||||
playlist.load(QUrl::fromLocalFile(QLatin1String(TESTDATA_DIR "testdata/missing_file.m3u")));
|
||||
QVERIFY(playlist.error() != QMediaPlaylist::NoError);
|
||||
|
||||
playlist.load(QUrl::fromLocalFile(QLatin1String(TESTDATA_DIR "testdata/test.m3u")));
|
||||
QCOMPARE(playlist.error(), QMediaPlaylist::NoError);
|
||||
QCOMPARE(playlist.mediaCount(), 7);
|
||||
|
||||
QCOMPARE(playlist.media(0).canonicalUrl(), QUrl(QLatin1String("http://test.host/path")));
|
||||
QCOMPARE(playlist.media(1).canonicalUrl(), QUrl(QLatin1String("http://test.host/path")));
|
||||
QCOMPARE(playlist.media(2).canonicalUrl(),
|
||||
QUrl(QLatin1String("file://" TESTDATA_DIR "testdata/testfile")));
|
||||
QCOMPARE(playlist.media(3).canonicalUrl(),
|
||||
QUrl(QLatin1String("file://" TESTDATA_DIR "testdata/testdir/testfile")));
|
||||
QCOMPARE(playlist.media(4).canonicalUrl(), QUrl(QLatin1String("file:///testdir/testfile")));
|
||||
QCOMPARE(playlist.media(5).canonicalUrl(), QUrl(QLatin1String("file://path/name#suffix")));
|
||||
//ensure #2 suffix is not stripped from path
|
||||
QCOMPARE(playlist.media(6).canonicalUrl(), QUrl::fromLocalFile(TESTDATA_DIR "testdata/testfile2#suffix"));
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::playbackMode_data()
|
||||
{
|
||||
QTest::addColumn<QMediaPlaylist::PlaybackMode>("playbackMode");
|
||||
QTest::addColumn<int>("expectedPrevious");
|
||||
QTest::addColumn<int>("pos");
|
||||
QTest::addColumn<int>("expectedNext");
|
||||
|
||||
QTest::newRow("Sequential, 0") << QMediaPlaylist::Sequential << -1 << 0 << 1;
|
||||
QTest::newRow("Sequential, 1") << QMediaPlaylist::Sequential << 0 << 1 << 2;
|
||||
QTest::newRow("Sequential, 2") << QMediaPlaylist::Sequential << 1 << 2 << -1;
|
||||
|
||||
QTest::newRow("Loop, 0") << QMediaPlaylist::Loop << 2 << 0 << 1;
|
||||
QTest::newRow("Loop, 1") << QMediaPlaylist::Loop << 0 << 1 << 2;
|
||||
QTest::newRow("Lopp, 2") << QMediaPlaylist::Loop << 1 << 2 << 0;
|
||||
|
||||
QTest::newRow("ItemOnce, 1") << QMediaPlaylist::CurrentItemOnce << -1 << 1 << -1;
|
||||
QTest::newRow("ItemInLoop, 1") << QMediaPlaylist::CurrentItemInLoop << 1 << 1 << 1;
|
||||
|
||||
// Bit difficult to test random this way
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::playbackMode()
|
||||
{
|
||||
QFETCH(QMediaPlaylist::PlaybackMode, playbackMode);
|
||||
QFETCH(int, expectedPrevious);
|
||||
QFETCH(int, pos);
|
||||
QFETCH(int, expectedNext);
|
||||
|
||||
QMediaPlaylist playlist;
|
||||
playlist.addMedia(content1);
|
||||
playlist.addMedia(content2);
|
||||
playlist.addMedia(content3);
|
||||
|
||||
QCOMPARE(playlist.playbackMode(), QMediaPlaylist::Sequential);
|
||||
QCOMPARE(playlist.currentIndex(), -1);
|
||||
|
||||
playlist.setPlaybackMode(playbackMode);
|
||||
QCOMPARE(playlist.playbackMode(), playbackMode);
|
||||
|
||||
playlist.setCurrentIndex(pos);
|
||||
QCOMPARE(playlist.currentIndex(), pos);
|
||||
QCOMPARE(playlist.nextIndex(), expectedNext);
|
||||
QCOMPARE(playlist.previousIndex(), expectedPrevious);
|
||||
|
||||
playlist.next();
|
||||
QCOMPARE(playlist.currentIndex(), expectedNext);
|
||||
|
||||
playlist.setCurrentIndex(pos);
|
||||
playlist.previous();
|
||||
QCOMPARE(playlist.currentIndex(), expectedPrevious);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::shuffle()
|
||||
{
|
||||
QMediaPlaylist playlist;
|
||||
QList<QMediaContent> contentList;
|
||||
|
||||
for (int i=0; i<100; i++) {
|
||||
QMediaContent content(QUrl::fromLocalFile(QString::number(i)));
|
||||
contentList.append(content);
|
||||
playlist.addMedia(content);
|
||||
}
|
||||
|
||||
playlist.shuffle();
|
||||
|
||||
QList<QMediaContent> shuffledContentList;
|
||||
for (int i=0; i<playlist.mediaCount(); i++)
|
||||
shuffledContentList.append(playlist.media(i));
|
||||
|
||||
QVERIFY(contentList != shuffledContentList);
|
||||
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::readOnlyPlaylist()
|
||||
{
|
||||
MockReadOnlyPlaylistObject mediaObject;
|
||||
QMediaPlaylist playlist;
|
||||
mediaObject.bind(&playlist);
|
||||
|
||||
QVERIFY(playlist.isReadOnly());
|
||||
QVERIFY(!playlist.isEmpty());
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
|
||||
QCOMPARE(playlist.media(0), content1);
|
||||
QCOMPARE(playlist.media(1), content2);
|
||||
QCOMPARE(playlist.media(2), content3);
|
||||
QCOMPARE(playlist.media(3), QMediaContent());
|
||||
|
||||
//it's a read only playlist, so all the modification should fail
|
||||
QVERIFY(!playlist.addMedia(content1));
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
QVERIFY(!playlist.addMedia(QList<QMediaContent>() << content1 << content2));
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
QVERIFY(!playlist.insertMedia(1, content1));
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
QVERIFY(!playlist.insertMedia(1, QList<QMediaContent>() << content1 << content2));
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
QVERIFY(!playlist.removeMedia(1));
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
QVERIFY(!playlist.removeMedia(0,2));
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
QVERIFY(!playlist.clear());
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
|
||||
//but it is still allowed to append/insert an empty list
|
||||
QVERIFY(playlist.addMedia(QList<QMediaContent>()));
|
||||
QVERIFY(playlist.insertMedia(1, QList<QMediaContent>()));
|
||||
|
||||
playlist.shuffle();
|
||||
//it's still the same
|
||||
QCOMPARE(playlist.media(0), content1);
|
||||
QCOMPARE(playlist.media(1), content2);
|
||||
QCOMPARE(playlist.media(2), content3);
|
||||
QCOMPARE(playlist.media(3), QMediaContent());
|
||||
|
||||
|
||||
//load to read only playlist should fail,
|
||||
//unless underlaying provider supports it
|
||||
QBuffer buffer;
|
||||
buffer.open(QBuffer::ReadWrite);
|
||||
buffer.write(QByteArray("file:///1\nfile:///2"));
|
||||
buffer.seek(0);
|
||||
|
||||
QSignalSpy errorSignal(&playlist, SIGNAL(loadFailed()));
|
||||
playlist.load(&buffer, "m3u");
|
||||
QCOMPARE(errorSignal.size(), 1);
|
||||
QCOMPARE(playlist.error(), QMediaPlaylist::AccessDeniedError);
|
||||
QVERIFY(!playlist.errorString().isEmpty());
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
|
||||
errorSignal.clear();
|
||||
playlist.load(QUrl::fromLocalFile(QLatin1String("tmp.m3u")), "m3u");
|
||||
|
||||
QCOMPARE(errorSignal.size(), 1);
|
||||
QCOMPARE(playlist.error(), QMediaPlaylist::AccessDeniedError);
|
||||
QVERIFY(!playlist.errorString().isEmpty());
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::setMediaObject()
|
||||
{
|
||||
MockReadOnlyPlaylistObject mediaObject;
|
||||
|
||||
QMediaPlaylist playlist;
|
||||
QVERIFY(playlist.mediaObject() == 0);
|
||||
QVERIFY(!playlist.isReadOnly());
|
||||
|
||||
mediaObject.bind(&playlist);
|
||||
QCOMPARE(playlist.mediaObject(), qobject_cast<QMediaObject*>(&mediaObject));
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
QVERIFY(playlist.isReadOnly());
|
||||
|
||||
mediaObject.unbind(&playlist);
|
||||
QVERIFY(playlist.mediaObject() == 0);
|
||||
QCOMPARE(playlist.mediaCount(), 0);
|
||||
QVERIFY(!playlist.isReadOnly());
|
||||
|
||||
mediaObject.bind(&playlist);
|
||||
QCOMPARE(playlist.mediaObject(), qobject_cast<QMediaObject*>(&mediaObject));
|
||||
QCOMPARE(playlist.mediaCount(), 3);
|
||||
QVERIFY(playlist.isReadOnly());
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::testCurrentIndexChanged_signal()
|
||||
{
|
||||
//create an instance of QMediaPlaylist class.
|
||||
QMediaPlaylist playlist;
|
||||
playlist.addMedia(content1); //set the media to playlist
|
||||
playlist.addMedia(content2); //set the media to playlist
|
||||
|
||||
QSignalSpy spy(&playlist, SIGNAL(currentIndexChanged(int)));
|
||||
QVERIFY(spy.size()== 0);
|
||||
QCOMPARE(playlist.currentIndex(), -1);
|
||||
|
||||
//set the current index for playlist.
|
||||
playlist.setCurrentIndex(0);
|
||||
QVERIFY(spy.size()== 1); //verify the signal emission.
|
||||
QCOMPARE(playlist.currentIndex(), 0); //verify the current index of playlist
|
||||
|
||||
//set the current index for playlist.
|
||||
playlist.setCurrentIndex(1);
|
||||
QVERIFY(spy.size()== 2); //verify the signal emission.
|
||||
QCOMPARE(playlist.currentIndex(), 1); //verify the current index of playlist
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::testCurrentMediaChanged_signal()
|
||||
{
|
||||
//create an instance of QMediaPlaylist class.
|
||||
QMediaPlaylist playlist;
|
||||
playlist.addMedia(content1); //set the media to playlist
|
||||
playlist.addMedia(content2); //set the media to playlist
|
||||
|
||||
QSignalSpy spy(&playlist, SIGNAL(currentMediaChanged(QMediaContent)));
|
||||
QVERIFY(spy.size()== 0);
|
||||
QCOMPARE(playlist.currentIndex(), -1);
|
||||
QCOMPARE(playlist.currentMedia(), QMediaContent());
|
||||
|
||||
//set the current index for playlist.
|
||||
playlist.setCurrentIndex(0);
|
||||
QVERIFY(spy.size()== 1); //verify the signal emission.
|
||||
QCOMPARE(playlist.currentIndex(), 0); //verify the current index of playlist
|
||||
QCOMPARE(playlist.currentMedia(), content1); //verify the current media of playlist
|
||||
|
||||
//set the current index for playlist.
|
||||
playlist.setCurrentIndex(1);
|
||||
QVERIFY(spy.size()== 2); //verify the signal emission.
|
||||
QCOMPARE(playlist.currentIndex(), 1); //verify the current index of playlist
|
||||
QCOMPARE(playlist.currentMedia(), content2); //verify the current media of playlist
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::testLoaded_signal()
|
||||
{
|
||||
//create an instance of QMediaPlaylist class.
|
||||
QMediaPlaylist playlist;
|
||||
playlist.addMedia(content1); //set the media to playlist
|
||||
playlist.addMedia(content2); //set the media to playlist
|
||||
playlist.addMedia(content3); //set the media to playlist
|
||||
|
||||
QSignalSpy spy(&playlist, SIGNAL(loaded()));
|
||||
QVERIFY(spy.size()== 0);
|
||||
|
||||
QBuffer buffer;
|
||||
buffer.open(QBuffer::ReadWrite);
|
||||
|
||||
//load the playlist
|
||||
playlist.load(&buffer,"m3u");
|
||||
QVERIFY(spy.size()== 1); //verify the signal emission.
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::testMediaChanged_signal()
|
||||
{
|
||||
//create an instance of QMediaPlaylist class.
|
||||
QMediaPlaylist playlist;
|
||||
|
||||
QSignalSpy spy(&playlist, SIGNAL(mediaChanged(int,int)));
|
||||
|
||||
// Add media to playlist
|
||||
playlist.addMedia(content1); //set the media to playlist
|
||||
playlist.addMedia(content2); //set the media to playlist
|
||||
playlist.addMedia(content3); //set the media to playlist
|
||||
|
||||
// Adds/inserts do not cause change signals
|
||||
QVERIFY(spy.size() == 0);
|
||||
|
||||
// Now change the list
|
||||
playlist.shuffle();
|
||||
|
||||
QVERIFY(spy.size() == 1);
|
||||
spy.clear();
|
||||
|
||||
//create media.
|
||||
QMediaContent content4(QUrl(QLatin1String("file:///4")));
|
||||
QMediaContent content5(QUrl(QLatin1String("file:///5")));
|
||||
|
||||
//insert media to playlist
|
||||
playlist.insertMedia(1, content4);
|
||||
playlist.insertMedia(2, content5);
|
||||
// Adds/inserts do not cause change signals
|
||||
QVERIFY(spy.size() == 0);
|
||||
|
||||
// And again
|
||||
playlist.shuffle();
|
||||
|
||||
QVERIFY(spy.size() == 1);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::testPlaybackModeChanged_signal()
|
||||
{
|
||||
//create an instance of QMediaPlaylist class.
|
||||
QMediaPlaylist playlist;
|
||||
playlist.addMedia(content1); //set the media to playlist
|
||||
playlist.addMedia(content2); //set the media to playlist
|
||||
playlist.addMedia(content3); //set the media to playlist
|
||||
|
||||
QSignalSpy spy(&playlist, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
|
||||
QVERIFY(playlist.playbackMode()== QMediaPlaylist::Sequential);
|
||||
QVERIFY(spy.size() == 0);
|
||||
|
||||
// Set playback mode to the playlist
|
||||
playlist.setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
|
||||
QVERIFY(playlist.playbackMode()== QMediaPlaylist::CurrentItemOnce);
|
||||
QVERIFY(spy.size() == 1);
|
||||
|
||||
// Set playback mode to the playlist
|
||||
playlist.setPlaybackMode(QMediaPlaylist::CurrentItemInLoop);
|
||||
QVERIFY(playlist.playbackMode()== QMediaPlaylist::CurrentItemInLoop);
|
||||
QVERIFY(spy.size() == 2);
|
||||
|
||||
// Set playback mode to the playlist
|
||||
playlist.setPlaybackMode(QMediaPlaylist::Sequential);
|
||||
QVERIFY(playlist.playbackMode()== QMediaPlaylist::Sequential);
|
||||
QVERIFY(spy.size() == 3);
|
||||
|
||||
// Set playback mode to the playlist
|
||||
playlist.setPlaybackMode(QMediaPlaylist::Loop);
|
||||
QVERIFY(playlist.playbackMode()== QMediaPlaylist::Loop);
|
||||
QVERIFY(spy.size() == 4);
|
||||
|
||||
// Set playback mode to the playlist
|
||||
playlist.setPlaybackMode(QMediaPlaylist::Random);
|
||||
QVERIFY(playlist.playbackMode()== QMediaPlaylist::Random);
|
||||
QVERIFY(spy.size() == 5);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylist::testEnums()
|
||||
{
|
||||
//create an instance of QMediaPlaylist class.
|
||||
QMediaPlaylist playlist;
|
||||
playlist.addMedia(content1); //set the media to playlist
|
||||
playlist.addMedia(content2); //set the media to playlist
|
||||
playlist.addMedia(content3); //set the media to playlist
|
||||
QCOMPARE(playlist.error(), QMediaPlaylist::NoError);
|
||||
|
||||
QBuffer buffer;
|
||||
buffer.open(QBuffer::ReadWrite);
|
||||
|
||||
// checking for QMediaPlaylist::FormatNotSupportedError enum
|
||||
QVERIFY(!playlist.save(&buffer, "unsupported_format"));
|
||||
QVERIFY(playlist.error() == QMediaPlaylist::FormatNotSupportedError);
|
||||
|
||||
playlist.load(&buffer,"unsupported_format");
|
||||
QVERIFY(playlist.error() == QMediaPlaylist::FormatNotSupportedError);
|
||||
}
|
||||
|
||||
// MaemoAPI-1849:test QMediaPlayListControl constructor
|
||||
void tst_QMediaPlaylist::mediaPlayListControl()
|
||||
{
|
||||
// To check changes in abstract classe's pure virtual functions
|
||||
QObject parent;
|
||||
MockMediaPlaylistControl plylistctrl(&parent);
|
||||
}
|
||||
|
||||
// MaemoAPI-1850:test QMediaPlayListSourceControl constructor
|
||||
void tst_QMediaPlaylist::mediaPlayListSourceControl()
|
||||
{
|
||||
// To check changes in abstract classe's pure virtual functions
|
||||
QObject parent;
|
||||
MockPlaylistSourceControl plylistsrcctrl(&parent);
|
||||
}
|
||||
|
||||
// MaemoAPI-1852:test constructor
|
||||
void tst_QMediaPlaylist::mediaPlayListProvider()
|
||||
{
|
||||
// srcs of QMediaPlaylistProvider is incomplete
|
||||
QObject parent;
|
||||
MockReadOnlyPlaylistProvider provider(&parent);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMediaPlaylist)
|
||||
#include "tst_qmediaplaylist.moc"
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediaplaylistnavigator
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qmediaplaylistnavigator.cpp
|
||||
|
||||
@@ -0,0 +1,525 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtTest/QtTest>
|
||||
#include <QDebug>
|
||||
#include "qlocalmediaplaylistprovider.h"
|
||||
#include "qmediaplaylistnavigator.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
class tst_QMediaPlaylistNavigator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
private slots:
|
||||
void construction();
|
||||
void setPlaylist();
|
||||
void linearPlayback();
|
||||
void loopPlayback();
|
||||
void currentItemOnce();
|
||||
void currentItemInLoop();
|
||||
void randomPlayback();
|
||||
|
||||
void testItemAt();
|
||||
void testNextIndex();
|
||||
void testPreviousIndex();
|
||||
void testCurrentIndexChangedSignal();
|
||||
void testPlaybackModeChangedSignal();
|
||||
void testSurroundingItemsChangedSignal();
|
||||
void testActivatedSignal();
|
||||
};
|
||||
|
||||
void tst_QMediaPlaylistNavigator::init()
|
||||
{
|
||||
qRegisterMetaType<QMediaPlaylist::PlaybackMode>("QMediaPlaylist::PlaybackMode");
|
||||
qRegisterMetaType<QMediaContent>("QMediaContent");
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::construction()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QCOMPARE(playlist.mediaCount(), 0);
|
||||
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
QVERIFY(navigator.currentItem().isNull());
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::setPlaylist()
|
||||
{
|
||||
QMediaPlaylistNavigator navigator(0);
|
||||
QVERIFY(navigator.playlist() != 0);
|
||||
QCOMPARE(navigator.playlist()->mediaCount(), 0);
|
||||
QCOMPARE(navigator.playlist()->media(0), QMediaContent());
|
||||
QVERIFY(navigator.playlist()->isReadOnly() );
|
||||
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QCOMPARE(playlist.mediaCount(), 0);
|
||||
|
||||
navigator.setPlaylist(&playlist);
|
||||
QCOMPARE(navigator.playlist(), (QMediaPlaylistProvider*)&playlist);
|
||||
QCOMPARE(navigator.playlist()->mediaCount(), 0);
|
||||
QVERIFY(!navigator.playlist()->isReadOnly() );
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::linearPlayback()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Sequential);
|
||||
QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range ");
|
||||
navigator.jump(0);//it's ok to have warning here
|
||||
QVERIFY(navigator.currentItem().isNull());
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
QMediaContent content1(QUrl(QLatin1String("file:///1")));
|
||||
playlist.addMedia(content1);
|
||||
navigator.jump(0);
|
||||
QVERIFY(!navigator.currentItem().isNull());
|
||||
|
||||
QCOMPARE(navigator.currentIndex(), 0);
|
||||
QCOMPARE(navigator.currentItem(), content1);
|
||||
QCOMPARE(navigator.nextItem(), QMediaContent());
|
||||
QCOMPARE(navigator.nextItem(2), QMediaContent());
|
||||
QCOMPARE(navigator.previousItem(), QMediaContent());
|
||||
QCOMPARE(navigator.previousItem(2), QMediaContent());
|
||||
|
||||
QMediaContent content2(QUrl(QLatin1String("file:///2")));
|
||||
playlist.addMedia(content2);
|
||||
QCOMPARE(navigator.currentIndex(), 0);
|
||||
QCOMPARE(navigator.currentItem(), content1);
|
||||
QCOMPARE(navigator.nextItem(), content2);
|
||||
QCOMPARE(navigator.nextItem(2), QMediaContent());
|
||||
QCOMPARE(navigator.previousItem(), QMediaContent());
|
||||
QCOMPARE(navigator.previousItem(2), QMediaContent());
|
||||
|
||||
navigator.jump(1);
|
||||
QCOMPARE(navigator.currentIndex(), 1);
|
||||
QCOMPARE(navigator.currentItem(), content2);
|
||||
QCOMPARE(navigator.nextItem(), QMediaContent());
|
||||
QCOMPARE(navigator.nextItem(2), QMediaContent());
|
||||
QCOMPARE(navigator.previousItem(), content1);
|
||||
QCOMPARE(navigator.previousItem(2), QMediaContent());
|
||||
|
||||
navigator.jump(0);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), 1);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
navigator.next();//jump to the first item
|
||||
QCOMPARE(navigator.currentIndex(), 0);
|
||||
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
navigator.previous();//jump to the last item
|
||||
QCOMPARE(navigator.currentIndex(), 1);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::loopPlayback()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Loop);
|
||||
QTest::ignoreMessage(QtWarningMsg, "QMediaPlaylistNavigator: Jump outside playlist range ");
|
||||
navigator.jump(0);
|
||||
QVERIFY(navigator.currentItem().isNull());
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
QMediaContent content1(QUrl(QLatin1String("file:///1")));
|
||||
playlist.addMedia(content1);
|
||||
navigator.jump(0);
|
||||
QVERIFY(!navigator.currentItem().isNull());
|
||||
|
||||
QCOMPARE(navigator.currentIndex(), 0);
|
||||
QCOMPARE(navigator.currentItem(), content1);
|
||||
QCOMPARE(navigator.nextItem(), content1);
|
||||
QCOMPARE(navigator.nextItem(2), content1);
|
||||
QCOMPARE(navigator.previousItem(), content1);
|
||||
QCOMPARE(navigator.previousItem(2), content1);
|
||||
|
||||
QMediaContent content2(QUrl(QLatin1String("file:///2")));
|
||||
playlist.addMedia(content2);
|
||||
QCOMPARE(navigator.currentIndex(), 0);
|
||||
QCOMPARE(navigator.currentItem(), content1);
|
||||
QCOMPARE(navigator.nextItem(), content2);
|
||||
QCOMPARE(navigator.nextItem(2), content1); //loop over end of the list
|
||||
QCOMPARE(navigator.previousItem(), content2);
|
||||
QCOMPARE(navigator.previousItem(2), content1);
|
||||
|
||||
navigator.jump(1);
|
||||
QCOMPARE(navigator.currentIndex(), 1);
|
||||
QCOMPARE(navigator.currentItem(), content2);
|
||||
QCOMPARE(navigator.nextItem(), content1);
|
||||
QCOMPARE(navigator.nextItem(2), content2);
|
||||
QCOMPARE(navigator.previousItem(), content1);
|
||||
QCOMPARE(navigator.previousItem(2), content2);
|
||||
|
||||
navigator.jump(0);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), 1);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), 0);
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.currentIndex(), 1);
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.currentIndex(), 0);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::currentItemOnce()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
|
||||
navigator.setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
|
||||
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::CurrentItemOnce);
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
|
||||
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
navigator.jump(1);
|
||||
QCOMPARE(navigator.currentIndex(), 1);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
navigator.jump(1);
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::currentItemInLoop()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
|
||||
navigator.setPlaybackMode(QMediaPlaylist::CurrentItemInLoop);
|
||||
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::CurrentItemInLoop);
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
|
||||
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
navigator.jump(1);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), 1);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), 1);
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.currentIndex(), 1);
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.currentIndex(), 1);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::randomPlayback()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Random);
|
||||
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
|
||||
|
||||
playlist.shuffle();
|
||||
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
navigator.next();
|
||||
int pos1 = navigator.currentIndex();
|
||||
navigator.next();
|
||||
int pos2 = navigator.currentIndex();
|
||||
navigator.next();
|
||||
int pos3 = navigator.currentIndex();
|
||||
|
||||
QVERIFY(pos1 != -1);
|
||||
QVERIFY(pos2 != -1);
|
||||
QVERIFY(pos3 != -1);
|
||||
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.currentIndex(), pos2);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), pos3);
|
||||
navigator.next();
|
||||
int pos4 = navigator.currentIndex();
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.currentIndex(), pos3);
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.currentIndex(), pos2);
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.currentIndex(), pos1);
|
||||
navigator.previous();
|
||||
int pos0 = navigator.currentIndex();
|
||||
QVERIFY(pos0 != -1);
|
||||
navigator.next();
|
||||
navigator.next();
|
||||
navigator.next();
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.currentIndex(), pos4);
|
||||
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::testItemAt()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
//Adding the media to the playlist
|
||||
QMediaContent content = QMediaContent(QUrl(QLatin1String("file:///1")));
|
||||
playlist.addMedia(content);
|
||||
|
||||
//Currently it is not pointing to any index , Returns Null mediacontent
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
QCOMPARE(navigator.itemAt(navigator.currentIndex()),QMediaContent());
|
||||
navigator.next();
|
||||
|
||||
//Points to the added media
|
||||
int pos1 = navigator.currentIndex();
|
||||
QCOMPARE(content,navigator.itemAt(pos1));
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::testNextIndex()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
//Adding the media to the playlist
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
|
||||
|
||||
playlist.shuffle();
|
||||
|
||||
//Currently it is not pointing to any index
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
navigator.next();
|
||||
int pos1 = navigator.currentIndex();
|
||||
//Pointing to the next index
|
||||
navigator.next();
|
||||
int pos2 = navigator.currentIndex();
|
||||
navigator.next();
|
||||
int pos3 = navigator.currentIndex();
|
||||
|
||||
//Pointing to the previous index
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.nextIndex(1), pos3);
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.nextIndex(1), pos2);
|
||||
QCOMPARE(navigator.nextIndex(2), pos3);
|
||||
navigator.previous();
|
||||
QCOMPARE(navigator.nextIndex(1), pos1);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::testPreviousIndex()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
//Adding the media to the playlist
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
|
||||
playlist.shuffle();
|
||||
|
||||
//Currently it is not pointing to any index
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
//pointing to next index
|
||||
navigator.next();
|
||||
int pos1 = navigator.currentIndex();
|
||||
navigator.next();
|
||||
int pos2 = navigator.currentIndex();
|
||||
navigator.next();
|
||||
int pos3 = navigator.currentIndex();
|
||||
QCOMPARE(navigator.previousIndex(1), pos2);
|
||||
QCOMPARE(navigator.previousIndex(2), pos1);
|
||||
navigator.next();
|
||||
QCOMPARE(navigator.previousIndex(1), pos3);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::testCurrentIndexChangedSignal()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
//Creating a QSignalSpy object for currentIndexChanged() signal
|
||||
QSignalSpy spy(&navigator,SIGNAL(currentIndexChanged(int)));
|
||||
QVERIFY(spy.count() == 0);
|
||||
|
||||
//Adding the media to the playlist
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///3"))));
|
||||
|
||||
//Currently it is not pointing to any index
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
navigator.next();
|
||||
QVERIFY(spy.count() == 1);
|
||||
int pos1 = navigator.currentIndex();
|
||||
//Pointing to the next index
|
||||
navigator.next();
|
||||
QVERIFY(navigator.previousIndex(1) == pos1);
|
||||
QVERIFY(spy.count() == 2);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::testPlaybackModeChangedSignal()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
//Creating a QSignalSpy object for currentIndexChanged() signal
|
||||
QSignalSpy spy(&navigator,SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
|
||||
QVERIFY(spy.count() == 0);
|
||||
|
||||
//Adding the media to the playlist
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
|
||||
|
||||
//set the play back mode to sequential
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Sequential);
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Sequential);
|
||||
QVERIFY(spy.count() == 1);
|
||||
|
||||
//set the play back mode to loop
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Loop);
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Loop);
|
||||
QVERIFY(spy.count() == 2);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::testSurroundingItemsChangedSignal()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
//Creating a QSignalSpy object for surroundingItemsChanged()signal
|
||||
QSignalSpy spy(&navigator,SIGNAL(surroundingItemsChanged()));
|
||||
QVERIFY(spy.count() == 0);
|
||||
|
||||
//Adding the media to the playlist
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
|
||||
QVERIFY(spy.count() == 1);
|
||||
|
||||
//set the play back mode to sequential
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Sequential);
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Sequential);
|
||||
QVERIFY(spy.count() == 2);
|
||||
|
||||
//Point to the next index
|
||||
navigator.next();
|
||||
QVERIFY(spy.count() == 3);
|
||||
}
|
||||
|
||||
void tst_QMediaPlaylistNavigator::testActivatedSignal()
|
||||
{
|
||||
QLocalMediaPlaylistProvider playlist;
|
||||
QMediaPlaylistNavigator navigator(&playlist);
|
||||
navigator.setPlaybackMode(QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.playbackMode(), QMediaPlaylist::Random);
|
||||
QCOMPARE(navigator.currentIndex(), -1);
|
||||
|
||||
//Creating a QSignalSpy object for surroundingItemsChanged()signal
|
||||
QSignalSpy spy(&navigator,SIGNAL(activated(QMediaContent)));
|
||||
QVERIFY(spy.count() == 0);
|
||||
|
||||
//Adding the media to the playlist
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///1"))));
|
||||
playlist.addMedia(QMediaContent(QUrl(QLatin1String("file:///2"))));
|
||||
playlist.shuffle();
|
||||
|
||||
//Point to the next index
|
||||
navigator.next();
|
||||
QVERIFY(spy.count() == 1);
|
||||
|
||||
//Jump to 0th item
|
||||
navigator.jump(0);
|
||||
QVERIFY(spy.count() == 2);
|
||||
|
||||
//move to previous item
|
||||
navigator.previous();
|
||||
QVERIFY(spy.count() == 3);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMediaPlaylistNavigator)
|
||||
#include "tst_qmediaplaylistnavigator.moc"
|
||||
14
tests/auto/unit/qmediapluginloader/qmediapluginloader.pro
Normal file
14
tests/auto/unit/qmediapluginloader/qmediapluginloader.pro
Normal file
@@ -0,0 +1,14 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediapluginloader
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qmediapluginloader.cpp
|
||||
|
||||
wince* {
|
||||
PLUGIN_DEPLOY.sources = $$OUTPUT_DIR/plugins/mediaservice/*.dll
|
||||
PLUGIN_DEPLOY.path = mediaservice
|
||||
DEPLOYMENT += PLUGIN_DEPLOY
|
||||
}
|
||||
|
||||
123
tests/auto/unit/qmediapluginloader/tst_qmediapluginloader.cpp
Normal file
123
tests/auto/unit/qmediapluginloader/tst_qmediapluginloader.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <private/qmediapluginloader_p.h>
|
||||
#include <qmediaserviceproviderplugin.h>
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDebug>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class tst_QMediaPluginLoader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
void testInstance();
|
||||
void testInstances();
|
||||
void testInvalidKey();
|
||||
|
||||
private:
|
||||
QMediaPluginLoader *loader;
|
||||
};
|
||||
|
||||
void tst_QMediaPluginLoader::initTestCase()
|
||||
{
|
||||
loader = new QMediaPluginLoader(QMediaServiceProviderFactoryInterface_iid,
|
||||
QLatin1String("/mediaservice"),
|
||||
Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
void tst_QMediaPluginLoader::cleanupTestCase()
|
||||
{
|
||||
delete loader;
|
||||
}
|
||||
|
||||
void tst_QMediaPluginLoader::testInstance()
|
||||
{
|
||||
const QStringList keys = loader->keys();
|
||||
|
||||
if (keys.isEmpty()) // Test is invalidated, skip.
|
||||
QSKIP("No plug-ins available", SkipAll);
|
||||
|
||||
foreach (const QString &key, keys)
|
||||
QVERIFY(loader->instance(key) != 0);
|
||||
}
|
||||
|
||||
void tst_QMediaPluginLoader::testInstances()
|
||||
{
|
||||
const QStringList keys = loader->keys();
|
||||
|
||||
if (keys.isEmpty()) // Test is invalidated, skip.
|
||||
QSKIP("No plug-ins available", SkipAll);
|
||||
|
||||
foreach (const QString &key, keys)
|
||||
QVERIFY(loader->instances(key).size() > 0);
|
||||
}
|
||||
|
||||
// Last so as to not interfere with the other tests if there is a failure.
|
||||
void tst_QMediaPluginLoader::testInvalidKey()
|
||||
{
|
||||
const QString key(QLatin1String("invalid-key"));
|
||||
|
||||
// This test assumes there is no 'invalid-key' in the key list, verify that.
|
||||
if (loader->keys().contains(key))
|
||||
QSKIP("a plug-in includes the invalid key", SkipAll);
|
||||
|
||||
QVERIFY(loader->instance(key) == 0);
|
||||
|
||||
// Test looking up the key hasn't inserted it into the list. See QMap::operator[].
|
||||
QVERIFY(!loader->keys().contains(key));
|
||||
|
||||
QVERIFY(loader->instances(key).isEmpty());
|
||||
QVERIFY(!loader->keys().contains(key));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMediaPluginLoader)
|
||||
|
||||
#include "tst_qmediapluginloader.moc"
|
||||
53
tests/auto/unit/qmediarecorder/main.cpp
Executable file
53
tests/auto/unit/qmediarecorder/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_qmediarecorder.h"
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
QCoreApplication app(argc,argv);
|
||||
int ret;
|
||||
tst_QMediaRecorder test_api;
|
||||
ret = QTest::qExec(&test_api, argc, argv);
|
||||
return ret;
|
||||
}
|
||||
12
tests/auto/unit/qmediarecorder/qmediarecorder.pro
Normal file
12
tests/auto/unit/qmediarecorder/qmediarecorder.pro
Normal file
@@ -0,0 +1,12 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediarecorder
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
include (../qmultimedia_common/mock.pri)
|
||||
include (../qmultimedia_common/mockrecorder.pri)
|
||||
|
||||
HEADERS += tst_qmediarecorder.h
|
||||
SOURCES += main.cpp tst_qmediarecorder.cpp
|
||||
|
||||
1286
tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp
Normal file
1286
tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp
Normal file
File diff suppressed because it is too large
Load Diff
127
tests/auto/unit/qmediarecorder/tst_qmediarecorder.h
Executable file
127
tests/auto/unit/qmediarecorder/tst_qmediarecorder.h
Executable file
@@ -0,0 +1,127 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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_QMEDIARECORDER_H
|
||||
#define TST_QMEDIARECORDER_H
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDebug>
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediacontrol.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediarecordercontrol.h>
|
||||
#include <qmediarecorder.h>
|
||||
#include <qmetadatawritercontrol.h>
|
||||
#include <qaudioendpointselector.h>
|
||||
#include <qaudioencodercontrol.h>
|
||||
#include <qmediacontainercontrol.h>
|
||||
#include <qvideoencodercontrol.h>
|
||||
|
||||
#include <qaudioformat.h>
|
||||
|
||||
#include "mockmediarecorderservice.h"
|
||||
#include "mockmediaobject.h"
|
||||
|
||||
class tst_QMediaRecorder: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
void testNullService();
|
||||
void testNullControls();
|
||||
void testDeleteMediaObject();
|
||||
void testError();
|
||||
void testSink();
|
||||
void testRecord();
|
||||
void testMute();
|
||||
void testAudioDeviceControl();
|
||||
void testAudioEncodeControl();
|
||||
void testMediaFormatsControl();
|
||||
void testVideoEncodeControl();
|
||||
void testEncodingSettings();
|
||||
void testAudioSettings();
|
||||
void testVideoSettings();
|
||||
|
||||
void nullMetaDataControl();
|
||||
void isMetaDataAvailable();
|
||||
void isWritable();
|
||||
void metaDataChanged();
|
||||
void metaData_data();
|
||||
void metaData();
|
||||
void setMetaData_data();
|
||||
void setMetaData();
|
||||
void extendedMetaData_data() { metaData_data(); }
|
||||
void extendedMetaData();
|
||||
void setExtendedMetaData_data() { extendedMetaData_data(); }
|
||||
void setExtendedMetaData();
|
||||
|
||||
void testAudioSettingsCopyConstructor();
|
||||
void testAudioSettingsOperatorNotEqual();
|
||||
void testAudioSettingsOperatorEqual();
|
||||
void testAudioSettingsOperatorAssign();
|
||||
void testAudioSettingsDestructor();
|
||||
|
||||
void testAvailabilityError();
|
||||
void testIsAvailable();
|
||||
void testMediaObject();
|
||||
void testEnum();
|
||||
|
||||
void testVideoSettingsQuality();
|
||||
void testVideoSettingsEncodingMode();
|
||||
void testVideoSettingsCopyConstructor();
|
||||
void testVideoSettingsOperatorAssignment();
|
||||
void testVideoSettingsOperatorNotEqual();
|
||||
void testVideoSettingsOperatorComparison();
|
||||
void testVideoSettingsDestructor();
|
||||
|
||||
private:
|
||||
QAudioEncoderControl* encode;
|
||||
QAudioEndpointSelector* audio;
|
||||
MockMediaObject *object;
|
||||
MockMediaRecorderService*service;
|
||||
MockMediaRecorderControl *mock;
|
||||
QMediaRecorder *capture;
|
||||
QVideoEncoderControl* videoEncode;
|
||||
};
|
||||
#endif //TST_QMEDIARECORDER_H
|
||||
8
tests/auto/unit/qmediaresource/qmediaresource.pro
Normal file
8
tests/auto/unit/qmediaresource/qmediaresource.pro
Normal file
@@ -0,0 +1,8 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediaresource
|
||||
|
||||
QT += network multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qmediaresource.cpp
|
||||
|
||||
700
tests/auto/unit/qmediaresource/tst_qmediaresource.cpp
Normal file
700
tests/auto/unit/qmediaresource/tst_qmediaresource.cpp
Normal file
@@ -0,0 +1,700 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtTest/QtTest>
|
||||
|
||||
#include "qmediaresource.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
class tst_QMediaResource : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void constructNull();
|
||||
void construct_data();
|
||||
void construct();
|
||||
void setResolution();
|
||||
void equality();
|
||||
void copy();
|
||||
void assign();
|
||||
|
||||
void constructorRequest();
|
||||
void copyConstructor();
|
||||
};
|
||||
|
||||
void tst_QMediaResource::constructNull()
|
||||
{
|
||||
QMediaResource resource;
|
||||
|
||||
QCOMPARE(resource.isNull(), true);
|
||||
QCOMPARE(resource.url(), QUrl());
|
||||
QCOMPARE(resource.request(), QNetworkRequest());
|
||||
QCOMPARE(resource.mimeType(), QString());
|
||||
QCOMPARE(resource.language(), QString());
|
||||
QCOMPARE(resource.audioCodec(), QString());
|
||||
QCOMPARE(resource.videoCodec(), QString());
|
||||
QCOMPARE(resource.dataSize(), qint64(0));
|
||||
QCOMPARE(resource.audioBitRate(), 0);
|
||||
QCOMPARE(resource.sampleRate(), 0);
|
||||
QCOMPARE(resource.channelCount(), 0);
|
||||
QCOMPARE(resource.videoBitRate(), 0);
|
||||
QCOMPARE(resource.resolution(), QSize());
|
||||
}
|
||||
|
||||
void tst_QMediaResource::construct_data()
|
||||
{
|
||||
QTest::addColumn<QUrl>("url");
|
||||
QTest::addColumn<QNetworkRequest>("request");
|
||||
QTest::addColumn<QString>("mimeType");
|
||||
QTest::addColumn<QString>("language");
|
||||
QTest::addColumn<QString>("audioCodec");
|
||||
QTest::addColumn<QString>("videoCodec");
|
||||
QTest::addColumn<qint64>("dataSize");
|
||||
QTest::addColumn<int>("audioBitRate");
|
||||
QTest::addColumn<int>("sampleRate");
|
||||
QTest::addColumn<int>("channelCount");
|
||||
QTest::addColumn<int>("videoBitRate");
|
||||
QTest::addColumn<QSize>("resolution");
|
||||
|
||||
QTest::newRow("audio content")
|
||||
<< QUrl(QString::fromLatin1("http:://test.com/test.mp3"))
|
||||
<< QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.mp3")))
|
||||
<< QString::fromLatin1("audio/mpeg")
|
||||
<< QString::fromLatin1("eng")
|
||||
<< QString::fromLatin1("mp3")
|
||||
<< QString()
|
||||
<< qint64(5465433)
|
||||
<< 128000
|
||||
<< 44100
|
||||
<< 2
|
||||
<< 0
|
||||
<< QSize();
|
||||
QTest::newRow("image content")
|
||||
<< QUrl(QString::fromLatin1("http:://test.com/test.jpg"))
|
||||
<< QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.jpg")))
|
||||
<< QString::fromLatin1("image/jpeg")
|
||||
<< QString()
|
||||
<< QString()
|
||||
<< QString()
|
||||
<< qint64(23600)
|
||||
<< 0
|
||||
<< 0
|
||||
<< 0
|
||||
<< 0
|
||||
<< QSize(640, 480);
|
||||
QTest::newRow("video content")
|
||||
<< QUrl(QString::fromLatin1("http:://test.com/test.mp4"))
|
||||
<< QNetworkRequest(QUrl(QString::fromLatin1("http:://test.com/test.mp4")))
|
||||
<< QString::fromLatin1("video/mp4")
|
||||
<< QString()
|
||||
<< QString::fromLatin1("aac")
|
||||
<< QString::fromLatin1("h264")
|
||||
<< qint64(36245851)
|
||||
<< 96000
|
||||
<< 44000
|
||||
<< 5
|
||||
<< 750000
|
||||
<< QSize(720, 576);
|
||||
QTest::newRow("thumbnail")
|
||||
<< QUrl(QString::fromLatin1("file::///thumbs/test.png"))
|
||||
<< QNetworkRequest(QUrl(QString::fromLatin1("file::///thumbs/test.png")))
|
||||
<< QString::fromLatin1("image/png")
|
||||
<< QString()
|
||||
<< QString()
|
||||
<< QString()
|
||||
<< qint64(2360)
|
||||
<< 0
|
||||
<< 0
|
||||
<< 0
|
||||
<< 0
|
||||
<< QSize(128, 128);
|
||||
}
|
||||
|
||||
void tst_QMediaResource::construct()
|
||||
{
|
||||
QFETCH(QUrl, url);
|
||||
QFETCH(QNetworkRequest, request);
|
||||
QFETCH(QString, mimeType);
|
||||
QFETCH(QString, language);
|
||||
QFETCH(QString, audioCodec);
|
||||
QFETCH(QString, videoCodec);
|
||||
QFETCH(qint64, dataSize);
|
||||
QFETCH(int, audioBitRate);
|
||||
QFETCH(int, sampleRate);
|
||||
QFETCH(int, channelCount);
|
||||
QFETCH(int, videoBitRate);
|
||||
QFETCH(QSize, resolution);
|
||||
|
||||
{
|
||||
QMediaResource resource(url);
|
||||
|
||||
QCOMPARE(resource.isNull(), false);
|
||||
QCOMPARE(resource.url(), url);
|
||||
QCOMPARE(resource.mimeType(), QString());
|
||||
QCOMPARE(resource.language(), QString());
|
||||
QCOMPARE(resource.audioCodec(), QString());
|
||||
QCOMPARE(resource.videoCodec(), QString());
|
||||
QCOMPARE(resource.dataSize(), qint64(0));
|
||||
QCOMPARE(resource.audioBitRate(), 0);
|
||||
QCOMPARE(resource.sampleRate(), 0);
|
||||
QCOMPARE(resource.channelCount(), 0);
|
||||
QCOMPARE(resource.videoBitRate(), 0);
|
||||
QCOMPARE(resource.resolution(), QSize());
|
||||
}
|
||||
{
|
||||
QMediaResource resource(url, mimeType);
|
||||
|
||||
QCOMPARE(resource.isNull(), false);
|
||||
QCOMPARE(resource.url(), url);
|
||||
QCOMPARE(resource.request(), request);
|
||||
QCOMPARE(resource.mimeType(), mimeType);
|
||||
QCOMPARE(resource.language(), QString());
|
||||
QCOMPARE(resource.audioCodec(), QString());
|
||||
QCOMPARE(resource.videoCodec(), QString());
|
||||
QCOMPARE(resource.dataSize(), qint64(0));
|
||||
QCOMPARE(resource.audioBitRate(), 0);
|
||||
QCOMPARE(resource.sampleRate(), 0);
|
||||
QCOMPARE(resource.channelCount(), 0);
|
||||
QCOMPARE(resource.videoBitRate(), 0);
|
||||
QCOMPARE(resource.resolution(), QSize());
|
||||
|
||||
resource.setLanguage(language);
|
||||
resource.setAudioCodec(audioCodec);
|
||||
resource.setVideoCodec(videoCodec);
|
||||
resource.setDataSize(dataSize);
|
||||
resource.setAudioBitRate(audioBitRate);
|
||||
resource.setSampleRate(sampleRate);
|
||||
resource.setChannelCount(channelCount);
|
||||
resource.setVideoBitRate(videoBitRate);
|
||||
resource.setResolution(resolution);
|
||||
|
||||
QCOMPARE(resource.language(), language);
|
||||
QCOMPARE(resource.audioCodec(), audioCodec);
|
||||
QCOMPARE(resource.videoCodec(), videoCodec);
|
||||
QCOMPARE(resource.dataSize(), dataSize);
|
||||
QCOMPARE(resource.audioBitRate(), audioBitRate);
|
||||
QCOMPARE(resource.sampleRate(), sampleRate);
|
||||
QCOMPARE(resource.channelCount(), channelCount);
|
||||
QCOMPARE(resource.videoBitRate(), videoBitRate);
|
||||
QCOMPARE(resource.resolution(), resolution);
|
||||
}
|
||||
{
|
||||
QMediaResource resource(request, mimeType);
|
||||
|
||||
QCOMPARE(resource.isNull(), false);
|
||||
QCOMPARE(resource.url(), url);
|
||||
QCOMPARE(resource.request(), request);
|
||||
QCOMPARE(resource.mimeType(), mimeType);
|
||||
QCOMPARE(resource.language(), QString());
|
||||
QCOMPARE(resource.audioCodec(), QString());
|
||||
QCOMPARE(resource.videoCodec(), QString());
|
||||
QCOMPARE(resource.dataSize(), qint64(0));
|
||||
QCOMPARE(resource.audioBitRate(), 0);
|
||||
QCOMPARE(resource.sampleRate(), 0);
|
||||
QCOMPARE(resource.channelCount(), 0);
|
||||
QCOMPARE(resource.videoBitRate(), 0);
|
||||
QCOMPARE(resource.resolution(), QSize());
|
||||
|
||||
resource.setLanguage(language);
|
||||
resource.setAudioCodec(audioCodec);
|
||||
resource.setVideoCodec(videoCodec);
|
||||
resource.setDataSize(dataSize);
|
||||
resource.setAudioBitRate(audioBitRate);
|
||||
resource.setSampleRate(sampleRate);
|
||||
resource.setChannelCount(channelCount);
|
||||
resource.setVideoBitRate(videoBitRate);
|
||||
resource.setResolution(resolution);
|
||||
|
||||
QCOMPARE(resource.language(), language);
|
||||
QCOMPARE(resource.audioCodec(), audioCodec);
|
||||
QCOMPARE(resource.videoCodec(), videoCodec);
|
||||
QCOMPARE(resource.dataSize(), dataSize);
|
||||
QCOMPARE(resource.audioBitRate(), audioBitRate);
|
||||
QCOMPARE(resource.sampleRate(), sampleRate);
|
||||
QCOMPARE(resource.channelCount(), channelCount);
|
||||
QCOMPARE(resource.videoBitRate(), videoBitRate);
|
||||
QCOMPARE(resource.resolution(), resolution);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QMediaResource::setResolution()
|
||||
{
|
||||
QMediaResource resource(
|
||||
QUrl(QString::fromLatin1("file::///thumbs/test.png")),
|
||||
QString::fromLatin1("image/png"));
|
||||
|
||||
QCOMPARE(resource.resolution(), QSize());
|
||||
|
||||
resource.setResolution(QSize(120, 80));
|
||||
QCOMPARE(resource.resolution(), QSize(120, 80));
|
||||
|
||||
resource.setResolution(QSize(-1, 23));
|
||||
QCOMPARE(resource.resolution(), QSize(-1, 23));
|
||||
|
||||
resource.setResolution(QSize(-43, 34));
|
||||
QCOMPARE(resource.resolution(), QSize(-43, 34));
|
||||
|
||||
resource.setResolution(QSize(64, -1));
|
||||
QCOMPARE(resource.resolution(), QSize(64, -1));
|
||||
|
||||
resource.setResolution(QSize(64, -83));
|
||||
QCOMPARE(resource.resolution(), QSize(64, -83));
|
||||
|
||||
resource.setResolution(QSize(-12, -83));
|
||||
QCOMPARE(resource.resolution(), QSize(-12, -83));
|
||||
|
||||
resource.setResolution(QSize());
|
||||
QCOMPARE(resource.resolution(), QSize(-1, -1));
|
||||
|
||||
resource.setResolution(120, 80);
|
||||
QCOMPARE(resource.resolution(), QSize(120, 80));
|
||||
|
||||
resource.setResolution(-1, 23);
|
||||
QCOMPARE(resource.resolution(), QSize(-1, 23));
|
||||
|
||||
resource.setResolution(-43, 34);
|
||||
QCOMPARE(resource.resolution(), QSize(-43, 34));
|
||||
|
||||
resource.setResolution(64, -1);
|
||||
QCOMPARE(resource.resolution(), QSize(64, -1));
|
||||
|
||||
resource.setResolution(64, -83);
|
||||
QCOMPARE(resource.resolution(), QSize(64, -83));
|
||||
|
||||
resource.setResolution(-12, -83);
|
||||
QCOMPARE(resource.resolution(), QSize(-12, -83));
|
||||
|
||||
resource.setResolution(-1, -1);
|
||||
QCOMPARE(resource.resolution(), QSize());
|
||||
}
|
||||
|
||||
void tst_QMediaResource::equality()
|
||||
{
|
||||
QMediaResource resource1(
|
||||
QUrl(QString::fromLatin1("http://test.com/test.mp4")),
|
||||
QString::fromLatin1("video/mp4"));
|
||||
QMediaResource resource2(
|
||||
QUrl(QString::fromLatin1("http://test.com/test.mp4")),
|
||||
QString::fromLatin1("video/mp4"));
|
||||
QMediaResource resource3(
|
||||
QUrl(QString::fromLatin1("file:///thumbs/test.jpg")));
|
||||
QMediaResource resource4(
|
||||
QUrl(QString::fromLatin1("file:///thumbs/test.jpg")));
|
||||
QMediaResource resource5(
|
||||
QUrl(QString::fromLatin1("http://test.com/test.mp3")),
|
||||
QString::fromLatin1("audio/mpeg"));
|
||||
|
||||
QNetworkRequest request(QUrl("http://test.com/test.mp3"));
|
||||
QString requestMimeType("audio/mp3");
|
||||
|
||||
QMediaResource requestResource1(request, requestMimeType);
|
||||
QMediaResource requestResource2(request, requestMimeType);
|
||||
|
||||
QCOMPARE(requestResource1 == requestResource2, true);
|
||||
QCOMPARE(requestResource1 != requestResource2, false);
|
||||
QCOMPARE(requestResource1 != resource5, true);
|
||||
|
||||
QCOMPARE(resource1 == resource2, true);
|
||||
QCOMPARE(resource1 != resource2, false);
|
||||
|
||||
QCOMPARE(resource3 == resource4, true);
|
||||
QCOMPARE(resource3 != resource4, false);
|
||||
|
||||
QCOMPARE(resource1 == resource3, false);
|
||||
QCOMPARE(resource1 != resource3, true);
|
||||
|
||||
QCOMPARE(resource1 == resource5, false);
|
||||
QCOMPARE(resource1 != resource5, true);
|
||||
|
||||
resource1.setAudioCodec(QString::fromLatin1("mp3"));
|
||||
resource2.setAudioCodec(QString::fromLatin1("aac"));
|
||||
|
||||
// Not equal differing audio codecs.
|
||||
QCOMPARE(resource1 == resource2, false);
|
||||
QCOMPARE(resource1 != resource2, true);
|
||||
|
||||
resource1.setAudioCodec(QString::fromLatin1("aac"));
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(resource1 == resource2, true);
|
||||
QCOMPARE(resource1 != resource2, false);
|
||||
|
||||
resource1.setVideoCodec(QString());
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(resource1 == resource2, true);
|
||||
QCOMPARE(resource1 != resource2, false);
|
||||
|
||||
resource1.setVideoCodec(QString::fromLatin1("h264"));
|
||||
|
||||
// Not equal differing video codecs.
|
||||
QCOMPARE(resource1 == resource2, false);
|
||||
QCOMPARE(resource1 != resource2, true);
|
||||
|
||||
resource2.setVideoCodec(QString::fromLatin1("h264"));
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(resource1 == resource2, true);
|
||||
QCOMPARE(resource1 != resource2, false);
|
||||
|
||||
resource2.setDataSize(0);
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(resource1 == resource2, true);
|
||||
QCOMPARE(resource1 != resource2, false);
|
||||
|
||||
resource1.setDataSize(546423);
|
||||
|
||||
// Not equal differing video codecs.
|
||||
QCOMPARE(resource1 == resource2, false);
|
||||
QCOMPARE(resource1 != resource2, true);
|
||||
|
||||
resource2.setDataSize(546423);
|
||||
|
||||
// Equal.
|
||||
QCOMPARE(resource1 == resource2, true);
|
||||
QCOMPARE(resource1 != resource2, false);
|
||||
|
||||
resource1.setAudioBitRate(96000);
|
||||
resource1.setSampleRate(48000);
|
||||
resource2.setSampleRate(44100);
|
||||
resource1.setChannelCount(0);
|
||||
resource1.setVideoBitRate(900000);
|
||||
resource2.setLanguage(QString::fromLatin1("eng"));
|
||||
|
||||
// Not equal, audio bit rate, sample rate, video bit rate, and
|
||||
// language.
|
||||
QCOMPARE(resource1 == resource2, false);
|
||||
QCOMPARE(resource1 != resource2, true);
|
||||
|
||||
resource2.setAudioBitRate(96000);
|
||||
resource1.setSampleRate(44100);
|
||||
|
||||
// Not equal, differing video bit rate, and language.
|
||||
QCOMPARE(resource1 == resource2, false);
|
||||
QCOMPARE(resource1 != resource2, true);
|
||||
|
||||
resource2.setVideoBitRate(900000);
|
||||
resource1.setLanguage(QString::fromLatin1("eng"));
|
||||
|
||||
// Equal
|
||||
QCOMPARE(resource1 == resource2, true);
|
||||
QCOMPARE(resource1 != resource2, false);
|
||||
|
||||
resource1.setResolution(QSize());
|
||||
|
||||
// Equal
|
||||
QCOMPARE(resource1 == resource2, true);
|
||||
QCOMPARE(resource1 != resource2, false);
|
||||
|
||||
resource2.setResolution(-1, -1);
|
||||
|
||||
// Equal
|
||||
QCOMPARE(resource1 == resource2, true);
|
||||
QCOMPARE(resource1 != resource2, false);
|
||||
|
||||
resource1.setResolution(QSize(-640, -480));
|
||||
|
||||
// Not equal, differing resolution.
|
||||
QCOMPARE(resource1 == resource2, false);
|
||||
QCOMPARE(resource1 != resource2, true);
|
||||
resource1.setResolution(QSize(640, 480));
|
||||
resource2.setResolution(QSize(800, 600));
|
||||
|
||||
// Not equal, differing resolution.
|
||||
QCOMPARE(resource1 == resource2, false);
|
||||
QCOMPARE(resource1 != resource2, true);
|
||||
|
||||
resource1.setResolution(800, 600);
|
||||
|
||||
// Equal
|
||||
QCOMPARE(resource1 == resource2, true);
|
||||
QCOMPARE(resource1 != resource2, false);
|
||||
|
||||
/* equality tests for constructor of QMediaresource(QNetworkrequest,mimeType)*/
|
||||
QNetworkRequest request2(QUrl(QString::fromLatin1("http://test.com/test.mp4")));
|
||||
QUrl url(QString::fromLatin1("http://test.com/test.mp4"));
|
||||
QString mimeType(QLatin1String("video/mp4"));
|
||||
|
||||
QMediaResource resource6(request2,mimeType);
|
||||
QMediaResource resource7(request2,mimeType);
|
||||
|
||||
|
||||
QVERIFY(resource6.request()==request2);
|
||||
QVERIFY(resource6.mimeType()==mimeType);
|
||||
|
||||
|
||||
QVERIFY(resource7.request()==request2);
|
||||
QVERIFY(resource7.mimeType()==mimeType);
|
||||
|
||||
QVERIFY(resource6.request()==resource7.request());
|
||||
QVERIFY(resource6.mimeType()==resource7.mimeType());
|
||||
|
||||
QVERIFY(resource6==resource7);
|
||||
|
||||
/*for copy constructor*/
|
||||
QMediaResource resource8(resource7);
|
||||
|
||||
QVERIFY(resource8.request()==request2);
|
||||
QVERIFY(resource8.mimeType()==mimeType);
|
||||
|
||||
|
||||
QVERIFY(resource7.request()==request2);
|
||||
QVERIFY(resource7.mimeType()==mimeType);
|
||||
|
||||
QVERIFY(resource8.request()==resource7.request());
|
||||
QVERIFY(resource8.mimeType()==resource7.mimeType());
|
||||
|
||||
|
||||
QVERIFY(resource8==resource7);
|
||||
|
||||
/*for assign constructor*/
|
||||
|
||||
QMediaResource resource9(request2,mimeType);
|
||||
|
||||
QMediaResource resource10=resource9;
|
||||
|
||||
QVERIFY(resource10.request()==request2);
|
||||
QVERIFY(resource10.mimeType()==mimeType);
|
||||
|
||||
|
||||
QVERIFY(resource9.request()==request2);
|
||||
QVERIFY(resource9.mimeType()==mimeType);
|
||||
|
||||
QVERIFY(resource8.request()==resource7.request());
|
||||
QVERIFY(resource8.mimeType()==resource7.mimeType());
|
||||
|
||||
QVERIFY(resource8==resource7);
|
||||
}
|
||||
|
||||
void tst_QMediaResource::copy()
|
||||
{
|
||||
const QUrl url(QString::fromLatin1("http://test.com/test.mp4"));
|
||||
const QString mimeType(QLatin1String("video/mp4"));
|
||||
const QString amrCodec(QLatin1String("amr"));
|
||||
const QString mp3Codec(QLatin1String("mp3"));
|
||||
const QString aacCodec(QLatin1String("aac"));
|
||||
const QString h264Codec(QLatin1String("h264"));
|
||||
|
||||
QMediaResource original(url, mimeType);
|
||||
original.setAudioCodec(amrCodec);
|
||||
|
||||
QMediaResource copy(original);
|
||||
|
||||
QCOMPARE(copy.url(), url);
|
||||
QCOMPARE(copy.mimeType(), mimeType);
|
||||
QCOMPARE(copy.audioCodec(), amrCodec);
|
||||
|
||||
QCOMPARE(original == copy, true);
|
||||
QCOMPARE(original != copy, false);
|
||||
|
||||
original.setAudioCodec(mp3Codec);
|
||||
|
||||
QCOMPARE(copy.audioCodec(), amrCodec);
|
||||
QCOMPARE(original == copy, false);
|
||||
QCOMPARE(original != copy, true);
|
||||
|
||||
copy.setAudioCodec(aacCodec);
|
||||
copy.setVideoCodec(h264Codec);
|
||||
|
||||
QCOMPARE(copy.url(), url);
|
||||
QCOMPARE(copy.mimeType(), mimeType);
|
||||
|
||||
QCOMPARE(original.audioCodec(), mp3Codec);
|
||||
}
|
||||
|
||||
void tst_QMediaResource::assign()
|
||||
{
|
||||
const QUrl url(QString::fromLatin1("http://test.com/test.mp4"));
|
||||
const QString mimeType(QLatin1String("video/mp4"));
|
||||
const QString amrCodec(QLatin1String("amr"));
|
||||
const QString mp3Codec(QLatin1String("mp3"));
|
||||
const QString aacCodec(QLatin1String("aac"));
|
||||
const QString h264Codec(QLatin1String("h264"));
|
||||
|
||||
QNetworkRequest request(QUrl(QString::fromLatin1("http://test.com/test.mp4")));
|
||||
const qint64 dataSize(23600);
|
||||
int audioBitRate = 1, sampleRate = 2, channelCount = 3, videoBitRate = 4;
|
||||
QSize resolution(QSize(640, 480));
|
||||
QString language("eng");
|
||||
|
||||
QMediaResource copy(QUrl(QString::fromLatin1("file:///thumbs/test.jpg")));
|
||||
|
||||
QMediaResource original(url, mimeType);
|
||||
original.setAudioCodec(amrCodec);
|
||||
|
||||
copy = original;
|
||||
|
||||
QCOMPARE(copy.url(), url);
|
||||
QCOMPARE(copy.mimeType(), mimeType);
|
||||
QCOMPARE(copy.audioCodec(), amrCodec);
|
||||
|
||||
QCOMPARE(original == copy, true);
|
||||
QCOMPARE(original != copy, false);
|
||||
|
||||
original.setAudioCodec(mp3Codec);
|
||||
|
||||
QCOMPARE(copy.audioCodec(), amrCodec);
|
||||
QCOMPARE(original == copy, false);
|
||||
QCOMPARE(original != copy, true);
|
||||
|
||||
copy.setAudioCodec(aacCodec);
|
||||
copy.setVideoCodec(h264Codec);
|
||||
|
||||
QCOMPARE(copy.url(), url);
|
||||
QCOMPARE(copy.mimeType(), mimeType);
|
||||
|
||||
QCOMPARE(original.audioCodec(), mp3Codec);
|
||||
|
||||
/* for constructor of QMediaresource(QNetworkrequest,mimeType)*/
|
||||
|
||||
QMediaResource copy1(QNetworkRequest(QUrl(QString::fromLatin1("file:///thumbs/test.jpg"))));
|
||||
|
||||
QMediaResource original1(request, mimeType);
|
||||
|
||||
original1.setAudioCodec(amrCodec);
|
||||
original1.setLanguage(QString("eng"));
|
||||
original1.setVideoCodec(h264Codec);
|
||||
original1.setDataSize(dataSize);
|
||||
original1.setAudioBitRate(audioBitRate);
|
||||
original1.setSampleRate(sampleRate);
|
||||
original1.setChannelCount(channelCount);
|
||||
original1.setVideoBitRate(videoBitRate);
|
||||
original1.setResolution(resolution);
|
||||
|
||||
copy1 = original1;
|
||||
|
||||
QCOMPARE(original1 == copy1, true);
|
||||
}
|
||||
|
||||
// Constructor for request without passing mimetype.
|
||||
void tst_QMediaResource::constructorRequest()
|
||||
{
|
||||
//Initialise the request and url.
|
||||
QNetworkRequest request(QUrl(QString::fromLatin1("http:://test.com/test.mp3")));
|
||||
QUrl url(QString::fromLatin1("http:://test.com/test.mp3"));
|
||||
|
||||
// Create the instance with request as parameter.
|
||||
QMediaResource resource(request);
|
||||
|
||||
// Verify all the parameters of objects.
|
||||
QCOMPARE(resource.isNull(), false);
|
||||
QCOMPARE(resource.url(), url);
|
||||
QCOMPARE(resource.request(), request);
|
||||
QCOMPARE(resource.mimeType(), QString());
|
||||
QCOMPARE(resource.language(), QString());
|
||||
QCOMPARE(resource.audioCodec(), QString());
|
||||
QCOMPARE(resource.videoCodec(), QString());
|
||||
QCOMPARE(resource.dataSize(), qint64(0));
|
||||
QCOMPARE(resource.audioBitRate(), 0);
|
||||
QCOMPARE(resource.sampleRate(), 0);
|
||||
QCOMPARE(resource.channelCount(), 0);
|
||||
QCOMPARE(resource.videoBitRate(), 0);
|
||||
QCOMPARE(resource.resolution(), QSize());
|
||||
}
|
||||
|
||||
// Copy constructor with all the parameter and copy constructor for constructor with request and mimetype as parameter.
|
||||
void tst_QMediaResource::copyConstructor()
|
||||
{
|
||||
// Initialise all the parameters.
|
||||
const QUrl url(QString::fromLatin1("http://test.com/test.mp4"));
|
||||
const QString mimeType(QLatin1String("video/mp4"));
|
||||
const QString amrCodec(QLatin1String("amr"));
|
||||
const QString h264Codec(QLatin1String("h264"));
|
||||
|
||||
const qint64 dataSize(23600);
|
||||
int audioBitRate = 1, sampleRate = 2, channelCount = 3, videoBitRate = 4;
|
||||
QSize resolution(QSize(640, 480));
|
||||
QString language("eng");
|
||||
|
||||
// Create the instance with url and mimetype.
|
||||
QMediaResource original(url, mimeType);
|
||||
|
||||
// Set all the parameters.
|
||||
original.setAudioCodec(amrCodec);
|
||||
original.setLanguage(QString("eng"));
|
||||
original.setVideoCodec(h264Codec);
|
||||
original.setDataSize(dataSize);
|
||||
original.setAudioBitRate(audioBitRate);
|
||||
original.setSampleRate(sampleRate);
|
||||
original.setChannelCount(channelCount);
|
||||
original.setVideoBitRate(videoBitRate);
|
||||
original.setResolution(resolution);
|
||||
|
||||
// Copy the instance to new object.
|
||||
QMediaResource copy(original);
|
||||
|
||||
// Verify all the parameters of the copied object.
|
||||
QCOMPARE(copy.url(), url);
|
||||
QCOMPARE(copy.mimeType(), mimeType);
|
||||
QCOMPARE(copy.audioCodec(), amrCodec);
|
||||
QCOMPARE(copy.language(), language );
|
||||
QCOMPARE(copy.videoCodec(), h264Codec);
|
||||
QCOMPARE(copy.dataSize(), dataSize);
|
||||
QCOMPARE(copy.audioBitRate(), audioBitRate);
|
||||
QCOMPARE(copy.sampleRate(), sampleRate);
|
||||
QCOMPARE(copy.channelCount(), channelCount);
|
||||
QCOMPARE(copy.videoBitRate(), videoBitRate);
|
||||
QCOMPARE(copy.resolution(), resolution);
|
||||
|
||||
// Compare both the objects are equal.
|
||||
QCOMPARE(original == copy, true);
|
||||
QCOMPARE(original != copy, false);
|
||||
|
||||
// Initialise the request parameter.
|
||||
QNetworkRequest request1(QUrl(QString::fromLatin1("http://test.com/test.mp4")));
|
||||
|
||||
// Constructor with rerquest and mimetype.
|
||||
QMediaResource original1(request1, mimeType);
|
||||
|
||||
// Copy the object and verify if both are eqaul or not.
|
||||
QMediaResource copy1(original1);
|
||||
QCOMPARE(copy1.url(), url);
|
||||
QCOMPARE(copy1.mimeType(), mimeType);
|
||||
QCOMPARE(copy1.request(), request1);
|
||||
QCOMPARE(original1 == copy1, true);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMediaResource)
|
||||
|
||||
#include "tst_qmediaresource.moc"
|
||||
7
tests/auto/unit/qmediaservice/qmediaservice.pro
Normal file
7
tests/auto/unit/qmediaservice/qmediaservice.pro
Normal file
@@ -0,0 +1,7 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediaservice
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qmediaservice.cpp
|
||||
280
tests/auto/unit/qmediaservice/tst_qmediaservice.cpp
Normal file
280
tests/auto/unit/qmediaservice/tst_qmediaservice.cpp
Normal file
@@ -0,0 +1,280 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtTest/QtTest>
|
||||
|
||||
#include <qvideodevicecontrol.h>
|
||||
#include <qmediacontrol.h>
|
||||
#include <qmediaservice.h>
|
||||
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QtTestMediaService;
|
||||
|
||||
class QtTestMediaControlA : public QMediaControl
|
||||
{
|
||||
Q_OBJECT
|
||||
};
|
||||
|
||||
#define QtTestMediaControlA_iid "com.nokia.QtTestMediaControlA"
|
||||
Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlA, QtTestMediaControlA_iid)
|
||||
|
||||
class QtTestMediaControlB : public QMediaControl
|
||||
{
|
||||
Q_OBJECT
|
||||
};
|
||||
|
||||
#define QtTestMediaControlB_iid "com.nokia.QtTestMediaControlB"
|
||||
Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlB, QtTestMediaControlB_iid)
|
||||
|
||||
|
||||
class QtTestMediaControlC : public QMediaControl
|
||||
{
|
||||
Q_OBJECT
|
||||
};
|
||||
|
||||
#define QtTestMediaControlC_iid "com.nokia.QtTestMediaControlC"
|
||||
Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlC, QtTestMediaControlA_iid) // Yes A.
|
||||
|
||||
class QtTestMediaControlD : public QMediaControl
|
||||
{
|
||||
Q_OBJECT
|
||||
};
|
||||
|
||||
#define QtTestMediaControlD_iid "com.nokia.QtTestMediaControlD"
|
||||
Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlD, QtTestMediaControlD_iid)
|
||||
|
||||
//unimplemented service
|
||||
#define QtTestMediaControlE_iid "com.nokia.QtTestMediaControlF"
|
||||
class QtTestMediaControlE : public QMediaControl
|
||||
{
|
||||
Q_OBJECT
|
||||
};
|
||||
|
||||
/* implementation of child class by inheriting The QMediaService base class for media service implementations. */
|
||||
class QtTestMediaService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
int refA;
|
||||
int refB;
|
||||
int refC;
|
||||
QtTestMediaControlA controlA;
|
||||
QtTestMediaControlB controlB;
|
||||
QtTestMediaControlC controlC;
|
||||
|
||||
//constructor
|
||||
QtTestMediaService(): QMediaService(0), refA(0), refB(0), refC(0)
|
||||
{
|
||||
}
|
||||
|
||||
//requestControl() pure virtual function of QMediaService class.
|
||||
QMediaControl *requestControl(const char *name)
|
||||
{
|
||||
if (strcmp(name, QtTestMediaControlA_iid) == 0) {
|
||||
refA += 1;
|
||||
|
||||
return &controlA;
|
||||
} else if (strcmp(name, QtTestMediaControlB_iid) == 0) {
|
||||
refB += 1;
|
||||
|
||||
return &controlB;
|
||||
} else if (strcmp(name, QtTestMediaControlC_iid) == 0) {
|
||||
refA += 1;
|
||||
|
||||
return &controlA;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//releaseControl() pure virtual function of QMediaService class.
|
||||
void releaseControl(QMediaControl *control)
|
||||
{
|
||||
if (control == &controlA)
|
||||
refA -= 1;
|
||||
else if (control == &controlB)
|
||||
refB -= 1;
|
||||
else if (control == &controlC)
|
||||
refC -= 1;
|
||||
}
|
||||
|
||||
//requestControl() function of QMediaService class.
|
||||
using QMediaService::requestControl;
|
||||
};
|
||||
|
||||
/* Test case implementation for QMediaService class which provides a common base class for media service implementations.*/
|
||||
class tst_QMediaService : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void tst_destructor();
|
||||
void tst_releaseControl();
|
||||
void tst_requestControl();
|
||||
void tst_requestControlTemplate();
|
||||
|
||||
void initTestCase();
|
||||
|
||||
void control_iid();
|
||||
void control();
|
||||
|
||||
};
|
||||
|
||||
/*MaemoAPI-1668 :destructor property test. */
|
||||
void tst_QMediaService::tst_destructor()
|
||||
{
|
||||
QtTestMediaService *service = new QtTestMediaService;
|
||||
delete service;
|
||||
}
|
||||
|
||||
void tst_QMediaService::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
/*MaemoAPI-1669 :releaseControl() API property test. */
|
||||
void tst_QMediaService::tst_releaseControl()
|
||||
{
|
||||
//test class instance creation
|
||||
QtTestMediaService service;
|
||||
|
||||
//Get a pointer to the media control implementing interface and verify.
|
||||
QMediaControl* controlA = service.requestControl(QtTestMediaControlA_iid);
|
||||
QCOMPARE(controlA, &service.controlA);
|
||||
service.releaseControl(controlA); //Controls must be returned to the service when no longer needed
|
||||
QVERIFY(service.refA == 0);
|
||||
|
||||
//Get a pointer to the media control implementing interface and verify.
|
||||
QMediaControl* controlB = service.requestControl(QtTestMediaControlB_iid);
|
||||
QCOMPARE(controlB, &service.controlB);
|
||||
service.releaseControl(controlB); //Controls must be returned to the service when no longer needed
|
||||
QVERIFY(service.refB == 0);
|
||||
}
|
||||
|
||||
/*MaemoAPI-1670 :requestControl() API property test. */
|
||||
void tst_QMediaService::tst_requestControl()
|
||||
{
|
||||
//test class instance creation
|
||||
QtTestMediaService service;
|
||||
|
||||
//Get a pointer to the media control implementing interface and verify.
|
||||
QMediaControl* controlA = service.requestControl(QtTestMediaControlA_iid);
|
||||
QCOMPARE(controlA, &service.controlA);
|
||||
service.releaseControl(controlA); //Controls must be returned to the service when no longer needed
|
||||
|
||||
//Get a pointer to the media control implementing interface and verify.
|
||||
QMediaControl* controlB = service.requestControl(QtTestMediaControlB_iid);
|
||||
QCOMPARE(controlB, &service.controlB);
|
||||
service.releaseControl(controlB); //Controls must be returned to the service when no longer needed
|
||||
|
||||
//If the service does not implement the control, a null pointer is returned instead.
|
||||
QMediaControl* controlE = service.requestControl(QtTestMediaControlE_iid);
|
||||
QVERIFY(!controlE); //should return null pointer
|
||||
service.releaseControl(controlE); //Controls must be returned to the service when no longer needed
|
||||
|
||||
//If the service is unavailable a null pointer is returned instead.
|
||||
QMediaControl* control = service.requestControl("");
|
||||
QVERIFY(!control); //should return null pointer
|
||||
service.releaseControl(control); //Controls must be returned to the service when no longer needed
|
||||
}
|
||||
|
||||
/*MaemoAPI-1671 :requestControl() API property test. */
|
||||
void tst_QMediaService::tst_requestControlTemplate()
|
||||
{
|
||||
//test class instance creation
|
||||
QtTestMediaService service;
|
||||
|
||||
//Get a pointer to the media control of type T implemented by a media service.
|
||||
QtTestMediaControlA *controlA = service.requestControl<QtTestMediaControlA *>();
|
||||
QCOMPARE(controlA, &service.controlA);
|
||||
service.releaseControl(controlA);
|
||||
|
||||
//Get a pointer to the media control of type T implemented by a media service.
|
||||
QtTestMediaControlB *controlB = service.requestControl<QtTestMediaControlB *>();
|
||||
QCOMPARE(controlB, &service.controlB);
|
||||
service.releaseControl(controlB);
|
||||
|
||||
QVERIFY(!service.requestControl<QtTestMediaControlC *>()); // Faulty implementation returns A.
|
||||
QCOMPARE(service.refA, 0); // Verify the control was released.
|
||||
|
||||
QVERIFY(!service.requestControl<QtTestMediaControlD *>()); // No control of that type.
|
||||
}
|
||||
|
||||
|
||||
void tst_QMediaService::control_iid()
|
||||
{
|
||||
const char *nullString = 0;
|
||||
|
||||
// Default implementation.
|
||||
QCOMPARE(qmediacontrol_iid<QtTestMediaControlE *>(), nullString);
|
||||
|
||||
// Partial template.
|
||||
QVERIFY(qstrcmp(qmediacontrol_iid<QtTestMediaControlA *>(), QtTestMediaControlA_iid) == 0);
|
||||
}
|
||||
|
||||
void tst_QMediaService::control()
|
||||
{
|
||||
QtTestMediaService service;
|
||||
|
||||
QtTestMediaControlA *controlA = service.requestControl<QtTestMediaControlA *>();
|
||||
QCOMPARE(controlA, &service.controlA);
|
||||
service.releaseControl(controlA);
|
||||
|
||||
QtTestMediaControlB *controlB = service.requestControl<QtTestMediaControlB *>();
|
||||
QCOMPARE(controlB, &service.controlB);
|
||||
service.releaseControl(controlB);
|
||||
|
||||
QVERIFY(!service.requestControl<QtTestMediaControlC *>()); // Faulty implementation returns A, but is wrong class
|
||||
QCOMPARE(service.refA, 0); // Verify the control was released.
|
||||
|
||||
QVERIFY(!service.requestControl<QtTestMediaControlD *>()); // No control of that type.
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
QTEST_MAIN(tst_QMediaService)
|
||||
|
||||
#include "tst_qmediaservice.moc"
|
||||
@@ -0,0 +1,8 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediaserviceprovider
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qmediaserviceprovider.cpp
|
||||
|
||||
@@ -0,0 +1,499 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtTest/QtTest>
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
||||
#include <qmediaserviceprovider.h>
|
||||
#include <qmediaserviceproviderplugin.h>
|
||||
#include <private/qmediapluginloader_p.h>
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediaplayer.h>
|
||||
#include <qaudiocapturesource.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
class MockMediaService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockMediaService(const QString& name, QObject *parent = 0) : QMediaService(parent)
|
||||
{ setObjectName(name); }
|
||||
~MockMediaService() {}
|
||||
|
||||
QMediaControl* requestControl(const char *) {return 0;}
|
||||
void releaseControl(QMediaControl *) {}
|
||||
};
|
||||
|
||||
class MockServicePlugin1 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedFormatsInterface,
|
||||
public QMediaServiceSupportedDevicesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
|
||||
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() <<
|
||||
QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin1");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
|
||||
{
|
||||
if (codecs.contains(QLatin1String("mpeg4")))
|
||||
return QtMultimedia::NotSupported;
|
||||
|
||||
if (mimeType == "audio/ogg") {
|
||||
return QtMultimedia::ProbablySupported;
|
||||
}
|
||||
|
||||
return QtMultimedia::MaybeSupported;
|
||||
}
|
||||
|
||||
QStringList supportedMimeTypes() const
|
||||
{
|
||||
return QStringList("audio/ogg");
|
||||
}
|
||||
|
||||
QList<QByteArray> devices(const QByteArray &service) const
|
||||
{
|
||||
QList<QByteArray> res;
|
||||
return res;
|
||||
}
|
||||
|
||||
QString deviceDescription(const QByteArray &service, const QByteArray &device)
|
||||
{
|
||||
if (devices(service).contains(device))
|
||||
return QString(device)+" description";
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
};
|
||||
|
||||
class MockServicePlugin2 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedFormatsInterface,
|
||||
public QMediaServiceFeaturesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
|
||||
Q_INTERFACES(QMediaServiceFeaturesInterface)
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)
|
||||
<< QLatin1String(Q_MEDIASERVICE_RADIO);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin2");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
|
||||
{
|
||||
Q_UNUSED(codecs);
|
||||
|
||||
if (mimeType == "audio/wav")
|
||||
return QtMultimedia::PreferredService;
|
||||
|
||||
return QtMultimedia::NotSupported;
|
||||
}
|
||||
|
||||
QStringList supportedMimeTypes() const
|
||||
{
|
||||
return QStringList("audio/wav");
|
||||
}
|
||||
|
||||
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const
|
||||
{
|
||||
if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER))
|
||||
return QMediaServiceProviderHint::LowLatencyPlayback;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class MockServicePlugin3 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedDevicesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() <<
|
||||
QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER) <<
|
||||
QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin3");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QList<QByteArray> devices(const QByteArray &service) const
|
||||
{
|
||||
QList<QByteArray> res;
|
||||
if (service == QByteArray(Q_MEDIASERVICE_AUDIOSOURCE))
|
||||
res << "audiosource1" << "audiosource2";
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
QString deviceDescription(const QByteArray &service, const QByteArray &device)
|
||||
{
|
||||
if (devices(service).contains(device))
|
||||
return QString(device)+" description";
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
};
|
||||
|
||||
class MockServicePlugin4 : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedFormatsInterface,
|
||||
public QMediaServiceFeaturesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
|
||||
Q_INTERFACES(QMediaServiceFeaturesInterface)
|
||||
public:
|
||||
QStringList keys() const
|
||||
{
|
||||
return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER);
|
||||
}
|
||||
|
||||
QMediaService* create(QString const& key)
|
||||
{
|
||||
if (keys().contains(key))
|
||||
return new MockMediaService("MockServicePlugin4");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QtMultimedia::SupportEstimate hasSupport(const QString &mimeType, const QStringList& codecs) const
|
||||
{
|
||||
if (codecs.contains(QLatin1String("jpeg2000")))
|
||||
return QtMultimedia::NotSupported;
|
||||
|
||||
if (supportedMimeTypes().contains(mimeType))
|
||||
return QtMultimedia::ProbablySupported;
|
||||
|
||||
return QtMultimedia::MaybeSupported;
|
||||
}
|
||||
|
||||
QStringList supportedMimeTypes() const
|
||||
{
|
||||
return QStringList() << "video/mp4" << "video/quicktime";
|
||||
}
|
||||
|
||||
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const
|
||||
{
|
||||
if (service == QByteArray(Q_MEDIASERVICE_MEDIAPLAYER))
|
||||
return QMediaServiceProviderHint::StreamPlayback;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MockMediaServiceProvider : public QMediaServiceProvider
|
||||
{
|
||||
QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &)
|
||||
{
|
||||
Q_UNUSED(type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void releaseService(QMediaService *service)
|
||||
{
|
||||
Q_UNUSED(service);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class tst_QMediaServiceProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
|
||||
private slots:
|
||||
void testDefaultProviderAvailable();
|
||||
void testObtainService();
|
||||
void testHasSupport();
|
||||
void testSupportedMimeTypes();
|
||||
void testProviderHints();
|
||||
|
||||
private:
|
||||
QObjectList plugins;
|
||||
};
|
||||
|
||||
void tst_QMediaServiceProvider::initTestCase()
|
||||
{
|
||||
plugins << new MockServicePlugin1;
|
||||
plugins << new MockServicePlugin2;
|
||||
plugins << new MockServicePlugin3;
|
||||
plugins << new MockServicePlugin4;
|
||||
|
||||
QMediaPluginLoader::setStaticPlugins(QLatin1String("mediaservice"), plugins);
|
||||
}
|
||||
|
||||
void tst_QMediaServiceProvider::testDefaultProviderAvailable()
|
||||
{
|
||||
// Must always be a default provider available
|
||||
QVERIFY(QMediaServiceProvider::defaultServiceProvider() != 0);
|
||||
}
|
||||
|
||||
void tst_QMediaServiceProvider::testObtainService()
|
||||
{
|
||||
QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
|
||||
|
||||
if (provider == 0)
|
||||
QSKIP("No default provider", SkipSingle);
|
||||
|
||||
QMediaService *service = 0;
|
||||
|
||||
// Player
|
||||
service = provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER);
|
||||
QVERIFY(service != 0);
|
||||
provider->releaseService(service);
|
||||
}
|
||||
|
||||
void tst_QMediaServiceProvider::testHasSupport()
|
||||
{
|
||||
MockMediaServiceProvider mockProvider;
|
||||
QCOMPARE(mockProvider.hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()),
|
||||
QtMultimedia::MaybeSupported);
|
||||
|
||||
QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
|
||||
|
||||
if (provider == 0)
|
||||
QSKIP("No default provider", SkipSingle);
|
||||
|
||||
QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()),
|
||||
QtMultimedia::MaybeSupported);
|
||||
|
||||
QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/ogg", QStringList()),
|
||||
QtMultimedia::ProbablySupported);
|
||||
|
||||
//while the service returns PreferredService, provider should return ProbablySupported
|
||||
QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/wav", QStringList()),
|
||||
QtMultimedia::ProbablySupported);
|
||||
|
||||
//even while all the plugins with "hasSupport" returned NotSupported,
|
||||
//MockServicePlugin3 has no "hasSupport" interface, so MaybeSupported
|
||||
QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/avi",
|
||||
QStringList() << "mpeg4"),
|
||||
QtMultimedia::MaybeSupported);
|
||||
|
||||
QCOMPARE(provider->hasSupport(QByteArray("non existing service"), "video/ogv", QStringList()),
|
||||
QtMultimedia::NotSupported);
|
||||
|
||||
QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QtMultimedia::MaybeSupported);
|
||||
QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QtMultimedia::ProbablySupported);
|
||||
QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QtMultimedia::ProbablySupported);
|
||||
|
||||
//test low latency flag support
|
||||
QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::LowLatency),
|
||||
QtMultimedia::ProbablySupported);
|
||||
//plugin1 probably supports audio/ogg, it checked because it doesn't provide features iface
|
||||
QCOMPARE(QMediaPlayer::hasSupport("audio/ogg", QStringList(), QMediaPlayer::LowLatency),
|
||||
QtMultimedia::ProbablySupported);
|
||||
//Plugin4 is not checked here, sine it's known not support low latency
|
||||
QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::LowLatency),
|
||||
QtMultimedia::MaybeSupported);
|
||||
|
||||
//test streaming flag support
|
||||
QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::StreamPlayback),
|
||||
QtMultimedia::ProbablySupported);
|
||||
//Plugin2 is not checked here, sine it's known not support streaming
|
||||
QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::StreamPlayback),
|
||||
QtMultimedia::MaybeSupported);
|
||||
|
||||
//ensure the correct media player plugin is chosen for mime type
|
||||
QMediaPlayer simplePlayer(0, QMediaPlayer::LowLatency);
|
||||
QCOMPARE(simplePlayer.service()->objectName(), QLatin1String("MockServicePlugin2"));
|
||||
|
||||
QMediaPlayer mediaPlayer;
|
||||
QVERIFY(mediaPlayer.service()->objectName() != QLatin1String("MockServicePlugin2"));
|
||||
|
||||
QMediaPlayer streamPlayer(0, QMediaPlayer::StreamPlayback);
|
||||
QCOMPARE(streamPlayer.service()->objectName(), QLatin1String("MockServicePlugin4"));
|
||||
}
|
||||
|
||||
void tst_QMediaServiceProvider::testSupportedMimeTypes()
|
||||
{
|
||||
QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
|
||||
|
||||
if (provider == 0)
|
||||
QSKIP("No default provider", SkipSingle);
|
||||
|
||||
QVERIFY(provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/ogg"));
|
||||
QVERIFY(!provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/mp3"));
|
||||
}
|
||||
|
||||
void tst_QMediaServiceProvider::testProviderHints()
|
||||
{
|
||||
{
|
||||
QMediaServiceProviderHint hint;
|
||||
QVERIFY(hint.isNull());
|
||||
QCOMPARE(hint.type(), QMediaServiceProviderHint::Null);
|
||||
QVERIFY(hint.device().isEmpty());
|
||||
QVERIFY(hint.mimeType().isEmpty());
|
||||
QVERIFY(hint.codecs().isEmpty());
|
||||
QCOMPARE(hint.features(), 0);
|
||||
}
|
||||
|
||||
{
|
||||
QByteArray deviceName(QByteArray("testDevice"));
|
||||
QMediaServiceProviderHint hint(deviceName);
|
||||
QVERIFY(!hint.isNull());
|
||||
QCOMPARE(hint.type(), QMediaServiceProviderHint::Device);
|
||||
QCOMPARE(hint.device(), deviceName);
|
||||
QVERIFY(hint.mimeType().isEmpty());
|
||||
QVERIFY(hint.codecs().isEmpty());
|
||||
QCOMPARE(hint.features(), 0);
|
||||
}
|
||||
|
||||
{
|
||||
QMediaServiceProviderHint hint(QMediaServiceProviderHint::LowLatencyPlayback);
|
||||
QVERIFY(!hint.isNull());
|
||||
QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures);
|
||||
QVERIFY(hint.device().isEmpty());
|
||||
QVERIFY(hint.mimeType().isEmpty());
|
||||
QVERIFY(hint.codecs().isEmpty());
|
||||
QCOMPARE(hint.features(), QMediaServiceProviderHint::LowLatencyPlayback);
|
||||
}
|
||||
|
||||
{
|
||||
QMediaServiceProviderHint hint(QMediaServiceProviderHint::RecordingSupport);
|
||||
QVERIFY(!hint.isNull());
|
||||
QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures);
|
||||
QVERIFY(hint.device().isEmpty());
|
||||
QVERIFY(hint.mimeType().isEmpty());
|
||||
QVERIFY(hint.codecs().isEmpty());
|
||||
QCOMPARE(hint.features(), QMediaServiceProviderHint::RecordingSupport);
|
||||
}
|
||||
|
||||
{
|
||||
QString mimeType(QLatin1String("video/ogg"));
|
||||
QStringList codecs;
|
||||
codecs << "theora" << "vorbis";
|
||||
|
||||
QMediaServiceProviderHint hint(mimeType,codecs);
|
||||
QVERIFY(!hint.isNull());
|
||||
QCOMPARE(hint.type(), QMediaServiceProviderHint::ContentType);
|
||||
QVERIFY(hint.device().isEmpty());
|
||||
QCOMPARE(hint.mimeType(), mimeType);
|
||||
QCOMPARE(hint.codecs(), codecs);
|
||||
|
||||
QMediaServiceProviderHint hint2(hint);
|
||||
|
||||
QVERIFY(!hint2.isNull());
|
||||
QCOMPARE(hint2.type(), QMediaServiceProviderHint::ContentType);
|
||||
QVERIFY(hint2.device().isEmpty());
|
||||
QCOMPARE(hint2.mimeType(), mimeType);
|
||||
QCOMPARE(hint2.codecs(), codecs);
|
||||
|
||||
QMediaServiceProviderHint hint3;
|
||||
QVERIFY(hint3.isNull());
|
||||
hint3 = hint;
|
||||
QVERIFY(!hint3.isNull());
|
||||
QCOMPARE(hint3.type(), QMediaServiceProviderHint::ContentType);
|
||||
QVERIFY(hint3.device().isEmpty());
|
||||
QCOMPARE(hint3.mimeType(), mimeType);
|
||||
QCOMPARE(hint3.codecs(), codecs);
|
||||
|
||||
QCOMPARE(hint, hint2);
|
||||
QCOMPARE(hint3, hint2);
|
||||
|
||||
QMediaServiceProviderHint hint4(mimeType,codecs);
|
||||
QCOMPARE(hint, hint4);
|
||||
|
||||
QMediaServiceProviderHint hint5(mimeType,QStringList());
|
||||
QVERIFY(hint != hint5);
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMediaServiceProvider)
|
||||
|
||||
#include "tst_qmediaserviceprovider.moc"
|
||||
8
tests/auto/unit/qmediatimerange/qmediatimerange.pro
Normal file
8
tests/auto/unit/qmediatimerange/qmediatimerange.pro
Normal file
@@ -0,0 +1,8 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmediatimerange
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qmediatimerange.cpp
|
||||
|
||||
806
tests/auto/unit/qmediatimerange/tst_qmediatimerange.cpp
Normal file
806
tests/auto/unit/qmediatimerange/tst_qmediatimerange.cpp
Normal file
@@ -0,0 +1,806 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtTest/QtTest>
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
#include <qmediatimerange.h>
|
||||
#include <qmediatimerange.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class tst_QMediaTimeRange: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void testCtor();
|
||||
void testIntervalCtor();
|
||||
void testGetters();
|
||||
void testAssignment();
|
||||
void testIntervalNormalize();
|
||||
void testIntervalTranslate();
|
||||
void testIntervalContains();
|
||||
void testEarliestLatest();
|
||||
void testContains();
|
||||
void testAddInterval();
|
||||
void testAddTimeRange();
|
||||
void testRemoveInterval();
|
||||
void testRemoveTimeRange();
|
||||
void testClear();
|
||||
void testComparisons();
|
||||
void testArithmetic();
|
||||
};
|
||||
|
||||
void tst_QMediaTimeRange::testIntervalCtor()
|
||||
{
|
||||
//Default Ctor for Time Interval
|
||||
/* create an instance for the time interval and verify the default cases */
|
||||
QMediaTimeInterval tInter;
|
||||
QVERIFY(tInter.isNormal());
|
||||
QVERIFY(tInter.start() == 0);
|
||||
QVERIFY(tInter.end() == 0);
|
||||
|
||||
// (qint, qint) Ctor time interval
|
||||
/* create an instace of QMediaTimeInterval passing start and end times and verify the all possible scenario's*/
|
||||
QMediaTimeInterval time(20,50);
|
||||
QVERIFY(time.isNormal());
|
||||
QVERIFY(time.start() == 20);
|
||||
QVERIFY(time.end() == 50);
|
||||
|
||||
// Copy Ctor Time interval
|
||||
QMediaTimeInterval other(time);
|
||||
QVERIFY(other.isNormal() == time.isNormal());
|
||||
QVERIFY(other.start() == time.start());
|
||||
QVERIFY(other.end() == time.end());
|
||||
QVERIFY(other.contains(20) == time.contains(20));
|
||||
QVERIFY(other == time);
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testIntervalContains()
|
||||
{
|
||||
QMediaTimeInterval time(20,50);
|
||||
|
||||
/* start() <= time <= end(). Returns true if the time interval contains the specified time. */
|
||||
QVERIFY(!time.contains(10));
|
||||
QVERIFY(time.contains(20));
|
||||
QVERIFY(time.contains(30));
|
||||
QVERIFY(time.contains(50));
|
||||
QVERIFY(!time.contains(60));
|
||||
|
||||
QMediaTimeInterval x(20, 10); // denormal
|
||||
|
||||
// Check denormal ranges
|
||||
QVERIFY(!x.contains(5));
|
||||
QVERIFY(x.contains(10));
|
||||
QVERIFY(x.contains(15));
|
||||
QVERIFY(x.contains(20));
|
||||
QVERIFY(!x.contains(25));
|
||||
|
||||
QMediaTimeInterval y = x.normalized();
|
||||
QVERIFY(!y.contains(5));
|
||||
QVERIFY(y.contains(10));
|
||||
QVERIFY(y.contains(15));
|
||||
QVERIFY(y.contains(20));
|
||||
QVERIFY(!y.contains(25));
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testCtor()
|
||||
{
|
||||
// Default Ctor
|
||||
QMediaTimeRange a;
|
||||
QVERIFY(a.isEmpty());
|
||||
|
||||
// (qint, qint) Ctor
|
||||
QMediaTimeRange b(10, 20);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(b.isContinuous());
|
||||
QVERIFY(b.earliestTime() == 10);
|
||||
QVERIFY(b.latestTime() == 20);
|
||||
|
||||
// Interval Ctor
|
||||
QMediaTimeRange c(QMediaTimeInterval(30, 40));
|
||||
|
||||
QVERIFY(!c.isEmpty());
|
||||
QVERIFY(c.isContinuous());
|
||||
QVERIFY(c.earliestTime() == 30);
|
||||
QVERIFY(c.latestTime() == 40);
|
||||
|
||||
// Abnormal Interval Ctor
|
||||
QMediaTimeRange d(QMediaTimeInterval(20, 10));
|
||||
|
||||
QVERIFY(d.isEmpty());
|
||||
|
||||
// Copy Ctor
|
||||
QMediaTimeRange e(b);
|
||||
|
||||
QVERIFY(!e.isEmpty());
|
||||
QVERIFY(e.isContinuous());
|
||||
QVERIFY(e.earliestTime() == 10);
|
||||
QVERIFY(e.latestTime() == 20);
|
||||
|
||||
QVERIFY(e == b);
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testGetters()
|
||||
{
|
||||
QMediaTimeRange x;
|
||||
|
||||
// isEmpty
|
||||
QVERIFY(x.isEmpty());
|
||||
|
||||
x.addInterval(10, 20);
|
||||
|
||||
// isEmpty + isContinuous
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
|
||||
x.addInterval(30, 40);
|
||||
|
||||
// isEmpty + isContinuous + intervals + start + end
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(!x.isContinuous());
|
||||
QVERIFY(x.intervals().count() == 2);
|
||||
QVERIFY(x.intervals()[0].start() == 10);
|
||||
QVERIFY(x.intervals()[0].end() == 20);
|
||||
QVERIFY(x.intervals()[1].start() == 30);
|
||||
QVERIFY(x.intervals()[1].end() == 40);
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testAssignment()
|
||||
{
|
||||
QMediaTimeRange x;
|
||||
|
||||
// Range Assignment
|
||||
x = QMediaTimeRange(10, 20);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.earliestTime() == 10);
|
||||
QVERIFY(x.latestTime() == 20);
|
||||
|
||||
// Interval Assignment
|
||||
x = QMediaTimeInterval(30, 40);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.earliestTime() == 30);
|
||||
QVERIFY(x.latestTime() == 40);
|
||||
|
||||
// Shared Data Check
|
||||
QMediaTimeRange y;
|
||||
|
||||
y = x;
|
||||
y.addInterval(10, 20);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.earliestTime() == 30);
|
||||
QVERIFY(x.latestTime() == 40);
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testIntervalNormalize()
|
||||
{
|
||||
QMediaTimeInterval x(20, 10);
|
||||
|
||||
QVERIFY(!x.isNormal());
|
||||
QVERIFY(x.start() == 20);
|
||||
QVERIFY(x.end() == 10);
|
||||
|
||||
QMediaTimeInterval y = x.normalized();
|
||||
|
||||
QVERIFY(y.isNormal());
|
||||
QVERIFY(y.start() == 10);
|
||||
QVERIFY(y.end() == 20);
|
||||
QVERIFY(x != y);
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testIntervalTranslate()
|
||||
{
|
||||
QMediaTimeInterval x(10, 20);
|
||||
x = x.translated(10);
|
||||
|
||||
QVERIFY(x.start() == 20);
|
||||
QVERIFY(x.end() == 30);
|
||||
|
||||
/* verifying the backward through time with a negative offset.*/
|
||||
x = x.translated(-10);
|
||||
|
||||
QVERIFY(x.start() == 10);
|
||||
QVERIFY(x.end() == 20);
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testEarliestLatest()
|
||||
{
|
||||
// Test over a single interval
|
||||
QMediaTimeRange x(30, 40);
|
||||
|
||||
QVERIFY(x.earliestTime() == 30);
|
||||
QVERIFY(x.latestTime() == 40);
|
||||
|
||||
// Test over multiple intervals
|
||||
x.addInterval(50, 60);
|
||||
|
||||
QVERIFY(x.earliestTime() == 30);
|
||||
QVERIFY(x.latestTime() == 60);
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testContains()
|
||||
{
|
||||
// Test over a single interval
|
||||
QMediaTimeRange x(10, 20);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.contains(15));
|
||||
QVERIFY(x.contains(10));
|
||||
QVERIFY(x.contains(20));
|
||||
QVERIFY(!x.contains(25));
|
||||
|
||||
// Test over multiple intervals
|
||||
x.addInterval(40, 50);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(!x.isContinuous());
|
||||
QVERIFY(x.contains(15));
|
||||
QVERIFY(x.contains(45));
|
||||
QVERIFY(!x.contains(30));
|
||||
|
||||
// Test over a concrete interval
|
||||
QMediaTimeInterval y(10, 20);
|
||||
QVERIFY(y.contains(15));
|
||||
QVERIFY(y.contains(10));
|
||||
QVERIFY(y.contains(20));
|
||||
QVERIFY(!y.contains(25));
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testAddInterval()
|
||||
{
|
||||
// All intervals Overlap
|
||||
QMediaTimeRange x;
|
||||
x.addInterval(10, 40);
|
||||
x.addInterval(30, 50);
|
||||
x.addInterval(20, 60);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.earliestTime() == 10);
|
||||
QVERIFY(x.latestTime() == 60);
|
||||
|
||||
// 1 adjacent interval, 1 encompassed interval
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(10, 40);
|
||||
x.addInterval(20, 30);
|
||||
x.addInterval(41, 50);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.earliestTime() == 10);
|
||||
QVERIFY(x.latestTime() == 50);
|
||||
|
||||
// 1 overlapping interval, 1 disjoint interval
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(10, 30);
|
||||
x.addInterval(20, 40);
|
||||
x.addInterval(50, 60);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(!x.isContinuous());
|
||||
QVERIFY(x.intervals().count() == 2);
|
||||
QVERIFY(x.intervals()[0].start() == 10);
|
||||
QVERIFY(x.intervals()[0].end() == 40);
|
||||
QVERIFY(x.intervals()[1].start() == 50);
|
||||
QVERIFY(x.intervals()[1].end() == 60);
|
||||
|
||||
// Identical Add
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(10, 20);
|
||||
x.addInterval(10, 20);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.earliestTime() == 10);
|
||||
QVERIFY(x.latestTime() == 20);
|
||||
|
||||
// Multi-Merge
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(10, 20);
|
||||
x.addInterval(30, 40);
|
||||
x.addInterval(50, 60);
|
||||
x.addInterval(15, 55);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.earliestTime() == 10);
|
||||
QVERIFY(x.latestTime() == 60);
|
||||
|
||||
// Interval Parameter - All intervals Overlap
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(QMediaTimeInterval(10, 40));
|
||||
x.addInterval(QMediaTimeInterval(30, 50));
|
||||
x.addInterval(QMediaTimeInterval(20, 60));
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.earliestTime() == 10);
|
||||
QVERIFY(x.latestTime() == 60);
|
||||
|
||||
// Interval Parameter - Abnormal Interval
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(QMediaTimeInterval(20, 10));
|
||||
|
||||
QVERIFY(x.isEmpty());
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testAddTimeRange()
|
||||
{
|
||||
// Add Time Range uses Add Interval internally,
|
||||
// so in this test the focus is on combinations of number
|
||||
// of intervals added, rather than the different types of
|
||||
// merges which can occur.
|
||||
QMediaTimeRange a, b;
|
||||
|
||||
// Add Single into Single
|
||||
a = QMediaTimeRange(10, 30);
|
||||
b = QMediaTimeRange(20, 40);
|
||||
|
||||
b.addTimeRange(a);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(b.isContinuous());
|
||||
QVERIFY(b.earliestTime() == 10);
|
||||
QVERIFY(b.latestTime() == 40);
|
||||
|
||||
// Add Multiple into Single
|
||||
a = QMediaTimeRange();
|
||||
a.addInterval(10, 30);
|
||||
a.addInterval(40, 60);
|
||||
|
||||
b = QMediaTimeRange(20, 50);
|
||||
|
||||
b.addTimeRange(a);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(b.isContinuous());
|
||||
QVERIFY(b.earliestTime() == 10);
|
||||
QVERIFY(b.latestTime() == 60);
|
||||
|
||||
// Add Single into Multiple
|
||||
a = QMediaTimeRange(20, 50);
|
||||
|
||||
b = QMediaTimeRange();
|
||||
b.addInterval(10, 30);
|
||||
b.addInterval(40, 60);
|
||||
|
||||
b.addTimeRange(a);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(b.isContinuous());
|
||||
QVERIFY(b.earliestTime() == 10);
|
||||
QVERIFY(b.latestTime() == 60);
|
||||
|
||||
// Add Multiple into Multiple
|
||||
a = QMediaTimeRange();
|
||||
a.addInterval(10, 30);
|
||||
a.addInterval(40, 70);
|
||||
a.addInterval(80, 100);
|
||||
|
||||
b = QMediaTimeRange();
|
||||
b.addInterval(20, 50);
|
||||
b.addInterval(60, 90);
|
||||
|
||||
b.addTimeRange(a);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(b.isContinuous());
|
||||
QVERIFY(b.earliestTime() == 10);
|
||||
QVERIFY(b.latestTime() == 100);
|
||||
|
||||
// Add Nothing to Single
|
||||
a = QMediaTimeRange();
|
||||
b = QMediaTimeRange(10, 20);
|
||||
|
||||
b.addTimeRange(a);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(b.isContinuous());
|
||||
QVERIFY(b.earliestTime() == 10);
|
||||
QVERIFY(b.latestTime() == 20);
|
||||
|
||||
// Add Single to Nothing
|
||||
a = QMediaTimeRange(10, 20);
|
||||
b = QMediaTimeRange();
|
||||
|
||||
b.addTimeRange(a);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(b.isContinuous());
|
||||
QVERIFY(b.earliestTime() == 10);
|
||||
QVERIFY(b.latestTime() == 20);
|
||||
|
||||
// Add Nothing to Nothing
|
||||
a = QMediaTimeRange();
|
||||
b = QMediaTimeRange();
|
||||
|
||||
b.addTimeRange(a);
|
||||
|
||||
QVERIFY(b.isEmpty());
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testRemoveInterval()
|
||||
{
|
||||
// Removing an interval, causing a split
|
||||
QMediaTimeRange x;
|
||||
x.addInterval(10, 50);
|
||||
x.removeInterval(20, 40);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(!x.isContinuous());
|
||||
QVERIFY(x.intervals().count() == 2);
|
||||
QVERIFY(x.intervals()[0].start() == 10);
|
||||
QVERIFY(x.intervals()[0].end() == 19);
|
||||
QVERIFY(x.intervals()[1].start() == 41);
|
||||
QVERIFY(x.intervals()[1].end() == 50);
|
||||
|
||||
// Removing an interval, causing a deletion
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(20, 30);
|
||||
x.removeInterval(10, 40);
|
||||
|
||||
QVERIFY(x.isEmpty());
|
||||
|
||||
// Removing an interval, causing a tail trim
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(20, 40);
|
||||
x.removeInterval(30, 50);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.earliestTime() == 20);
|
||||
QVERIFY(x.latestTime() == 29);
|
||||
|
||||
// Removing an interval, causing a head trim
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(20, 40);
|
||||
x.removeInterval(10, 30);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.earliestTime() == 31);
|
||||
QVERIFY(x.latestTime() == 40);
|
||||
|
||||
// Identical Remove
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(10, 20);
|
||||
x.removeInterval(10, 20);
|
||||
|
||||
QVERIFY(x.isEmpty());
|
||||
|
||||
// Multi-Trim
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(10, 20);
|
||||
x.addInterval(30, 40);
|
||||
x.removeInterval(15, 35);
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(!x.isContinuous());
|
||||
QVERIFY(x.intervals().count() == 2);
|
||||
QVERIFY(x.intervals()[0].start() == 10);
|
||||
QVERIFY(x.intervals()[0].end() == 14);
|
||||
QVERIFY(x.intervals()[1].start() == 36);
|
||||
QVERIFY(x.intervals()[1].end() == 40);
|
||||
|
||||
// Multi-Delete
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(10, 20);
|
||||
x.addInterval(30, 40);
|
||||
x.addInterval(50, 60);
|
||||
x.removeInterval(10, 60);
|
||||
|
||||
QVERIFY(x.isEmpty());
|
||||
|
||||
// Interval Parameter - Removing an interval, causing a split
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(10, 50);
|
||||
x.removeInterval(QMediaTimeInterval(20, 40));
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(!x.isContinuous());
|
||||
QVERIFY(x.intervals().count() == 2);
|
||||
QVERIFY(x.intervals()[0].start() == 10);
|
||||
QVERIFY(x.intervals()[0].end() == 19);
|
||||
QVERIFY(x.intervals()[1].start() == 41);
|
||||
QVERIFY(x.intervals()[1].end() == 50);
|
||||
|
||||
// Interval Parameter - Abnormal Interval
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(10, 40);
|
||||
x.removeInterval(QMediaTimeInterval(30, 20));
|
||||
|
||||
QVERIFY(!x.isEmpty());
|
||||
QVERIFY(x.isContinuous());
|
||||
QVERIFY(x.earliestTime() == 10);
|
||||
QVERIFY(x.latestTime() == 40);
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testRemoveTimeRange()
|
||||
{
|
||||
// Remove Time Range uses Remove Interval internally,
|
||||
// so in this test the focus is on combinations of number
|
||||
// of intervals removed, rather than the different types of
|
||||
// deletions which can occur.
|
||||
QMediaTimeRange a, b;
|
||||
|
||||
// Remove Single from Single
|
||||
a = QMediaTimeRange(10, 30);
|
||||
b = QMediaTimeRange(20, 40);
|
||||
|
||||
b.removeTimeRange(a);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(b.isContinuous());
|
||||
QVERIFY(b.earliestTime() == 31);
|
||||
QVERIFY(b.latestTime() == 40);
|
||||
|
||||
// Remove Multiple from Single
|
||||
a = QMediaTimeRange();
|
||||
a.addInterval(10, 30);
|
||||
a.addInterval(40, 60);
|
||||
|
||||
b = QMediaTimeRange(20, 50);
|
||||
|
||||
b.removeTimeRange(a);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(b.isContinuous());
|
||||
QVERIFY(b.earliestTime() == 31);
|
||||
QVERIFY(b.latestTime() == 39);
|
||||
|
||||
// Remove Single from Multiple
|
||||
a = QMediaTimeRange(20, 50);
|
||||
|
||||
b = QMediaTimeRange();
|
||||
b.addInterval(10, 30);
|
||||
b.addInterval(40, 60);
|
||||
|
||||
b.removeTimeRange(a);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(!b.isContinuous());
|
||||
QVERIFY(b.intervals().count() == 2);
|
||||
QVERIFY(b.intervals()[0].start() == 10);
|
||||
QVERIFY(b.intervals()[0].end() == 19);
|
||||
QVERIFY(b.intervals()[1].start() == 51);
|
||||
QVERIFY(b.intervals()[1].end() == 60);
|
||||
|
||||
// Remove Multiple from Multiple
|
||||
a = QMediaTimeRange();
|
||||
a.addInterval(20, 50);
|
||||
a.addInterval(50, 90);
|
||||
|
||||
|
||||
b = QMediaTimeRange();
|
||||
b.addInterval(10, 30);
|
||||
b.addInterval(40, 70);
|
||||
b.addInterval(80, 100);
|
||||
|
||||
b.removeTimeRange(a);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(!b.isContinuous());
|
||||
QVERIFY(b.intervals().count() == 2);
|
||||
QVERIFY(b.intervals()[0].start() == 10);
|
||||
QVERIFY(b.intervals()[0].end() == 19);
|
||||
QVERIFY(b.intervals()[1].start() == 91);
|
||||
QVERIFY(b.intervals()[1].end() == 100);
|
||||
|
||||
// Remove Nothing from Single
|
||||
a = QMediaTimeRange();
|
||||
b = QMediaTimeRange(10, 20);
|
||||
|
||||
b.removeTimeRange(a);
|
||||
|
||||
QVERIFY(!b.isEmpty());
|
||||
QVERIFY(b.isContinuous());
|
||||
QVERIFY(b.earliestTime() == 10);
|
||||
QVERIFY(b.latestTime() == 20);
|
||||
|
||||
// Remove Single from Nothing
|
||||
a = QMediaTimeRange(10, 20);
|
||||
b = QMediaTimeRange();
|
||||
|
||||
b.removeTimeRange(a);
|
||||
|
||||
QVERIFY(b.isEmpty());
|
||||
|
||||
// Remove Nothing from Nothing
|
||||
a = QMediaTimeRange();
|
||||
b = QMediaTimeRange();
|
||||
|
||||
b.removeTimeRange(a);
|
||||
|
||||
QVERIFY(b.isEmpty());
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testClear()
|
||||
{
|
||||
QMediaTimeRange x;
|
||||
|
||||
// Clear Nothing
|
||||
x.clear();
|
||||
|
||||
QVERIFY(x.isEmpty());
|
||||
|
||||
// Clear Single
|
||||
x = QMediaTimeRange(10, 20);
|
||||
x.clear();
|
||||
|
||||
QVERIFY(x.isEmpty());
|
||||
|
||||
// Clear Multiple
|
||||
x = QMediaTimeRange();
|
||||
x.addInterval(10, 20);
|
||||
x.addInterval(30, 40);
|
||||
x.clear();
|
||||
|
||||
QVERIFY(x.isEmpty());
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testComparisons()
|
||||
{
|
||||
// Interval equality
|
||||
QVERIFY(QMediaTimeInterval(10, 20) == QMediaTimeInterval(10, 20));
|
||||
QVERIFY(QMediaTimeInterval(10, 20) != QMediaTimeInterval(10, 30));
|
||||
QVERIFY(!(QMediaTimeInterval(10, 20) != QMediaTimeInterval(10, 20)));
|
||||
QVERIFY(!(QMediaTimeInterval(10, 20) == QMediaTimeInterval(10, 30)));
|
||||
|
||||
// Time range equality - Single Interval
|
||||
QMediaTimeRange a(10, 20), b(20, 30), c(10, 20);
|
||||
|
||||
QVERIFY(a == c);
|
||||
QVERIFY(!(a == b));
|
||||
QVERIFY(a != b);
|
||||
QVERIFY(!(a != c));
|
||||
|
||||
// Time Range Equality - Multiple Intervals
|
||||
QMediaTimeRange x, y, z;
|
||||
|
||||
x.addInterval(10, 20);
|
||||
x.addInterval(30, 40);
|
||||
x.addInterval(50, 60);
|
||||
|
||||
y.addInterval(10, 20);
|
||||
y.addInterval(35, 45);
|
||||
y.addInterval(50, 60);
|
||||
|
||||
z.addInterval(10, 20);
|
||||
z.addInterval(30, 40);
|
||||
z.addInterval(50, 60);
|
||||
|
||||
QVERIFY(x == z);
|
||||
QVERIFY(!(x == y));
|
||||
QVERIFY(x != y);
|
||||
QVERIFY(!(x != z));
|
||||
}
|
||||
|
||||
void tst_QMediaTimeRange::testArithmetic()
|
||||
{
|
||||
QMediaTimeRange a(10, 20), b(20, 30);
|
||||
|
||||
// Test +=
|
||||
a += b;
|
||||
|
||||
QVERIFY(a.isContinuous());
|
||||
QVERIFY(a.earliestTime() == 10);
|
||||
QVERIFY(a.latestTime() == 30);
|
||||
|
||||
// Test -=
|
||||
a -= b;
|
||||
|
||||
QVERIFY(a.isContinuous());
|
||||
QVERIFY(a.earliestTime() == 10);
|
||||
QVERIFY(a.latestTime() == 19);
|
||||
|
||||
// Test += and -= on intervals
|
||||
a -= QMediaTimeInterval(10, 20);
|
||||
a += QMediaTimeInterval(40, 50);
|
||||
|
||||
QVERIFY(a.isContinuous());
|
||||
QVERIFY(a.earliestTime() == 40);
|
||||
QVERIFY(a.latestTime() == 50);
|
||||
|
||||
// Test Interval + Interval
|
||||
a = QMediaTimeInterval(10, 20) + QMediaTimeInterval(20, 30);
|
||||
QVERIFY(a.isContinuous());
|
||||
QVERIFY(a.earliestTime() == 10);
|
||||
QVERIFY(a.latestTime() == 30);
|
||||
|
||||
// Test Range + Interval
|
||||
a = a + QMediaTimeInterval(30, 40);
|
||||
QVERIFY(a.isContinuous());
|
||||
QVERIFY(a.earliestTime() == 10);
|
||||
QVERIFY(a.latestTime() == 40);
|
||||
|
||||
// Test Interval + Range
|
||||
a = QMediaTimeInterval(40, 50) + a;
|
||||
QVERIFY(a.isContinuous());
|
||||
QVERIFY(a.earliestTime() == 10);
|
||||
QVERIFY(a.latestTime() == 50);
|
||||
|
||||
// Test Range + Range
|
||||
a = a + QMediaTimeRange(50, 60);
|
||||
QVERIFY(a.isContinuous());
|
||||
QVERIFY(a.earliestTime() == 10);
|
||||
QVERIFY(a.latestTime() == 60);
|
||||
|
||||
// Test Range - Interval
|
||||
a = a - QMediaTimeInterval(50, 60);
|
||||
QVERIFY(a.isContinuous());
|
||||
QVERIFY(a.earliestTime() == 10);
|
||||
QVERIFY(a.latestTime() == 49);
|
||||
|
||||
// Test Range - Range
|
||||
a = a - QMediaTimeRange(40, 50);
|
||||
QVERIFY(a.isContinuous());
|
||||
QVERIFY(a.earliestTime() == 10);
|
||||
QVERIFY(a.latestTime() == 39);
|
||||
|
||||
// Test Interval - Range
|
||||
b = QMediaTimeInterval(0, 20) - a;
|
||||
QVERIFY(b.isContinuous());
|
||||
QVERIFY(b.earliestTime() == 0);
|
||||
QVERIFY(b.latestTime() == 9);
|
||||
|
||||
// Test Interval - Interval
|
||||
a = QMediaTimeInterval(10, 20) - QMediaTimeInterval(15, 30);
|
||||
QVERIFY(a.isContinuous());
|
||||
QVERIFY(a.earliestTime() == 10);
|
||||
QVERIFY(a.latestTime() == 14);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMediaTimeRange)
|
||||
|
||||
#include "tst_qmediatimerange.moc"
|
||||
@@ -0,0 +1,10 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmetadatareadercontrol
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qmetadatareadercontrol.cpp
|
||||
|
||||
include (../qmultimedia_common/mockcontainer.pri)
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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/QString>
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
#include "mockmetadatareadercontrol.h"
|
||||
|
||||
class tst_QMetaDataReaderControl : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
// Test case for QMetaDataReaderControl
|
||||
void metaDataReaderControlConstructor();
|
||||
void metaDataReaderControlAvailableMetaData();
|
||||
void metaDataReaderControlExtendedMetaData();
|
||||
void metaDataReaderControlIsMetaDataAvailable();
|
||||
void metaDataReaderControlMetaData();
|
||||
void metaDataReaderControlAvailableExtendedMetaData();
|
||||
void metaDataReaderControlMetaDataAvailableChangedSignal();
|
||||
void metaDataReaderControlMetaDataChangedSignal();
|
||||
};
|
||||
|
||||
QTEST_MAIN(tst_QMetaDataReaderControl);
|
||||
|
||||
/* Test case for constructor. */
|
||||
void tst_QMetaDataReaderControl::metaDataReaderControlConstructor()
|
||||
{
|
||||
MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
|
||||
QVERIFY(metaData !=NULL);
|
||||
delete metaData;
|
||||
}
|
||||
|
||||
/* Test case for availableMetaData() */
|
||||
void tst_QMetaDataReaderControl::metaDataReaderControlAvailableMetaData()
|
||||
{
|
||||
MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
|
||||
QVERIFY(metaData !=NULL);
|
||||
metaData->availableMetaData() ;
|
||||
delete metaData;
|
||||
}
|
||||
|
||||
/* Test case for extendedMetaData */
|
||||
void tst_QMetaDataReaderControl::metaDataReaderControlExtendedMetaData ()
|
||||
{
|
||||
const QString titleKey(QLatin1String("Title"));
|
||||
MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
|
||||
QVERIFY(metaData !=NULL);
|
||||
metaData->extendedMetaData(titleKey);
|
||||
delete metaData;
|
||||
}
|
||||
|
||||
/* Test case for availableMetaData */
|
||||
void tst_QMetaDataReaderControl::metaDataReaderControlIsMetaDataAvailable ()
|
||||
{
|
||||
MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
|
||||
QVERIFY(metaData !=NULL);
|
||||
metaData->availableMetaData();
|
||||
delete metaData;
|
||||
}
|
||||
|
||||
/* Test case for metaData */
|
||||
void tst_QMetaDataReaderControl::metaDataReaderControlMetaData ()
|
||||
{
|
||||
MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
|
||||
QVERIFY(metaData !=NULL);
|
||||
metaData->metaData(QtMultimedia::Title);
|
||||
delete metaData;
|
||||
}
|
||||
|
||||
/* Test case for availableExtendedMetaData */
|
||||
void tst_QMetaDataReaderControl::metaDataReaderControlAvailableExtendedMetaData ()
|
||||
{
|
||||
MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
|
||||
QVERIFY(metaData !=NULL);
|
||||
metaData->availableExtendedMetaData();
|
||||
delete metaData;
|
||||
}
|
||||
|
||||
/* Test case for signal metaDataAvailableChanged */
|
||||
void tst_QMetaDataReaderControl::metaDataReaderControlMetaDataAvailableChangedSignal ()
|
||||
{
|
||||
MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
|
||||
QVERIFY(metaData !=NULL);
|
||||
QSignalSpy spy(metaData,SIGNAL(metaDataAvailableChanged(bool)));
|
||||
metaData->setMetaDataAvailable(true);
|
||||
QVERIFY(spy.count() == 1);
|
||||
delete metaData;
|
||||
}
|
||||
|
||||
/* Test case for signal metaDataChanged */
|
||||
void tst_QMetaDataReaderControl::metaDataReaderControlMetaDataChangedSignal ()
|
||||
{
|
||||
MockMetaDataReaderControl *metaData = new MockMetaDataReaderControl();
|
||||
QVERIFY(metaData !=NULL);
|
||||
QSignalSpy spy(metaData,SIGNAL(metaDataChanged()));
|
||||
metaData->metaDataChanged();
|
||||
QVERIFY(spy.count () == 1);
|
||||
delete metaData;
|
||||
}
|
||||
|
||||
#include "tst_qmetadatareadercontrol.moc"
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qmetadatawritercontrol
|
||||
|
||||
QT += multimedia-private testlib
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
SOURCES += tst_qmetadatawritercontrol.cpp
|
||||
|
||||
include (../qmultimedia_common/mockcontainer.pri)
|
||||
@@ -0,0 +1,89 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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/QString>
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include "qmetadatawritercontrol.h"
|
||||
|
||||
#include "mockmetadatawritercontrol.h"
|
||||
|
||||
class tst_QMetaDataWriterControl: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
void constructor();
|
||||
};
|
||||
|
||||
void tst_QMetaDataWriterControl::initTestCase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void tst_QMetaDataWriterControl::cleanupTestCase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//MaemoAPI-1862:test constructor
|
||||
void tst_QMetaDataWriterControl::constructor()
|
||||
{
|
||||
QMetaDataWriterControl *mock = new MockMetaDataWriterControl();
|
||||
mock->availableExtendedMetaData();
|
||||
mock->availableMetaData();
|
||||
mock->isMetaDataAvailable();
|
||||
mock->isWritable();
|
||||
mock->metaData((QtMultimedia::MetaData) 1 );
|
||||
mock->extendedMetaData(QString("XYZ"));
|
||||
mock->setExtendedMetaData(QString("XYZ"),QVariant());
|
||||
mock->setMetaData((QtMultimedia::MetaData) 1,QVariant());
|
||||
((MockMetaDataWriterControl*)mock)->setWritable();
|
||||
((MockMetaDataWriterControl*)mock)->setMetaDataAvailable();
|
||||
delete mock;
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QMetaDataWriterControl);
|
||||
|
||||
#include "tst_qmetadatawritercontrol.moc"
|
||||
7
tests/auto/unit/qmultimedia_common/mock.pri
Normal file
7
tests/auto/unit/qmultimedia_common/mock.pri
Normal file
@@ -0,0 +1,7 @@
|
||||
INCLUDEPATH += $$PWD \
|
||||
../../../src/multimedia \
|
||||
|
||||
HEADERS *= \
|
||||
../qmultimedia_common/mockmediaserviceprovider.h \
|
||||
../qmultimedia_common/mockmediaservice.h \
|
||||
../qmultimedia_common/mockmediaobject.h
|
||||
127
tests/auto/unit/qmultimedia_common/mockaudioencodercontrol.h
Normal file
127
tests/auto/unit/qmultimedia_common/mockaudioencodercontrol.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKAUDIOENCODERCONTROL_H
|
||||
#define MOCKAUDIOENCODERCONTROL_H
|
||||
|
||||
#include "qaudioencodercontrol.h"
|
||||
|
||||
class MockAudioEncoderControl : public QAudioEncoderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockAudioEncoderControl(QObject *parent):
|
||||
QAudioEncoderControl(parent)
|
||||
{
|
||||
m_codecs << "audio/pcm" << "audio/mpeg";
|
||||
m_descriptions << "Pulse Code Modulation" << "mp3 format";
|
||||
m_supportedEncodeOptions.insert("audio/pcm", QStringList());
|
||||
m_supportedEncodeOptions.insert("audio/mpeg", QStringList() << "quality" << "bitrate" << "mode" << "vbr");
|
||||
m_audioSettings.setCodec("audio/pcm");
|
||||
m_audioSettings.setBitRate(128*1024);
|
||||
m_audioSettings.setSampleRate(8000);
|
||||
m_freqs << 8000 << 11025 << 22050 << 44100;
|
||||
}
|
||||
|
||||
~MockAudioEncoderControl() {}
|
||||
|
||||
QAudioEncoderSettings audioSettings() const
|
||||
{
|
||||
return m_audioSettings;
|
||||
}
|
||||
|
||||
void setAudioSettings(const QAudioEncoderSettings &settings)
|
||||
{
|
||||
m_audioSettings = settings;
|
||||
}
|
||||
|
||||
QList<int> supportedChannelCounts(const QAudioEncoderSettings & = QAudioEncoderSettings()) const
|
||||
{
|
||||
QList<int> list; list << 1 << 2; return list;
|
||||
}
|
||||
|
||||
QList<int> supportedSampleRates(const QAudioEncoderSettings & = QAudioEncoderSettings(), bool *continuous = 0) const
|
||||
{
|
||||
if (continuous)
|
||||
*continuous = false;
|
||||
|
||||
return m_freqs;
|
||||
}
|
||||
|
||||
QStringList supportedAudioCodecs() const
|
||||
{
|
||||
return m_codecs;
|
||||
}
|
||||
|
||||
QString codecDescription(const QString &codecName) const
|
||||
{
|
||||
return m_descriptions.value(m_codecs.indexOf(codecName));
|
||||
}
|
||||
|
||||
QStringList supportedEncodingOptions(const QString &codec) const
|
||||
{
|
||||
return m_supportedEncodeOptions.value(codec);
|
||||
}
|
||||
|
||||
QVariant encodingOption(const QString &codec, const QString &name) const
|
||||
{
|
||||
return m_encodeOptions[codec].value(name);
|
||||
}
|
||||
|
||||
void setEncodingOption(const QString &codec, const QString &name, const QVariant &value)
|
||||
{
|
||||
m_encodeOptions[codec][name] = value;
|
||||
}
|
||||
|
||||
private:
|
||||
QAudioEncoderSettings m_audioSettings;
|
||||
|
||||
QStringList m_codecs;
|
||||
QStringList m_descriptions;
|
||||
|
||||
QList<int> m_freqs;
|
||||
|
||||
QMap<QString, QStringList> m_supportedEncodeOptions;
|
||||
QMap<QString, QMap<QString, QVariant> > m_encodeOptions;
|
||||
|
||||
};
|
||||
|
||||
#endif // MOCKAUDIOENCODERCONTROL_H
|
||||
117
tests/auto/unit/qmultimedia_common/mockaudioendpointselector.h
Normal file
117
tests/auto/unit/qmultimedia_common/mockaudioendpointselector.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKAUDIOENDPOINTSELECTOR_H
|
||||
#define MOCKAUDIOENDPOINTSELECTOR_H
|
||||
|
||||
#include "qaudioendpointselector.h"
|
||||
|
||||
class MockAudioEndpointSelector : public QAudioEndpointSelector
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockAudioEndpointSelector(QObject *parent):
|
||||
QAudioEndpointSelector(parent)
|
||||
{
|
||||
m_names << "device1" << "device2" << "device3";
|
||||
m_descriptions << "dev1 comment" << "dev2 comment" << "dev3 comment";
|
||||
m_audioInput = "device1";
|
||||
emit availableEndpointsChanged();
|
||||
}
|
||||
~MockAudioEndpointSelector() {}
|
||||
|
||||
QList<QString> availableEndpoints() const
|
||||
{
|
||||
return m_names;
|
||||
}
|
||||
|
||||
QString endpointDescription(const QString& name) const
|
||||
{
|
||||
QString desc;
|
||||
|
||||
for (int i = 0; i < m_names.count(); i++) {
|
||||
if (m_names.at(i).compare(name) == 0) {
|
||||
desc = m_descriptions.at(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
QString defaultEndpoint() const
|
||||
{
|
||||
return m_names.at(0);
|
||||
}
|
||||
|
||||
QString activeEndpoint() const
|
||||
{
|
||||
return m_audioInput;
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
void setActiveEndpoint(const QString& name)
|
||||
{
|
||||
m_audioInput = name;
|
||||
emit activeEndpointChanged(name);
|
||||
}
|
||||
|
||||
void addEndpoints()
|
||||
{
|
||||
m_names << "device4";
|
||||
emit availableEndpointsChanged();
|
||||
}
|
||||
|
||||
void removeEndpoints()
|
||||
{
|
||||
m_names.clear();
|
||||
emit availableEndpointsChanged();
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_audioInput;
|
||||
QList<QString> m_names;
|
||||
QList<QString> m_descriptions;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // MOCKAUDIOENDPOINTSELECTOR_H
|
||||
22
tests/auto/unit/qmultimedia_common/mockcamera.pri
Normal file
22
tests/auto/unit/qmultimedia_common/mockcamera.pri
Normal file
@@ -0,0 +1,22 @@
|
||||
# Camera related mock backend files
|
||||
INCLUDEPATH += $$PWD \
|
||||
../../../src/multimedia \
|
||||
../../../src/multimedia/video \
|
||||
../../../src/multimedia/camera
|
||||
|
||||
HEADERS *= \
|
||||
../qmultimedia_common/mockcameraservice.h \
|
||||
../qmultimedia_common/mockcameraflashcontrol.h \
|
||||
../qmultimedia_common/mockcameralockscontrol.h \
|
||||
../qmultimedia_common/mockcamerafocuscontrol.h \
|
||||
../qmultimedia_common/mockcameraimageprocessingcontrol.h \
|
||||
../qmultimedia_common/mockcameraimagecapturecontrol.h \
|
||||
../qmultimedia_common/mockcameraexposurecontrol.h \
|
||||
../qmultimedia_common/mockcameracapturedestinationcontrol.h \
|
||||
../qmultimedia_common/mockcameracapturebuffercontrol.h \
|
||||
../qmultimedia_common/mockimageencodercontrol.h \
|
||||
../qmultimedia_common/mockcameracontrol.h \
|
||||
|
||||
|
||||
include(mockvideo.pri)
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKCAMERACAPTUREBUFFERCONTROL_H
|
||||
#define MOCKCAMERACAPTUREBUFFERCONTROL_H
|
||||
|
||||
#include "qcameracapturebufferformatcontrol.h"
|
||||
|
||||
class MockCaptureBufferFormatControl : public QCameraCaptureBufferFormatControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockCaptureBufferFormatControl(QObject *parent = 0):
|
||||
QCameraCaptureBufferFormatControl(parent),
|
||||
m_format(QVideoFrame::Format_Jpeg)
|
||||
{
|
||||
}
|
||||
|
||||
QList<QVideoFrame::PixelFormat> supportedBufferFormats() const
|
||||
{
|
||||
return QList<QVideoFrame::PixelFormat>()
|
||||
<< QVideoFrame::Format_Jpeg
|
||||
<< QVideoFrame::Format_RGB32
|
||||
<< QVideoFrame::Format_AdobeDng;
|
||||
}
|
||||
|
||||
QVideoFrame::PixelFormat bufferFormat() const
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
|
||||
void setBufferFormat(QVideoFrame::PixelFormat format)
|
||||
{
|
||||
if (format != m_format && supportedBufferFormats().contains(format)) {
|
||||
m_format = format;
|
||||
emit bufferFormatChanged(m_format);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
QVideoFrame::PixelFormat m_format;
|
||||
};
|
||||
|
||||
|
||||
#endif // MOCKCAMERACAPTUREBUFFERCONTROL_H
|
||||
@@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKCAMERACAPTUREDESTINATIONCONTROL_H
|
||||
#define MOCKCAMERACAPTUREDESTINATIONCONTROL_H
|
||||
|
||||
#include "qcameracapturedestinationcontrol.h"
|
||||
|
||||
class MockCaptureDestinationControl : public QCameraCaptureDestinationControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockCaptureDestinationControl(QObject *parent = 0):
|
||||
QCameraCaptureDestinationControl(parent),
|
||||
m_destination(QCameraImageCapture::CaptureToFile)
|
||||
{
|
||||
}
|
||||
|
||||
bool isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const
|
||||
{
|
||||
return destination == QCameraImageCapture::CaptureToBuffer ||
|
||||
destination == QCameraImageCapture::CaptureToFile;
|
||||
}
|
||||
|
||||
QCameraImageCapture::CaptureDestinations captureDestination() const
|
||||
{
|
||||
return m_destination;
|
||||
}
|
||||
|
||||
void setCaptureDestination(QCameraImageCapture::CaptureDestinations destination)
|
||||
{
|
||||
if (isCaptureDestinationSupported(destination) && destination != m_destination) {
|
||||
m_destination = destination;
|
||||
emit captureDestinationChanged(m_destination);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
QCameraImageCapture::CaptureDestinations m_destination;
|
||||
};
|
||||
|
||||
#endif // MOCKCAMERACAPTUREDESTINATIONCONTROL_H
|
||||
145
tests/auto/unit/qmultimedia_common/mockcameracontrol.h
Normal file
145
tests/auto/unit/qmultimedia_common/mockcameracontrol.h
Normal file
@@ -0,0 +1,145 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKCAMERACONTROL_H
|
||||
#define MOCKCAMERACONTROL_H
|
||||
|
||||
#include "qcameracontrol.h"
|
||||
|
||||
class MockCameraControl : public QCameraControl
|
||||
{
|
||||
friend class MockCaptureControl;
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockCameraControl(QObject *parent = 0):
|
||||
QCameraControl(parent),
|
||||
m_state(QCamera::UnloadedState),
|
||||
m_captureMode(QCamera::CaptureStillImage),
|
||||
m_status(QCamera::UnloadedStatus),
|
||||
m_propertyChangesSupported(false)
|
||||
{
|
||||
}
|
||||
|
||||
~MockCameraControl() {}
|
||||
|
||||
void start() { m_state = QCamera::ActiveState; }
|
||||
virtual void stop() { m_state = QCamera::UnloadedState; }
|
||||
QCamera::State state() const { return m_state; }
|
||||
void setState(QCamera::State state) {
|
||||
if (m_state != state) {
|
||||
m_state = state;
|
||||
|
||||
switch (state) {
|
||||
case QCamera::UnloadedState:
|
||||
m_status = QCamera::UnloadedStatus;
|
||||
break;
|
||||
case QCamera::LoadedState:
|
||||
m_status = QCamera::LoadedStatus;
|
||||
break;
|
||||
case QCamera::ActiveState:
|
||||
m_status = QCamera::ActiveStatus;
|
||||
break;
|
||||
default:
|
||||
emit error(QCamera::NotSupportedFeatureError, "State not supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
emit stateChanged(m_state);
|
||||
emit statusChanged(m_status);
|
||||
}
|
||||
}
|
||||
|
||||
QCamera::Status status() const { return m_status; }
|
||||
|
||||
QCamera::CaptureMode captureMode() const { return m_captureMode; }
|
||||
void setCaptureMode(QCamera::CaptureMode mode)
|
||||
{
|
||||
if (m_captureMode != mode) {
|
||||
if (m_state == QCamera::ActiveState && !m_propertyChangesSupported)
|
||||
return;
|
||||
m_captureMode = mode;
|
||||
emit captureModeChanged(mode);
|
||||
}
|
||||
}
|
||||
|
||||
bool isCaptureModeSupported(QCamera::CaptureMode mode) const
|
||||
{
|
||||
return mode == QCamera::CaptureStillImage || mode == QCamera::CaptureVideo;
|
||||
}
|
||||
|
||||
QCamera::LockTypes supportedLocks() const
|
||||
{
|
||||
return QCamera::LockExposure | QCamera::LockFocus | QCamera::LockWhiteBalance;
|
||||
}
|
||||
|
||||
bool canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const
|
||||
{
|
||||
Q_UNUSED(status);
|
||||
if (changeType == QCameraControl::ImageEncodingSettings && m_captureMode == QCamera::CaptureVideo)
|
||||
return true;
|
||||
else if (changeType== QCameraControl::VideoEncodingSettings)
|
||||
return true;
|
||||
else
|
||||
return m_propertyChangesSupported;
|
||||
}
|
||||
|
||||
/* helper method to emit the signal error */
|
||||
void setError(QCamera::Error err, QString errorString)
|
||||
{
|
||||
emit error(err, errorString);
|
||||
}
|
||||
|
||||
/* helper method to emit the signal statusChaged */
|
||||
void setStatus(QCamera::Status newStatus)
|
||||
{
|
||||
m_status = newStatus;
|
||||
emit statusChanged(newStatus);
|
||||
}
|
||||
|
||||
QCamera::State m_state;
|
||||
QCamera::CaptureMode m_captureMode;
|
||||
QCamera::Status m_status;
|
||||
bool m_propertyChangesSupported;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // MOCKCAMERACONTROL_H
|
||||
282
tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h
Normal file
282
tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h
Normal file
@@ -0,0 +1,282 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKCAMERAEXPOSURECONTROL_H
|
||||
#define MOCKCAMERAEXPOSURECONTROL_H
|
||||
|
||||
#include "qcameraexposurecontrol.h"
|
||||
|
||||
class MockCameraExposureControl : public QCameraExposureControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockCameraExposureControl(QObject *parent = 0):
|
||||
QCameraExposureControl(parent),
|
||||
m_aperture(2.8),
|
||||
m_shutterSpeed(0.01),
|
||||
m_isoSensitivity(100),
|
||||
m_meteringMode(QCameraExposure::MeteringMatrix),
|
||||
m_exposureCompensation(0),
|
||||
m_exposureMode(QCameraExposure::ExposureAuto),
|
||||
m_flashMode(QCameraExposure::FlashAuto)
|
||||
{
|
||||
m_isoRanges << 100 << 200 << 400 << 800;
|
||||
m_apertureRanges << 2.8 << 4.0 << 5.6 << 8.0 << 11.0 << 16.0;
|
||||
m_shutterRanges << 0.001 << 0.01 << 0.1 << 1.0;
|
||||
m_exposureRanges << -2.0 << 2.0;
|
||||
}
|
||||
|
||||
~MockCameraExposureControl() {}
|
||||
|
||||
QCameraExposure::FlashModes flashMode() const {return m_flashMode;}
|
||||
|
||||
void setFlashMode(QCameraExposure::FlashModes mode)
|
||||
{
|
||||
if (isFlashModeSupported(mode)) {
|
||||
m_flashMode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
bool isFlashModeSupported(QCameraExposure::FlashModes mode) const
|
||||
{
|
||||
return mode & (QCameraExposure::FlashAuto | QCameraExposure::FlashOff | QCameraExposure::FlashOn);
|
||||
}
|
||||
|
||||
bool isFlashReady() const { return true;}
|
||||
|
||||
QCameraExposure::ExposureMode exposureMode() const { return m_exposureMode; }
|
||||
|
||||
void setExposureMode(QCameraExposure::ExposureMode mode)
|
||||
{
|
||||
if (isExposureModeSupported(mode))
|
||||
m_exposureMode = mode;
|
||||
}
|
||||
|
||||
//Setting the Exposure Mode Supported Enum values
|
||||
bool isExposureModeSupported(QCameraExposure::ExposureMode mode) const
|
||||
{
|
||||
return ( mode == QCameraExposure::ExposureAuto || mode == QCameraExposure::ExposureManual || mode == QCameraExposure::ExposureBacklight ||
|
||||
mode == QCameraExposure::ExposureNight || mode == QCameraExposure::ExposureSpotlight ||mode == QCameraExposure::ExposureSports ||
|
||||
mode == QCameraExposure::ExposureSnow || mode == QCameraExposure:: ExposureLargeAperture ||mode == QCameraExposure::ExposureSmallAperture ||
|
||||
mode == QCameraExposure::ExposurePortrait || mode == QCameraExposure::ExposureModeVendor ||mode == QCameraExposure::ExposureBeach );
|
||||
}
|
||||
|
||||
bool isParameterSupported(ExposureParameter parameter) const
|
||||
{
|
||||
switch (parameter) {
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
case QCameraExposureControl::ISO:
|
||||
case QCameraExposureControl::Aperture:
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant exposureParameter(ExposureParameter parameter) const
|
||||
{
|
||||
switch (parameter) {
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
return QVariant(m_exposureCompensation);
|
||||
case QCameraExposureControl::ISO:
|
||||
return QVariant(m_isoSensitivity);
|
||||
case QCameraExposureControl::Aperture:
|
||||
return QVariant(m_aperture);
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
return QVariant(m_shutterSpeed);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
QVariantList supportedParameterRange(ExposureParameter parameter) const
|
||||
{
|
||||
QVariantList res;
|
||||
switch (parameter) {
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
return m_exposureRanges;
|
||||
case QCameraExposureControl::ISO:
|
||||
return m_isoRanges;
|
||||
case QCameraExposureControl::Aperture:
|
||||
return m_apertureRanges;
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
return m_shutterRanges;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ParameterFlags exposureParameterFlags(ExposureParameter parameter) const
|
||||
{
|
||||
ParameterFlags res = 0;
|
||||
switch (parameter) {
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
case QCameraExposureControl::Aperture:
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
res |= ContinuousRange;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// Added exposureParameterChanged and exposureParameterRangeChanged signal
|
||||
bool setExposureParameter(ExposureParameter parameter, const QVariant& value)
|
||||
{
|
||||
switch (parameter) {
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
{
|
||||
m_res.clear();
|
||||
m_res << -4.0 << 4.0;
|
||||
qreal exposureCompensationlocal = qBound<qreal>(-2.0, value.toReal(), 2.0);
|
||||
if (exposureParameter(parameter).toReal() != exposureCompensationlocal) {
|
||||
m_exposureCompensation = exposureCompensationlocal;
|
||||
emit exposureParameterChanged(parameter);
|
||||
}
|
||||
|
||||
if (m_exposureRanges.last().toReal() != m_res.last().toReal()) {
|
||||
m_exposureRanges.clear();
|
||||
m_exposureRanges = m_res;
|
||||
emit exposureParameterRangeChanged(parameter);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QCameraExposureControl::ISO:
|
||||
{
|
||||
m_res.clear();
|
||||
m_res << 20 << 50;
|
||||
qreal exposureCompensationlocal = 100*qRound(qBound(100, value.toInt(), 800)/100.0);
|
||||
if (exposureParameter(parameter).toReal() != exposureCompensationlocal) {
|
||||
m_isoSensitivity = exposureCompensationlocal;
|
||||
emit exposureParameterChanged(parameter);
|
||||
}
|
||||
|
||||
if (m_isoRanges.last().toInt() != m_res.last().toInt()) {
|
||||
m_isoRanges.clear();
|
||||
m_isoRanges = m_res;
|
||||
emit exposureParameterRangeChanged(parameter);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QCameraExposureControl::Aperture:
|
||||
{
|
||||
m_res.clear();
|
||||
m_res << 12.0 << 18.0 << 20.0;
|
||||
qreal exposureCompensationlocal = qBound<qreal>(2.8, value.toReal(), 16.0);
|
||||
if (exposureParameter(parameter).toReal() != exposureCompensationlocal) {
|
||||
m_aperture = exposureCompensationlocal;
|
||||
emit exposureParameterChanged(parameter);
|
||||
}
|
||||
|
||||
if (m_apertureRanges.last().toReal() != m_res.last().toReal()) {
|
||||
m_apertureRanges.clear();
|
||||
m_apertureRanges = m_res;
|
||||
emit exposureParameterRangeChanged(parameter);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
{
|
||||
m_res.clear();
|
||||
m_res << 0.12 << 1.0 << 2.0;
|
||||
qreal exposureCompensationlocal = qBound<qreal>(0.001, value.toReal(), 1.0);
|
||||
if (exposureParameter(parameter).toReal() != exposureCompensationlocal) {
|
||||
m_shutterSpeed = exposureCompensationlocal;
|
||||
emit exposureParameterChanged(parameter);
|
||||
}
|
||||
|
||||
if (m_shutterRanges.last().toReal() != m_res.last().toReal()) {
|
||||
m_shutterRanges.clear();
|
||||
m_shutterRanges = m_res;
|
||||
emit exposureParameterRangeChanged(parameter);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
emit flashReady(true); // depends on Flashcontrol
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString extendedParameterName(ExposureParameter)
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QCameraExposure::MeteringMode meteringMode() const
|
||||
{
|
||||
return m_meteringMode;
|
||||
}
|
||||
|
||||
void setMeteringMode(QCameraExposure::MeteringMode mode)
|
||||
{
|
||||
if (isMeteringModeSupported(mode))
|
||||
m_meteringMode = mode;
|
||||
}
|
||||
|
||||
//Setting the values for metering mode
|
||||
bool isMeteringModeSupported(QCameraExposure::MeteringMode mode) const
|
||||
{
|
||||
return mode == QCameraExposure::MeteringAverage
|
||||
|| mode == QCameraExposure::MeteringMatrix
|
||||
|| mode == QCameraExposure::MeteringAverage
|
||||
|| mode ==QCameraExposure::MeteringSpot;
|
||||
}
|
||||
|
||||
private:
|
||||
qreal m_aperture;
|
||||
qreal m_shutterSpeed;
|
||||
int m_isoSensitivity;
|
||||
QCameraExposure::MeteringMode m_meteringMode;
|
||||
qreal m_exposureCompensation;
|
||||
QCameraExposure::ExposureMode m_exposureMode;
|
||||
QCameraExposure::FlashModes m_flashMode;
|
||||
QVariantList m_isoRanges,m_apertureRanges, m_shutterRanges, m_exposureRanges, m_res;
|
||||
};
|
||||
|
||||
#endif // MOCKCAMERAEXPOSURECONTROL_H
|
||||
89
tests/auto/unit/qmultimedia_common/mockcameraflashcontrol.h
Normal file
89
tests/auto/unit/qmultimedia_common/mockcameraflashcontrol.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKCAMERAFLASHCONTROL_H
|
||||
#define MOCKCAMERAFLASHCONTROL_H
|
||||
|
||||
#include "qcameraflashcontrol.h"
|
||||
|
||||
class MockCameraFlashControl : public QCameraFlashControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockCameraFlashControl(QObject *parent = 0):
|
||||
QCameraFlashControl(parent),
|
||||
m_flashMode(QCameraExposure::FlashAuto)
|
||||
{
|
||||
}
|
||||
|
||||
~MockCameraFlashControl() {}
|
||||
|
||||
QCameraExposure::FlashModes flashMode() const
|
||||
{
|
||||
return m_flashMode;
|
||||
}
|
||||
|
||||
void setFlashMode(QCameraExposure::FlashModes mode)
|
||||
{
|
||||
if (isFlashModeSupported(mode)) {
|
||||
m_flashMode = mode;
|
||||
}
|
||||
emit flashReady(true);
|
||||
}
|
||||
//Setting the values for Flash mode
|
||||
|
||||
bool isFlashModeSupported(QCameraExposure::FlashModes mode) const
|
||||
{
|
||||
return (mode || (QCameraExposure::FlashAuto | QCameraExposure::FlashOff | QCameraExposure::FlashOn |
|
||||
QCameraExposure::FlashFill |QCameraExposure::FlashTorch |QCameraExposure::FlashSlowSyncFrontCurtain |
|
||||
QCameraExposure::FlashRedEyeReduction));
|
||||
}
|
||||
|
||||
bool isFlashReady() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
QCameraExposure::FlashModes m_flashMode;
|
||||
};
|
||||
|
||||
#endif // MOCKCAMERAFLASHCONTROL_H
|
||||
199
tests/auto/unit/qmultimedia_common/mockcamerafocuscontrol.h
Normal file
199
tests/auto/unit/qmultimedia_common/mockcamerafocuscontrol.h
Normal file
@@ -0,0 +1,199 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKCAMERAFOCUSCONTROL_H
|
||||
#define MOCKCAMERAFOCUSCONTROL_H
|
||||
|
||||
#include "qcamerafocuscontrol.h"
|
||||
#include "qcamerafocus.h"
|
||||
|
||||
class MockCameraFocusControl : public QCameraFocusControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockCameraFocusControl(QObject *parent = 0):
|
||||
QCameraFocusControl(parent),
|
||||
m_opticalZoom(1.0),
|
||||
m_digitalZoom(1.0),
|
||||
m_focusMode(QCameraFocus::AutoFocus),
|
||||
m_focusPointMode(QCameraFocus::FocusPointAuto),
|
||||
m_focusPoint(0.5, 0.5),
|
||||
m_maxOpticalZoom(3.0),
|
||||
m_maxDigitalZoom(4.0)
|
||||
|
||||
{
|
||||
m_zones << QCameraFocusZone(QRectF(0.45, 0.45, 0.1, 0.1));
|
||||
}
|
||||
|
||||
~MockCameraFocusControl() {}
|
||||
|
||||
QCameraFocus::FocusMode focusMode() const
|
||||
{
|
||||
return m_focusMode;
|
||||
}
|
||||
|
||||
void setFocusMode(QCameraFocus::FocusMode mode)
|
||||
{
|
||||
if (isFocusModeSupported(mode))
|
||||
m_focusMode = mode;
|
||||
}
|
||||
|
||||
bool isFocusModeSupported(QCameraFocus::FocusMode mode) const
|
||||
{
|
||||
return mode == QCameraFocus::AutoFocus || mode == QCameraFocus::ContinuousFocus;
|
||||
}
|
||||
|
||||
qreal maximumOpticalZoom() const
|
||||
{
|
||||
return m_maxOpticalZoom;
|
||||
}
|
||||
|
||||
qreal maximumDigitalZoom() const
|
||||
{
|
||||
return m_maxDigitalZoom;
|
||||
}
|
||||
|
||||
qreal opticalZoom() const
|
||||
{
|
||||
return m_opticalZoom;
|
||||
}
|
||||
|
||||
qreal digitalZoom() const
|
||||
{
|
||||
return m_digitalZoom;
|
||||
}
|
||||
|
||||
void zoomTo(qreal optical, qreal digital)
|
||||
{
|
||||
optical = qBound<qreal>(1.0, optical, maximumOpticalZoom());
|
||||
digital = qBound<qreal>(1.0, digital, maximumDigitalZoom());
|
||||
|
||||
if (!qFuzzyCompare(digital, m_digitalZoom)) {
|
||||
m_digitalZoom = digital;
|
||||
emit digitalZoomChanged(m_digitalZoom);
|
||||
}
|
||||
|
||||
if (!qFuzzyCompare(optical, m_opticalZoom)) {
|
||||
m_opticalZoom = optical;
|
||||
emit opticalZoomChanged(m_opticalZoom);
|
||||
}
|
||||
|
||||
maxOpticalDigitalZoomChange(4.0, 5.0);
|
||||
focusZonesChange(0.50, 0.50, 0.3, 0.3);
|
||||
}
|
||||
|
||||
QCameraFocus::FocusPointMode focusPointMode() const
|
||||
{
|
||||
return m_focusPointMode;
|
||||
}
|
||||
|
||||
void setFocusPointMode(QCameraFocus::FocusPointMode mode)
|
||||
{
|
||||
if (isFocusPointModeSupported(mode))
|
||||
m_focusPointMode = mode;
|
||||
}
|
||||
|
||||
bool isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const
|
||||
{
|
||||
switch (mode) {
|
||||
case QCameraFocus::FocusPointAuto:
|
||||
case QCameraFocus::FocusPointCenter:
|
||||
case QCameraFocus::FocusPointCustom:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QPointF customFocusPoint() const
|
||||
{
|
||||
return m_focusPoint;
|
||||
}
|
||||
|
||||
void setCustomFocusPoint(const QPointF &point)
|
||||
{
|
||||
m_focusPoint = point;
|
||||
}
|
||||
|
||||
QCameraFocusZoneList focusZones() const
|
||||
{
|
||||
return m_zones;
|
||||
}
|
||||
|
||||
// helper function to emit maximum Optical and Digital Zoom Changed signals
|
||||
void maxOpticalDigitalZoomChange(qreal maxOptical, qreal maxDigital)
|
||||
{
|
||||
if (maxOptical != m_maxOpticalZoom) {
|
||||
m_maxOpticalZoom = maxOptical;
|
||||
emit maximumOpticalZoomChanged(m_maxOpticalZoom);
|
||||
}
|
||||
|
||||
if (maxDigital != m_maxDigitalZoom) {
|
||||
m_maxDigitalZoom = maxDigital;
|
||||
emit maximumDigitalZoomChanged(m_maxDigitalZoom);
|
||||
}
|
||||
}
|
||||
|
||||
// helper function to emit Focus Zones Changed signals
|
||||
void focusZonesChange(qreal left, qreal top, qreal width, qreal height)
|
||||
{
|
||||
QCameraFocusZone myZone(QRectF(left, top, width, height));
|
||||
if (m_zones.last().area() != myZone.area()) {
|
||||
m_zones.clear();
|
||||
m_zones << myZone;
|
||||
emit focusZonesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
qreal m_opticalZoom;
|
||||
qreal m_digitalZoom;
|
||||
QCameraFocus::FocusMode m_focusMode;
|
||||
QCameraFocus::FocusPointMode m_focusPointMode;
|
||||
QPointF m_focusPoint;
|
||||
// to emit maximum Optical and Digital Zoom Changed signals
|
||||
qreal m_maxOpticalZoom;
|
||||
qreal m_maxDigitalZoom;
|
||||
// to emit focus zone changed signal
|
||||
QCameraFocusZoneList m_zones;
|
||||
};
|
||||
|
||||
#endif // MOCKCAMERAFOCUSCONTROL_H
|
||||
@@ -0,0 +1,130 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKCAMERACAPTURECONTROL_H
|
||||
#define MOCKCAMERACAPTURECONTROL_H
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
|
||||
#include "qcameraimagecapturecontrol.h"
|
||||
#include "qcameracontrol.h"
|
||||
#include "mockcameracontrol.h"
|
||||
|
||||
class MockCaptureControl : public QCameraImageCaptureControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockCaptureControl(MockCameraControl *cameraControl, QObject *parent = 0)
|
||||
: QCameraImageCaptureControl(parent), m_cameraControl(cameraControl), m_captureRequest(0), m_ready(true), m_captureCanceled(false)
|
||||
{
|
||||
}
|
||||
|
||||
~MockCaptureControl()
|
||||
{
|
||||
}
|
||||
|
||||
QCameraImageCapture::DriveMode driveMode() const { return QCameraImageCapture::SingleImageCapture; }
|
||||
void setDriveMode(QCameraImageCapture::DriveMode) {}
|
||||
|
||||
bool isReadyForCapture() const { return m_ready && m_cameraControl->state() == QCamera::ActiveState; }
|
||||
|
||||
int capture(const QString &fileName)
|
||||
{
|
||||
if (isReadyForCapture()) {
|
||||
m_fileName = fileName;
|
||||
m_captureRequest++;
|
||||
emit readyForCaptureChanged(m_ready = false);
|
||||
QTimer::singleShot(5, this, SLOT(captured()));
|
||||
return m_captureRequest;
|
||||
} else {
|
||||
emit error(-1, QCameraImageCapture::NotReadyError,
|
||||
QLatin1String("Could not capture in stopped state"));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void cancelCapture()
|
||||
{
|
||||
m_captureCanceled = true;
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
void captured()
|
||||
{
|
||||
if (!m_captureCanceled) {
|
||||
emit imageCaptured(m_captureRequest, QImage());
|
||||
|
||||
emit imageMetadataAvailable(m_captureRequest,
|
||||
QtMultimedia::FocalLengthIn35mmFilm,
|
||||
QVariant(50));
|
||||
|
||||
emit imageMetadataAvailable(m_captureRequest,
|
||||
QtMultimedia::DateTimeOriginal,
|
||||
QVariant(QDateTime::currentDateTime()));
|
||||
|
||||
emit imageMetadataAvailable(m_captureRequest,
|
||||
QLatin1String("Answer to the Ultimate Question of Life, the Universe, and Everything"),
|
||||
QVariant(42));
|
||||
}
|
||||
|
||||
if (!m_ready)
|
||||
{
|
||||
emit readyForCaptureChanged(m_ready = true);
|
||||
emit imageExposed(m_captureRequest);
|
||||
}
|
||||
|
||||
if (!m_captureCanceled)
|
||||
emit imageSaved(m_captureRequest, m_fileName);
|
||||
|
||||
m_captureCanceled = false;
|
||||
}
|
||||
|
||||
private:
|
||||
MockCameraControl *m_cameraControl;
|
||||
QString m_fileName;
|
||||
int m_captureRequest;
|
||||
bool m_ready;
|
||||
bool m_captureCanceled;
|
||||
};
|
||||
|
||||
#endif // MOCKCAMERACAPTURECONTROL_H
|
||||
@@ -0,0 +1,156 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKCAMERAIMAGEPROCESSINGCONTROL_H
|
||||
#define MOCKCAMERAIMAGEPROCESSINGCONTROL_H
|
||||
|
||||
#include "qcameraimageprocessingcontrol.h"
|
||||
|
||||
class MockImageProcessingControl : public QCameraImageProcessingControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockImageProcessingControl(QObject *parent = 0)
|
||||
: QCameraImageProcessingControl(parent)
|
||||
{
|
||||
m_supportedWhiteBalance.insert(QCameraImageProcessing::WhiteBalanceAuto);
|
||||
}
|
||||
|
||||
QCameraImageProcessing::WhiteBalanceMode whiteBalanceMode() const
|
||||
{
|
||||
return m_whiteBalanceMode;
|
||||
}
|
||||
void setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode)
|
||||
{
|
||||
m_whiteBalanceMode = mode;
|
||||
}
|
||||
|
||||
bool isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const
|
||||
{
|
||||
return m_supportedWhiteBalance.contains(mode);
|
||||
}
|
||||
|
||||
void setSupportedWhiteBalanceModes(QSet<QCameraImageProcessing::WhiteBalanceMode> modes)
|
||||
{
|
||||
m_supportedWhiteBalance = modes;
|
||||
}
|
||||
|
||||
bool isProcessingParameterSupported(ProcessingParameter parameter) const
|
||||
{
|
||||
//return parameter == Contrast || parameter == Sharpening || parameter == ColorTemperature;
|
||||
switch (parameter)
|
||||
{
|
||||
case Contrast:
|
||||
case Brightness:
|
||||
case Sharpening:
|
||||
case Saturation:
|
||||
case Denoising:
|
||||
case ColorTemperature:
|
||||
case ExtendedParameter:
|
||||
return true;
|
||||
default :
|
||||
return false;
|
||||
}
|
||||
}
|
||||
QVariant processingParameter(ProcessingParameter parameter) const
|
||||
{
|
||||
switch (parameter) {
|
||||
case Contrast:
|
||||
return m_contrast;
|
||||
case Saturation:
|
||||
return m_saturation;
|
||||
case Brightness:
|
||||
return m_brightness;
|
||||
case Sharpening:
|
||||
return m_sharpeningLevel;
|
||||
case Denoising:
|
||||
return m_denoising;
|
||||
case ColorTemperature:
|
||||
return m_manualWhiteBalance;
|
||||
case ExtendedParameter:
|
||||
return m_extendedParameter;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
void setProcessingParameter(ProcessingParameter parameter, QVariant value)
|
||||
{
|
||||
switch (parameter) {
|
||||
case Contrast:
|
||||
m_contrast = value;
|
||||
break;
|
||||
case Saturation:
|
||||
m_saturation = value;
|
||||
break;
|
||||
case Brightness:
|
||||
m_brightness = value;
|
||||
break;
|
||||
case Sharpening:
|
||||
m_sharpeningLevel = value;
|
||||
break;
|
||||
case Denoising:
|
||||
m_denoising = value;
|
||||
break;
|
||||
case ColorTemperature:
|
||||
m_manualWhiteBalance = value;
|
||||
break;
|
||||
case ExtendedParameter:
|
||||
m_extendedParameter = value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
QCameraImageProcessing::WhiteBalanceMode m_whiteBalanceMode;
|
||||
QSet<QCameraImageProcessing::WhiteBalanceMode> m_supportedWhiteBalance;
|
||||
QVariant m_manualWhiteBalance;
|
||||
QVariant m_contrast;
|
||||
QVariant m_sharpeningLevel;
|
||||
QVariant m_saturation;
|
||||
QVariant m_brightness;
|
||||
QVariant m_denoising;
|
||||
QVariant m_extendedParameter;
|
||||
};
|
||||
|
||||
#endif // MOCKCAMERAIMAGEPROCESSINGCONTROL_H
|
||||
144
tests/auto/unit/qmultimedia_common/mockcameralockscontrol.h
Normal file
144
tests/auto/unit/qmultimedia_common/mockcameralockscontrol.h
Normal file
@@ -0,0 +1,144 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKCAMERALOCKCONTROL_H
|
||||
#define MOCKCAMERALOCKCONTROL_H
|
||||
|
||||
#include <QTimer>
|
||||
#include "qcameralockscontrol.h"
|
||||
|
||||
class MockCameraLocksControl : public QCameraLocksControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockCameraLocksControl(QObject *parent = 0):
|
||||
QCameraLocksControl(parent),
|
||||
m_focusLock(QCamera::Unlocked),
|
||||
m_exposureLock(QCamera::Unlocked)
|
||||
{
|
||||
}
|
||||
|
||||
~MockCameraLocksControl() {}
|
||||
|
||||
QCamera::LockTypes supportedLocks() const
|
||||
{
|
||||
return QCamera::LockExposure | QCamera::LockFocus;
|
||||
}
|
||||
|
||||
QCamera::LockStatus lockStatus(QCamera::LockType lock) const
|
||||
{
|
||||
switch (lock) {
|
||||
case QCamera::LockExposure:
|
||||
return m_exposureLock;
|
||||
case QCamera::LockFocus:
|
||||
return m_focusLock;
|
||||
default:
|
||||
return QCamera::Unlocked;
|
||||
}
|
||||
}
|
||||
|
||||
void searchAndLock(QCamera::LockTypes locks)
|
||||
{
|
||||
if (locks & QCamera::LockExposure) {
|
||||
QCamera::LockStatus newStatus = locks & QCamera::LockFocus ? QCamera::Searching : QCamera::Locked;
|
||||
|
||||
if (newStatus != m_exposureLock)
|
||||
emit lockStatusChanged(QCamera::LockExposure,
|
||||
m_exposureLock = newStatus,
|
||||
QCamera::UserRequest);
|
||||
}
|
||||
|
||||
if (locks & QCamera::LockFocus) {
|
||||
emit lockStatusChanged(QCamera::LockFocus,
|
||||
m_focusLock = QCamera::Searching,
|
||||
QCamera::UserRequest);
|
||||
|
||||
QTimer::singleShot(5, this, SLOT(focused()));
|
||||
}
|
||||
}
|
||||
|
||||
void unlock(QCamera::LockTypes locks) {
|
||||
if (locks & QCamera::LockFocus && m_focusLock != QCamera::Unlocked) {
|
||||
emit lockStatusChanged(QCamera::LockFocus,
|
||||
m_focusLock = QCamera::Unlocked,
|
||||
QCamera::UserRequest);
|
||||
}
|
||||
|
||||
if (locks & QCamera::LockExposure && m_exposureLock != QCamera::Unlocked) {
|
||||
emit lockStatusChanged(QCamera::LockExposure,
|
||||
m_exposureLock = QCamera::Unlocked,
|
||||
QCamera::UserRequest);
|
||||
}
|
||||
}
|
||||
|
||||
/* helper method to emit the signal with LockChangeReason */
|
||||
void setLockChangeReason (QCamera::LockChangeReason lockChangeReason)
|
||||
{
|
||||
emit lockStatusChanged(QCamera::NoLock,
|
||||
QCamera::Unlocked,
|
||||
lockChangeReason);
|
||||
|
||||
}
|
||||
|
||||
private slots:
|
||||
void focused()
|
||||
{
|
||||
if (m_focusLock == QCamera::Searching) {
|
||||
emit lockStatusChanged(QCamera::LockFocus,
|
||||
m_focusLock = QCamera::Locked,
|
||||
QCamera::UserRequest);
|
||||
}
|
||||
|
||||
if (m_exposureLock == QCamera::Searching) {
|
||||
emit lockStatusChanged(QCamera::LockExposure,
|
||||
m_exposureLock = QCamera::Locked,
|
||||
QCamera::UserRequest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
QCamera::LockStatus m_focusLock;
|
||||
QCamera::LockStatus m_exposureLock;
|
||||
};
|
||||
|
||||
|
||||
#endif // MOCKCAMERALOCKCONTROL_H
|
||||
196
tests/auto/unit/qmultimedia_common/mockcameraservice.h
Normal file
196
tests/auto/unit/qmultimedia_common/mockcameraservice.h
Normal file
@@ -0,0 +1,196 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKCAMERASERVICE_H
|
||||
#define MOCKCAMERASERVICE_H
|
||||
|
||||
#include "qmediaservice.h"
|
||||
#include "../qmultimedia_common/mockcameraflashcontrol.h"
|
||||
#include "../qmultimedia_common/mockcameralockscontrol.h"
|
||||
#include "../qmultimedia_common/mockcamerafocuscontrol.h"
|
||||
#include "../qmultimedia_common/mockcameraimageprocessingcontrol.h"
|
||||
#include "../qmultimedia_common/mockcameraimagecapturecontrol.h"
|
||||
#include "../qmultimedia_common/mockcameraexposurecontrol.h"
|
||||
#include "../qmultimedia_common/mockcameracapturedestinationcontrol.h"
|
||||
#include "../qmultimedia_common/mockcameracapturebuffercontrol.h"
|
||||
#include "../qmultimedia_common/mockimageencodercontrol.h"
|
||||
#include "../qmultimedia_common/mockcameracontrol.h"
|
||||
#include "../qmultimedia_common/mockvideosurface.h"
|
||||
#include "../qmultimedia_common/mockvideorenderercontrol.h"
|
||||
|
||||
#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
|
||||
#include "../qmultimedia_common/mockvideowindowcontrol.h"
|
||||
#endif
|
||||
|
||||
class MockSimpleCameraService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MockSimpleCameraService(): QMediaService(0)
|
||||
{
|
||||
mockControl = new MockCameraControl(this);
|
||||
}
|
||||
|
||||
~MockSimpleCameraService()
|
||||
{
|
||||
}
|
||||
|
||||
QMediaControl* requestControl(const char *iid)
|
||||
{
|
||||
if (qstrcmp(iid, QCameraControl_iid) == 0)
|
||||
return mockControl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void releaseControl(QMediaControl*) {}
|
||||
|
||||
MockCameraControl *mockControl;
|
||||
};
|
||||
|
||||
|
||||
class MockCameraService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MockCameraService(): QMediaService(0)
|
||||
{
|
||||
mockControl = new MockCameraControl(this);
|
||||
mockLocksControl = new MockCameraLocksControl(this);
|
||||
mockExposureControl = new MockCameraExposureControl(this);
|
||||
mockFlashControl = new MockCameraFlashControl(this);
|
||||
mockFocusControl = new MockCameraFocusControl(this);
|
||||
mockCaptureControl = new MockCaptureControl(mockControl, this);
|
||||
mockCaptureBufferControl = new MockCaptureBufferFormatControl(this);
|
||||
mockCaptureDestinationControl = new MockCaptureDestinationControl(this);
|
||||
mockImageProcessingControl = new MockImageProcessingControl(this);
|
||||
mockImageEncoderControl = new MockImageEncoderControl(this);
|
||||
rendererControl = new MockVideoRendererControl(this);
|
||||
#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
|
||||
windowControl = new MockVideoWindowControl(this);
|
||||
#endif
|
||||
rendererRef = 0;
|
||||
windowRef = 0;
|
||||
}
|
||||
|
||||
~MockCameraService()
|
||||
{
|
||||
}
|
||||
|
||||
QMediaControl* requestControl(const char *iid)
|
||||
{
|
||||
if (qstrcmp(iid, QCameraControl_iid) == 0)
|
||||
return mockControl;
|
||||
|
||||
if (qstrcmp(iid, QCameraLocksControl_iid) == 0)
|
||||
return mockLocksControl;
|
||||
|
||||
if (qstrcmp(iid, QCameraExposureControl_iid) == 0)
|
||||
return mockExposureControl;
|
||||
|
||||
if (qstrcmp(iid, QCameraFlashControl_iid) == 0)
|
||||
return mockFlashControl;
|
||||
|
||||
if (qstrcmp(iid, QCameraFocusControl_iid) == 0)
|
||||
return mockFocusControl;
|
||||
|
||||
if (qstrcmp(iid, QCameraImageCaptureControl_iid) == 0)
|
||||
return mockCaptureControl;
|
||||
|
||||
if (qstrcmp(iid, QCameraCaptureBufferFormatControl_iid) == 0)
|
||||
return mockCaptureBufferControl;
|
||||
|
||||
if (qstrcmp(iid, QCameraCaptureDestinationControl_iid) == 0)
|
||||
return mockCaptureDestinationControl;
|
||||
|
||||
if (qstrcmp(iid, QCameraImageProcessingControl_iid) == 0)
|
||||
return mockImageProcessingControl;
|
||||
|
||||
if (qstrcmp(iid, QImageEncoderControl_iid) == 0)
|
||||
return mockImageEncoderControl;
|
||||
|
||||
if (qstrcmp(iid, QVideoRendererControl_iid) == 0) {
|
||||
if (rendererRef == 0) {
|
||||
rendererRef += 1;
|
||||
return rendererControl;
|
||||
}
|
||||
}
|
||||
#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
|
||||
if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
|
||||
if (windowRef == 0) {
|
||||
windowRef += 1;
|
||||
return windowControl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void releaseControl(QMediaControl *control)
|
||||
{
|
||||
if (control == rendererControl)
|
||||
rendererRef -= 1;
|
||||
#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
|
||||
if (control == windowControl)
|
||||
windowRef -= 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
MockCameraControl *mockControl;
|
||||
MockCameraLocksControl *mockLocksControl;
|
||||
MockCaptureControl *mockCaptureControl;
|
||||
MockCaptureBufferFormatControl *mockCaptureBufferControl;
|
||||
MockCaptureDestinationControl *mockCaptureDestinationControl;
|
||||
MockCameraExposureControl *mockExposureControl;
|
||||
MockCameraFlashControl *mockFlashControl;
|
||||
MockCameraFocusControl *mockFocusControl;
|
||||
MockImageProcessingControl *mockImageProcessingControl;
|
||||
MockImageEncoderControl *mockImageEncoderControl;
|
||||
MockVideoRendererControl *rendererControl;
|
||||
#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
|
||||
MockVideoWindowControl *windowControl;
|
||||
#endif
|
||||
int rendererRef;
|
||||
int windowRef;
|
||||
};
|
||||
|
||||
#endif // MOCKCAMERASERVICE_H
|
||||
7
tests/auto/unit/qmultimedia_common/mockcontainer.pri
Normal file
7
tests/auto/unit/qmultimedia_common/mockcontainer.pri
Normal file
@@ -0,0 +1,7 @@
|
||||
INCLUDEPATH *= $$PWD \
|
||||
../../../src/multimedia \
|
||||
|
||||
HEADERS *= \
|
||||
../qmultimedia_common/mockmediacontainercontrol.h \
|
||||
../qmultimedia_common/mockmetadatawritercontrol.h \
|
||||
../qmultimedia_common/mockmetadatareadercontrol.h
|
||||
103
tests/auto/unit/qmultimedia_common/mockimageencodercontrol.h
Normal file
103
tests/auto/unit/qmultimedia_common/mockimageencodercontrol.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKIMAGEENCODERCONTROL_H
|
||||
#define MOCKIMAGEENCODERCONTROL_H
|
||||
|
||||
#include "qimageencodercontrol.h"
|
||||
|
||||
class MockImageEncoderControl : public QImageEncoderControl
|
||||
{
|
||||
public:
|
||||
MockImageEncoderControl(QObject *parent = 0)
|
||||
: QImageEncoderControl(parent)
|
||||
{
|
||||
m_settings = QImageEncoderSettings();
|
||||
}
|
||||
|
||||
QList<QSize> supportedResolutions(const QImageEncoderSettings & settings = QImageEncoderSettings(),
|
||||
bool *continuous = 0) const
|
||||
{
|
||||
if (continuous)
|
||||
*continuous = true;
|
||||
|
||||
QList<QSize> resolutions;
|
||||
if (settings.resolution().isValid()) {
|
||||
if (settings.resolution() == QSize(160,160) ||
|
||||
settings.resolution() == QSize(320,240))
|
||||
resolutions << settings.resolution();
|
||||
|
||||
if (settings.quality() == QtMultimedia::HighQuality && settings.resolution() == QSize(640,480))
|
||||
resolutions << settings.resolution();
|
||||
} else {
|
||||
resolutions << QSize(160, 120);
|
||||
resolutions << QSize(320, 240);
|
||||
if (settings.quality() == QtMultimedia::HighQuality)
|
||||
resolutions << QSize(640, 480);
|
||||
}
|
||||
|
||||
return resolutions;
|
||||
}
|
||||
|
||||
QStringList supportedImageCodecs() const
|
||||
{
|
||||
QStringList codecs;
|
||||
codecs << "PNG" << "JPEG";
|
||||
return codecs;
|
||||
}
|
||||
|
||||
QString imageCodecDescription(const QString &codecName) const {
|
||||
if (codecName == "PNG")
|
||||
return QString("Portable Network Graphic");
|
||||
if (codecName == "JPEG")
|
||||
return QString("Joint Photographic Expert Group");
|
||||
return QString();
|
||||
}
|
||||
|
||||
QImageEncoderSettings imageSettings() const { return m_settings; }
|
||||
void setImageSettings(const QImageEncoderSettings &settings) { m_settings = settings; }
|
||||
|
||||
private:
|
||||
QImageEncoderSettings m_settings;
|
||||
};
|
||||
|
||||
|
||||
#endif // MOCKIMAGEENCODERCONTROL_H
|
||||
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 test suite 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 MOCKMEDIACONTAINERCONTROL_H
|
||||
#define MOCKMEDIACONTAINERCONTROL_H
|
||||
|
||||
#include <QObject>
|
||||
#include "qmediacontainercontrol.h"
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
class MockMediaContainerControl : public QMediaContainerControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MockMediaContainerControl(QObject *parent):
|
||||
QMediaContainerControl(parent)
|
||||
{
|
||||
m_supportedContainers.append("wav");
|
||||
m_supportedContainers.append("mp3");
|
||||
m_supportedContainers.append("mov");
|
||||
|
||||
m_descriptions.insert("wav", "WAV format");
|
||||
m_descriptions.insert("mp3", "MP3 format");
|
||||
m_descriptions.insert("mov", "MOV format");
|
||||
}
|
||||
|
||||
virtual ~MockMediaContainerControl() {};
|
||||
|
||||
QStringList supportedContainers() const
|
||||
{
|
||||
return m_supportedContainers;
|
||||
}
|
||||
|
||||
QString containerMimeType() const
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
|
||||
void setContainerMimeType(const QString &formatMimeType)
|
||||
{
|
||||
if (m_supportedContainers.contains(formatMimeType))
|
||||
m_format = formatMimeType;
|
||||
}
|
||||
|
||||
QString containerDescription(const QString &formatMimeType) const
|
||||
{
|
||||
return m_descriptions.value(formatMimeType);
|
||||
}
|
||||
|
||||
private:
|
||||
QStringList m_supportedContainers;
|
||||
QMap<QString, QString> m_descriptions;
|
||||
QString m_format;
|
||||
};
|
||||
|
||||
#endif // MOCKMEDIACONTAINERCONTROL_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user