API unit tests from Maemo API test team.
A large number of tweaks and changes to original tests, and refactor a lot of the mock backends to reduce duplication. Changed viewfinder test case to use mock service and provider so that it matches the image capture test case. Reviewed-by: Jonas Rabbe (cherry picked from commit e40bef5508a4165cec4a46b97115aed461027fa5) Also licence header fix: (cherry picked from commit e9ee9e8c48b45b97d62ee4a82e400fa9d8ea8107) Change-Id: Ic59891d75563bb2e008a336eea859e8c44d8d831 Reviewed-on: http://codereview.qt.nokia.com/2078 Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
1e4dda9710
commit
a6128410da
@@ -4,6 +4,17 @@ SUBDIRS += \
|
|||||||
qabstractvideobuffer \
|
qabstractvideobuffer \
|
||||||
qabstractvideosurface \
|
qabstractvideosurface \
|
||||||
qaudiocapturesource \
|
qaudiocapturesource \
|
||||||
|
qaudiodeviceinfo \
|
||||||
|
qaudioformat \
|
||||||
|
qaudioinput \
|
||||||
|
qaudiooutput \
|
||||||
|
qcamera \
|
||||||
|
qcamerabackend \
|
||||||
|
qcameraimagecapture \
|
||||||
|
qcameraviewfinder \
|
||||||
|
qmediabindableinterface \
|
||||||
|
qmediacontainercontrol \
|
||||||
|
qmediacontent \
|
||||||
qmediaobject \
|
qmediaobject \
|
||||||
qmediaplayer \
|
qmediaplayer \
|
||||||
qmediaplayerbackend \
|
qmediaplayerbackend \
|
||||||
@@ -11,17 +22,24 @@ SUBDIRS += \
|
|||||||
qmediarecorder \
|
qmediarecorder \
|
||||||
qmediaresource \
|
qmediaresource \
|
||||||
qmediaservice \
|
qmediaservice \
|
||||||
qmediacontent \
|
|
||||||
qradiotuner \
|
|
||||||
qcamera \
|
|
||||||
qmediatimerange \
|
qmediatimerange \
|
||||||
qaudiodeviceinfo \
|
qradiotuner \
|
||||||
qaudiooutput \
|
|
||||||
qaudioinput \
|
|
||||||
qaudioformat \
|
|
||||||
qvideoframe \
|
qvideoframe \
|
||||||
qvideosurfaceformat \
|
qvideosurfaceformat \
|
||||||
qcamerabackend
|
qmetadatareadercontrol \
|
||||||
|
qmetadatawritercontrol \
|
||||||
|
|
||||||
|
# This is disabled because it is unfinished
|
||||||
|
# qmediastreamscontrol \
|
||||||
|
|
||||||
|
# These is disabled until intent is clearer
|
||||||
|
# qvideodevicecontrol \
|
||||||
|
# qvideoencodercontrol \
|
||||||
|
|
||||||
|
# This is a commment for the mock backend directory so that maketestselftest
|
||||||
|
# doesn't believe it's an untested directory
|
||||||
|
# qmultimedia_common
|
||||||
|
|
||||||
|
|
||||||
# Tests depending on private interfaces should only be built if
|
# Tests depending on private interfaces should only be built if
|
||||||
# these interfaces are exported.
|
# these interfaces are exported.
|
||||||
@@ -47,4 +65,3 @@ contains (QT_CONFIG, declarative) {
|
|||||||
disabled:SUBDIRS += qdeclarativevideo
|
disabled:SUBDIRS += qdeclarativevideo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ private slots:
|
|||||||
void handleType_data();
|
void handleType_data();
|
||||||
void handleType();
|
void handleType();
|
||||||
void handle();
|
void handle();
|
||||||
|
void mapMode();
|
||||||
};
|
};
|
||||||
|
|
||||||
class QtTestVideoBuffer : public QAbstractVideoBuffer
|
class QtTestVideoBuffer : public QAbstractVideoBuffer
|
||||||
@@ -69,7 +70,7 @@ class QtTestVideoBuffer : public QAbstractVideoBuffer
|
|||||||
public:
|
public:
|
||||||
QtTestVideoBuffer(QAbstractVideoBuffer::HandleType type) : QAbstractVideoBuffer(type) {}
|
QtTestVideoBuffer(QAbstractVideoBuffer::HandleType type) : QAbstractVideoBuffer(type) {}
|
||||||
|
|
||||||
MapMode mapMode() const { return NotMapped; }
|
MapMode mapMode() const { return QAbstractVideoBuffer::ReadWrite; }
|
||||||
|
|
||||||
uchar *map(MapMode, int *, int *) { return 0; }
|
uchar *map(MapMode, int *, int *) { return 0; }
|
||||||
void unmap() {}
|
void unmap() {}
|
||||||
@@ -107,6 +108,12 @@ void tst_QAbstractVideoBuffer::handleType_data()
|
|||||||
<< QAbstractVideoBuffer::NoHandle;
|
<< QAbstractVideoBuffer::NoHandle;
|
||||||
QTest::newRow("opengl")
|
QTest::newRow("opengl")
|
||||||
<< QAbstractVideoBuffer::GLTextureHandle;
|
<< QAbstractVideoBuffer::GLTextureHandle;
|
||||||
|
QTest::newRow("XvShmImageHandle")
|
||||||
|
<< QAbstractVideoBuffer::XvShmImageHandle;
|
||||||
|
QTest::newRow("CoreImageHandle")
|
||||||
|
<< QAbstractVideoBuffer::CoreImageHandle;
|
||||||
|
QTest::newRow("QPixmapHandle")
|
||||||
|
<< QAbstractVideoBuffer::QPixmapHandle;
|
||||||
QTest::newRow("user1")
|
QTest::newRow("user1")
|
||||||
<< QAbstractVideoBuffer::UserHandle;
|
<< QAbstractVideoBuffer::UserHandle;
|
||||||
QTest::newRow("user2")
|
QTest::newRow("user2")
|
||||||
@@ -129,6 +136,12 @@ void tst_QAbstractVideoBuffer::handle()
|
|||||||
QVERIFY(buffer.handle().isNull());
|
QVERIFY(buffer.handle().isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QAbstractVideoBuffer::mapMode()
|
||||||
|
{
|
||||||
|
QtTestVideoBuffer maptest(QAbstractVideoBuffer::NoHandle);
|
||||||
|
QVERIFY2(maptest.mapMode() == QAbstractVideoBuffer::ReadWrite, "ReadWrite Failed");
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QAbstractVideoBuffer)
|
QTEST_MAIN(tst_QAbstractVideoBuffer)
|
||||||
|
|
||||||
#include "tst_qabstractvideobuffer.moc"
|
#include "tst_qabstractvideobuffer.moc"
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ private slots:
|
|||||||
void nearestFormat();
|
void nearestFormat();
|
||||||
void start_data();
|
void start_data();
|
||||||
void start();
|
void start();
|
||||||
|
void nativeResolution();
|
||||||
|
void supportedFormatsChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QMap<QAbstractVideoBuffer::HandleType, QVideoFrame::PixelFormat> SupportedFormatMap;
|
typedef QMap<QAbstractVideoBuffer::HandleType, QVideoFrame::PixelFormat> SupportedFormatMap;
|
||||||
@@ -93,6 +95,20 @@ public:
|
|||||||
|
|
||||||
using QAbstractVideoSurface::setError;
|
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:
|
private:
|
||||||
SupportedFormatMap supportedFormats;
|
SupportedFormatMap supportedFormats;
|
||||||
};
|
};
|
||||||
@@ -137,6 +153,12 @@ void tst_QAbstractVideoSurface::setError()
|
|||||||
|
|
||||||
surface.setError(QAbstractVideoSurface::NoError);
|
surface.setError(QAbstractVideoSurface::NoError);
|
||||||
QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
|
QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
|
||||||
|
|
||||||
|
surface.setError(QAbstractVideoSurface::UnsupportedFormatError);
|
||||||
|
QCOMPARE(surface.error(), QAbstractVideoSurface::UnsupportedFormatError);
|
||||||
|
|
||||||
|
surface.setError(QAbstractVideoSurface::IncorrectFormatError);
|
||||||
|
QCOMPARE(surface.error(), QAbstractVideoSurface::IncorrectFormatError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAbstractVideoSurface::isFormatSupported_data()
|
void tst_QAbstractVideoSurface::isFormatSupported_data()
|
||||||
@@ -307,6 +329,44 @@ void tst_QAbstractVideoSurface::start()
|
|||||||
QCOMPARE(activeSpy.last().at(0).toBool(), false);
|
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);
|
||||||
|
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)
|
QTEST_MAIN(tst_QAbstractVideoSurface)
|
||||||
|
|
||||||
#include "tst_qabstractvideosurface.moc"
|
#include "tst_qabstractvideosurface.moc"
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ load(qttest_p4)
|
|||||||
|
|
||||||
QT += multimediakit-private
|
QT += multimediakit-private
|
||||||
|
|
||||||
# TARGET = tst_qaudiocapturesource
|
|
||||||
# CONFIG += testcase
|
|
||||||
|
|
||||||
SOURCES += tst_qaudiocapturesource.cpp
|
SOURCES += tst_qaudiocapturesource.cpp
|
||||||
|
|
||||||
|
include (../qmultimedia_common/mockrecorder.pri)
|
||||||
|
include (../qmultimedia_common/mock.pri)
|
||||||
|
|
||||||
|
|||||||
@@ -48,218 +48,16 @@
|
|||||||
#include <qaudioencodercontrol.h>
|
#include <qaudioencodercontrol.h>
|
||||||
#include <qmediarecordercontrol.h>
|
#include <qmediarecordercontrol.h>
|
||||||
#include <qaudioendpointselector.h>
|
#include <qaudioendpointselector.h>
|
||||||
|
#include <qaudiodeviceinfo.h>
|
||||||
|
#include <qaudioinput.h>
|
||||||
|
#include <qmediaobject.h>
|
||||||
|
|
||||||
//TESTED_COMPONENT=src/multimedia
|
//TESTED_COMPONENT=src/multimedia
|
||||||
|
|
||||||
|
#include "mockmediaserviceprovider.h"
|
||||||
|
#include "mockmediarecorderservice.h"
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
QT_USE_NAMESPACE
|
||||||
class MockAudioEncoderControl : public QAudioEncoderControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
MockAudioEncoderControl(QObject *parent = 0):
|
|
||||||
QAudioEncoderControl(parent)
|
|
||||||
{
|
|
||||||
m_codecs << "audio/pcm" << "audio/mpeg";
|
|
||||||
m_descriptions << "Pulse Code Modulation" << "mp3 format";
|
|
||||||
m_audioSettings.setCodec("audio/pcm");
|
|
||||||
m_audioSettings.setSampleRate(8000);
|
|
||||||
m_freqs << 8000 << 11025 << 22050 << 44100;
|
|
||||||
}
|
|
||||||
|
|
||||||
~MockAudioEncoderControl() {}
|
|
||||||
|
|
||||||
QStringList supportedAudioCodecs() const { return m_codecs; }
|
|
||||||
QString codecDescription(const QString &codecName) const { return m_descriptions.at(m_codecs.indexOf(codecName)); }
|
|
||||||
|
|
||||||
QStringList supportedEncodingOptions(const QString &) const { return QStringList() << "bitrate"; }
|
|
||||||
QVariant encodingOption(const QString &, const QString &) const { return m_optionValue; }
|
|
||||||
void setEncodingOption(const QString &, const QString &, const QVariant &value) { m_optionValue = value; }
|
|
||||||
|
|
||||||
QList<int> supportedSampleRates(const QAudioEncoderSettings & = QAudioEncoderSettings(),
|
|
||||||
bool *continuous = 0) const
|
|
||||||
{
|
|
||||||
if (continuous)
|
|
||||||
*continuous = false;
|
|
||||||
return m_freqs;
|
|
||||||
}
|
|
||||||
QList<int> supportedChannelCounts(const QAudioEncoderSettings & = QAudioEncoderSettings()) const { QList<int> list; list << 1 << 2; return list; }
|
|
||||||
|
|
||||||
QAudioEncoderSettings audioSettings() const { return m_audioSettings; }
|
|
||||||
void setAudioSettings(const QAudioEncoderSettings &settings) { m_audioSettings = settings;}
|
|
||||||
|
|
||||||
QStringList m_codecs;
|
|
||||||
QStringList m_descriptions;
|
|
||||||
|
|
||||||
QAudioEncoderSettings m_audioSettings;
|
|
||||||
|
|
||||||
QList<int> m_freqs;
|
|
||||||
QVariant m_optionValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockMediaRecorderControl : public QMediaRecorderControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
MockMediaRecorderControl(QObject *parent = 0):
|
|
||||||
QMediaRecorderControl(parent),
|
|
||||||
m_state(QMediaRecorder::StoppedState),
|
|
||||||
m_position(0),
|
|
||||||
m_muted(false) {}
|
|
||||||
|
|
||||||
~MockMediaRecorderControl() {}
|
|
||||||
|
|
||||||
QUrl outputLocation() const { return m_sink; }
|
|
||||||
bool setOutputLocation(const QUrl &sink) { m_sink = sink; return true; }
|
|
||||||
QMediaRecorder::State state() const { return m_state; }
|
|
||||||
qint64 duration() const { return m_position; }
|
|
||||||
void applySettings() {}
|
|
||||||
bool isMuted() const { return m_muted; }
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void record()
|
|
||||||
{
|
|
||||||
m_state = QMediaRecorder::RecordingState;
|
|
||||||
m_position=1;
|
|
||||||
emit stateChanged(m_state);
|
|
||||||
emit durationChanged(m_position);
|
|
||||||
}
|
|
||||||
void pause()
|
|
||||||
{
|
|
||||||
m_state = QMediaRecorder::PausedState;
|
|
||||||
emit stateChanged(m_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void stop()
|
|
||||||
{
|
|
||||||
m_position=0;
|
|
||||||
m_state = QMediaRecorder::StoppedState;
|
|
||||||
emit stateChanged(m_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMuted(bool muted)
|
|
||||||
{
|
|
||||||
if (m_muted != muted)
|
|
||||||
emit mutedChanged(m_muted = muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
QUrl m_sink;
|
|
||||||
QMediaRecorder::State m_state;
|
|
||||||
qint64 m_position;
|
|
||||||
bool m_muted;
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_audioInput;
|
|
||||||
QList<QString> m_names;
|
|
||||||
QList<QString> m_descriptions;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class MockAudioSourceService : public QMediaService
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MockAudioSourceService(): QMediaService(0), hasAudioDeviceControl(true)
|
|
||||||
{
|
|
||||||
mockAudioEncoderControl = new MockAudioEncoderControl(this);
|
|
||||||
mockMediaRecorderControl = new MockMediaRecorderControl(this);
|
|
||||||
mockAudioEndpointSelector = new MockAudioEndpointSelector(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
~MockAudioSourceService()
|
|
||||||
{
|
|
||||||
delete mockAudioEncoderControl;
|
|
||||||
delete mockMediaRecorderControl;
|
|
||||||
delete mockAudioEndpointSelector;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMediaControl* requestControl(const char *iid)
|
|
||||||
{
|
|
||||||
if (qstrcmp(iid, QAudioEncoderControl_iid) == 0)
|
|
||||||
return mockAudioEncoderControl;
|
|
||||||
|
|
||||||
if (qstrcmp(iid, QMediaRecorderControl_iid) == 0)
|
|
||||||
return mockMediaRecorderControl;
|
|
||||||
|
|
||||||
if (hasAudioDeviceControl && qstrcmp(iid, QAudioEndpointSelector_iid) == 0)
|
|
||||||
return mockAudioEndpointSelector;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void releaseControl(QMediaControl*) {}
|
|
||||||
|
|
||||||
MockAudioEncoderControl *mockAudioEncoderControl;
|
|
||||||
MockMediaRecorderControl *mockMediaRecorderControl;
|
|
||||||
MockAudioEndpointSelector *mockAudioEndpointSelector;
|
|
||||||
bool hasAudioDeviceControl;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockProvider : public QMediaServiceProvider
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MockProvider(MockAudioSourceService *service):mockService(service) {}
|
|
||||||
QMediaService *requestService(const QByteArray&, const QMediaServiceProviderHint &)
|
|
||||||
{
|
|
||||||
return mockService;
|
|
||||||
}
|
|
||||||
|
|
||||||
void releaseService(QMediaService *) {}
|
|
||||||
|
|
||||||
MockAudioSourceService *mockService;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class tst_QAudioCaptureSource: public QObject
|
class tst_QAudioCaptureSource: public QObject
|
||||||
{
|
{
|
||||||
@@ -275,23 +73,26 @@ private slots:
|
|||||||
void testAudioSource();
|
void testAudioSource();
|
||||||
void testOptions();
|
void testOptions();
|
||||||
void testDevices();
|
void testDevices();
|
||||||
|
void testAvailability();
|
||||||
|
void testAvailableAudioInputChangedSignal();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAudioCaptureSource *audiosource;
|
QAudioCaptureSource *audiosource;
|
||||||
MockAudioSourceService *mockAudioSourceService;
|
MockMediaRecorderService *mockMediaRecorderService;
|
||||||
MockProvider *mockProvider;
|
MockMediaServiceProvider *mockProvider;
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_QAudioCaptureSource::initTestCase()
|
void tst_QAudioCaptureSource::initTestCase()
|
||||||
{
|
{
|
||||||
mockAudioSourceService = new MockAudioSourceService;
|
mockMediaRecorderService = new MockMediaRecorderService;
|
||||||
mockProvider = new MockProvider(mockAudioSourceService);
|
mockProvider = new MockMediaServiceProvider(mockMediaRecorderService);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAudioCaptureSource::cleanupTestCase()
|
void tst_QAudioCaptureSource::cleanupTestCase()
|
||||||
{
|
{
|
||||||
delete audiosource;
|
delete audiosource;
|
||||||
delete mockProvider;
|
delete mockProvider;
|
||||||
|
audiosource = 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
void tst_QAudioCaptureSource::testNullService()
|
void tst_QAudioCaptureSource::testNullService()
|
||||||
@@ -307,7 +108,7 @@ void tst_QAudioCaptureSource::testNullService()
|
|||||||
/*
|
/*
|
||||||
void tst_QAudioCaptureSource::testNullControl()
|
void tst_QAudioCaptureSource::testNullControl()
|
||||||
{
|
{
|
||||||
MockAudioSourceService service;
|
MockRecorderService service;
|
||||||
service.hasAudioDeviceControl = false;
|
service.hasAudioDeviceControl = false;
|
||||||
MockProvider provider(&service);
|
MockProvider provider(&service);
|
||||||
QAudioCaptureSource source(0, &provider);
|
QAudioCaptureSource source(0, &provider);
|
||||||
@@ -328,31 +129,74 @@ void tst_QAudioCaptureSource::testAudioSource()
|
|||||||
{
|
{
|
||||||
audiosource = new QAudioCaptureSource(0, mockProvider);
|
audiosource = new QAudioCaptureSource(0, mockProvider);
|
||||||
|
|
||||||
QCOMPARE(audiosource->service(),(QMediaService *) mockAudioSourceService);
|
QCOMPARE(audiosource->service(),(QMediaService *) mockMediaRecorderService);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAudioCaptureSource::testOptions()
|
void tst_QAudioCaptureSource::testOptions()
|
||||||
{
|
{
|
||||||
const QString codec(QLatin1String("mp3"));
|
const QString codec(QLatin1String("audio/mpeg"));
|
||||||
|
|
||||||
QStringList options = mockAudioSourceService->mockAudioEncoderControl->supportedEncodingOptions(codec);
|
QStringList options = mockMediaRecorderService->mockAudioEncoderControl->supportedEncodingOptions(codec);
|
||||||
QVERIFY(options.count() == 1);
|
QCOMPARE(options.count(), 4);
|
||||||
mockAudioSourceService->mockAudioEncoderControl->setEncodingOption(codec, options.first(),8000);
|
mockMediaRecorderService->mockAudioEncoderControl->setEncodingOption(codec, options.first(),8000);
|
||||||
QVERIFY(mockAudioSourceService->mockAudioEncoderControl->encodingOption(codec, options.first()).toInt() == 8000);
|
QVERIFY(mockMediaRecorderService->mockAudioEncoderControl->encodingOption(codec, options.first()).toInt() == 8000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAudioCaptureSource::testDevices()
|
void tst_QAudioCaptureSource::testDevices()
|
||||||
{
|
{
|
||||||
|
audiosource = new QAudioCaptureSource(0,mockProvider);
|
||||||
QList<QString> devices = audiosource->audioInputs();
|
QList<QString> devices = audiosource->audioInputs();
|
||||||
QVERIFY(devices.size() > 0);
|
QVERIFY(devices.size() > 0);
|
||||||
QVERIFY(devices.at(0).compare("device1") == 0);
|
QVERIFY(devices.at(0).compare("device1") == 0);
|
||||||
QVERIFY(audiosource->audioDescription("device1").compare("dev1 comment") == 0);
|
QVERIFY(audiosource->audioDescription("device1").compare("dev1 comment") == 0);
|
||||||
QVERIFY(audiosource->defaultAudioInput() == "device1");
|
QVERIFY(audiosource->defaultAudioInput() == "device1");
|
||||||
|
QVERIFY(audiosource->isAvailable() == true);
|
||||||
|
|
||||||
QSignalSpy checkSignal(audiosource, SIGNAL(activeAudioInputChanged(QString)));
|
QSignalSpy checkSignal(audiosource, SIGNAL(activeAudioInputChanged(QString)));
|
||||||
audiosource->setAudioInput("device2");
|
audiosource->setAudioInput("device2");
|
||||||
QVERIFY(audiosource->activeAudioInput().compare("device2") == 0);
|
QVERIFY(audiosource->activeAudioInput().compare("device2") == 0);
|
||||||
QVERIFY(checkSignal.count() == 1);
|
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() == QtMultimediaKit::ServiceMissingError);
|
||||||
|
|
||||||
|
service.hasControls = true;
|
||||||
|
MockMediaServiceProvider provider2(&service);
|
||||||
|
QAudioCaptureSource source2(0, &provider2);
|
||||||
|
|
||||||
|
QVERIFY(source2.isAvailable() == true);
|
||||||
|
QVERIFY(source2.availabilityError() == QtMultimediaKit::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)
|
QTEST_MAIN(tst_QAudioCaptureSource)
|
||||||
|
|||||||
@@ -66,9 +66,14 @@ private slots:
|
|||||||
void byteOrders();
|
void byteOrders();
|
||||||
void sampleTypes();
|
void sampleTypes();
|
||||||
void frequencies();
|
void frequencies();
|
||||||
void isformat();
|
void isFormatSupported();
|
||||||
void preferred();
|
void preferred();
|
||||||
void nearest();
|
void nearest();
|
||||||
|
void supportedChannelCounts();
|
||||||
|
void supportedSampleRates();
|
||||||
|
void assignOperator();
|
||||||
|
void deviceName();
|
||||||
|
void defaultConstructor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool available;
|
bool available;
|
||||||
@@ -79,7 +84,7 @@ void tst_QAudioDeviceInfo::initTestCase()
|
|||||||
{
|
{
|
||||||
// Only perform tests if audio output device exists!
|
// Only perform tests if audio output device exists!
|
||||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||||
if(devices.size() > 0)
|
if (devices.size() > 0)
|
||||||
available = true;
|
available = true;
|
||||||
else {
|
else {
|
||||||
qWarning()<<"NOTE: no audio output device found, no test will be performed";
|
qWarning()<<"NOTE: no audio output device found, no test will be performed";
|
||||||
@@ -92,26 +97,26 @@ void tst_QAudioDeviceInfo::checkAvailableDefaultInput()
|
|||||||
// Only perform tests if audio input device exists!
|
// Only perform tests if audio input device exists!
|
||||||
bool storeAvailable = available;
|
bool storeAvailable = available;
|
||||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
|
||||||
if(devices.size() > 0)
|
if (devices.size() > 0)
|
||||||
available = true;
|
available = true;
|
||||||
else {
|
else {
|
||||||
qWarning()<<"NOTE: no audio input device found, no test will be performed";
|
qWarning()<<"NOTE: no audio input device found, no test will be performed";
|
||||||
available = false;
|
available = false;
|
||||||
}
|
}
|
||||||
if(available)
|
if (available)
|
||||||
QVERIFY(!QAudioDeviceInfo::defaultInputDevice().isNull());
|
QVERIFY(!QAudioDeviceInfo::defaultInputDevice().isNull());
|
||||||
available = storeAvailable;
|
available = storeAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAudioDeviceInfo::checkAvailableDefaultOutput()
|
void tst_QAudioDeviceInfo::checkAvailableDefaultOutput()
|
||||||
{
|
{
|
||||||
if(available)
|
if (available)
|
||||||
QVERIFY(!QAudioDeviceInfo::defaultOutputDevice().isNull());
|
QVERIFY(!QAudioDeviceInfo::defaultOutputDevice().isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAudioDeviceInfo::outputList()
|
void tst_QAudioDeviceInfo::outputList()
|
||||||
{
|
{
|
||||||
if(available) {
|
if (available) {
|
||||||
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||||
QVERIFY(devices.size() > 0);
|
QVERIFY(devices.size() > 0);
|
||||||
device = new QAudioDeviceInfo(devices.at(0));
|
device = new QAudioDeviceInfo(devices.at(0));
|
||||||
@@ -120,7 +125,7 @@ void tst_QAudioDeviceInfo::outputList()
|
|||||||
|
|
||||||
void tst_QAudioDeviceInfo::codecs()
|
void tst_QAudioDeviceInfo::codecs()
|
||||||
{
|
{
|
||||||
if(available) {
|
if (available) {
|
||||||
QStringList avail = device->supportedCodecs();
|
QStringList avail = device->supportedCodecs();
|
||||||
QVERIFY(avail.size() > 0);
|
QVERIFY(avail.size() > 0);
|
||||||
}
|
}
|
||||||
@@ -128,7 +133,7 @@ void tst_QAudioDeviceInfo::codecs()
|
|||||||
|
|
||||||
void tst_QAudioDeviceInfo::channels()
|
void tst_QAudioDeviceInfo::channels()
|
||||||
{
|
{
|
||||||
if(available) {
|
if (available) {
|
||||||
QList<int> avail = device->supportedChannels();
|
QList<int> avail = device->supportedChannels();
|
||||||
QVERIFY(avail.size() > 0);
|
QVERIFY(avail.size() > 0);
|
||||||
}
|
}
|
||||||
@@ -136,7 +141,7 @@ void tst_QAudioDeviceInfo::channels()
|
|||||||
|
|
||||||
void tst_QAudioDeviceInfo::sampleSizes()
|
void tst_QAudioDeviceInfo::sampleSizes()
|
||||||
{
|
{
|
||||||
if(available) {
|
if (available) {
|
||||||
QList<int> avail = device->supportedSampleSizes();
|
QList<int> avail = device->supportedSampleSizes();
|
||||||
QVERIFY(avail.size() > 0);
|
QVERIFY(avail.size() > 0);
|
||||||
}
|
}
|
||||||
@@ -144,7 +149,7 @@ void tst_QAudioDeviceInfo::sampleSizes()
|
|||||||
|
|
||||||
void tst_QAudioDeviceInfo::byteOrders()
|
void tst_QAudioDeviceInfo::byteOrders()
|
||||||
{
|
{
|
||||||
if(available) {
|
if (available) {
|
||||||
QList<QAudioFormat::Endian> avail = device->supportedByteOrders();
|
QList<QAudioFormat::Endian> avail = device->supportedByteOrders();
|
||||||
QVERIFY(avail.size() > 0);
|
QVERIFY(avail.size() > 0);
|
||||||
}
|
}
|
||||||
@@ -152,7 +157,7 @@ void tst_QAudioDeviceInfo::byteOrders()
|
|||||||
|
|
||||||
void tst_QAudioDeviceInfo::sampleTypes()
|
void tst_QAudioDeviceInfo::sampleTypes()
|
||||||
{
|
{
|
||||||
if(available) {
|
if (available) {
|
||||||
QList<QAudioFormat::SampleType> avail = device->supportedSampleTypes();
|
QList<QAudioFormat::SampleType> avail = device->supportedSampleTypes();
|
||||||
QVERIFY(avail.size() > 0);
|
QVERIFY(avail.size() > 0);
|
||||||
}
|
}
|
||||||
@@ -160,16 +165,16 @@ void tst_QAudioDeviceInfo::sampleTypes()
|
|||||||
|
|
||||||
void tst_QAudioDeviceInfo::frequencies()
|
void tst_QAudioDeviceInfo::frequencies()
|
||||||
{
|
{
|
||||||
if(available) {
|
if (available) {
|
||||||
QList<int> avail = device->supportedFrequencies();
|
QList<int> avail = device->supportedFrequencies();
|
||||||
QVERIFY(avail.size() > 0);
|
QVERIFY(avail.size() > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAudioDeviceInfo::isformat()
|
void tst_QAudioDeviceInfo::isFormatSupported()
|
||||||
{
|
{
|
||||||
if(available) {
|
if (available) {
|
||||||
QAudioFormat format;
|
QAudioFormat format;
|
||||||
format.setFrequency(44100);
|
format.setFrequency(44100);
|
||||||
format.setChannels(2);
|
format.setChannels(2);
|
||||||
format.setSampleType(QAudioFormat::SignedInt);
|
format.setSampleType(QAudioFormat::SignedInt);
|
||||||
@@ -184,24 +189,89 @@ void tst_QAudioDeviceInfo::isformat()
|
|||||||
|
|
||||||
void tst_QAudioDeviceInfo::preferred()
|
void tst_QAudioDeviceInfo::preferred()
|
||||||
{
|
{
|
||||||
if(available) {
|
if (available) {
|
||||||
QAudioFormat format = device->preferredFormat();
|
QAudioFormat format = device->preferredFormat();
|
||||||
QVERIFY(format.isValid());
|
QVERIFY(format.isValid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns closest QAudioFormat to settings that system audio supports.
|
||||||
void tst_QAudioDeviceInfo::nearest()
|
void tst_QAudioDeviceInfo::nearest()
|
||||||
{
|
{
|
||||||
if(available) {
|
if (available) {
|
||||||
/*
|
/*
|
||||||
QAudioFormat format1, format2;
|
QAudioFormat format1, format2;
|
||||||
format1.setFrequency(8000);
|
format1.setFrequency(8000);
|
||||||
format2 = device->nearestFormat(format1);
|
format2 = device->nearestFormat(format1);
|
||||||
QVERIFY(format2.frequency() == 44100);
|
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)
|
QTEST_MAIN(tst_QAudioDeviceInfo)
|
||||||
|
|
||||||
#include "tst_qaudiodeviceinfo.moc"
|
#include "tst_qaudiodeviceinfo.moc"
|
||||||
|
|||||||
@@ -59,23 +59,24 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void checkNull();
|
void checkNull();
|
||||||
void checkFrequency();
|
void checkFrequency();
|
||||||
void checkChannels();
|
|
||||||
void checkSampleSize();
|
void checkSampleSize();
|
||||||
void checkCodec();
|
void checkCodec();
|
||||||
void checkByteOrder();
|
void checkByteOrder();
|
||||||
void checkSampleType();
|
void checkSampleType();
|
||||||
void checkEquality();
|
void checkEquality();
|
||||||
void checkAssignment();
|
void checkAssignment();
|
||||||
|
void checkSampleRate();
|
||||||
|
void checkChannelCount();
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_QAudioFormat::checkNull()
|
void tst_QAudioFormat::checkNull()
|
||||||
{
|
{
|
||||||
// Default constructed QAudioFormat is invalid.
|
// Default constructed QAudioFormat is invalid.
|
||||||
QAudioFormat audioFormat0;
|
QAudioFormat audioFormat0;
|
||||||
QVERIFY(!audioFormat0.isValid());
|
QVERIFY(!audioFormat0.isValid());
|
||||||
|
|
||||||
// validity is transferred
|
// validity is transferred
|
||||||
QAudioFormat audioFormat1(audioFormat0);
|
QAudioFormat audioFormat1(audioFormat0);
|
||||||
QVERIFY(!audioFormat1.isValid());
|
QVERIFY(!audioFormat1.isValid());
|
||||||
|
|
||||||
audioFormat0.setFrequency(44100);
|
audioFormat0.setFrequency(44100);
|
||||||
@@ -88,50 +89,52 @@ void tst_QAudioFormat::checkNull()
|
|||||||
|
|
||||||
void tst_QAudioFormat::checkFrequency()
|
void tst_QAudioFormat::checkFrequency()
|
||||||
{
|
{
|
||||||
QAudioFormat audioFormat;
|
QAudioFormat audioFormat;
|
||||||
audioFormat.setFrequency(44100);
|
audioFormat.setFrequency(44100);
|
||||||
QVERIFY(audioFormat.frequency() == 44100);
|
QVERIFY(audioFormat.frequency() == 44100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAudioFormat::checkChannels()
|
|
||||||
{
|
|
||||||
QAudioFormat audioFormat;
|
|
||||||
audioFormat.setChannels(2);
|
|
||||||
QVERIFY(audioFormat.channels() == 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QAudioFormat::checkSampleSize()
|
void tst_QAudioFormat::checkSampleSize()
|
||||||
{
|
{
|
||||||
QAudioFormat audioFormat;
|
QAudioFormat audioFormat;
|
||||||
audioFormat.setSampleSize(16);
|
audioFormat.setSampleSize(16);
|
||||||
QVERIFY(audioFormat.sampleSize() == 16);
|
QVERIFY(audioFormat.sampleSize() == 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAudioFormat::checkCodec()
|
void tst_QAudioFormat::checkCodec()
|
||||||
{
|
{
|
||||||
QAudioFormat audioFormat;
|
QAudioFormat audioFormat;
|
||||||
audioFormat.setCodec(QString::fromLatin1("audio/pcm"));
|
audioFormat.setCodec(QString::fromLatin1("audio/pcm"));
|
||||||
QVERIFY(audioFormat.codec() == QString::fromLatin1("audio/pcm"));
|
QVERIFY(audioFormat.codec() == QString::fromLatin1("audio/pcm"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAudioFormat::checkByteOrder()
|
void tst_QAudioFormat::checkByteOrder()
|
||||||
{
|
{
|
||||||
QAudioFormat audioFormat;
|
QAudioFormat audioFormat;
|
||||||
audioFormat.setByteOrder(QAudioFormat::LittleEndian);
|
audioFormat.setByteOrder(QAudioFormat::LittleEndian);
|
||||||
QVERIFY(audioFormat.byteOrder() == QAudioFormat::LittleEndian);
|
QVERIFY(audioFormat.byteOrder() == QAudioFormat::LittleEndian);
|
||||||
|
|
||||||
|
audioFormat.setByteOrder(QAudioFormat::BigEndian);
|
||||||
|
QVERIFY(audioFormat.byteOrder() == QAudioFormat::BigEndian);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAudioFormat::checkSampleType()
|
void tst_QAudioFormat::checkSampleType()
|
||||||
{
|
{
|
||||||
QAudioFormat audioFormat;
|
QAudioFormat audioFormat;
|
||||||
audioFormat.setSampleType(QAudioFormat::SignedInt);
|
audioFormat.setSampleType(QAudioFormat::SignedInt);
|
||||||
QVERIFY(audioFormat.sampleType() == QAudioFormat::SignedInt);
|
QVERIFY(audioFormat.sampleType() == QAudioFormat::SignedInt);
|
||||||
|
|
||||||
|
audioFormat.setSampleType(QAudioFormat::Unknown);
|
||||||
|
QVERIFY(audioFormat.sampleType() == QAudioFormat::Unknown);
|
||||||
|
|
||||||
|
audioFormat.setSampleType(QAudioFormat::Float);
|
||||||
|
QVERIFY(audioFormat.sampleType() == QAudioFormat::Float);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAudioFormat::checkEquality()
|
void tst_QAudioFormat::checkEquality()
|
||||||
{
|
{
|
||||||
QAudioFormat audioFormat0;
|
QAudioFormat audioFormat0;
|
||||||
QAudioFormat audioFormat1;
|
QAudioFormat audioFormat1;
|
||||||
|
|
||||||
// Null formats are equivalent
|
// Null formats are equivalent
|
||||||
QVERIFY(audioFormat0 == audioFormat1);
|
QVERIFY(audioFormat0 == audioFormat1);
|
||||||
@@ -162,8 +165,8 @@ void tst_QAudioFormat::checkEquality()
|
|||||||
|
|
||||||
void tst_QAudioFormat::checkAssignment()
|
void tst_QAudioFormat::checkAssignment()
|
||||||
{
|
{
|
||||||
QAudioFormat audioFormat0;
|
QAudioFormat audioFormat0;
|
||||||
QAudioFormat audioFormat1;
|
QAudioFormat audioFormat1;
|
||||||
|
|
||||||
audioFormat0.setFrequency(8000);
|
audioFormat0.setFrequency(8000);
|
||||||
audioFormat0.setChannels(1);
|
audioFormat0.setChannels(1);
|
||||||
@@ -175,10 +178,38 @@ void tst_QAudioFormat::checkAssignment()
|
|||||||
audioFormat1 = audioFormat0;
|
audioFormat1 = audioFormat0;
|
||||||
QVERIFY(audioFormat1 == audioFormat0);
|
QVERIFY(audioFormat1 == audioFormat0);
|
||||||
|
|
||||||
QAudioFormat audioFormat2(audioFormat0);
|
QAudioFormat audioFormat2(audioFormat0);
|
||||||
QVERIFY(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);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QAudioFormat)
|
QTEST_MAIN(tst_QAudioFormat)
|
||||||
|
|
||||||
#include "tst_qaudioformat.moc"
|
#include "tst_qaudioformat.moc"
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ void tst_QAudioInput::initTestCase()
|
|||||||
|
|
||||||
QVERIFY(testFormats.size());
|
QVERIFY(testFormats.size());
|
||||||
|
|
||||||
foreach (format, testFormats) {
|
foreach (const QAudioFormat &format, testFormats) {
|
||||||
QFile* file = new QFile(workingDir() + formatToFileName(format) + QString(".wav"));
|
QFile* file = new QFile(workingDir() + formatToFileName(format) + QString(".wav"));
|
||||||
audioFiles.append(file);
|
audioFiles.append(file);
|
||||||
}
|
}
|
||||||
@@ -265,6 +265,7 @@ void tst_QAudioInput::invalidFormat()
|
|||||||
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
|
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
|
||||||
|
|
||||||
audioInput.start();
|
audioInput.start();
|
||||||
|
|
||||||
// Check that error is raised
|
// Check that error is raised
|
||||||
QTRY_VERIFY2((audioInput.error() == QAudio::OpenError),"error() was not set to QAudio::OpenError after start()");
|
QTRY_VERIFY2((audioInput.error() == QAudio::OpenError),"error() was not set to QAudio::OpenError after start()");
|
||||||
}
|
}
|
||||||
@@ -435,6 +436,7 @@ void tst_QAudioInput::pull()
|
|||||||
QVERIFY(wavHeader.write(*audioFiles.at(i)));
|
QVERIFY(wavHeader.write(*audioFiles.at(i)));
|
||||||
|
|
||||||
audioInput.start(audioFiles.at(i));
|
audioInput.start(audioFiles.at(i));
|
||||||
|
|
||||||
// Check that QAudioInput immediately transitions to ActiveState or IdleState
|
// Check that QAudioInput immediately transitions to ActiveState or IdleState
|
||||||
QTRY_VERIFY2((stateSignal.count() > 0),"didn't emit signals on start()");
|
QTRY_VERIFY2((stateSignal.count() > 0),"didn't emit signals on start()");
|
||||||
QVERIFY2((audioInput.state() == QAudio::ActiveState || audioInput.state() == QAudio::IdleState),
|
QVERIFY2((audioInput.state() == QAudio::ActiveState || audioInput.state() == QAudio::IdleState),
|
||||||
@@ -493,6 +495,7 @@ void tst_QAudioInput::pullSuspendResume()
|
|||||||
QVERIFY(wavHeader.write(*audioFiles.at(i)));
|
QVERIFY(wavHeader.write(*audioFiles.at(i)));
|
||||||
|
|
||||||
audioInput.start(audioFiles.at(i));
|
audioInput.start(audioFiles.at(i));
|
||||||
|
|
||||||
// Check that QAudioInput immediately transitions to ActiveState or IdleState
|
// Check that QAudioInput immediately transitions to ActiveState or IdleState
|
||||||
QTRY_VERIFY2((stateSignal.count() > 0),"didn't emit signals on start()");
|
QTRY_VERIFY2((stateSignal.count() > 0),"didn't emit signals on start()");
|
||||||
QVERIFY2((audioInput.state() == QAudio::ActiveState || audioInput.state() == QAudio::IdleState),
|
QVERIFY2((audioInput.state() == QAudio::ActiveState || audioInput.state() == QAudio::IdleState),
|
||||||
@@ -766,32 +769,71 @@ void tst_QAudioInput::pushSuspendResume()
|
|||||||
void tst_QAudioInput::reset()
|
void tst_QAudioInput::reset()
|
||||||
{
|
{
|
||||||
for(int i=0; i<audioFiles.count(); i++) {
|
for(int i=0; i<audioFiles.count(); i++) {
|
||||||
QAudioInput audioInput(testFormats.at(i), this);
|
|
||||||
|
|
||||||
audioInput.setNotifyInterval(100);
|
// Try both push/pull.. the vagaries of Active vs Idle are tested elsewhere
|
||||||
|
{
|
||||||
|
QAudioInput audioInput(testFormats.at(i), this);
|
||||||
|
|
||||||
QSignalSpy notifySignal(&audioInput, SIGNAL(notify()));
|
audioInput.setNotifyInterval(100);
|
||||||
QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
|
|
||||||
|
|
||||||
// Check that we are in the default state before calling start
|
QSignalSpy notifySignal(&audioInput, SIGNAL(notify()));
|
||||||
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
|
QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
|
||||||
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
|
|
||||||
QVERIFY2((audioInput.elapsedUSecs() == qint64(0)),"elapsedUSecs() not zero on creation");
|
|
||||||
|
|
||||||
audioInput.start();
|
// Check that we are in the default state before calling start
|
||||||
// Check that QAudioInput immediately transitions to IdleState
|
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
|
||||||
QTRY_VERIFY2((stateSignal.count() == 1),"didn't emit IdleState signal on start()");
|
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
|
||||||
QVERIFY2((audioInput.state() == QAudio::IdleState), "didn't transition to IdleState after start()");
|
QVERIFY2((audioInput.elapsedUSecs() == qint64(0)),"elapsedUSecs() not zero on creation");
|
||||||
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
|
|
||||||
QVERIFY(audioInput.periodSize() > 0);
|
|
||||||
QTest::qWait(500);
|
|
||||||
QVERIFY(audioInput.bytesReady() > 0);
|
|
||||||
stateSignal.clear();
|
|
||||||
|
|
||||||
audioInput.reset();
|
QIODevice* device = audioInput.start();
|
||||||
QTRY_VERIFY2((stateSignal.count() == 1),"didn't emit StoppedState signal after reset()");
|
// Check that QAudioInput immediately transitions to IdleState
|
||||||
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after reset()");
|
QTRY_VERIFY2((stateSignal.count() == 1),"didn't emit IdleState signal on start()");
|
||||||
QVERIFY2((audioInput.bytesReady() == 0), "buffer not cleared after reset()");
|
QVERIFY2((audioInput.state() == QAudio::IdleState), "didn't transition to IdleState after start()");
|
||||||
|
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
|
||||||
|
QVERIFY(audioInput.periodSize() > 0);
|
||||||
|
QTRY_VERIFY2((audioInput.bytesReady() > 0), "no bytes available after starting");
|
||||||
|
|
||||||
|
// Trigger a read
|
||||||
|
QByteArray data = device->read(1);
|
||||||
|
|
||||||
|
QTRY_VERIFY2((audioInput.state() == QAudio::ActiveState), "didn't transition to ActiveState after read()");
|
||||||
|
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
|
||||||
|
stateSignal.clear();
|
||||||
|
|
||||||
|
audioInput.reset();
|
||||||
|
QTRY_VERIFY2((stateSignal.count() == 1),"didn't emit StoppedState signal after reset()");
|
||||||
|
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after reset()");
|
||||||
|
QVERIFY2((audioInput.bytesReady() == 0), "buffer not cleared after reset()");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
QAudioInput audioInput(testFormats.at(i), this);
|
||||||
|
QBuffer buffer;
|
||||||
|
|
||||||
|
audioInput.setNotifyInterval(100);
|
||||||
|
|
||||||
|
QSignalSpy notifySignal(&audioInput, SIGNAL(notify()));
|
||||||
|
QSignalSpy stateSignal(&audioInput, SIGNAL(stateChanged(QAudio::State)));
|
||||||
|
|
||||||
|
// Check that we are in the default state before calling start
|
||||||
|
QVERIFY2((audioInput.state() == QAudio::StoppedState), "state() was not set to StoppedState before start()");
|
||||||
|
QVERIFY2((audioInput.error() == QAudio::NoError), "error() was not set to QAudio::NoError before start()");
|
||||||
|
QVERIFY2((audioInput.elapsedUSecs() == qint64(0)),"elapsedUSecs() not zero on creation");
|
||||||
|
|
||||||
|
audioInput.start(&buffer);
|
||||||
|
|
||||||
|
// Check that QAudioInput immediately transitions to ActiveState
|
||||||
|
QTRY_VERIFY2((stateSignal.count() >= 1),"didn't emit state changed signal on start()");
|
||||||
|
QTRY_VERIFY2((audioInput.state() == QAudio::ActiveState), "didn't transition to ActiveState after start()");
|
||||||
|
QVERIFY2((audioInput.error() == QAudio::NoError), "error state is not equal to QAudio::NoError after start()");
|
||||||
|
QVERIFY(audioInput.periodSize() > 0);
|
||||||
|
QTRY_VERIFY2((audioInput.bytesReady() > 0), "no bytes available after starting");
|
||||||
|
stateSignal.clear();
|
||||||
|
|
||||||
|
audioInput.reset();
|
||||||
|
QTRY_VERIFY2((stateSignal.count() == 1),"didn't emit StoppedState signal after reset()");
|
||||||
|
QVERIFY2((audioInput.state() == QAudio::StoppedState), "didn't transitions to StoppedState after reset()");
|
||||||
|
QVERIFY2((audioInput.bytesReady() == 0), "buffer not cleared after reset()");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ void tst_QAudioOutput::initTestCase()
|
|||||||
|
|
||||||
QVERIFY(testFormats.size());
|
QVERIFY(testFormats.size());
|
||||||
|
|
||||||
foreach (format, testFormats) {
|
foreach (const QAudioFormat &format, testFormats) {
|
||||||
qint64 len = (format.frequency()*format.channels()*(format.sampleSize()/8)*2); // 2 seconds
|
qint64 len = (format.frequency()*format.channels()*(format.sampleSize()/8)*2); // 2 seconds
|
||||||
createSineWaveData(format, len);
|
createSineWaveData(format, len);
|
||||||
// Write generate sine wave data to file
|
// Write generate sine wave data to file
|
||||||
@@ -488,6 +488,7 @@ void tst_QAudioOutput::pull()
|
|||||||
audioFiles.at(i)->seek(WavHeader::headerLength());
|
audioFiles.at(i)->seek(WavHeader::headerLength());
|
||||||
|
|
||||||
audioOutput.start(audioFiles.at(i));
|
audioOutput.start(audioFiles.at(i));
|
||||||
|
|
||||||
// Check that QAudioOutput immediately transitions to ActiveState
|
// Check that QAudioOutput immediately transitions to ActiveState
|
||||||
QTRY_VERIFY2((stateSignal.count() == 1),
|
QTRY_VERIFY2((stateSignal.count() == 1),
|
||||||
QString("didn't emit signal on start(), got %1 signals instead").arg(stateSignal.count()).toLocal8Bit().constData());
|
QString("didn't emit signal on start(), got %1 signals instead").arg(stateSignal.count()).toLocal8Bit().constData());
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ load(qttest_p4)
|
|||||||
|
|
||||||
QT += multimediakit-private
|
QT += multimediakit-private
|
||||||
|
|
||||||
|
include (../qmultimedia_common/mock.pri)
|
||||||
|
include (../qmultimedia_common/mockcamera.pri)
|
||||||
|
|
||||||
# TARGET = tst_qcamera
|
# TARGET = tst_qcamera
|
||||||
# CONFIG += testcase
|
# CONFIG += testcase
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
9
tests/auto/qcameraimagecapture/qcameraimagecapture.pro
Normal file
9
tests/auto/qcameraimagecapture/qcameraimagecapture.pro
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
load(qttest_p4)
|
||||||
|
|
||||||
|
QT += multimediakit-private
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
tst_qcameraimagecapture.cpp
|
||||||
|
|
||||||
|
include (../qmultimedia_common/mock.pri)
|
||||||
|
include (../qmultimedia_common/mockcamera.pri)
|
||||||
410
tests/auto/qcameraimagecapture/tst_qcameraimagecapture.cpp
Normal file
410
tests/auto/qcameraimagecapture/tst_qcameraimagecapture.cpp
Normal file
@@ -0,0 +1,410 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 <qgraphicsvideoitem.h>
|
||||||
|
#include <qcameraviewfinder.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 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
//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(QtMultimediaKit::NormalQuality);
|
||||||
|
imageCapture.setEncodingSettings(settings);
|
||||||
|
QVERIFY(!imageCapture.encodingSettings().isNull());
|
||||||
|
QVERIFY(imageCapture.encodingSettings().codec() == "JPEG");
|
||||||
|
QVERIFY(imageCapture.encodingSettings().quality() == QtMultimediaKit::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() == QtMultimediaKit::ServiceMissingError);
|
||||||
|
|
||||||
|
|
||||||
|
QCamera camera(0, provider);
|
||||||
|
QCameraImageCapture imageCapture(&camera);
|
||||||
|
QVERIFY(imageCapture.isAvailable() == true);
|
||||||
|
QVERIFY(imageCapture.error() == QCameraImageCapture::NoError);
|
||||||
|
QVERIFY(imageCapture.errorString().isEmpty());
|
||||||
|
QVERIFY(imageCapture.availabilityError() == QtMultimediaKit::NoError);
|
||||||
|
|
||||||
|
imageCapture.capture();
|
||||||
|
QVERIFY(imageCapture.error() == QCameraImageCapture::NotReadyError);
|
||||||
|
QVERIFY2(!imageCapture.errorString().isEmpty(), "Could not capture in stopped state");
|
||||||
|
QVERIFY(imageCapture.availabilityError() == QtMultimediaKit::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"
|
||||||
8
tests/auto/qcameraviewfinder/qcameraviewfinder.pro
Normal file
8
tests/auto/qcameraviewfinder/qcameraviewfinder.pro
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
load(qttest_p4)
|
||||||
|
|
||||||
|
QT += multimediakit-private
|
||||||
|
|
||||||
|
include (../qmultimedia_common/mock.pri)
|
||||||
|
include (../qmultimedia_common/mockcamera.pri)
|
||||||
|
|
||||||
|
SOURCES += tst_qcameraviewfinder.cpp
|
||||||
113
tests/auto/qcameraviewfinder/tst_qcameraviewfinder.cpp
Normal file
113
tests/auto/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"
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
load(qttest_p4)
|
||||||
|
|
||||||
|
QT += multimediakit-private
|
||||||
|
|
||||||
|
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,8 @@
|
|||||||
|
load(qttest_p4)
|
||||||
|
|
||||||
|
QT += multimediakit-private
|
||||||
|
|
||||||
|
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"
|
||||||
@@ -89,6 +89,7 @@ void tst_QMediaContent::testRequestCtor()
|
|||||||
QMediaContent media(request);
|
QMediaContent media(request);
|
||||||
|
|
||||||
QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov"));
|
QCOMPARE(media.canonicalUrl(), QUrl("http://example.com/movie.mov"));
|
||||||
|
QCOMPARE(media.canonicalRequest(),request);
|
||||||
QCOMPARE(media.canonicalResource().request(), request);
|
QCOMPARE(media.canonicalResource().request(), request);
|
||||||
QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov"));
|
QCOMPARE(media.canonicalResource().url(), QUrl("http://example.com/movie.mov"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ private slots:
|
|||||||
void setVideoOutput();
|
void setVideoOutput();
|
||||||
void debugEnums();
|
void debugEnums();
|
||||||
|
|
||||||
|
void mediaChanged_signal();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
tst_QMediaImageViewer() : m_network(0) {}
|
tst_QMediaImageViewer() : m_network(0) {}
|
||||||
|
|
||||||
@@ -386,7 +388,17 @@ void tst_QMediaImageViewer::setConsecutiveMedia()
|
|||||||
QMediaImageViewerService *service = qobject_cast<QMediaImageViewerService *>(viewer.service());
|
QMediaImageViewerService *service = qobject_cast<QMediaImageViewerService *>(viewer.service());
|
||||||
service->setNetworkManager(m_network);
|
service->setNetworkManager(m_network);
|
||||||
|
|
||||||
|
viewer.setMedia(networkMedia2);
|
||||||
viewer.setMedia(networkMedia1);
|
viewer.setMedia(networkMedia1);
|
||||||
|
|
||||||
|
QCOMPARE(viewer.media(), networkMedia1);
|
||||||
|
QCOMPARE(viewer.mediaStatus(), QMediaImageViewer::LoadingMedia);
|
||||||
|
|
||||||
|
QTestEventLoop::instance().enterLoop(2);
|
||||||
|
QCOMPARE(viewer.media(), networkMedia1);
|
||||||
|
QCOMPARE(viewer.mediaStatus(), QMediaImageViewer::LoadedMedia);
|
||||||
|
|
||||||
|
viewer.setMedia(fileMedia1);
|
||||||
viewer.setMedia(networkMedia2);
|
viewer.setMedia(networkMedia2);
|
||||||
|
|
||||||
QCOMPARE(viewer.media(), networkMedia2);
|
QCOMPARE(viewer.media(), networkMedia2);
|
||||||
@@ -420,6 +432,7 @@ void tst_QMediaImageViewer::setConsecutiveMedia()
|
|||||||
void tst_QMediaImageViewer::setInvalidMedia()
|
void tst_QMediaImageViewer::setInvalidMedia()
|
||||||
{
|
{
|
||||||
QMediaImageViewer viewer;
|
QMediaImageViewer viewer;
|
||||||
|
viewer.setTimeout(250);
|
||||||
|
|
||||||
QMediaImageViewerService *service = qobject_cast<QMediaImageViewerService *>(viewer.service());
|
QMediaImageViewerService *service = qobject_cast<QMediaImageViewerService *>(viewer.service());
|
||||||
service->setNetworkManager(m_network);
|
service->setNetworkManager(m_network);
|
||||||
@@ -1031,6 +1044,20 @@ void tst_QMediaImageViewer::debugEnums()
|
|||||||
qDebug() << QMediaImageViewer::NoMedia;
|
qDebug() << QMediaImageViewer::NoMedia;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QMediaImageViewer::mediaChanged_signal()
|
||||||
|
{
|
||||||
|
QMediaContent imageMedia(imageUrl("image.png"));
|
||||||
|
QMediaImageViewer viewer;
|
||||||
|
viewer.setTimeout(250);
|
||||||
|
viewer.setNotifyInterval(150);
|
||||||
|
|
||||||
|
QSignalSpy spy(&viewer, SIGNAL(mediaChanged(QMediaContent)));
|
||||||
|
QVERIFY(spy.size() == 0);
|
||||||
|
|
||||||
|
viewer.setMedia(imageMedia);
|
||||||
|
QVERIFY(spy.size() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QMediaImageViewer)
|
QTEST_MAIN(tst_QMediaImageViewer)
|
||||||
|
|
||||||
#include "tst_qmediaimageviewer.moc"
|
#include "tst_qmediaimageviewer.moc"
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ QT += multimediakit-private
|
|||||||
# TARGET = tst_qmediaobject
|
# TARGET = tst_qmediaobject
|
||||||
# CONFIG += testcase
|
# CONFIG += testcase
|
||||||
|
|
||||||
|
include (../qmultimedia_common/mockrecorder.pri)
|
||||||
|
|
||||||
HEADERS+= tst_qmediaobject.h
|
HEADERS+= tst_qmediaobject.h
|
||||||
SOURCES += main.cpp tst_qmediaobject.cpp
|
SOURCES += main.cpp tst_qmediaobject.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,10 @@
|
|||||||
//TESTED_COMPONENT=src/multimedia
|
//TESTED_COMPONENT=src/multimedia
|
||||||
|
|
||||||
#include "tst_qmediaobject.h"
|
#include "tst_qmediaobject.h"
|
||||||
|
#include "qvideowidget.h"
|
||||||
|
|
||||||
|
#include "mockmediarecorderservice.h"
|
||||||
|
#include "mockmediaserviceprovider.h"
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
@@ -357,3 +361,44 @@ void tst_QMediaObject::availability()
|
|||||||
QCOMPARE(object.isAvailable(), true);
|
QCOMPARE(object.isAvailable(), true);
|
||||||
QCOMPARE(object.availabilityError(), QtMultimediaKit::NoError);
|
QCOMPARE(object.availabilityError(), QtMultimediaKit::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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,9 +48,38 @@
|
|||||||
#include <qmediaobject.h>
|
#include <qmediaobject.h>
|
||||||
#include <qmediaservice.h>
|
#include <qmediaservice.h>
|
||||||
#include <qmetadatareadercontrol.h>
|
#include <qmetadatareadercontrol.h>
|
||||||
|
#include <qaudiocapturesource.h>
|
||||||
|
#include <qaudioendpointselector.h>
|
||||||
|
|
||||||
//TESTED_COMPONENT=src/multimedia
|
//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
|
QT_USE_NAMESPACE
|
||||||
class tst_QMediaObject : public QObject
|
class tst_QMediaObject : public QObject
|
||||||
{
|
{
|
||||||
@@ -72,72 +101,13 @@ private slots:
|
|||||||
void extendedMetaData_data() { metaData_data(); }
|
void extendedMetaData_data() { metaData_data(); }
|
||||||
void extendedMetaData();
|
void extendedMetaData();
|
||||||
|
|
||||||
|
void service();
|
||||||
|
void availabilityChangedSignal();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupNotifyTests();
|
void setupNotifyTests();
|
||||||
};
|
};
|
||||||
|
|
||||||
class QtTestMetaDataProvider : public QMetaDataReaderControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
QtTestMetaDataProvider(QObject *parent = 0)
|
|
||||||
: QMetaDataReaderControl(parent)
|
|
||||||
, m_available(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isMetaDataAvailable() const { return m_available; }
|
|
||||||
void setMetaDataAvailable(bool available) {
|
|
||||||
if (m_available != available)
|
|
||||||
emit metaDataAvailableChanged(m_available = available);
|
|
||||||
}
|
|
||||||
QList<QtMultimediaKit::MetaData> availableMetaData() const { return m_data.keys(); }
|
|
||||||
|
|
||||||
|
|
||||||
QVariant metaData(QtMultimediaKit::MetaData key) const { return m_data.value(key); }
|
|
||||||
|
|
||||||
QVariant extendedMetaData(const QString &key) const { return m_extendedData.value(key); }
|
|
||||||
|
|
||||||
QStringList availableExtendedMetaData() const { return m_extendedData.keys(); }
|
|
||||||
|
|
||||||
using QMetaDataReaderControl::metaDataChanged;
|
|
||||||
|
|
||||||
void populateMetaData()
|
|
||||||
{
|
|
||||||
m_available = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool m_available;
|
|
||||||
QMap<QtMultimediaKit::MetaData, QVariant> m_data;
|
|
||||||
QMap<QString, QVariant> m_extendedData;
|
|
||||||
};
|
|
||||||
|
|
||||||
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 *)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QtTestMetaDataProvider metaData;
|
|
||||||
int metaDataRef;
|
|
||||||
bool hasMetaData;
|
|
||||||
};
|
|
||||||
|
|
||||||
class QtTestMediaObject : public QMediaObject
|
class QtTestMediaObject : public QMediaObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -8,3 +8,5 @@ QT += network multimediakit-private
|
|||||||
HEADERS += tst_qmediaplayer.h
|
HEADERS += tst_qmediaplayer.h
|
||||||
SOURCES += main.cpp tst_qmediaplayer.cpp
|
SOURCES += main.cpp tst_qmediaplayer.cpp
|
||||||
|
|
||||||
|
include (../qmultimedia_common/mock.pri)
|
||||||
|
include (../qmultimedia_common/mockplayer.pri)
|
||||||
|
|||||||
@@ -79,6 +79,8 @@
|
|||||||
|
|
||||||
QT_USE_NAMESPACE
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
|
#include "mockvideosurface.h"
|
||||||
|
|
||||||
void tst_QMediaPlayer::initTestCase_data()
|
void tst_QMediaPlayer::initTestCase_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<bool>("valid");
|
QTest::addColumn<bool>("valid");
|
||||||
@@ -126,8 +128,8 @@ void tst_QMediaPlayer::initTestCase()
|
|||||||
qRegisterMetaType<QMediaPlayer::MediaStatus>("QMediaPlayer::MediaStatus");
|
qRegisterMetaType<QMediaPlayer::MediaStatus>("QMediaPlayer::MediaStatus");
|
||||||
qRegisterMetaType<QMediaContent>("QMediaContent");
|
qRegisterMetaType<QMediaContent>("QMediaContent");
|
||||||
|
|
||||||
mockService = new MockPlayerService;
|
mockService = new MockMediaPlayerService;
|
||||||
mockProvider = new MockProvider(mockService);
|
mockProvider = new MockMediaServiceProvider(mockService, true);
|
||||||
player = new QMediaPlayer(0, 0, mockProvider);
|
player = new QMediaPlayer(0, 0, mockProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +149,7 @@ void tst_QMediaPlayer::cleanup()
|
|||||||
|
|
||||||
void tst_QMediaPlayer::testNullService()
|
void tst_QMediaPlayer::testNullService()
|
||||||
{
|
{
|
||||||
MockProvider provider(0);
|
MockMediaServiceProvider provider(0);
|
||||||
QMediaPlayer player(0, 0, &provider);
|
QMediaPlayer player(0, 0, &provider);
|
||||||
|
|
||||||
const QIODevice *nullDevice = 0;
|
const QIODevice *nullDevice = 0;
|
||||||
@@ -842,6 +844,68 @@ void tst_QMediaPlayer::testPlaylist()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QMediaPlayer::testPlayerFlags()
|
||||||
|
{
|
||||||
|
MockMediaServiceProvider provider(0, true);
|
||||||
|
QMediaPlayer::Flag flags = QMediaPlayer::LowLatency;
|
||||||
|
|
||||||
|
QMediaPlayer player(0, flags, &provider);
|
||||||
|
QMediaServiceProviderHint::Feature feature;
|
||||||
|
|
||||||
|
if (flags & QMediaPlayer::LowLatency)
|
||||||
|
{
|
||||||
|
/* if the flag is low latency set the low latency play back for the service provider */
|
||||||
|
feature = QMediaServiceProviderHint::LowLatencyPlayback;
|
||||||
|
const QByteArray service(Q_MEDIASERVICE_MEDIAPLAYER);
|
||||||
|
const QMediaServiceProviderHint providerHint(feature);
|
||||||
|
/* request service for the service provider */
|
||||||
|
provider.requestService(service,providerHint);
|
||||||
|
|
||||||
|
/* Constructs a SupportedFeatures media service provider hint. */
|
||||||
|
QMediaServiceProviderHint servicepro(feature);
|
||||||
|
|
||||||
|
/* compare the flag value */
|
||||||
|
QVERIFY(servicepro.features() == QMediaServiceProviderHint::LowLatencyPlayback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The player is expected to play QIODevice based streams.
|
||||||
|
If passed to QMediaPlayer constructor,
|
||||||
|
the service supporting streams playback will be chosen. */
|
||||||
|
flags = QMediaPlayer::StreamPlayback;
|
||||||
|
/* Construct a QMediaPlayer that uses the playback service from provider,
|
||||||
|
parented to parent and with flags.*/
|
||||||
|
QMediaPlayer player2(0,flags , &provider);
|
||||||
|
|
||||||
|
if (flags & QMediaPlayer::StreamPlayback)
|
||||||
|
{
|
||||||
|
/* if the flag is stream play back set the stream play back for the service provider */
|
||||||
|
feature = QMediaServiceProviderHint::StreamPlayback;
|
||||||
|
const QByteArray service(Q_MEDIASERVICE_MEDIAPLAYER);
|
||||||
|
const QMediaServiceProviderHint providerHint(feature);
|
||||||
|
|
||||||
|
/* request service for the service provider */
|
||||||
|
provider.requestService(service,providerHint);
|
||||||
|
|
||||||
|
/* Constructs a SupportedFeatures media service provider hint. */
|
||||||
|
QMediaServiceProviderHint servicepro(feature);
|
||||||
|
|
||||||
|
/* compare the flag value */
|
||||||
|
QVERIFY(servicepro.features() == QMediaServiceProviderHint::StreamPlayback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QMediaPlayer::testDestructor()
|
||||||
|
{
|
||||||
|
/* create an object for player */
|
||||||
|
QMediaPlayer *player = new QMediaPlayer;
|
||||||
|
|
||||||
|
/* check whether the object is created */
|
||||||
|
QVERIFY(player);
|
||||||
|
|
||||||
|
/* delete the instance */
|
||||||
|
delete player;
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QMediaPlayer::testNetworkAccess()
|
void tst_QMediaPlayer::testNetworkAccess()
|
||||||
{
|
{
|
||||||
QNetworkConfigurationManager manager;
|
QNetworkConfigurationManager manager;
|
||||||
@@ -876,9 +940,8 @@ void tst_QMediaPlayer::testSetVideoOutput()
|
|||||||
QGraphicsVideoItem item;
|
QGraphicsVideoItem item;
|
||||||
MockVideoSurface surface;
|
MockVideoSurface surface;
|
||||||
|
|
||||||
MockPlayerService service;
|
MockMediaPlayerService service;
|
||||||
MockProvider provider(&service);
|
MockMediaServiceProvider provider(&service);
|
||||||
provider.deleteServiceOnRelease = false;
|
|
||||||
QMediaPlayer player(0, 0, &provider);
|
QMediaPlayer player(0, 0, &provider);
|
||||||
|
|
||||||
player.setVideoOutput(&widget);
|
player.setVideoOutput(&widget);
|
||||||
@@ -922,7 +985,7 @@ void tst_QMediaPlayer::testSetVideoOutputNoService()
|
|||||||
QGraphicsVideoItem item;
|
QGraphicsVideoItem item;
|
||||||
MockVideoSurface surface;
|
MockVideoSurface surface;
|
||||||
|
|
||||||
MockProvider provider(0);
|
MockMediaServiceProvider provider(0, true);
|
||||||
QMediaPlayer player(0, 0, &provider);
|
QMediaPlayer player(0, 0, &provider);
|
||||||
|
|
||||||
player.setVideoOutput(&widget);
|
player.setVideoOutput(&widget);
|
||||||
@@ -941,12 +1004,11 @@ void tst_QMediaPlayer::testSetVideoOutputNoControl()
|
|||||||
QGraphicsVideoItem item;
|
QGraphicsVideoItem item;
|
||||||
MockVideoSurface surface;
|
MockVideoSurface surface;
|
||||||
|
|
||||||
MockPlayerService service;
|
MockMediaPlayerService service;
|
||||||
service.rendererRef = 1;
|
service.rendererRef = 1;
|
||||||
service.windowRef = 1;
|
service.windowRef = 1;
|
||||||
|
|
||||||
MockProvider provider(&service);
|
MockMediaServiceProvider provider(&service);
|
||||||
provider.deleteServiceOnRelease = false;
|
|
||||||
QMediaPlayer player(0, 0, &provider);
|
QMediaPlayer player(0, 0, &provider);
|
||||||
|
|
||||||
player.setVideoOutput(&widget);
|
player.setVideoOutput(&widget);
|
||||||
@@ -963,9 +1025,8 @@ void tst_QMediaPlayer::testSetVideoOutputDestruction()
|
|||||||
{
|
{
|
||||||
MockVideoSurface surface;
|
MockVideoSurface surface;
|
||||||
|
|
||||||
MockPlayerService service;
|
MockMediaPlayerService service;
|
||||||
MockProvider provider(&service);
|
MockMediaServiceProvider provider(&service);
|
||||||
provider.deleteServiceOnRelease = false;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
QMediaPlayer player(0, 0, &provider);
|
QMediaPlayer player(0, 0, &provider);
|
||||||
@@ -1016,4 +1077,9 @@ void tst_QMediaPlayer::debugEnums()
|
|||||||
qDebug() << QMediaPlayer::NetworkError;
|
qDebug() << QMediaPlayer::NetworkError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QMediaPlayer::testSupportedMimeTypes()
|
||||||
|
{
|
||||||
|
QStringList mimeList = QMediaPlayer::supportedMimeTypes(QMediaPlayer::LowLatency);
|
||||||
|
|
||||||
|
// This is empty on some platforms, and not on others, so can't test something here at the moment.
|
||||||
|
}
|
||||||
|
|||||||
@@ -56,6 +56,9 @@
|
|||||||
#include <qvideorenderercontrol.h>
|
#include <qvideorenderercontrol.h>
|
||||||
#include <qvideowindowcontrol.h>
|
#include <qvideowindowcontrol.h>
|
||||||
|
|
||||||
|
#include "mockmediaserviceprovider.h"
|
||||||
|
#include "mockmediaplayerservice.h"
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
class AutoConnection
|
class AutoConnection
|
||||||
@@ -79,313 +82,6 @@ private:
|
|||||||
const char *method;
|
const char *method;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MockPlayerControl : public QMediaPlayerControl
|
|
||||||
{
|
|
||||||
friend class MockPlayerService;
|
|
||||||
|
|
||||||
public:
|
|
||||||
MockPlayerControl():QMediaPlayerControl(0) {}
|
|
||||||
|
|
||||||
QMediaPlayer::State state() const { return _state; }
|
|
||||||
QMediaPlayer::MediaStatus mediaStatus() const { return _mediaStatus; }
|
|
||||||
|
|
||||||
qint64 duration() const { return _duration; }
|
|
||||||
|
|
||||||
qint64 position() const { return _position; }
|
|
||||||
|
|
||||||
void setPosition(qint64 position) { if (position != _position) emit positionChanged(_position = position); }
|
|
||||||
|
|
||||||
int volume() const { return _volume; }
|
|
||||||
void setVolume(int volume) { emit volumeChanged(_volume = volume); }
|
|
||||||
|
|
||||||
bool isMuted() const { return _muted; }
|
|
||||||
void setMuted(bool muted) { if (muted != _muted) emit mutedChanged(_muted = muted); }
|
|
||||||
|
|
||||||
int bufferStatus() const { return _bufferStatus; }
|
|
||||||
|
|
||||||
bool isAudioAvailable() const { return _audioAvailable; }
|
|
||||||
bool isVideoAvailable() const { return _videoAvailable; }
|
|
||||||
|
|
||||||
bool isSeekable() const { return _isSeekable; }
|
|
||||||
QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(_seekRange.first, _seekRange.second); }
|
|
||||||
void setSeekRange(qint64 minimum, qint64 maximum) { _seekRange = qMakePair(minimum, maximum); }
|
|
||||||
|
|
||||||
qreal playbackRate() const { return _playbackRate; }
|
|
||||||
void setPlaybackRate(qreal rate) { if (rate != _playbackRate) emit playbackRateChanged(_playbackRate = rate); }
|
|
||||||
|
|
||||||
QMediaContent media() const { return _media; }
|
|
||||||
void setMedia(const QMediaContent &content, QIODevice *stream)
|
|
||||||
{
|
|
||||||
_stream = stream;
|
|
||||||
_media = content;
|
|
||||||
if (_state != QMediaPlayer::StoppedState) {
|
|
||||||
_mediaStatus = _media.isNull() ? QMediaPlayer::NoMedia : QMediaPlayer::LoadingMedia;
|
|
||||||
emit stateChanged(_state = QMediaPlayer::StoppedState);
|
|
||||||
emit mediaStatusChanged(_mediaStatus);
|
|
||||||
}
|
|
||||||
emit mediaChanged(_media = content);
|
|
||||||
}
|
|
||||||
QIODevice *mediaStream() const { return _stream; }
|
|
||||||
|
|
||||||
void play() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PlayingState) emit stateChanged(_state = QMediaPlayer::PlayingState); }
|
|
||||||
void pause() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PausedState) emit stateChanged(_state = QMediaPlayer::PausedState); }
|
|
||||||
void stop() { if (_state != QMediaPlayer::StoppedState) emit stateChanged(_state = QMediaPlayer::StoppedState); }
|
|
||||||
|
|
||||||
QMediaPlayer::State _state;
|
|
||||||
QMediaPlayer::MediaStatus _mediaStatus;
|
|
||||||
QMediaPlayer::Error _error;
|
|
||||||
qint64 _duration;
|
|
||||||
qint64 _position;
|
|
||||||
int _volume;
|
|
||||||
bool _muted;
|
|
||||||
int _bufferStatus;
|
|
||||||
bool _audioAvailable;
|
|
||||||
bool _videoAvailable;
|
|
||||||
bool _isSeekable;
|
|
||||||
QPair<qint64, qint64> _seekRange;
|
|
||||||
qreal _playbackRate;
|
|
||||||
QMediaContent _media;
|
|
||||||
QIODevice *_stream;
|
|
||||||
bool _isValid;
|
|
||||||
QString _errorString;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockVideoSurface : public QAbstractVideoSurface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
|
||||||
const QAbstractVideoBuffer::HandleType) const
|
|
||||||
{
|
|
||||||
return QList<QVideoFrame::PixelFormat>();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool present(const QVideoFrame &) { return false; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockVideoRendererControl : public QVideoRendererControl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MockVideoRendererControl() : m_surface(0) {}
|
|
||||||
|
|
||||||
QAbstractVideoSurface *surface() const { return m_surface; }
|
|
||||||
void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
|
|
||||||
|
|
||||||
QAbstractVideoSurface *m_surface;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockVideoWindowControl : public QVideoWindowControl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WId winId() const { return 0; }
|
|
||||||
void setWinId(WId) {}
|
|
||||||
QRect displayRect() const { return QRect(); }
|
|
||||||
void setDisplayRect(const QRect &) {}
|
|
||||||
bool isFullScreen() const { return false; }
|
|
||||||
void setFullScreen(bool) {}
|
|
||||||
void repaint() {}
|
|
||||||
QSize nativeSize() const { return QSize(); }
|
|
||||||
Qt::AspectRatioMode aspectRatioMode() const { return Qt::KeepAspectRatio; }
|
|
||||||
void setAspectRatioMode(Qt::AspectRatioMode) {}
|
|
||||||
int brightness() const { return 0; }
|
|
||||||
void setBrightness(int) {}
|
|
||||||
int contrast() const { return 0; }
|
|
||||||
void setContrast(int) {}
|
|
||||||
int hue() const { return 0; }
|
|
||||||
void setHue(int) {}
|
|
||||||
int saturation() const { return 0; }
|
|
||||||
void setSaturation(int) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockStreamsControl : public QMediaStreamsControl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MockStreamsControl(QObject *parent = 0) : QMediaStreamsControl(parent) {}
|
|
||||||
|
|
||||||
int streamCount() { return _streams.count(); }
|
|
||||||
void setStreamCount(int count) { _streams.resize(count); }
|
|
||||||
|
|
||||||
StreamType streamType(int index) { return _streams.at(index).type; }
|
|
||||||
void setStreamType(int index, StreamType type) { _streams[index].type = type; }
|
|
||||||
|
|
||||||
QVariant metaData(int index, QtMultimediaKit::MetaData key) {
|
|
||||||
return _streams.at(index).metaData.value(key); }
|
|
||||||
void setMetaData(int index, QtMultimediaKit::MetaData key, const QVariant &value) {
|
|
||||||
_streams[index].metaData.insert(key, value); }
|
|
||||||
|
|
||||||
bool isActive(int index) { return _streams.at(index).active; }
|
|
||||||
void setActive(int index, bool state) { _streams[index].active = state; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct Stream
|
|
||||||
{
|
|
||||||
Stream() : type(UnknownStream), active(false) {}
|
|
||||||
StreamType type;
|
|
||||||
QMap<QtMultimediaKit::MetaData, QVariant> metaData;
|
|
||||||
bool active;
|
|
||||||
};
|
|
||||||
|
|
||||||
QVector<Stream> _streams;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockNetworkAccessControl : public QMediaNetworkAccessControl
|
|
||||||
{
|
|
||||||
friend class MockPlayerService;
|
|
||||||
|
|
||||||
public:
|
|
||||||
MockNetworkAccessControl() {}
|
|
||||||
~MockNetworkAccessControl() {}
|
|
||||||
|
|
||||||
void setConfigurations(const QList<QNetworkConfiguration> &configurations)
|
|
||||||
{
|
|
||||||
_configurations = configurations;
|
|
||||||
_current = QNetworkConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
QNetworkConfiguration currentConfiguration() const
|
|
||||||
{
|
|
||||||
return _current;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setCurrentConfiguration(QNetworkConfiguration configuration)
|
|
||||||
{
|
|
||||||
if (_configurations.contains(configuration))
|
|
||||||
emit configurationChanged(_current = configuration);
|
|
||||||
else
|
|
||||||
emit configurationChanged(_current = QNetworkConfiguration());
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QNetworkConfiguration> _configurations;
|
|
||||||
QNetworkConfiguration _current;
|
|
||||||
};
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QNetworkConfiguration)
|
|
||||||
|
|
||||||
class MockPlayerService : public QMediaService
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MockPlayerService():QMediaService(0)
|
|
||||||
{
|
|
||||||
mockControl = new MockPlayerControl;
|
|
||||||
mockStreamsControl = new MockStreamsControl;
|
|
||||||
mockNetworkControl = new MockNetworkAccessControl;
|
|
||||||
rendererControl = new MockVideoRendererControl;
|
|
||||||
windowControl = new MockVideoWindowControl;
|
|
||||||
rendererRef = 0;
|
|
||||||
windowRef = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
~MockPlayerService()
|
|
||||||
{
|
|
||||||
delete mockControl;
|
|
||||||
delete mockStreamsControl;
|
|
||||||
delete mockNetworkControl;
|
|
||||||
delete rendererControl;
|
|
||||||
delete windowControl;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMediaControl* requestControl(const char *iid)
|
|
||||||
{
|
|
||||||
if (qstrcmp(iid, QMediaPlayerControl_iid) == 0) {
|
|
||||||
return mockControl;
|
|
||||||
} else if (qstrcmp(iid, QVideoRendererControl_iid) == 0) {
|
|
||||||
if (rendererRef == 0) {
|
|
||||||
rendererRef += 1;
|
|
||||||
return rendererControl;
|
|
||||||
}
|
|
||||||
} else if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
|
|
||||||
if (windowRef == 0) {
|
|
||||||
windowRef += 1;
|
|
||||||
return windowControl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (qstrcmp(iid, QMediaNetworkAccessControl_iid) == 0)
|
|
||||||
return mockNetworkControl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void releaseControl(QMediaControl *control)
|
|
||||||
{
|
|
||||||
if (control == rendererControl)
|
|
||||||
rendererRef -= 1;
|
|
||||||
else if (control == windowControl)
|
|
||||||
windowRef -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setState(QMediaPlayer::State state) { emit mockControl->stateChanged(mockControl->_state = state); }
|
|
||||||
void setState(QMediaPlayer::State state, QMediaPlayer::MediaStatus status) {
|
|
||||||
mockControl->_state = state;
|
|
||||||
mockControl->_mediaStatus = status;
|
|
||||||
emit mockControl->mediaStatusChanged(status);
|
|
||||||
emit mockControl->stateChanged(state);
|
|
||||||
}
|
|
||||||
void setMediaStatus(QMediaPlayer::MediaStatus status) { emit mockControl->mediaStatusChanged(mockControl->_mediaStatus = status); }
|
|
||||||
void setIsValid(bool isValid) { mockControl->_isValid = isValid; }
|
|
||||||
void setMedia(QMediaContent media) { mockControl->_media = media; }
|
|
||||||
void setDuration(qint64 duration) { mockControl->_duration = duration; }
|
|
||||||
void setPosition(qint64 position) { mockControl->_position = position; }
|
|
||||||
void setSeekable(bool seekable) { mockControl->_isSeekable = seekable; }
|
|
||||||
void setVolume(int volume) { mockControl->_volume = volume; }
|
|
||||||
void setMuted(bool muted) { mockControl->_muted = muted; }
|
|
||||||
void setVideoAvailable(bool videoAvailable) { mockControl->_videoAvailable = videoAvailable; }
|
|
||||||
void setBufferStatus(int bufferStatus) { mockControl->_bufferStatus = bufferStatus; }
|
|
||||||
void setPlaybackRate(qreal playbackRate) { mockControl->_playbackRate = playbackRate; }
|
|
||||||
void setError(QMediaPlayer::Error error) { mockControl->_error = error; emit mockControl->error(mockControl->_error, mockControl->_errorString); }
|
|
||||||
void setErrorString(QString errorString) { mockControl->_errorString = errorString; emit mockControl->error(mockControl->_error, mockControl->_errorString); }
|
|
||||||
|
|
||||||
void selectCurrentConfiguration(QNetworkConfiguration config) { mockNetworkControl->setCurrentConfiguration(config); }
|
|
||||||
|
|
||||||
void reset()
|
|
||||||
{
|
|
||||||
mockControl->_state = QMediaPlayer::StoppedState;
|
|
||||||
mockControl->_mediaStatus = QMediaPlayer::UnknownMediaStatus;
|
|
||||||
mockControl->_error = QMediaPlayer::NoError;
|
|
||||||
mockControl->_duration = 0;
|
|
||||||
mockControl->_position = 0;
|
|
||||||
mockControl->_volume = 0;
|
|
||||||
mockControl->_muted = false;
|
|
||||||
mockControl->_bufferStatus = 0;
|
|
||||||
mockControl->_videoAvailable = false;
|
|
||||||
mockControl->_isSeekable = false;
|
|
||||||
mockControl->_playbackRate = 0.0;
|
|
||||||
mockControl->_media = QMediaContent();
|
|
||||||
mockControl->_stream = 0;
|
|
||||||
mockControl->_isValid = false;
|
|
||||||
mockControl->_errorString = QString();
|
|
||||||
|
|
||||||
mockNetworkControl->_current = QNetworkConfiguration();
|
|
||||||
mockNetworkControl->_configurations = QList<QNetworkConfiguration>();
|
|
||||||
}
|
|
||||||
|
|
||||||
MockPlayerControl *mockControl;
|
|
||||||
MockStreamsControl *mockStreamsControl;
|
|
||||||
MockNetworkAccessControl *mockNetworkControl;
|
|
||||||
MockVideoRendererControl *rendererControl;
|
|
||||||
MockVideoWindowControl *windowControl;
|
|
||||||
int rendererRef;
|
|
||||||
int windowRef;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockProvider : public QMediaServiceProvider
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MockProvider(MockPlayerService *service):mockService(service), deleteServiceOnRelease(true) {}
|
|
||||||
QMediaService *requestService(const QByteArray &, const QMediaServiceProviderHint &)
|
|
||||||
{
|
|
||||||
return mockService;
|
|
||||||
}
|
|
||||||
|
|
||||||
void releaseService(QMediaService *service) { if (deleteServiceOnRelease) delete service; }
|
|
||||||
|
|
||||||
MockPlayerService *mockService;
|
|
||||||
bool deleteServiceOnRelease;
|
|
||||||
};
|
|
||||||
|
|
||||||
class tst_QMediaPlayer: public QObject
|
class tst_QMediaPlayer: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -425,10 +121,13 @@ private slots:
|
|||||||
void testSetVideoOutputDestruction();
|
void testSetVideoOutputDestruction();
|
||||||
void testPositionPropertyWatch();
|
void testPositionPropertyWatch();
|
||||||
void debugEnums();
|
void debugEnums();
|
||||||
|
void testPlayerFlags();
|
||||||
|
void testDestructor();
|
||||||
|
void testSupportedMimeTypes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MockProvider *mockProvider;
|
MockMediaServiceProvider *mockProvider;
|
||||||
MockPlayerService *mockService;
|
MockMediaPlayerService *mockService;
|
||||||
QMediaPlayer *player;
|
QMediaPlayer *player;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ load(qttest_p4)
|
|||||||
# temporarily blacklist test because is fails miserably
|
# temporarily blacklist test because is fails miserably
|
||||||
CONFIG += insignificant_test
|
CONFIG += insignificant_test
|
||||||
|
|
||||||
|
include (../qmultimedia_common/mockplaylist.pri)
|
||||||
|
|
||||||
QT += multimediakit-private
|
QT += multimediakit-private
|
||||||
|
|
||||||
# TARGET = tst_qmediaplaylist
|
# TARGET = tst_qmediaplaylist
|
||||||
@@ -13,7 +15,6 @@ DEFINES += TESTDATA_DIR=\\\"$$PWD/\\\"
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$QT.multimediakit.sources/../plugins/m3u/qm3uhandler.h
|
$$QT.multimediakit.sources/../plugins/m3u/qm3uhandler.h
|
||||||
|
|
||||||
message($$HEADERS)
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
tst_qmediaplaylist.cpp \
|
tst_qmediaplaylist.cpp \
|
||||||
$$QT.multimediakit.sources/../plugins/m3u/qm3uhandler.cpp
|
$$QT.multimediakit.sources/../plugins/m3u/qm3uhandler.cpp
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include "qmediaservice.h"
|
#include "qmediaservice.h"
|
||||||
#include "qmediaplaylist.h"
|
#include "qmediaplaylist.h"
|
||||||
#include "qmediaplaylistcontrol.h"
|
#include "qmediaplaylistcontrol.h"
|
||||||
|
#include "qmediaplaylistsourcecontrol.h"
|
||||||
#include "qmediaplaylistnavigator.h"
|
#include "qmediaplaylistnavigator.h"
|
||||||
#include <private/qmediapluginloader_p.h>
|
#include <private/qmediapluginloader_p.h>
|
||||||
|
|
||||||
@@ -51,91 +52,16 @@
|
|||||||
|
|
||||||
//TESTED_COMPONENT=src/multimedia
|
//TESTED_COMPONENT=src/multimedia
|
||||||
|
|
||||||
|
#include "mockplaylistservice.h"
|
||||||
|
#include "mockmediaplaylistcontrol.h"
|
||||||
|
#include "mockmediaplaylistsourcecontrol.h"
|
||||||
|
#include "mockreadonlyplaylistprovider.h"
|
||||||
|
|
||||||
#ifndef TESTDATA_DIR
|
#ifndef TESTDATA_DIR
|
||||||
#define TESTDATA_DIR "./"
|
#define TESTDATA_DIR "./"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
QT_USE_NAMESPACE
|
||||||
class MockReadOnlyPlaylistProvider : public QMediaPlaylistProvider
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
MockReadOnlyPlaylistProvider(QObject *parent)
|
|
||||||
:QMediaPlaylistProvider(parent)
|
|
||||||
{
|
|
||||||
m_items.append(QMediaContent(QUrl(QLatin1String("file:///1"))));
|
|
||||||
m_items.append(QMediaContent(QUrl(QLatin1String("file:///2"))));
|
|
||||||
m_items.append(QMediaContent(QUrl(QLatin1String("file:///3"))));
|
|
||||||
}
|
|
||||||
|
|
||||||
int mediaCount() const { return m_items.size(); }
|
|
||||||
QMediaContent media(int index) const
|
|
||||||
{
|
|
||||||
return index >=0 && index < mediaCount() ? m_items.at(index) : QMediaContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QList<QMediaContent> m_items;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockPlaylistControl : public QMediaPlaylistControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
MockPlaylistControl(QObject *parent) : QMediaPlaylistControl(parent)
|
|
||||||
{
|
|
||||||
m_navigator = new QMediaPlaylistNavigator(new MockReadOnlyPlaylistProvider(this), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
~MockPlaylistControl()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); }
|
|
||||||
bool setPlaylistProvider(QMediaPlaylistProvider *playlist) { m_navigator->setPlaylist(playlist); return true; }
|
|
||||||
|
|
||||||
int currentIndex() const { return m_navigator->currentIndex(); }
|
|
||||||
void setCurrentIndex(int position) { m_navigator->jump(position); }
|
|
||||||
int nextIndex(int steps) const { return m_navigator->nextIndex(steps); }
|
|
||||||
int previousIndex(int steps) const { return m_navigator->previousIndex(steps); }
|
|
||||||
|
|
||||||
void next() { m_navigator->next(); }
|
|
||||||
void previous() { m_navigator->previous(); }
|
|
||||||
|
|
||||||
QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); }
|
|
||||||
void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) { m_navigator->setPlaybackMode(mode); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
QMediaPlaylistNavigator *m_navigator;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockPlaylistService : public QMediaService
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MockPlaylistService():QMediaService(0)
|
|
||||||
{
|
|
||||||
mockControl = new MockPlaylistControl(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
~MockPlaylistService()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QMediaControl* requestControl(const char *iid)
|
|
||||||
{
|
|
||||||
if (qstrcmp(iid, QMediaPlaylistControl_iid) == 0)
|
|
||||||
return mockControl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void releaseControl(QMediaControl *)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MockPlaylistControl *mockControl;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockReadOnlyPlaylistObject : public QMediaObject
|
class MockReadOnlyPlaylistObject : public QMediaObject
|
||||||
{
|
{
|
||||||
@@ -147,7 +73,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class tst_QMediaPlaylist : public QObject
|
class tst_QMediaPlaylist : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -171,6 +96,19 @@ private slots:
|
|||||||
void readOnlyPlaylist();
|
void readOnlyPlaylist();
|
||||||
void setMediaObject();
|
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:
|
private:
|
||||||
QMediaContent content1;
|
QMediaContent content1;
|
||||||
QMediaContent content2;
|
QMediaContent content2;
|
||||||
@@ -183,6 +121,7 @@ void tst_QMediaPlaylist::init()
|
|||||||
|
|
||||||
void tst_QMediaPlaylist::initTestCase()
|
void tst_QMediaPlaylist::initTestCase()
|
||||||
{
|
{
|
||||||
|
qRegisterMetaType<QMediaContent>();
|
||||||
content1 = QMediaContent(QUrl(QLatin1String("file:///1")));
|
content1 = QMediaContent(QUrl(QLatin1String("file:///1")));
|
||||||
content2 = QMediaContent(QUrl(QLatin1String("file:///2")));
|
content2 = QMediaContent(QUrl(QLatin1String("file:///2")));
|
||||||
content3 = QMediaContent(QUrl(QLatin1String("file:///3")));
|
content3 = QMediaContent(QUrl(QLatin1String("file:///3")));
|
||||||
@@ -420,7 +359,7 @@ void tst_QMediaPlaylist::saveAndLoad()
|
|||||||
|
|
||||||
bool res = playlist.save(&buffer, "unsupported_format");
|
bool res = playlist.save(&buffer, "unsupported_format");
|
||||||
QVERIFY(!res);
|
QVERIFY(!res);
|
||||||
QVERIFY(playlist.error() != QMediaPlaylist::NoError);
|
QVERIFY(playlist.error() == QMediaPlaylist::FormatNotSupportedError);
|
||||||
QVERIFY(!playlist.errorString().isEmpty());
|
QVERIFY(!playlist.errorString().isEmpty());
|
||||||
|
|
||||||
QSignalSpy errorSignal(&playlist, SIGNAL(loadFailed()));
|
QSignalSpy errorSignal(&playlist, SIGNAL(loadFailed()));
|
||||||
@@ -437,7 +376,7 @@ void tst_QMediaPlaylist::saveAndLoad()
|
|||||||
errorSignal.clear();
|
errorSignal.clear();
|
||||||
playlist.load(QUrl(QLatin1String("tmp.unsupported_format")), "unsupported_format");
|
playlist.load(QUrl(QLatin1String("tmp.unsupported_format")), "unsupported_format");
|
||||||
QCOMPARE(errorSignal.size(), 1);
|
QCOMPARE(errorSignal.size(), 1);
|
||||||
QVERIFY(playlist.error() != QMediaPlaylist::NoError);
|
QVERIFY(playlist.error() == QMediaPlaylist::FormatNotSupportedError);
|
||||||
QVERIFY(!playlist.errorString().isEmpty());
|
QVERIFY(!playlist.errorString().isEmpty());
|
||||||
|
|
||||||
res = playlist.save(&buffer, "m3u");
|
res = playlist.save(&buffer, "m3u");
|
||||||
@@ -509,6 +448,7 @@ void tst_QMediaPlaylist::playbackMode_data()
|
|||||||
QTest::newRow("ItemOnce, 1") << QMediaPlaylist::CurrentItemOnce << -1 << 1 << -1;
|
QTest::newRow("ItemOnce, 1") << QMediaPlaylist::CurrentItemOnce << -1 << 1 << -1;
|
||||||
QTest::newRow("ItemInLoop, 1") << QMediaPlaylist::CurrentItemInLoop << 1 << 1 << 1;
|
QTest::newRow("ItemInLoop, 1") << QMediaPlaylist::CurrentItemInLoop << 1 << 1 << 1;
|
||||||
|
|
||||||
|
// Bit difficult to test random this way
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMediaPlaylist::playbackMode()
|
void tst_QMediaPlaylist::playbackMode()
|
||||||
@@ -653,6 +593,191 @@ void tst_QMediaPlaylist::setMediaObject()
|
|||||||
QVERIFY(playlist.isReadOnly());
|
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)
|
QTEST_MAIN(tst_QMediaPlaylist)
|
||||||
#include "tst_qmediaplaylist.moc"
|
#include "tst_qmediaplaylist.moc"
|
||||||
|
|
||||||
|
|||||||
@@ -62,10 +62,20 @@ private slots:
|
|||||||
void currentItemOnce();
|
void currentItemOnce();
|
||||||
void currentItemInLoop();
|
void currentItemInLoop();
|
||||||
void randomPlayback();
|
void randomPlayback();
|
||||||
|
|
||||||
|
void testItemAt();
|
||||||
|
void testNextIndex();
|
||||||
|
void testPreviousIndex();
|
||||||
|
void testCurrentIndexChangedSignal();
|
||||||
|
void testPlaybackModeChangedSignal();
|
||||||
|
void testSurroundingItemsChangedSignal();
|
||||||
|
void testActivatedSignal();
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_QMediaPlaylistNavigator::init()
|
void tst_QMediaPlaylistNavigator::init()
|
||||||
{
|
{
|
||||||
|
qRegisterMetaType<QMediaPlaylist::PlaybackMode>("QMediaPlaylist::PlaybackMode");
|
||||||
|
qRegisterMetaType<QMediaContent>("QMediaContent");
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMediaPlaylistNavigator::cleanup()
|
void tst_QMediaPlaylistNavigator::cleanup()
|
||||||
@@ -314,5 +324,202 @@ void tst_QMediaPlaylistNavigator::randomPlayback()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
QTEST_MAIN(tst_QMediaPlaylistNavigator)
|
||||||
#include "tst_qmediaplaylistnavigator.moc"
|
#include "tst_qmediaplaylistnavigator.moc"
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ QT += multimediakit-private
|
|||||||
# TARGET = tst_qmediarecorder
|
# TARGET = tst_qmediarecorder
|
||||||
# CONFIG += testcase
|
# CONFIG += testcase
|
||||||
|
|
||||||
|
include (../qmultimedia_common/mock.pri)
|
||||||
|
include (../qmultimedia_common/mockrecorder.pri)
|
||||||
|
|
||||||
HEADERS += tst_qmediarecorder.h
|
HEADERS += tst_qmediarecorder.h
|
||||||
SOURCES += main.cpp tst_qmediarecorder.cpp
|
SOURCES += main.cpp tst_qmediarecorder.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ void tst_QMediaRecorder::initTestCase()
|
|||||||
qRegisterMetaType<QMediaRecorder::State>("QMediaRecorder::State");
|
qRegisterMetaType<QMediaRecorder::State>("QMediaRecorder::State");
|
||||||
qRegisterMetaType<QMediaRecorder::Error>("QMediaRecorder::Error");
|
qRegisterMetaType<QMediaRecorder::Error>("QMediaRecorder::Error");
|
||||||
|
|
||||||
mock = new MockProvider(this);
|
mock = new MockMediaRecorderControl(this);
|
||||||
service = new MockService(this, mock);
|
service = new MockMediaRecorderService(this, mock);
|
||||||
object = new MockObject(this, service);
|
object = new MockMediaObject(this, service);
|
||||||
capture = new QMediaRecorder(object);
|
capture = new QMediaRecorder(object);
|
||||||
|
|
||||||
audio = qobject_cast<QAudioEndpointSelector*>(service->requestControl(QAudioEndpointSelector_iid));
|
audio = qobject_cast<QAudioEndpointSelector*>(service->requestControl(QAudioEndpointSelector_iid));
|
||||||
@@ -72,7 +72,7 @@ void tst_QMediaRecorder::testNullService()
|
|||||||
{
|
{
|
||||||
const QString id(QLatin1String("application/x-format"));
|
const QString id(QLatin1String("application/x-format"));
|
||||||
|
|
||||||
MockObject object(0, 0);
|
MockMediaObject object(0, 0);
|
||||||
QMediaRecorder recorder(&object);
|
QMediaRecorder recorder(&object);
|
||||||
|
|
||||||
QCOMPARE(recorder.outputLocation(), QUrl());
|
QCOMPARE(recorder.outputLocation(), QUrl());
|
||||||
@@ -104,9 +104,9 @@ void tst_QMediaRecorder::testNullControls()
|
|||||||
{
|
{
|
||||||
const QString id(QLatin1String("application/x-format"));
|
const QString id(QLatin1String("application/x-format"));
|
||||||
|
|
||||||
MockService service(0, 0);
|
MockMediaRecorderService service(0, 0);
|
||||||
service.hasControls = false;
|
service.hasControls = false;
|
||||||
MockObject object(0, &service);
|
MockMediaObject object(0, &service);
|
||||||
QMediaRecorder recorder(&object);
|
QMediaRecorder recorder(&object);
|
||||||
|
|
||||||
QCOMPARE(recorder.outputLocation(), QUrl());
|
QCOMPARE(recorder.outputLocation(), QUrl());
|
||||||
@@ -256,7 +256,9 @@ void tst_QMediaRecorder::testAudioEncodeControl()
|
|||||||
QVERIFY(encode->encodingOption("audio/mpeg","bitrate").isNull());
|
QVERIFY(encode->encodingOption("audio/mpeg","bitrate").isNull());
|
||||||
encode->setEncodingOption("audio/mpeg", "bitrate", QString("vbr"));
|
encode->setEncodingOption("audio/mpeg", "bitrate", QString("vbr"));
|
||||||
QCOMPARE(encode->encodingOption("audio/mpeg","bitrate").toString(), QString("vbr"));
|
QCOMPARE(encode->encodingOption("audio/mpeg","bitrate").toString(), QString("vbr"));
|
||||||
QCOMPARE(capture->supportedAudioSampleRates(), QList<int>() << 44100);
|
QList<int> rates;
|
||||||
|
rates << 8000 << 11025 << 22050 << 44100;
|
||||||
|
QCOMPARE(capture->supportedAudioSampleRates(), rates);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMediaRecorder::testMediaFormatsControl()
|
void tst_QMediaRecorder::testMediaFormatsControl()
|
||||||
@@ -297,7 +299,7 @@ void tst_QMediaRecorder::testEncodingSettings()
|
|||||||
QAudioEncoderSettings audioSettings = capture->audioSettings();
|
QAudioEncoderSettings audioSettings = capture->audioSettings();
|
||||||
QCOMPARE(audioSettings.codec(), QString("audio/pcm"));
|
QCOMPARE(audioSettings.codec(), QString("audio/pcm"));
|
||||||
QCOMPARE(audioSettings.bitRate(), 128*1024);
|
QCOMPARE(audioSettings.bitRate(), 128*1024);
|
||||||
QCOMPARE(audioSettings.sampleRate(), -1);
|
QCOMPARE(audioSettings.sampleRate(), 8000);
|
||||||
QCOMPARE(audioSettings.quality(), QtMultimediaKit::NormalQuality);
|
QCOMPARE(audioSettings.quality(), QtMultimediaKit::NormalQuality);
|
||||||
QCOMPARE(audioSettings.channelCount(), -1);
|
QCOMPARE(audioSettings.channelCount(), -1);
|
||||||
|
|
||||||
@@ -595,10 +597,10 @@ void tst_QMediaRecorder::nullMetaDataControl()
|
|||||||
const QString titleKey(QLatin1String("Title"));
|
const QString titleKey(QLatin1String("Title"));
|
||||||
const QString title(QLatin1String("Host of Seraphim"));
|
const QString title(QLatin1String("Host of Seraphim"));
|
||||||
|
|
||||||
MockProvider recorderControl(0);
|
MockMediaRecorderControl recorderControl(0);
|
||||||
MockService service(0, &recorderControl);
|
MockMediaRecorderService service(0, &recorderControl);
|
||||||
service.hasControls = false;
|
service.hasControls = false;
|
||||||
MockObject object(0, &service);
|
MockMediaObject object(0, &service);
|
||||||
|
|
||||||
QMediaRecorder recorder(&object);
|
QMediaRecorder recorder(&object);
|
||||||
|
|
||||||
@@ -619,10 +621,10 @@ void tst_QMediaRecorder::nullMetaDataControl()
|
|||||||
|
|
||||||
void tst_QMediaRecorder::isMetaDataAvailable()
|
void tst_QMediaRecorder::isMetaDataAvailable()
|
||||||
{
|
{
|
||||||
MockProvider recorderControl(0);
|
MockMediaRecorderControl recorderControl(0);
|
||||||
MockService service(0, &recorderControl);
|
MockMediaRecorderService service(0, &recorderControl);
|
||||||
service.mockMetaDataControl->setMetaDataAvailable(false);
|
service.mockMetaDataControl->setMetaDataAvailable(false);
|
||||||
MockObject object(0, &service);
|
MockMediaObject object(0, &service);
|
||||||
|
|
||||||
QMediaRecorder recorder(&object);
|
QMediaRecorder recorder(&object);
|
||||||
QCOMPARE(recorder.isMetaDataAvailable(), false);
|
QCOMPARE(recorder.isMetaDataAvailable(), false);
|
||||||
@@ -643,11 +645,11 @@ void tst_QMediaRecorder::isMetaDataAvailable()
|
|||||||
|
|
||||||
void tst_QMediaRecorder::isWritable()
|
void tst_QMediaRecorder::isWritable()
|
||||||
{
|
{
|
||||||
MockProvider recorderControl(0);
|
MockMediaRecorderControl recorderControl(0);
|
||||||
MockService service(0, &recorderControl);
|
MockMediaRecorderService service(0, &recorderControl);
|
||||||
service.mockMetaDataControl->setWritable(false);
|
service.mockMetaDataControl->setWritable(false);
|
||||||
|
|
||||||
MockObject object(0, &service);
|
MockMediaObject object(0, &service);
|
||||||
|
|
||||||
QMediaRecorder recorder(&object);
|
QMediaRecorder recorder(&object);
|
||||||
|
|
||||||
@@ -670,9 +672,9 @@ void tst_QMediaRecorder::isWritable()
|
|||||||
|
|
||||||
void tst_QMediaRecorder::metaDataChanged()
|
void tst_QMediaRecorder::metaDataChanged()
|
||||||
{
|
{
|
||||||
MockProvider recorderControl(0);
|
MockMediaRecorderControl recorderControl(0);
|
||||||
MockService service(0, &recorderControl);
|
MockMediaRecorderService service(0, &recorderControl);
|
||||||
MockObject object(0, &service);
|
MockMediaObject object(0, &service);
|
||||||
|
|
||||||
QMediaRecorder recorder(&object);
|
QMediaRecorder recorder(&object);
|
||||||
|
|
||||||
@@ -703,11 +705,11 @@ void tst_QMediaRecorder::metaData()
|
|||||||
QFETCH(QString, title);
|
QFETCH(QString, title);
|
||||||
QFETCH(QString, genre);
|
QFETCH(QString, genre);
|
||||||
|
|
||||||
MockProvider recorderControl(0);
|
MockMediaRecorderControl recorderControl(0);
|
||||||
MockService service(0, &recorderControl);
|
MockMediaRecorderService service(0, &recorderControl);
|
||||||
service.mockMetaDataControl->populateMetaData();
|
service.mockMetaDataControl->populateMetaData();
|
||||||
|
|
||||||
MockObject object(0, &service);
|
MockMediaObject object(0, &service);
|
||||||
|
|
||||||
QMediaRecorder recorder(&object);
|
QMediaRecorder recorder(&object);
|
||||||
QVERIFY(object.availableMetaData().isEmpty());
|
QVERIFY(object.availableMetaData().isEmpty());
|
||||||
@@ -738,11 +740,11 @@ void tst_QMediaRecorder::setMetaData()
|
|||||||
{
|
{
|
||||||
QFETCH(QString, title);
|
QFETCH(QString, title);
|
||||||
|
|
||||||
MockProvider recorderControl(0);
|
MockMediaRecorderControl recorderControl(0);
|
||||||
MockService service(0, &recorderControl);
|
MockMediaRecorderService service(0, &recorderControl);
|
||||||
service.mockMetaDataControl->populateMetaData();
|
service.mockMetaDataControl->populateMetaData();
|
||||||
|
|
||||||
MockObject object(0, &service);
|
MockMediaObject object(0, &service);
|
||||||
|
|
||||||
QMediaRecorder recorder(&object);
|
QMediaRecorder recorder(&object);
|
||||||
|
|
||||||
@@ -757,9 +759,9 @@ void tst_QMediaRecorder::extendedMetaData()
|
|||||||
QFETCH(QString, title);
|
QFETCH(QString, title);
|
||||||
QFETCH(QString, genre);
|
QFETCH(QString, genre);
|
||||||
|
|
||||||
MockProvider recorderControl(0);
|
MockMediaRecorderControl recorderControl(0);
|
||||||
MockService service(0, &recorderControl);
|
MockMediaRecorderService service(0, &recorderControl);
|
||||||
MockObject object(0, &service);
|
MockMediaObject object(0, &service);
|
||||||
|
|
||||||
QMediaRecorder recorder(&object);
|
QMediaRecorder recorder(&object);
|
||||||
QVERIFY(recorder.availableExtendedMetaData().isEmpty());
|
QVERIFY(recorder.availableExtendedMetaData().isEmpty());
|
||||||
@@ -780,11 +782,11 @@ void tst_QMediaRecorder::extendedMetaData()
|
|||||||
|
|
||||||
void tst_QMediaRecorder::setExtendedMetaData()
|
void tst_QMediaRecorder::setExtendedMetaData()
|
||||||
{
|
{
|
||||||
MockProvider recorderControl(0);
|
MockMediaRecorderControl recorderControl(0);
|
||||||
MockService service(0, &recorderControl);
|
MockMediaRecorderService service(0, &recorderControl);
|
||||||
service.mockMetaDataControl->populateMetaData();
|
service.mockMetaDataControl->populateMetaData();
|
||||||
|
|
||||||
MockObject object(0, &service);
|
MockMediaObject object(0, &service);
|
||||||
|
|
||||||
QMediaRecorder recorder(&object);
|
QMediaRecorder recorder(&object);
|
||||||
|
|
||||||
@@ -794,3 +796,471 @@ void tst_QMediaRecorder::setExtendedMetaData()
|
|||||||
QCOMPARE(recorder.extendedMetaData(QLatin1String("Title")).toString(), title);
|
QCOMPARE(recorder.extendedMetaData(QLatin1String("Title")).toString(), title);
|
||||||
QCOMPARE(service.mockMetaDataControl->m_extendedData.value(QLatin1String("Title")).toString(), title);
|
QCOMPARE(service.mockMetaDataControl->m_extendedData.value(QLatin1String("Title")).toString(), title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void tst_QMediaRecorder::testAudioSettingsCopyConstructor()
|
||||||
|
{
|
||||||
|
/* create an object for AudioEncodersettings */
|
||||||
|
QAudioEncoderSettings audiosettings;
|
||||||
|
QVERIFY(audiosettings.isNull());
|
||||||
|
|
||||||
|
/* setting the desired properties for the AudioEncoder */
|
||||||
|
audiosettings.setBitRate(128*1000);
|
||||||
|
audiosettings.setChannelCount(4);
|
||||||
|
audiosettings.setCodec("audio/pcm");
|
||||||
|
audiosettings.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
audiosettings.setQuality(QtMultimediaKit::LowQuality);
|
||||||
|
audiosettings.setSampleRate(44100);
|
||||||
|
|
||||||
|
/* Copy constructor */
|
||||||
|
QAudioEncoderSettings other(audiosettings);
|
||||||
|
QVERIFY(!(other.isNull()));
|
||||||
|
|
||||||
|
/* Verifying whether data is copied properly or not */
|
||||||
|
QVERIFY(other.bitRate() == audiosettings.bitRate());
|
||||||
|
QVERIFY(other.sampleRate() == audiosettings.sampleRate());
|
||||||
|
QVERIFY(other.channelCount() == audiosettings.channelCount());
|
||||||
|
QCOMPARE(other.codec(), audiosettings.codec());
|
||||||
|
QVERIFY(other.encodingMode() == audiosettings.encodingMode());
|
||||||
|
QVERIFY(other.quality() == audiosettings.quality());
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QMediaRecorder::testAudioSettingsOperatorNotEqual()
|
||||||
|
{
|
||||||
|
/* create an object for AudioEncodersettings */
|
||||||
|
QAudioEncoderSettings audiosettings1;
|
||||||
|
QVERIFY(audiosettings1.isNull());
|
||||||
|
|
||||||
|
QAudioEncoderSettings audiosettings2;
|
||||||
|
QVERIFY(audiosettings2.isNull());
|
||||||
|
|
||||||
|
/* setting the desired properties to for the AudioEncoder */
|
||||||
|
audiosettings1.setBitRate(128*1000);
|
||||||
|
audiosettings1.setChannelCount(4);
|
||||||
|
audiosettings1.setCodec("audio/pcm");
|
||||||
|
audiosettings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
audiosettings1.setQuality(QtMultimediaKit::LowQuality);
|
||||||
|
audiosettings1.setSampleRate(44100);
|
||||||
|
|
||||||
|
/* setting the desired properties for the AudioEncoder */
|
||||||
|
audiosettings2.setBitRate(128*1000);
|
||||||
|
audiosettings2.setChannelCount(4);
|
||||||
|
audiosettings2.setCodec("audio/pcm");
|
||||||
|
audiosettings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
audiosettings2.setQuality(QtMultimediaKit::LowQuality);
|
||||||
|
audiosettings2.setSampleRate(44100);
|
||||||
|
|
||||||
|
/* verify the both are equal or not */
|
||||||
|
QVERIFY(!(audiosettings1 != audiosettings2));
|
||||||
|
|
||||||
|
/* Modify the settings value for one object */
|
||||||
|
audiosettings2.setBitRate(64*1000);
|
||||||
|
audiosettings2.setEncodingMode(QtMultimediaKit::ConstantQualityEncoding);
|
||||||
|
|
||||||
|
/* verify the not equal opertor */
|
||||||
|
QVERIFY(audiosettings1 != audiosettings2);
|
||||||
|
|
||||||
|
QVERIFY(audiosettings2.bitRate() != audiosettings1.bitRate());
|
||||||
|
QVERIFY(audiosettings2.encodingMode() != audiosettings1.encodingMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QMediaRecorder::testAudioSettingsOperatorEqual()
|
||||||
|
{
|
||||||
|
/* create an object for AudioEncodersettings */
|
||||||
|
QAudioEncoderSettings audiosettings1;
|
||||||
|
QVERIFY(audiosettings1.isNull());
|
||||||
|
|
||||||
|
/* setting the desired properties to for the AudioEncoder */
|
||||||
|
audiosettings1.setBitRate(128*1000);
|
||||||
|
audiosettings1.setChannelCount(4);
|
||||||
|
audiosettings1.setCodec("audio/pcm");
|
||||||
|
audiosettings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
audiosettings1.setQuality(QtMultimediaKit::LowQuality);
|
||||||
|
audiosettings1.setSampleRate(44100);
|
||||||
|
|
||||||
|
QAudioEncoderSettings audiosettings2;
|
||||||
|
QVERIFY(audiosettings2.isNull());
|
||||||
|
|
||||||
|
/* setting the desired properties for the AudioEncoder */
|
||||||
|
audiosettings2.setBitRate(128*1000);
|
||||||
|
audiosettings2.setChannelCount(4);
|
||||||
|
audiosettings2.setCodec("audio/pcm");
|
||||||
|
audiosettings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
audiosettings2.setQuality(QtMultimediaKit::LowQuality);
|
||||||
|
audiosettings2.setSampleRate(44100);
|
||||||
|
|
||||||
|
/* verify both the values are same or not */
|
||||||
|
QVERIFY(audiosettings1 == audiosettings2);
|
||||||
|
audiosettings2.setChannelCount(2);
|
||||||
|
QVERIFY(audiosettings1 != audiosettings2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QMediaRecorder::testAudioSettingsOperatorAssign()
|
||||||
|
{
|
||||||
|
|
||||||
|
/* create an object for AudioEncodersettings */
|
||||||
|
QAudioEncoderSettings audiosettings1;
|
||||||
|
QVERIFY(audiosettings1.isNull());
|
||||||
|
|
||||||
|
/* setting the desired properties for the AudioEncoder */
|
||||||
|
audiosettings1.setBitRate(128*1000);
|
||||||
|
audiosettings1.setChannelCount(4);
|
||||||
|
audiosettings1.setCodec("audio/pcm");
|
||||||
|
audiosettings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
audiosettings1.setQuality(QtMultimediaKit::LowQuality);
|
||||||
|
audiosettings1.setSampleRate(44100);
|
||||||
|
|
||||||
|
QAudioEncoderSettings audiosettings2;
|
||||||
|
audiosettings2 = audiosettings1;
|
||||||
|
/* Verifying whether data is copied properly or not */
|
||||||
|
QVERIFY(audiosettings2.bitRate() == audiosettings1.bitRate());
|
||||||
|
QVERIFY(audiosettings2.sampleRate() == audiosettings1.sampleRate());
|
||||||
|
QVERIFY(audiosettings2.channelCount() == audiosettings1.channelCount());
|
||||||
|
QCOMPARE(audiosettings2.codec(), audiosettings1.codec());
|
||||||
|
QVERIFY(audiosettings2.encodingMode() == audiosettings1.encodingMode());
|
||||||
|
QVERIFY(audiosettings2.quality() == audiosettings1.quality());
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QMediaRecorder::testAudioSettingsDestructor()
|
||||||
|
{
|
||||||
|
/* Creating null object for the audioencodersettings */
|
||||||
|
QAudioEncoderSettings * audiosettings = new QAudioEncoderSettings;
|
||||||
|
|
||||||
|
/* Verifying the object is null or not */
|
||||||
|
QVERIFY(audiosettings->isNull());
|
||||||
|
/* delete the allocated memory */
|
||||||
|
delete audiosettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* availabilityError() API test. */
|
||||||
|
void tst_QMediaRecorder::testAvailabilityError()
|
||||||
|
{
|
||||||
|
MockMediaRecorderService service(0, 0);
|
||||||
|
MockMediaObject object(0, &service);
|
||||||
|
QMediaRecorder recorder(&object);
|
||||||
|
QCOMPARE(recorder.availabilityError(), QtMultimediaKit::ServiceMissingError);
|
||||||
|
|
||||||
|
MockMediaRecorderControl recorderControl(0);
|
||||||
|
MockMediaRecorderService service1(0, &recorderControl);
|
||||||
|
service1.mockMetaDataControl->populateMetaData();
|
||||||
|
MockMediaObject object1(0, &service1);
|
||||||
|
QMediaRecorder recorder1(&object1);
|
||||||
|
QCOMPARE(recorder1.availabilityError(), QtMultimediaKit::NoError);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* isAvailable() API test. */
|
||||||
|
void tst_QMediaRecorder::testIsAvailable()
|
||||||
|
{
|
||||||
|
MockMediaRecorderService service(0, 0);
|
||||||
|
MockMediaObject object(0, &service);
|
||||||
|
QMediaRecorder recorder(&object);
|
||||||
|
QCOMPARE(recorder.isAvailable(), false);
|
||||||
|
|
||||||
|
MockMediaRecorderControl recorderControl(0);
|
||||||
|
MockMediaRecorderService service1(0, &recorderControl);
|
||||||
|
service1.mockMetaDataControl->populateMetaData();
|
||||||
|
MockMediaObject object1(0, &service1);
|
||||||
|
QMediaRecorder recorder1(&object1);
|
||||||
|
QCOMPARE(recorder1.isAvailable(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* mediaObject() API test. */
|
||||||
|
void tst_QMediaRecorder::testMediaObject()
|
||||||
|
{
|
||||||
|
MockMediaRecorderService service(0, 0);
|
||||||
|
service.hasControls = false;
|
||||||
|
MockMediaObject object(0, &service);
|
||||||
|
QMediaRecorder recorder(&object);
|
||||||
|
|
||||||
|
QMediaObject *medobj = recorder.mediaObject();
|
||||||
|
QVERIFY(medobj == NULL);
|
||||||
|
|
||||||
|
QMediaObject *medobj1 = capture->mediaObject();
|
||||||
|
QVERIFY(medobj1 != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* enum QMediaRecorder::ResourceError property test. */
|
||||||
|
void tst_QMediaRecorder::testEnum()
|
||||||
|
{
|
||||||
|
const QString errorString(QLatin1String("resource error"));
|
||||||
|
|
||||||
|
QSignalSpy spy(capture, SIGNAL(error(QMediaRecorder::Error)));
|
||||||
|
|
||||||
|
QCOMPARE(capture->error(), QMediaRecorder::NoError);
|
||||||
|
QCOMPARE(capture->errorString(), QString());
|
||||||
|
|
||||||
|
mock->error(QMediaRecorder::ResourceError, errorString);
|
||||||
|
QCOMPARE(capture->error(), QMediaRecorder::ResourceError);
|
||||||
|
QCOMPARE(capture->errorString(), errorString);
|
||||||
|
QCOMPARE(spy.count(), 1);
|
||||||
|
|
||||||
|
QCOMPARE(spy.last()[0].value<QMediaRecorder::Error>(), QMediaRecorder::ResourceError);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test the QVideoEncoderSettings quality API*/
|
||||||
|
void tst_QMediaRecorder::testVideoSettingsQuality()
|
||||||
|
{
|
||||||
|
/* Create the instance*/
|
||||||
|
QVideoEncoderSettings settings;
|
||||||
|
QVERIFY(settings.isNull());
|
||||||
|
QVERIFY(settings == QVideoEncoderSettings());
|
||||||
|
|
||||||
|
/* Verify the default value is intialised correctly*/
|
||||||
|
QCOMPARE(settings.quality(), QtMultimediaKit::NormalQuality);
|
||||||
|
|
||||||
|
/* Set all types of Quality parameter and Verify if it is set correctly*/
|
||||||
|
settings.setQuality(QtMultimediaKit::HighQuality);
|
||||||
|
QCOMPARE(settings.quality(), QtMultimediaKit::HighQuality);
|
||||||
|
QVERIFY(!settings.isNull());
|
||||||
|
|
||||||
|
settings.setQuality(QtMultimediaKit::VeryLowQuality);
|
||||||
|
QCOMPARE(settings.quality(), QtMultimediaKit::VeryLowQuality);
|
||||||
|
|
||||||
|
settings.setQuality(QtMultimediaKit::LowQuality);
|
||||||
|
QCOMPARE(settings.quality(), QtMultimediaKit::LowQuality);
|
||||||
|
|
||||||
|
settings.setQuality(QtMultimediaKit::VeryHighQuality);
|
||||||
|
QCOMPARE(settings.quality(), QtMultimediaKit::VeryHighQuality);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test QVideoEncoderSettings encodingMode */
|
||||||
|
void tst_QMediaRecorder::testVideoSettingsEncodingMode()
|
||||||
|
{
|
||||||
|
/* Create the instance*/
|
||||||
|
QVideoEncoderSettings settings;
|
||||||
|
QVERIFY(settings.isNull());
|
||||||
|
QVERIFY(settings == QVideoEncoderSettings());
|
||||||
|
|
||||||
|
/* Verify the default values are initialised correctly*/
|
||||||
|
QCOMPARE(settings.encodingMode(), QtMultimediaKit::ConstantQualityEncoding);
|
||||||
|
QVERIFY(settings.isNull());
|
||||||
|
|
||||||
|
/* Set each type of encoding mode and Verify if it is set correctly*/
|
||||||
|
settings.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
QCOMPARE(settings.encodingMode(),QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
QVERIFY(!settings.isNull());
|
||||||
|
|
||||||
|
settings.setEncodingMode(QtMultimediaKit::AverageBitRateEncoding);
|
||||||
|
QCOMPARE(settings.encodingMode(), QtMultimediaKit::AverageBitRateEncoding);
|
||||||
|
|
||||||
|
settings.setEncodingMode(QtMultimediaKit::TwoPassEncoding);
|
||||||
|
QCOMPARE(settings.encodingMode(), QtMultimediaKit::TwoPassEncoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test QVideoEncoderSettings copy constructor */
|
||||||
|
void tst_QMediaRecorder::testVideoSettingsCopyConstructor()
|
||||||
|
{
|
||||||
|
/* Create the instance and initialise it*/
|
||||||
|
QVideoEncoderSettings settings1;
|
||||||
|
settings1.setCodec(QLatin1String("codecName"));
|
||||||
|
settings1.setBitRate(128000);
|
||||||
|
settings1.setQuality(QtMultimediaKit::HighQuality);
|
||||||
|
settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
settings1.setFrameRate(30000.0/10001);
|
||||||
|
settings1.setResolution(QSize(320,240));
|
||||||
|
|
||||||
|
/* Create another instance with instance1 as argument*/
|
||||||
|
QVideoEncoderSettings settings2(settings1);
|
||||||
|
|
||||||
|
/* Verify if all the parameters are copied correctly*/
|
||||||
|
QCOMPARE(settings2 != settings1, false);
|
||||||
|
QCOMPARE(settings2.codec(), QLatin1String("codecName"));
|
||||||
|
QCOMPARE(settings2.bitRate(), 128000);
|
||||||
|
QCOMPARE(settings2.encodingMode(), QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
QVERIFY(qFuzzyCompare(settings2.frameRate(), qreal(30000.0/10001)));
|
||||||
|
QCOMPARE(settings2.resolution(), QSize(320,240));
|
||||||
|
QCOMPARE(settings2.quality(), QtMultimediaKit::HighQuality);
|
||||||
|
|
||||||
|
/* Verify both the instances are equal*/
|
||||||
|
QCOMPARE(settings2, settings1);
|
||||||
|
QVERIFY(!settings2.isNull());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test QVideoEncoderSettings Overloaded Operator assignment*/
|
||||||
|
void tst_QMediaRecorder::testVideoSettingsOperatorAssignment()
|
||||||
|
{
|
||||||
|
/* Create two instances.*/
|
||||||
|
QVideoEncoderSettings settings1;
|
||||||
|
QVideoEncoderSettings settings2;
|
||||||
|
QCOMPARE(settings2, settings1);
|
||||||
|
QVERIFY(settings2.isNull());
|
||||||
|
|
||||||
|
/* Initialize all the parameters */
|
||||||
|
settings1.setCodec(QLatin1String("codecName"));
|
||||||
|
settings1.setBitRate(128000);
|
||||||
|
settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
settings1.setFrameRate(30000.0/10001);
|
||||||
|
settings1.setResolution(QSize(320,240));
|
||||||
|
settings1.setQuality(QtMultimediaKit::HighQuality);
|
||||||
|
/* Assign one object to other*/
|
||||||
|
settings2 = settings1;
|
||||||
|
|
||||||
|
/* Verify all the parameters are copied correctly*/
|
||||||
|
QCOMPARE(settings2, settings1);
|
||||||
|
QCOMPARE(settings2.codec(), QLatin1String("codecName"));
|
||||||
|
QCOMPARE(settings2.bitRate(), 128000);
|
||||||
|
QCOMPARE(settings2.encodingMode(), QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
QVERIFY(qFuzzyCompare(settings2.frameRate(), qreal(30000.0/10001)));
|
||||||
|
QCOMPARE(settings2.resolution(), QSize(320,240));
|
||||||
|
QCOMPARE(settings2.quality(), QtMultimediaKit::HighQuality);
|
||||||
|
QCOMPARE(settings2, settings1);
|
||||||
|
QVERIFY(!settings2.isNull());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test QVideoEncoderSettings Overloaded OperatorNotEqual*/
|
||||||
|
void tst_QMediaRecorder::testVideoSettingsOperatorNotEqual()
|
||||||
|
{
|
||||||
|
/* Create the instance and set the bit rate and Verify objects with OperatorNotEqual*/
|
||||||
|
QVideoEncoderSettings settings1;
|
||||||
|
settings1.setBitRate(1);
|
||||||
|
QVideoEncoderSettings settings2;
|
||||||
|
settings2.setBitRate(1);
|
||||||
|
/* OperatorNotEqual returns false when both objects are equal*/
|
||||||
|
QCOMPARE(settings1 != settings2, false);
|
||||||
|
settings2.setBitRate(2);
|
||||||
|
/* OperatorNotEqual returns true when both objects are not equal*/
|
||||||
|
QVERIFY(settings1 != settings2);
|
||||||
|
|
||||||
|
/* Verify Resolution with not equal operator*/
|
||||||
|
settings1 = QVideoEncoderSettings();
|
||||||
|
settings1.setResolution(800,600);
|
||||||
|
settings2 = QVideoEncoderSettings();
|
||||||
|
settings2.setResolution(QSize(800,600));
|
||||||
|
/* OperatorNotEqual returns false when both objects are equal*/
|
||||||
|
QCOMPARE(settings1 != settings2, false);
|
||||||
|
settings2.setResolution(QSize(400,300));
|
||||||
|
/* OperatorNotEqual returns true when both objects are not equal*/
|
||||||
|
QVERIFY(settings1 != settings2);
|
||||||
|
|
||||||
|
/* Verify Codec with not equal operator*/
|
||||||
|
settings1 = QVideoEncoderSettings();
|
||||||
|
settings1.setCodec("codec1");
|
||||||
|
settings2 = QVideoEncoderSettings();
|
||||||
|
settings2.setCodec("codec1");
|
||||||
|
/* OperatorNotEqual returns false when both objects are equal*/
|
||||||
|
QCOMPARE(settings1 != settings2, false);
|
||||||
|
settings2.setCodec("codec2");
|
||||||
|
/* OperatorNotEqual returns true when both objects are not equal*/
|
||||||
|
QVERIFY(settings1 != settings2);
|
||||||
|
|
||||||
|
/* Verify EncodingMode with not equal operator*/
|
||||||
|
settings1 = QVideoEncoderSettings();
|
||||||
|
settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
settings2 = QVideoEncoderSettings();
|
||||||
|
settings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
/* OperatorNotEqual returns false when both objects are equal*/
|
||||||
|
QCOMPARE(settings1 != settings2, false);
|
||||||
|
settings2.setEncodingMode(QtMultimediaKit::TwoPassEncoding);
|
||||||
|
/* OperatorNotEqual returns true when both objects are not equal*/
|
||||||
|
QVERIFY(settings1 != settings2);
|
||||||
|
|
||||||
|
/* Verify Quality with not equal operator*/
|
||||||
|
settings1 = QVideoEncoderSettings();
|
||||||
|
settings1.setQuality(QtMultimediaKit::NormalQuality);
|
||||||
|
settings2 = QVideoEncoderSettings();
|
||||||
|
settings2.setQuality(QtMultimediaKit::NormalQuality);
|
||||||
|
/* OperatorNotEqual returns false when both objects are equal*/
|
||||||
|
QCOMPARE(settings1 != settings2, false);
|
||||||
|
settings2.setQuality(QtMultimediaKit::LowQuality);
|
||||||
|
/* OperatorNotEqual returns true when both objects are not equal*/
|
||||||
|
QVERIFY(settings1 != settings2);
|
||||||
|
|
||||||
|
/* Verify FrameRate with not equal operator*/
|
||||||
|
settings1 = QVideoEncoderSettings();
|
||||||
|
settings1.setFrameRate(1);
|
||||||
|
settings2 = QVideoEncoderSettings();
|
||||||
|
settings2.setFrameRate(1);
|
||||||
|
/* OperatorNotEqual returns false when both objects are equal*/
|
||||||
|
QCOMPARE(settings1 != settings2, false);
|
||||||
|
settings2.setFrameRate(2);
|
||||||
|
/* OperatorNotEqual returns true when both objects are not equal*/
|
||||||
|
QVERIFY(settings1 != settings2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test QVideoEncoderSettings Overloaded comparison operator*/
|
||||||
|
void tst_QMediaRecorder::testVideoSettingsOperatorComparison()
|
||||||
|
{
|
||||||
|
/* Create the instance and set the bit rate and Verify objects with comparison operator*/
|
||||||
|
QVideoEncoderSettings settings1;
|
||||||
|
settings1.setBitRate(1);
|
||||||
|
QVideoEncoderSettings settings2;
|
||||||
|
settings2.setBitRate(1);
|
||||||
|
|
||||||
|
/* Comparison operator returns true when both objects are equal*/
|
||||||
|
QVERIFY(settings1 == settings2);
|
||||||
|
settings2.setBitRate(2);
|
||||||
|
/* Comparison operator returns false when both objects are not equal*/
|
||||||
|
QCOMPARE(settings1 == settings2, false);
|
||||||
|
|
||||||
|
/* Verify resolution with comparison operator*/
|
||||||
|
settings1 = QVideoEncoderSettings();
|
||||||
|
settings1.setResolution(800,600);
|
||||||
|
settings2 = QVideoEncoderSettings();
|
||||||
|
settings2.setResolution(QSize(800,600));
|
||||||
|
/* Comparison operator returns true when both objects are equal*/
|
||||||
|
QVERIFY(settings1 == settings2);
|
||||||
|
settings2.setResolution(QSize(400,300));
|
||||||
|
/* Comparison operator returns false when both objects are not equal*/
|
||||||
|
QCOMPARE(settings1 == settings2, false);
|
||||||
|
|
||||||
|
/* Verify Codec with comparison operator*/
|
||||||
|
settings1 = QVideoEncoderSettings();
|
||||||
|
settings1.setCodec("codec1");
|
||||||
|
settings2 = QVideoEncoderSettings();
|
||||||
|
settings2.setCodec("codec1");
|
||||||
|
/* Comparison operator returns true when both objects are equal*/
|
||||||
|
QVERIFY(settings1 == settings2);
|
||||||
|
settings2.setCodec("codec2");
|
||||||
|
/* Comparison operator returns false when both objects are not equal*/
|
||||||
|
QCOMPARE(settings1 == settings2, false);
|
||||||
|
|
||||||
|
/* Verify EncodingMode with comparison operator*/
|
||||||
|
settings1 = QVideoEncoderSettings();
|
||||||
|
settings1.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
settings2 = QVideoEncoderSettings();
|
||||||
|
settings2.setEncodingMode(QtMultimediaKit::ConstantBitRateEncoding);
|
||||||
|
/* Comparison operator returns true when both objects are equal*/
|
||||||
|
QVERIFY(settings1 == settings2);
|
||||||
|
settings2.setEncodingMode(QtMultimediaKit::TwoPassEncoding);
|
||||||
|
/* Comparison operator returns false when both objects are not equal*/
|
||||||
|
QCOMPARE(settings1 == settings2, false);
|
||||||
|
|
||||||
|
/* Verify Quality with comparison operator*/
|
||||||
|
settings1 = QVideoEncoderSettings();
|
||||||
|
settings1.setQuality(QtMultimediaKit::NormalQuality);
|
||||||
|
settings2 = QVideoEncoderSettings();
|
||||||
|
settings2.setQuality(QtMultimediaKit::NormalQuality);
|
||||||
|
/* Comparison operator returns true when both objects are equal*/
|
||||||
|
QVERIFY(settings1 == settings2);
|
||||||
|
settings2.setQuality(QtMultimediaKit::LowQuality);
|
||||||
|
/* Comparison operator returns false when both objects are not equal*/
|
||||||
|
QCOMPARE(settings1 == settings2, false);
|
||||||
|
|
||||||
|
/* Verify FrameRate with comparison operator*/
|
||||||
|
settings1 = QVideoEncoderSettings();
|
||||||
|
settings1.setFrameRate(1);
|
||||||
|
settings2 = QVideoEncoderSettings();
|
||||||
|
settings2.setFrameRate(1);
|
||||||
|
/* Comparison operator returns true when both objects are equal*/
|
||||||
|
QVERIFY(settings1 == settings2);
|
||||||
|
settings2.setFrameRate(2);
|
||||||
|
/* Comparison operator returns false when both objects are not equal*/
|
||||||
|
QCOMPARE(settings1 == settings2, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test the destuctor of the QVideoEncoderSettings*/
|
||||||
|
void tst_QMediaRecorder::testVideoSettingsDestructor()
|
||||||
|
{
|
||||||
|
/* Create the instance on heap and verify if object deleted correctly*/
|
||||||
|
QVideoEncoderSettings *settings1 = new QVideoEncoderSettings();
|
||||||
|
QVERIFY(settings1 != NULL);
|
||||||
|
QVERIFY(settings1->isNull());
|
||||||
|
delete settings1;
|
||||||
|
|
||||||
|
/* Create the instance on heap and initialise it and verify if object deleted correctly.*/
|
||||||
|
QVideoEncoderSettings *settings2 = new QVideoEncoderSettings();
|
||||||
|
QVERIFY(settings2 != NULL);
|
||||||
|
settings2->setCodec(QString("codec"));
|
||||||
|
QVERIFY(!settings2->isNull());
|
||||||
|
delete settings2;
|
||||||
|
}
|
||||||
|
|||||||
@@ -56,417 +56,8 @@
|
|||||||
|
|
||||||
#include <qaudioformat.h>
|
#include <qaudioformat.h>
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
#include "mockmediarecorderservice.h"
|
||||||
class MockMediaContainerControl : public QMediaContainerControl
|
#include "mockmediaobject.h"
|
||||||
{
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockVideoEncodeProvider : public QVideoEncoderControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
MockVideoEncodeProvider(QObject *parent):
|
|
||||||
QVideoEncoderControl(parent)
|
|
||||||
{
|
|
||||||
m_supportedEncodeOptions.insert("video/3gpp", QStringList() << "quantizer" << "me");
|
|
||||||
m_supportedEncodeOptions.insert("video/H264", QStringList() << "quantizer" << "me" << "bframes");
|
|
||||||
m_videoCodecs << "video/3gpp" << "video/H264";
|
|
||||||
m_sizes << QSize(320,240) << QSize(640,480);
|
|
||||||
m_framerates << 30 << 15 << 1;
|
|
||||||
}
|
|
||||||
~MockVideoEncodeProvider() {}
|
|
||||||
|
|
||||||
QVideoEncoderSettings videoSettings() const { return m_videoSettings; }
|
|
||||||
void setVideoSettings(const QVideoEncoderSettings &settings) { m_videoSettings = settings; };
|
|
||||||
|
|
||||||
QList<QSize> supportedResolutions(const QVideoEncoderSettings & = QVideoEncoderSettings(),
|
|
||||||
bool *continuous = 0) const
|
|
||||||
{
|
|
||||||
if (continuous)
|
|
||||||
*continuous = true;
|
|
||||||
|
|
||||||
return m_sizes;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<qreal> supportedFrameRates(const QVideoEncoderSettings & = QVideoEncoderSettings(),
|
|
||||||
bool *continuous = 0) const
|
|
||||||
{
|
|
||||||
if (continuous)
|
|
||||||
*continuous = false;
|
|
||||||
|
|
||||||
return m_framerates;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList supportedVideoCodecs() const { return m_videoCodecs; }
|
|
||||||
QString videoCodecDescription(const QString &codecName) const { return 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:
|
|
||||||
QVideoEncoderSettings m_videoSettings;
|
|
||||||
|
|
||||||
QMap<QString, QStringList> m_supportedEncodeOptions;
|
|
||||||
QMap< QString, QMap<QString, QVariant> > m_encodeOptions;
|
|
||||||
|
|
||||||
QStringList m_videoCodecs;
|
|
||||||
QList<QSize> m_sizes;
|
|
||||||
QList<qreal> m_framerates;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockAudioEncodeProvider : public QAudioEncoderControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
MockAudioEncodeProvider(QObject *parent):
|
|
||||||
QAudioEncoderControl(parent)
|
|
||||||
{
|
|
||||||
m_codecs << "audio/pcm" << "audio/mpeg";
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
~MockAudioEncodeProvider() {}
|
|
||||||
|
|
||||||
QAudioEncoderSettings audioSettings() const { return m_audioSettings; }
|
|
||||||
void setAudioSettings(const QAudioEncoderSettings &settings) { m_audioSettings = settings; }
|
|
||||||
|
|
||||||
QList<int> supportedSampleRates(const QAudioEncoderSettings & = QAudioEncoderSettings(), bool *continuous = 0) const
|
|
||||||
{
|
|
||||||
if (continuous)
|
|
||||||
*continuous = false;
|
|
||||||
|
|
||||||
return QList<int>() << 44100;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList supportedAudioCodecs() const
|
|
||||||
{
|
|
||||||
return m_codecs;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString codecDescription(const QString &codecName) const
|
|
||||||
{
|
|
||||||
if (codecName == "audio/pcm")
|
|
||||||
return QString("Pulse Code Modulation");
|
|
||||||
|
|
||||||
if (codecName == "audio/mpeg")
|
|
||||||
return QString("MP3 audio format");
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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_codecsDesc;
|
|
||||||
|
|
||||||
QMap<QString, QStringList> m_supportedEncodeOptions;
|
|
||||||
QMap< QString, QMap<QString, QVariant> > m_encodeOptions;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockAudioEndpointSelectorProvider : public QAudioEndpointSelector
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
MockAudioEndpointSelectorProvider(QObject *parent):
|
|
||||||
QAudioEndpointSelector(parent)
|
|
||||||
{
|
|
||||||
m_names << "device1" << "device2" << "device3";
|
|
||||||
m_descriptions << "dev1 comment" << "dev2 comment" << "dev3 comment";
|
|
||||||
emit availableEndpointsChanged();
|
|
||||||
}
|
|
||||||
~MockAudioEndpointSelectorProvider() {};
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_audioInput;
|
|
||||||
QList<QString> m_names;
|
|
||||||
QList<QString> m_descriptions;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockProvider : public QMediaRecorderControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MockProvider(QObject *parent):
|
|
||||||
QMediaRecorderControl(parent),
|
|
||||||
m_state(QMediaRecorder::StoppedState),
|
|
||||||
m_position(0),
|
|
||||||
m_muted(false) {}
|
|
||||||
|
|
||||||
QUrl outputLocation() const
|
|
||||||
{
|
|
||||||
return m_sink;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool setOutputLocation(const QUrl &sink)
|
|
||||||
{
|
|
||||||
m_sink = sink;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMediaRecorder::State state() const
|
|
||||||
{
|
|
||||||
return m_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 duration() const
|
|
||||||
{
|
|
||||||
return m_position;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isMuted() const
|
|
||||||
{
|
|
||||||
return m_muted;
|
|
||||||
}
|
|
||||||
|
|
||||||
void applySettings() {}
|
|
||||||
|
|
||||||
using QMediaRecorderControl::error;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void record()
|
|
||||||
{
|
|
||||||
m_state = QMediaRecorder::RecordingState;
|
|
||||||
m_position=1;
|
|
||||||
emit stateChanged(m_state);
|
|
||||||
emit durationChanged(m_position);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pause()
|
|
||||||
{
|
|
||||||
m_state = QMediaRecorder::PausedState;
|
|
||||||
emit stateChanged(m_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void stop()
|
|
||||||
{
|
|
||||||
m_position=0;
|
|
||||||
m_state = QMediaRecorder::StoppedState;
|
|
||||||
emit stateChanged(m_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMuted(bool muted)
|
|
||||||
{
|
|
||||||
if (m_muted != muted)
|
|
||||||
emit mutedChanged(m_muted = muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
QUrl m_sink;
|
|
||||||
QMediaRecorder::State m_state;
|
|
||||||
qint64 m_position;
|
|
||||||
bool m_muted;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class QtTestMetaDataProvider : public QMetaDataWriterControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
QtTestMetaDataProvider(QObject *parent = 0)
|
|
||||||
: QMetaDataWriterControl(parent)
|
|
||||||
, m_available(false)
|
|
||||||
, m_writable(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isMetaDataAvailable() const { return m_available; }
|
|
||||||
void setMetaDataAvailable(bool available) {
|
|
||||||
if (m_available != available)
|
|
||||||
emit metaDataAvailableChanged(m_available = available);
|
|
||||||
}
|
|
||||||
QList<QtMultimediaKit::MetaData> availableMetaData() const { return m_data.keys(); }
|
|
||||||
|
|
||||||
bool isWritable() const { return m_writable; }
|
|
||||||
void setWritable(bool writable) { emit writableChanged(m_writable = writable); }
|
|
||||||
|
|
||||||
QVariant metaData(QtMultimediaKit::MetaData key) const { return m_data.value(key); }
|
|
||||||
void setMetaData(QtMultimediaKit::MetaData key, const QVariant &value) {
|
|
||||||
m_data.insert(key, value); }
|
|
||||||
|
|
||||||
QVariant extendedMetaData(const QString &key) const { return m_extendedData.value(key); }
|
|
||||||
void setExtendedMetaData(const QString &key, const QVariant &value) {
|
|
||||||
m_extendedData.insert(key, value); }
|
|
||||||
|
|
||||||
QStringList availableExtendedMetaData() const { return m_extendedData.keys(); }
|
|
||||||
|
|
||||||
using QMetaDataWriterControl::metaDataChanged;
|
|
||||||
|
|
||||||
void populateMetaData()
|
|
||||||
{
|
|
||||||
m_available = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool m_available;
|
|
||||||
bool m_writable;
|
|
||||||
QMap<QtMultimediaKit::MetaData, QVariant> m_data;
|
|
||||||
QMap<QString, QVariant> m_extendedData;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockService : public QMediaService
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
MockService(QObject *parent, QMediaControl *control):
|
|
||||||
QMediaService(parent),
|
|
||||||
mockControl(control),
|
|
||||||
hasControls(true)
|
|
||||||
{
|
|
||||||
mockAudioEndpointSelector = new MockAudioEndpointSelectorProvider(parent);
|
|
||||||
mockAudioEncodeControl = new MockAudioEncodeProvider(parent);
|
|
||||||
mockFormatControl = new MockMediaContainerControl(parent);
|
|
||||||
mockVideoEncodeControl = new MockVideoEncodeProvider(parent);
|
|
||||||
mockMetaDataControl = new QtTestMetaDataProvider(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
QMediaControl* requestControl(const char *name)
|
|
||||||
{
|
|
||||||
if(hasControls && qstrcmp(name,QAudioEncoderControl_iid) == 0)
|
|
||||||
return mockAudioEncodeControl;
|
|
||||||
if(hasControls && qstrcmp(name,QAudioEndpointSelector_iid) == 0)
|
|
||||||
return mockAudioEndpointSelector;
|
|
||||||
if(hasControls && qstrcmp(name,QMediaRecorderControl_iid) == 0)
|
|
||||||
return mockControl;
|
|
||||||
if(hasControls && qstrcmp(name,QMediaContainerControl_iid) == 0)
|
|
||||||
return mockFormatControl;
|
|
||||||
if(hasControls && qstrcmp(name,QVideoEncoderControl_iid) == 0)
|
|
||||||
return mockVideoEncodeControl;
|
|
||||||
if (hasControls && qstrcmp(name, QMetaDataWriterControl_iid) == 0)
|
|
||||||
return mockMetaDataControl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void releaseControl(QMediaControl*) {}
|
|
||||||
|
|
||||||
QMediaControl *mockControl;
|
|
||||||
QAudioEndpointSelector *mockAudioEndpointSelector;
|
|
||||||
QAudioEncoderControl *mockAudioEncodeControl;
|
|
||||||
QMediaContainerControl *mockFormatControl;
|
|
||||||
QVideoEncoderControl *mockVideoEncodeControl;
|
|
||||||
QtTestMetaDataProvider *mockMetaDataControl;
|
|
||||||
bool hasControls;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockObject : public QMediaObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
MockObject(QObject *parent, MockService *service):
|
|
||||||
QMediaObject(parent, service)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class tst_QMediaRecorder: public QObject
|
class tst_QMediaRecorder: public QObject
|
||||||
{
|
{
|
||||||
@@ -504,13 +95,32 @@ private slots:
|
|||||||
void setExtendedMetaData_data() { extendedMetaData_data(); }
|
void setExtendedMetaData_data() { extendedMetaData_data(); }
|
||||||
void setExtendedMetaData();
|
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:
|
private:
|
||||||
QAudioEncoderControl* encode;
|
QAudioEncoderControl* encode;
|
||||||
QAudioEndpointSelector* audio;
|
QAudioEndpointSelector* audio;
|
||||||
MockObject *object;
|
MockMediaObject *object;
|
||||||
MockService *service;
|
MockMediaRecorderService*service;
|
||||||
MockProvider *mock;
|
MockMediaRecorderControl *mock;
|
||||||
QMediaRecorder *capture;
|
QMediaRecorder *capture;
|
||||||
QVideoEncoderControl* videoEncode;
|
QVideoEncoderControl* videoEncode;
|
||||||
};
|
};
|
||||||
#endif //TST_QMEDIARECORDER_H
|
#endif //TST_QMEDIARECORDER_H
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ private slots:
|
|||||||
void equality();
|
void equality();
|
||||||
void copy();
|
void copy();
|
||||||
void assign();
|
void assign();
|
||||||
|
|
||||||
|
void constructorRequest();
|
||||||
|
void copyConstructor();
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_QMediaResource::constructNull()
|
void tst_QMediaResource::constructNull()
|
||||||
@@ -447,6 +450,61 @@ void tst_QMediaResource::equality()
|
|||||||
// Equal
|
// Equal
|
||||||
QCOMPARE(resource1 == resource2, true);
|
QCOMPARE(resource1 == resource2, true);
|
||||||
QCOMPARE(resource1 != resource2, false);
|
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()
|
void tst_QMediaResource::copy()
|
||||||
@@ -494,6 +552,12 @@ void tst_QMediaResource::assign()
|
|||||||
const QString aacCodec(QLatin1String("aac"));
|
const QString aacCodec(QLatin1String("aac"));
|
||||||
const QString h264Codec(QLatin1String("h264"));
|
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 copy(QUrl(QString::fromLatin1("file:///thumbs/test.jpg")));
|
||||||
|
|
||||||
QMediaResource original(url, mimeType);
|
QMediaResource original(url, mimeType);
|
||||||
@@ -521,6 +585,114 @@ void tst_QMediaResource::assign()
|
|||||||
QCOMPARE(copy.mimeType(), mimeType);
|
QCOMPARE(copy.mimeType(), mimeType);
|
||||||
|
|
||||||
QCOMPARE(original.audioCodec(), mp3Codec);
|
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)
|
QTEST_MAIN(tst_QMediaResource)
|
||||||
|
|||||||
@@ -54,17 +54,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
class QtTestMediaService;
|
class QtTestMediaService;
|
||||||
|
|
||||||
class tst_QMediaService : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
private slots:
|
|
||||||
void initTestCase();
|
|
||||||
|
|
||||||
void control_iid();
|
|
||||||
void control();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class QtTestMediaControlA : public QMediaControl
|
class QtTestMediaControlA : public QMediaControl
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -98,23 +87,31 @@ class QtTestMediaControlD : public QMediaControl
|
|||||||
#define QtTestMediaControlD_iid "com.nokia.QtTestMediaControlD"
|
#define QtTestMediaControlD_iid "com.nokia.QtTestMediaControlD"
|
||||||
Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlD, QtTestMediaControlD_iid)
|
Q_MEDIA_DECLARE_CONTROL(QtTestMediaControlD, QtTestMediaControlD_iid)
|
||||||
|
|
||||||
|
//unimplemented service
|
||||||
|
#define QtTestMediaControlE_iid "com.nokia.QtTestMediaControlF"
|
||||||
class QtTestMediaControlE : public QMediaControl
|
class QtTestMediaControlE : public QMediaControl
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* implementation of child class by inheriting The QMediaService base class for media service implementations. */
|
||||||
class QtTestMediaService : public QMediaService
|
class QtTestMediaService : public QMediaService
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QtTestMediaService()
|
int refA;
|
||||||
: QMediaService(0)
|
int refB;
|
||||||
, refA(0)
|
int refC;
|
||||||
, refB(0)
|
QtTestMediaControlA controlA;
|
||||||
, refC(0)
|
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)
|
QMediaControl *requestControl(const char *name)
|
||||||
{
|
{
|
||||||
if (strcmp(name, QtTestMediaControlA_iid) == 0) {
|
if (strcmp(name, QtTestMediaControlA_iid) == 0) {
|
||||||
@@ -134,6 +131,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//releaseControl() pure virtual function of QMediaService class.
|
||||||
void releaseControl(QMediaControl *control)
|
void releaseControl(QMediaControl *control)
|
||||||
{
|
{
|
||||||
if (control == &controlA)
|
if (control == &controlA)
|
||||||
@@ -144,20 +142,107 @@ public:
|
|||||||
refC -= 1;
|
refC -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//requestControl() function of QMediaService class.
|
||||||
using QMediaService::requestControl;
|
using QMediaService::requestControl;
|
||||||
|
|
||||||
int refA;
|
|
||||||
int refB;
|
|
||||||
int refC;
|
|
||||||
QtTestMediaControlA controlA;
|
|
||||||
QtTestMediaControlB controlB;
|
|
||||||
QtTestMediaControlC controlC;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* 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()
|
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()
|
void tst_QMediaService::control_iid()
|
||||||
{
|
{
|
||||||
const char *nullString = 0;
|
const char *nullString = 0;
|
||||||
@@ -181,7 +266,7 @@ void tst_QMediaService::control()
|
|||||||
QCOMPARE(controlB, &service.controlB);
|
QCOMPARE(controlB, &service.controlB);
|
||||||
service.releaseControl(controlB);
|
service.releaseControl(controlB);
|
||||||
|
|
||||||
QVERIFY(!service.requestControl<QtTestMediaControlC *>()); // Faulty implementation returns A.
|
QVERIFY(!service.requestControl<QtTestMediaControlC *>()); // Faulty implementation returns A, but is wrong class
|
||||||
QCOMPARE(service.refA, 0); // Verify the control was released.
|
QCOMPARE(service.refA, 0); // Verify the control was released.
|
||||||
|
|
||||||
QVERIFY(!service.requestControl<QtTestMediaControlD *>()); // No control of that type.
|
QVERIFY(!service.requestControl<QtTestMediaControlD *>()); // No control of that type.
|
||||||
|
|||||||
@@ -444,6 +444,16 @@ void tst_QMediaServiceProvider::testProviderHints()
|
|||||||
QCOMPARE(hint.features(), QMediaServiceProviderHint::LowLatencyPlayback);
|
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"));
|
QString mimeType(QLatin1String("video/ogg"));
|
||||||
QStringList codecs;
|
QStringList codecs;
|
||||||
|
|||||||
8
tests/auto/qmediastreamscontrol/qmediastreamscontrol.pro
Normal file
8
tests/auto/qmediastreamscontrol/qmediastreamscontrol.pro
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
load(qttest_p4)
|
||||||
|
|
||||||
|
QT += multimediakit-private
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
tst_qmediastreamscontrol.cpp
|
||||||
|
|
||||||
|
include(../multimedia_common.pri)
|
||||||
408
tests/auto/qmediastreamscontrol/tst_qmediastreamscontrol.cpp
Normal file
408
tests/auto/qmediastreamscontrol/tst_qmediastreamscontrol.cpp
Normal file
@@ -0,0 +1,408 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 <QtCore/QString>
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
|
|
||||||
|
|
||||||
|
#include <qmediaplayercontrol.h>
|
||||||
|
#include <qmediaservice.h>
|
||||||
|
|
||||||
|
#include <qmediastreamscontrol.h>
|
||||||
|
|
||||||
|
#include <QtGui/QImage>
|
||||||
|
#include <QtCore/QPointer>
|
||||||
|
|
||||||
|
QT_USE_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
|
#define WAIT_FOR_CONDITION(a,e) \
|
||||||
|
for (int _i = 0; _i < 500; _i += 1) { \
|
||||||
|
if ((a) == (e)) break; \
|
||||||
|
QTest::qWait(10);}
|
||||||
|
|
||||||
|
class tst_qmediastreamscontrol : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
tst_qmediastreamscontrol();
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void initTestCase();
|
||||||
|
void cleanupTestCase();
|
||||||
|
void control_iid();
|
||||||
|
void control();
|
||||||
|
void isActive();
|
||||||
|
void streamCount();
|
||||||
|
void streamsChanged();
|
||||||
|
void metadata();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class mediaStatusList : public QObject, public QList<QMediaStreamsControl::StreamType>
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public slots:
|
||||||
|
void mediaStatus(QMediaStreamsControl::StreamType status) {
|
||||||
|
append(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
mediaStatusList(QObject *obj, const char *aSignal)
|
||||||
|
: QObject()
|
||||||
|
{
|
||||||
|
QObject::connect(obj, aSignal, this, SLOT(mediaStatus(QMediaStreamsControl::StreamType)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class QtTestMediaStreamsControl: public QMediaStreamsControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QtTestMediaStreamsControl(QObject *parent = 0)
|
||||||
|
: QMediaStreamsControl(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int streamCount()
|
||||||
|
{
|
||||||
|
QList <StreamType> m_stype;
|
||||||
|
|
||||||
|
return streams.count();
|
||||||
|
}
|
||||||
|
void setStreamCount(int count)
|
||||||
|
{
|
||||||
|
streams.resize(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamType streamType(int index)
|
||||||
|
{
|
||||||
|
return streams.at(index).type;
|
||||||
|
}
|
||||||
|
void setStreamType(int index, StreamType type)
|
||||||
|
{
|
||||||
|
streams[index].type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant metaData(int index, QtMultimediaKit::MetaData key)
|
||||||
|
{
|
||||||
|
QtMultimediaKit::MetaData keys = key;
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMetaData(int index, QtMultimediaKit::MetaData key, const QVariant &value)
|
||||||
|
{
|
||||||
|
streams[index].metaData.insert(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isActive(int index)
|
||||||
|
{
|
||||||
|
return streams.at(index).active;
|
||||||
|
}
|
||||||
|
void setActive(int index, bool state)
|
||||||
|
{
|
||||||
|
streams[index].active = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAudioOnlyContent()
|
||||||
|
{
|
||||||
|
mediaContent = audioOnlyContent;
|
||||||
|
|
||||||
|
m_player->setMedia(*mediaContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setVideoOnlyContent()
|
||||||
|
{
|
||||||
|
mediaContent = videoOnlyContent;
|
||||||
|
duration = 60000;
|
||||||
|
|
||||||
|
m_player->setMedia(*mediaContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAudioVideoContent()
|
||||||
|
{
|
||||||
|
if (mediaContent == audioVideoContent)
|
||||||
|
{
|
||||||
|
mediaContent = audioVideoAltContent;
|
||||||
|
duration = 101840;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mediaContent = audioVideoContent;
|
||||||
|
duration = 141000;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_player->setMedia(*mediaContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setStreamingContent()
|
||||||
|
{
|
||||||
|
mediaContent = streamingContent;
|
||||||
|
|
||||||
|
m_player->setMedia(*mediaContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Stream
|
||||||
|
{
|
||||||
|
Stream() : type(UnknownStream), active(false) {}
|
||||||
|
StreamType type;
|
||||||
|
QMap<QtMultimediaKit::MetaData, QVariant> metaData;
|
||||||
|
bool active;
|
||||||
|
};
|
||||||
|
|
||||||
|
QVector<Stream> streams;
|
||||||
|
QMediaContent* audioOnlyContent;
|
||||||
|
QMediaContent* videoOnlyContent;
|
||||||
|
QMediaContent* audioVideoContent;
|
||||||
|
QMediaContent* audioVideoAltContent;
|
||||||
|
QMediaContent* mediaContent;
|
||||||
|
QMediaContent* streamingContent;
|
||||||
|
|
||||||
|
qint64 duration;
|
||||||
|
QMediaPlayer *m_player;
|
||||||
|
QVideoWidget *m_widget;
|
||||||
|
QWidget *m_windowWidget;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class QTestMediaStreamsControlA : public QMediaControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
};
|
||||||
|
|
||||||
|
#define QTestMediaStreamsControlA_iid "com.nokia.QTestMediaStreamsControlA"
|
||||||
|
Q_MEDIA_DECLARE_CONTROL(QTestMediaStreamsControlA, QTestMediaStreamsControlA_iid)
|
||||||
|
|
||||||
|
class QTestMediaStreamsControlB : public QMediaControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
QTestMediaStreamsControlB()
|
||||||
|
: QMediaControl(0)
|
||||||
|
,ctrlA(0)
|
||||||
|
,ctrlB(0)
|
||||||
|
,ctrlC(0) {}
|
||||||
|
|
||||||
|
bool isActive(int stream)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ctrlA;
|
||||||
|
int ctrlB;
|
||||||
|
int ctrlC;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define QTestMediaStreamsControlB_iid "com.nokia.QTestMediaStreamsControlB"
|
||||||
|
Q_MEDIA_DECLARE_CONTROL(QTestMediaStreamsControlB, QTestMediaStreamsControlB_iid)
|
||||||
|
|
||||||
|
|
||||||
|
class QTestMediaStreamsControlC : public QMediaControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
};
|
||||||
|
|
||||||
|
#define QTestMediaStreamsControlC_iid "com.nokia.QTestMediaStreamsControlC"
|
||||||
|
Q_MEDIA_DECLARE_CONTROL(QTestMediaStreamsControlC, QTestMediaStreamsControlC_iid) // Yes A.
|
||||||
|
|
||||||
|
class QTestMediaStreamsControlD : public QMediaControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
};
|
||||||
|
|
||||||
|
#define QTestMediaStreamsControlD_iid "com.nokia.QTestMediaStreamsControlD"
|
||||||
|
Q_MEDIA_DECLARE_CONTROL(QTestMediaStreamsControlD, QTestMediaStreamsControlD_iid)
|
||||||
|
|
||||||
|
|
||||||
|
class QtTestMediaService : public QMediaService
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
QtTestMediaService()
|
||||||
|
: QMediaService(0)
|
||||||
|
, refA(0)
|
||||||
|
, refB(0)
|
||||||
|
, refC(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaControl *requestControl(const char *name)
|
||||||
|
{
|
||||||
|
if (strcmp(name, QTestMediaStreamsControlA_iid) == 0) {
|
||||||
|
refA += 1;
|
||||||
|
|
||||||
|
return &controlA;
|
||||||
|
} else if (strcmp(name, QTestMediaStreamsControlB_iid) == 0) {
|
||||||
|
refB += 1;
|
||||||
|
|
||||||
|
return &controlB;
|
||||||
|
} else if (strcmp(name, QTestMediaStreamsControlC_iid) == 0) {
|
||||||
|
refA += 1;
|
||||||
|
|
||||||
|
return &controlA;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void releaseControl(QMediaControl *control)
|
||||||
|
{
|
||||||
|
if (control == &controlA)
|
||||||
|
refA -= 1;
|
||||||
|
else if (control == &controlB)
|
||||||
|
refB -= 1;
|
||||||
|
else if (control == &controlC)
|
||||||
|
refC -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
using QMediaService::requestControl;
|
||||||
|
|
||||||
|
int refA;
|
||||||
|
int refB;
|
||||||
|
int refC;
|
||||||
|
QTestMediaStreamsControlA controlA;
|
||||||
|
QTestMediaStreamsControlB controlB;
|
||||||
|
QTestMediaStreamsControlC controlC;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
tst_qmediastreamscontrol::tst_qmediastreamscontrol()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_qmediastreamscontrol::initTestCase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_qmediastreamscontrol::cleanupTestCase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_qmediastreamscontrol::control_iid()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Default implementation.
|
||||||
|
QCOMPARE(qmediacontrol_iid<QTestMediaStreamsControlA *>(), QTestMediaStreamsControlA_iid);
|
||||||
|
|
||||||
|
// Partial template.
|
||||||
|
QVERIFY(qstrcmp(qmediacontrol_iid<QTestMediaStreamsControlA *>(), QTestMediaStreamsControlA_iid) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_qmediastreamscontrol::control()
|
||||||
|
{
|
||||||
|
QtTestMediaService *service = new QtTestMediaService();
|
||||||
|
QMediaStreamsControl *control = qobject_cast<QMediaStreamsControl *>
|
||||||
|
(service->requestControl("com.nokia.Qt.MediaStreamsControl/1.0"));
|
||||||
|
// QCOMPARE(control,service->controlA.objectName());
|
||||||
|
QTestMediaStreamsControlA *controlA = (QTestMediaStreamsControlA *)service->requestControl("controlA");
|
||||||
|
// QCOMPARE(controlA,service->controlA);
|
||||||
|
QVERIFY(service->requestControl<QTestMediaStreamsControlA *>());
|
||||||
|
|
||||||
|
service->releaseControl(controlA);
|
||||||
|
delete service;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_qmediastreamscontrol::isActive()
|
||||||
|
{
|
||||||
|
QTestMediaStreamsControlB ser;
|
||||||
|
QVERIFY(ser.isActive(1));
|
||||||
|
QtTestMediaStreamsControl m_active;
|
||||||
|
//setActive
|
||||||
|
m_active.setActive(1,1);
|
||||||
|
QVERIFY(m_active.isActive(1));
|
||||||
|
//set InActive
|
||||||
|
m_active.setActive(2,0);
|
||||||
|
QVERIFY(!m_active.isActive(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Returns the number of media streams.
|
||||||
|
void tst_qmediastreamscontrol::streamCount()
|
||||||
|
{
|
||||||
|
QtTestMediaStreamsControl m_cnt;
|
||||||
|
m_cnt.setStreamType(0,QMediaStreamsControl::UnknownStream);
|
||||||
|
m_cnt.setStreamType(1,QMediaStreamsControl::VideoStream);
|
||||||
|
m_cnt.setStreamType(2,QMediaStreamsControl::AudioStream);
|
||||||
|
m_cnt.setStreamType(3,QMediaStreamsControl::SubPictureStream);
|
||||||
|
m_cnt.setStreamType(4,QMediaStreamsControl::DataStream);
|
||||||
|
m_cnt.setStreamCount(5);
|
||||||
|
QVERIFY(m_cnt.streamCount() == m_cnt.streams.count());
|
||||||
|
}
|
||||||
|
|
||||||
|
//The signal is emitted when the available streams list is changed.
|
||||||
|
void tst_qmediastreamscontrol::streamsChanged()
|
||||||
|
{
|
||||||
|
QMediaPlayer *m_player = new QMediaPlayer(0);
|
||||||
|
QMediaStreamsControl* m_streamControl = (QMediaStreamsControl*)
|
||||||
|
(m_player->service()->requestControl(QTestMediaStreamsControlA_iid));
|
||||||
|
|
||||||
|
QMediaContent videoOnlyContent;
|
||||||
|
|
||||||
|
m_player->setMedia(videoOnlyContent);
|
||||||
|
if (m_streamControl) {
|
||||||
|
QSignalSpy m_strm_lst_chgSpy(m_streamControl,SIGNAL(streamsChanged()));
|
||||||
|
QVERIFY(m_strm_lst_chgSpy.isValid());
|
||||||
|
QVERIFY(m_strm_lst_chgSpy.isEmpty());
|
||||||
|
WAIT_FOR_CONDITION(m_player->mediaStatus(),QMediaPlayer::LoadedMedia);
|
||||||
|
QVERIFY(m_streamControl->streamCount() == 1);
|
||||||
|
QVERIFY(m_strm_lst_chgSpy.count() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete m_player;
|
||||||
|
m_player = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_qmediastreamscontrol::metadata()
|
||||||
|
{
|
||||||
|
QtTestMediaStreamsControl m_metadata;
|
||||||
|
m_metadata.metaData(1,QtMultimediaKit::AlbumArtist);
|
||||||
|
qDebug() << m_metadata.metaData(1,QtMultimediaKit::AlbumArtist);
|
||||||
|
}
|
||||||
|
QTEST_MAIN(tst_qmediastreamscontrol);
|
||||||
|
|
||||||
|
#include "tst_qmediastreamscontrol.moc"
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
|
|
||||||
|
#include <qmediatimerange.h>
|
||||||
#include <qmediatimerange.h>
|
#include <qmediatimerange.h>
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
QT_USE_NAMESPACE
|
||||||
@@ -56,10 +57,12 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void testCtor();
|
void testCtor();
|
||||||
|
void testIntervalCtor();
|
||||||
void testGetters();
|
void testGetters();
|
||||||
void testAssignment();
|
void testAssignment();
|
||||||
void testNormalize();
|
void testIntervalNormalize();
|
||||||
void testTranslated();
|
void testIntervalTranslate();
|
||||||
|
void testIntervalContains();
|
||||||
void testEarliestLatest();
|
void testEarliestLatest();
|
||||||
void testContains();
|
void testContains();
|
||||||
void testAddInterval();
|
void testAddInterval();
|
||||||
@@ -71,6 +74,59 @@ private slots:
|
|||||||
void testArithmetic();
|
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()
|
void tst_QMediaTimeRange::testCtor()
|
||||||
{
|
{
|
||||||
// Default Ctor
|
// Default Ctor
|
||||||
@@ -105,6 +161,8 @@ void tst_QMediaTimeRange::testCtor()
|
|||||||
QVERIFY(e.isContinuous());
|
QVERIFY(e.isContinuous());
|
||||||
QVERIFY(e.earliestTime() == 10);
|
QVERIFY(e.earliestTime() == 10);
|
||||||
QVERIFY(e.latestTime() == 20);
|
QVERIFY(e.latestTime() == 20);
|
||||||
|
|
||||||
|
QVERIFY(e == b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMediaTimeRange::testGetters()
|
void tst_QMediaTimeRange::testGetters()
|
||||||
@@ -164,26 +222,35 @@ void tst_QMediaTimeRange::testAssignment()
|
|||||||
QVERIFY(x.latestTime() == 40);
|
QVERIFY(x.latestTime() == 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMediaTimeRange::testNormalize()
|
void tst_QMediaTimeRange::testIntervalNormalize()
|
||||||
{
|
{
|
||||||
QMediaTimeInterval x(20, 10);
|
QMediaTimeInterval x(20, 10);
|
||||||
|
|
||||||
QVERIFY(!x.isNormal());
|
QVERIFY(!x.isNormal());
|
||||||
|
QVERIFY(x.start() == 20);
|
||||||
|
QVERIFY(x.end() == 10);
|
||||||
|
|
||||||
x = x.normalized();
|
QMediaTimeInterval y = x.normalized();
|
||||||
|
|
||||||
QVERIFY(x.isNormal());
|
QVERIFY(y.isNormal());
|
||||||
QVERIFY(x.start() == 10);
|
QVERIFY(y.start() == 10);
|
||||||
QVERIFY(x.end() == 20);
|
QVERIFY(y.end() == 20);
|
||||||
|
QVERIFY(x != y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMediaTimeRange::testTranslated()
|
void tst_QMediaTimeRange::testIntervalTranslate()
|
||||||
{
|
{
|
||||||
QMediaTimeInterval x(10, 20);
|
QMediaTimeInterval x(10, 20);
|
||||||
x = x.translated(10);
|
x = x.translated(10);
|
||||||
|
|
||||||
QVERIFY(x.start() == 20);
|
QVERIFY(x.start() == 20);
|
||||||
QVERIFY(x.end() == 30);
|
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()
|
void tst_QMediaTimeRange::testEarliestLatest()
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
load(qttest_p4)
|
||||||
|
|
||||||
|
QT += multimediakit-private
|
||||||
|
|
||||||
|
SOURCES += tst_qmetadatareadercontrol.cpp
|
||||||
|
|
||||||
|
include (../qmultimedia_common/mockcontainer.pri)
|
||||||
|
|
||||||
143
tests/auto/qmetadatareadercontrol/tst_qmetadatareadercontrol.cpp
Normal file
143
tests/auto/qmetadatareadercontrol/tst_qmetadatareadercontrol.cpp
Normal file
@@ -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(QtMultimediaKit::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,7 @@
|
|||||||
|
load(qttest_p4)
|
||||||
|
|
||||||
|
QT += multimediakit-private
|
||||||
|
|
||||||
|
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((QtMultimediaKit::MetaData) 1 );
|
||||||
|
mock->extendedMetaData(QString("XYZ"));
|
||||||
|
mock->setExtendedMetaData(QString("XYZ"),QVariant());
|
||||||
|
mock->setMetaData((QtMultimediaKit::MetaData) 1,QVariant());
|
||||||
|
((MockMetaDataWriterControl*)mock)->setWritable();
|
||||||
|
((MockMetaDataWriterControl*)mock)->setMetaDataAvailable();
|
||||||
|
delete mock;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTEST_MAIN(tst_QMetaDataWriterControl);
|
||||||
|
|
||||||
|
#include "tst_qmetadatawritercontrol.moc"
|
||||||
7
tests/auto/qmultimedia_common/mock.pri
Normal file
7
tests/auto/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/qmultimedia_common/mockaudioencodercontrol.h
Normal file
127
tests/auto/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/qmultimedia_common/mockaudioendpointselector.h
Normal file
117
tests/auto/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/qmultimedia_common/mockcamera.pri
Normal file
22
tests/auto/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/qmultimedia_common/mockcameracontrol.h
Normal file
145
tests/auto/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/qmultimedia_common/mockcameraexposurecontrol.h
Normal file
282
tests/auto/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/qmultimedia_common/mockcameraflashcontrol.h
Normal file
89
tests/auto/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/qmultimedia_common/mockcamerafocuscontrol.h
Normal file
199
tests/auto/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
|
||||||
130
tests/auto/qmultimedia_common/mockcameraimagecapturecontrol.h
Normal file
130
tests/auto/qmultimedia_common/mockcameraimagecapturecontrol.h
Normal file
@@ -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,
|
||||||
|
QtMultimediaKit::FocalLengthIn35mmFilm,
|
||||||
|
QVariant(50));
|
||||||
|
|
||||||
|
emit imageMetadataAvailable(m_captureRequest,
|
||||||
|
QtMultimediaKit::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
|
||||||
156
tests/auto/qmultimedia_common/mockcameraimageprocessingcontrol.h
Normal file
156
tests/auto/qmultimedia_common/mockcameraimageprocessingcontrol.h
Normal file
@@ -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/qmultimedia_common/mockcameralockscontrol.h
Normal file
144
tests/auto/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
|
||||||
184
tests/auto/qmultimedia_common/mockcameraservice.h
Normal file
184
tests/auto/qmultimedia_common/mockcameraservice.h
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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"
|
||||||
|
#include "../qmultimedia_common/mockvideowindowcontrol.h"
|
||||||
|
|
||||||
|
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);
|
||||||
|
windowControl = new MockVideoWindowControl(this);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
} else if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
|
||||||
|
if (windowRef == 0) {
|
||||||
|
windowRef += 1;
|
||||||
|
return windowControl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void releaseControl(QMediaControl *control)
|
||||||
|
{
|
||||||
|
if (control == rendererControl)
|
||||||
|
rendererRef -= 1;
|
||||||
|
else if (control == windowControl)
|
||||||
|
windowRef -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
MockCameraControl *mockControl;
|
||||||
|
MockCameraLocksControl *mockLocksControl;
|
||||||
|
MockCaptureControl *mockCaptureControl;
|
||||||
|
MockCaptureBufferFormatControl *mockCaptureBufferControl;
|
||||||
|
MockCaptureDestinationControl *mockCaptureDestinationControl;
|
||||||
|
MockCameraExposureControl *mockExposureControl;
|
||||||
|
MockCameraFlashControl *mockFlashControl;
|
||||||
|
MockCameraFocusControl *mockFocusControl;
|
||||||
|
MockImageProcessingControl *mockImageProcessingControl;
|
||||||
|
MockImageEncoderControl *mockImageEncoderControl;
|
||||||
|
MockVideoRendererControl *rendererControl;
|
||||||
|
MockVideoWindowControl *windowControl;
|
||||||
|
int rendererRef;
|
||||||
|
int windowRef;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKCAMERASERVICE_H
|
||||||
7
tests/auto/qmultimedia_common/mockcontainer.pri
Normal file
7
tests/auto/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/qmultimedia_common/mockimageencodercontrol.h
Normal file
103
tests/auto/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() == QtMultimediaKit::HighQuality && settings.resolution() == QSize(640,480))
|
||||||
|
resolutions << settings.resolution();
|
||||||
|
} else {
|
||||||
|
resolutions << QSize(160, 120);
|
||||||
|
resolutions << QSize(320, 240);
|
||||||
|
if (settings.quality() == QtMultimediaKit::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
|
||||||
97
tests/auto/qmultimedia_common/mockmediacontainercontrol.h
Normal file
97
tests/auto/qmultimedia_common/mockmediacontainercontrol.h
Normal file
@@ -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
|
||||||
@@ -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 MOCKMEDIANETWORKACCESSCONTROL_H
|
||||||
|
#define MOCKMEDIANETWORKACCESSCONTROL_H
|
||||||
|
|
||||||
|
#include "qmedianetworkaccesscontrol.h"
|
||||||
|
#include "qnetworkconfiguration.h"
|
||||||
|
|
||||||
|
class MockNetworkAccessControl : public QMediaNetworkAccessControl
|
||||||
|
{
|
||||||
|
friend class MockMediaPlayerService;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MockNetworkAccessControl() {}
|
||||||
|
~MockNetworkAccessControl() {}
|
||||||
|
|
||||||
|
void setConfigurations(const QList<QNetworkConfiguration> &configurations)
|
||||||
|
{
|
||||||
|
_configurations = configurations;
|
||||||
|
_current = QNetworkConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
QNetworkConfiguration currentConfiguration() const
|
||||||
|
{
|
||||||
|
return _current;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setCurrentConfiguration(QNetworkConfiguration configuration)
|
||||||
|
{
|
||||||
|
if (_configurations.contains(configuration))
|
||||||
|
emit configurationChanged(_current = configuration);
|
||||||
|
else
|
||||||
|
emit configurationChanged(_current = QNetworkConfiguration());
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QNetworkConfiguration> _configurations;
|
||||||
|
QNetworkConfiguration _current;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QNetworkConfiguration)
|
||||||
|
|
||||||
|
|
||||||
|
#endif // MOCKMEDIANETWORKACCESSCONTROL_H
|
||||||
57
tests/auto/qmultimedia_common/mockmediaobject.h
Normal file
57
tests/auto/qmultimedia_common/mockmediaobject.h
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKMEDIAOBJECT_H
|
||||||
|
#define MOCKMEDIAOBJECT_H
|
||||||
|
|
||||||
|
#include "qmediaobject.h"
|
||||||
|
|
||||||
|
class MockMediaObject : public QMediaObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MockMediaObject(QObject *parent, QMediaService *service):
|
||||||
|
QMediaObject(parent, service)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKMEDIAOBJECT_H
|
||||||
118
tests/auto/qmultimedia_common/mockmediaplayercontrol.h
Normal file
118
tests/auto/qmultimedia_common/mockmediaplayercontrol.h
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKMEDIAPLAYERCONTROL_H
|
||||||
|
#define MOCKMEDIAPLAYERCONTROL_H
|
||||||
|
|
||||||
|
#include "qmediaplayercontrol.h"
|
||||||
|
|
||||||
|
class MockMediaPlayerControl : public QMediaPlayerControl
|
||||||
|
{
|
||||||
|
friend class MockMediaPlayerService;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MockMediaPlayerControl():QMediaPlayerControl(0) {}
|
||||||
|
|
||||||
|
QMediaPlayer::State state() const { return _state; }
|
||||||
|
QMediaPlayer::MediaStatus mediaStatus() const { return _mediaStatus; }
|
||||||
|
|
||||||
|
qint64 duration() const { return _duration; }
|
||||||
|
|
||||||
|
qint64 position() const { return _position; }
|
||||||
|
|
||||||
|
void setPosition(qint64 position) { if (position != _position) emit positionChanged(_position = position); }
|
||||||
|
|
||||||
|
int volume() const { return _volume; }
|
||||||
|
void setVolume(int volume) { emit volumeChanged(_volume = volume); }
|
||||||
|
|
||||||
|
bool isMuted() const { return _muted; }
|
||||||
|
void setMuted(bool muted) { if (muted != _muted) emit mutedChanged(_muted = muted); }
|
||||||
|
|
||||||
|
int bufferStatus() const { return _bufferStatus; }
|
||||||
|
|
||||||
|
bool isAudioAvailable() const { return _audioAvailable; }
|
||||||
|
bool isVideoAvailable() const { return _videoAvailable; }
|
||||||
|
|
||||||
|
bool isSeekable() const { return _isSeekable; }
|
||||||
|
QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(_seekRange.first, _seekRange.second); }
|
||||||
|
void setSeekRange(qint64 minimum, qint64 maximum) { _seekRange = qMakePair(minimum, maximum); }
|
||||||
|
|
||||||
|
qreal playbackRate() const { return _playbackRate; }
|
||||||
|
void setPlaybackRate(qreal rate) { if (rate != _playbackRate) emit playbackRateChanged(_playbackRate = rate); }
|
||||||
|
|
||||||
|
QMediaContent media() const { return _media; }
|
||||||
|
void setMedia(const QMediaContent &content, QIODevice *stream)
|
||||||
|
{
|
||||||
|
_stream = stream;
|
||||||
|
_media = content;
|
||||||
|
if (_state != QMediaPlayer::StoppedState) {
|
||||||
|
_mediaStatus = _media.isNull() ? QMediaPlayer::NoMedia : QMediaPlayer::LoadingMedia;
|
||||||
|
emit stateChanged(_state = QMediaPlayer::StoppedState);
|
||||||
|
emit mediaStatusChanged(_mediaStatus);
|
||||||
|
}
|
||||||
|
emit mediaChanged(_media = content);
|
||||||
|
}
|
||||||
|
QIODevice *mediaStream() const { return _stream; }
|
||||||
|
|
||||||
|
void play() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PlayingState) emit stateChanged(_state = QMediaPlayer::PlayingState); }
|
||||||
|
void pause() { if (_isValid && !_media.isNull() && _state != QMediaPlayer::PausedState) emit stateChanged(_state = QMediaPlayer::PausedState); }
|
||||||
|
void stop() { if (_state != QMediaPlayer::StoppedState) emit stateChanged(_state = QMediaPlayer::StoppedState); }
|
||||||
|
|
||||||
|
QMediaPlayer::State _state;
|
||||||
|
QMediaPlayer::MediaStatus _mediaStatus;
|
||||||
|
QMediaPlayer::Error _error;
|
||||||
|
qint64 _duration;
|
||||||
|
qint64 _position;
|
||||||
|
int _volume;
|
||||||
|
bool _muted;
|
||||||
|
int _bufferStatus;
|
||||||
|
bool _audioAvailable;
|
||||||
|
bool _videoAvailable;
|
||||||
|
bool _isSeekable;
|
||||||
|
QPair<qint64, qint64> _seekRange;
|
||||||
|
qreal _playbackRate;
|
||||||
|
QMediaContent _media;
|
||||||
|
QIODevice *_stream;
|
||||||
|
bool _isValid;
|
||||||
|
QString _errorString;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKMEDIAPLAYERCONTROL_H
|
||||||
164
tests/auto/qmultimedia_common/mockmediaplayerservice.h
Normal file
164
tests/auto/qmultimedia_common/mockmediaplayerservice.h
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKPLAYERSERVICE_H
|
||||||
|
#define MOCKPLAYERSERVICE_H
|
||||||
|
|
||||||
|
#include "qmediaservice.h"
|
||||||
|
|
||||||
|
#include "mockmediaplayercontrol.h"
|
||||||
|
#include "mockmediastreamscontrol.h"
|
||||||
|
#include "mockmedianetworkaccesscontrol.h"
|
||||||
|
#include "mockvideorenderercontrol.h"
|
||||||
|
#include "mockvideowindowcontrol.h"
|
||||||
|
|
||||||
|
class MockMediaPlayerService : public QMediaService
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MockMediaPlayerService():QMediaService(0)
|
||||||
|
{
|
||||||
|
mockControl = new MockMediaPlayerControl;
|
||||||
|
mockStreamsControl = new MockStreamsControl;
|
||||||
|
mockNetworkControl = new MockNetworkAccessControl;
|
||||||
|
rendererControl = new MockVideoRendererControl;
|
||||||
|
windowControl = new MockVideoWindowControl;
|
||||||
|
rendererRef = 0;
|
||||||
|
windowRef = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
~MockMediaPlayerService()
|
||||||
|
{
|
||||||
|
delete mockControl;
|
||||||
|
delete mockStreamsControl;
|
||||||
|
delete mockNetworkControl;
|
||||||
|
delete rendererControl;
|
||||||
|
delete windowControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaControl* requestControl(const char *iid)
|
||||||
|
{
|
||||||
|
if (qstrcmp(iid, QMediaPlayerControl_iid) == 0) {
|
||||||
|
return mockControl;
|
||||||
|
} else if (qstrcmp(iid, QVideoRendererControl_iid) == 0) {
|
||||||
|
if (rendererRef == 0) {
|
||||||
|
rendererRef += 1;
|
||||||
|
return rendererControl;
|
||||||
|
}
|
||||||
|
} else if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
|
||||||
|
if (windowRef == 0) {
|
||||||
|
windowRef += 1;
|
||||||
|
return windowControl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (qstrcmp(iid, QMediaNetworkAccessControl_iid) == 0)
|
||||||
|
return mockNetworkControl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void releaseControl(QMediaControl *control)
|
||||||
|
{
|
||||||
|
if (control == rendererControl)
|
||||||
|
rendererRef -= 1;
|
||||||
|
else if (control == windowControl)
|
||||||
|
windowRef -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setState(QMediaPlayer::State state) { emit mockControl->stateChanged(mockControl->_state = state); }
|
||||||
|
void setState(QMediaPlayer::State state, QMediaPlayer::MediaStatus status) {
|
||||||
|
mockControl->_state = state;
|
||||||
|
mockControl->_mediaStatus = status;
|
||||||
|
emit mockControl->mediaStatusChanged(status);
|
||||||
|
emit mockControl->stateChanged(state);
|
||||||
|
}
|
||||||
|
void setMediaStatus(QMediaPlayer::MediaStatus status) { emit mockControl->mediaStatusChanged(mockControl->_mediaStatus = status); }
|
||||||
|
void setIsValid(bool isValid) { mockControl->_isValid = isValid; }
|
||||||
|
void setMedia(QMediaContent media) { mockControl->_media = media; }
|
||||||
|
void setDuration(qint64 duration) { mockControl->_duration = duration; }
|
||||||
|
void setPosition(qint64 position) { mockControl->_position = position; }
|
||||||
|
void setSeekable(bool seekable) { mockControl->_isSeekable = seekable; }
|
||||||
|
void setVolume(int volume) { mockControl->_volume = volume; }
|
||||||
|
void setMuted(bool muted) { mockControl->_muted = muted; }
|
||||||
|
void setVideoAvailable(bool videoAvailable) { mockControl->_videoAvailable = videoAvailable; }
|
||||||
|
void setBufferStatus(int bufferStatus) { mockControl->_bufferStatus = bufferStatus; }
|
||||||
|
void setPlaybackRate(qreal playbackRate) { mockControl->_playbackRate = playbackRate; }
|
||||||
|
void setError(QMediaPlayer::Error error) { mockControl->_error = error; emit mockControl->error(mockControl->_error, mockControl->_errorString); }
|
||||||
|
void setErrorString(QString errorString) { mockControl->_errorString = errorString; emit mockControl->error(mockControl->_error, mockControl->_errorString); }
|
||||||
|
|
||||||
|
void selectCurrentConfiguration(QNetworkConfiguration config) { mockNetworkControl->setCurrentConfiguration(config); }
|
||||||
|
|
||||||
|
void reset()
|
||||||
|
{
|
||||||
|
mockControl->_state = QMediaPlayer::StoppedState;
|
||||||
|
mockControl->_mediaStatus = QMediaPlayer::UnknownMediaStatus;
|
||||||
|
mockControl->_error = QMediaPlayer::NoError;
|
||||||
|
mockControl->_duration = 0;
|
||||||
|
mockControl->_position = 0;
|
||||||
|
mockControl->_volume = 0;
|
||||||
|
mockControl->_muted = false;
|
||||||
|
mockControl->_bufferStatus = 0;
|
||||||
|
mockControl->_videoAvailable = false;
|
||||||
|
mockControl->_isSeekable = false;
|
||||||
|
mockControl->_playbackRate = 0.0;
|
||||||
|
mockControl->_media = QMediaContent();
|
||||||
|
mockControl->_stream = 0;
|
||||||
|
mockControl->_isValid = false;
|
||||||
|
mockControl->_errorString = QString();
|
||||||
|
|
||||||
|
mockNetworkControl->_current = QNetworkConfiguration();
|
||||||
|
mockNetworkControl->_configurations = QList<QNetworkConfiguration>();
|
||||||
|
}
|
||||||
|
|
||||||
|
MockMediaPlayerControl *mockControl;
|
||||||
|
MockStreamsControl *mockStreamsControl;
|
||||||
|
MockNetworkAccessControl *mockNetworkControl;
|
||||||
|
MockVideoRendererControl *rendererControl;
|
||||||
|
MockVideoWindowControl *windowControl;
|
||||||
|
int rendererRef;
|
||||||
|
int windowRef;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // MOCKPLAYERSERVICE_H
|
||||||
112
tests/auto/qmultimedia_common/mockmediaplaylistcontrol.h
Normal file
112
tests/auto/qmultimedia_common/mockmediaplaylistcontrol.h
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKMEDIAPLAYLISTCONTROL_H
|
||||||
|
#define MOCKMEDIAPLAYLISTCONTROL_H
|
||||||
|
|
||||||
|
#include "qmediaplaylistcontrol.h"
|
||||||
|
#include "qmediaplaylistnavigator.h"
|
||||||
|
|
||||||
|
#include "mockreadonlyplaylistprovider.h"
|
||||||
|
|
||||||
|
// Hmm, read only.
|
||||||
|
class MockMediaPlaylistControl : public QMediaPlaylistControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MockMediaPlaylistControl(QObject *parent) : QMediaPlaylistControl(parent)
|
||||||
|
{
|
||||||
|
m_navigator = new QMediaPlaylistNavigator(new MockReadOnlyPlaylistProvider(this), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
~MockMediaPlaylistControl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); }
|
||||||
|
bool setPlaylistProvider(QMediaPlaylistProvider *newProvider)
|
||||||
|
{
|
||||||
|
bool bMediaContentChanged = false;
|
||||||
|
int i = 0;
|
||||||
|
for (; i < playlistProvider()->mediaCount(); i++) {
|
||||||
|
if (playlistProvider()->media(i).canonicalUrl().toString() != newProvider->media(i).canonicalUrl().toString()) {
|
||||||
|
bMediaContentChanged = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playlistProvider()->mediaCount() != newProvider->mediaCount() || bMediaContentChanged ) {
|
||||||
|
emit playlistProviderChanged();
|
||||||
|
emit currentMediaChanged(newProvider->media(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_navigator->setPlaylist(newProvider);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentIndex() const { return m_navigator->currentIndex(); }
|
||||||
|
void setCurrentIndex(int position)
|
||||||
|
{
|
||||||
|
if (position != currentIndex())
|
||||||
|
emit currentIndexChanged(position);
|
||||||
|
m_navigator->jump(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
int nextIndex(int steps) const { return m_navigator->nextIndex(steps); }
|
||||||
|
int previousIndex(int steps) const { return m_navigator->previousIndex(steps); }
|
||||||
|
|
||||||
|
void next() { m_navigator->next(); }
|
||||||
|
void previous() { m_navigator->previous(); }
|
||||||
|
|
||||||
|
QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); }
|
||||||
|
void setPlaybackMode(QMediaPlaylist::PlaybackMode mode)
|
||||||
|
{
|
||||||
|
if (playbackMode() != mode)
|
||||||
|
emit playbackModeChanged(mode);
|
||||||
|
|
||||||
|
m_navigator->setPlaybackMode(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMediaPlaylistNavigator *m_navigator;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKMEDIAPLAYLISTCONTROL_H
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKMEDIAPLAYLISTSOURCECONTROL_H
|
||||||
|
#define MOCKMEDIAPLAYLISTSOURCECONTROL_H
|
||||||
|
|
||||||
|
#include "qmediaplaylistsourcecontrol.h"
|
||||||
|
|
||||||
|
class MockPlaylistSourceControl : public QMediaPlaylistSourceControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MockPlaylistSourceControl(QObject *parent)
|
||||||
|
: QMediaPlaylistSourceControl(parent),
|
||||||
|
m_playlist(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~MockPlaylistSourceControl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPlaylist(QMediaPlaylist *playlist)
|
||||||
|
{
|
||||||
|
m_playlist = playlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaPlaylist *playlist() const
|
||||||
|
{
|
||||||
|
return m_playlist;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
QMediaPlaylist *m_playlist;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKMEDIAPLAYLISTSOURCECONTROL_H
|
||||||
125
tests/auto/qmultimedia_common/mockmediarecordercontrol.h
Normal file
125
tests/auto/qmultimedia_common/mockmediarecordercontrol.h
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKRECORDERCONTROL_H
|
||||||
|
#define MOCKRECORDERCONTROL_H
|
||||||
|
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "qmediarecordercontrol.h"
|
||||||
|
|
||||||
|
class MockMediaRecorderControl : public QMediaRecorderControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MockMediaRecorderControl(QObject *parent = 0):
|
||||||
|
QMediaRecorderControl(parent),
|
||||||
|
m_state(QMediaRecorder::StoppedState),
|
||||||
|
m_position(0),
|
||||||
|
m_muted(false) {}
|
||||||
|
|
||||||
|
QUrl outputLocation() const
|
||||||
|
{
|
||||||
|
return m_sink;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool setOutputLocation(const QUrl &sink)
|
||||||
|
{
|
||||||
|
m_sink = sink;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaRecorder::State state() const
|
||||||
|
{
|
||||||
|
return m_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 duration() const
|
||||||
|
{
|
||||||
|
return m_position;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isMuted() const
|
||||||
|
{
|
||||||
|
return m_muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
void applySettings() {}
|
||||||
|
|
||||||
|
using QMediaRecorderControl::error;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void record()
|
||||||
|
{
|
||||||
|
m_state = QMediaRecorder::RecordingState;
|
||||||
|
m_position=1;
|
||||||
|
emit stateChanged(m_state);
|
||||||
|
emit durationChanged(m_position);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pause()
|
||||||
|
{
|
||||||
|
m_state = QMediaRecorder::PausedState;
|
||||||
|
emit stateChanged(m_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop()
|
||||||
|
{
|
||||||
|
m_position=0;
|
||||||
|
m_state = QMediaRecorder::StoppedState;
|
||||||
|
emit stateChanged(m_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMuted(bool muted)
|
||||||
|
{
|
||||||
|
if (m_muted != muted)
|
||||||
|
emit mutedChanged(m_muted = muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
QUrl m_sink;
|
||||||
|
QMediaRecorder::State m_state;
|
||||||
|
qint64 m_position;
|
||||||
|
bool m_muted;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKRECORDERCONTROL_H
|
||||||
101
tests/auto/qmultimedia_common/mockmediarecorderservice.h
Normal file
101
tests/auto/qmultimedia_common/mockmediarecorderservice.h
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKSERVICE_H
|
||||||
|
#define MOCKSERVICE_H
|
||||||
|
|
||||||
|
#include "qmediaservice.h"
|
||||||
|
|
||||||
|
#include "mockaudioencodercontrol.h"
|
||||||
|
#include "mockmediarecordercontrol.h"
|
||||||
|
#include "mockvideoencodercontrol.h"
|
||||||
|
#include "mockaudioendpointselector.h"
|
||||||
|
#include "mockmediacontainercontrol.h"
|
||||||
|
#include "mockmetadatawritercontrol.h"
|
||||||
|
|
||||||
|
class MockMediaRecorderService : public QMediaService
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MockMediaRecorderService(QObject *parent = 0, QMediaControl *control = 0):
|
||||||
|
QMediaService(parent),
|
||||||
|
mockControl(control),
|
||||||
|
hasControls(true)
|
||||||
|
{
|
||||||
|
mockAudioEndpointSelector = new MockAudioEndpointSelector(parent);
|
||||||
|
mockAudioEncoderControl = new MockAudioEncoderControl(parent);
|
||||||
|
mockFormatControl = new MockMediaContainerControl(parent);
|
||||||
|
mockVideoEncoderControl = new MockVideoEncoderControl(parent);
|
||||||
|
mockMetaDataControl = new MockMetaDataWriterControl(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaControl* requestControl(const char *name)
|
||||||
|
{
|
||||||
|
if (hasControls && qstrcmp(name,QAudioEncoderControl_iid) == 0)
|
||||||
|
return mockAudioEncoderControl;
|
||||||
|
if (hasControls && qstrcmp(name,QAudioEndpointSelector_iid) == 0)
|
||||||
|
return mockAudioEndpointSelector;
|
||||||
|
if (hasControls && qstrcmp(name,QMediaRecorderControl_iid) == 0)
|
||||||
|
return mockControl;
|
||||||
|
if (hasControls && qstrcmp(name,QMediaContainerControl_iid) == 0)
|
||||||
|
return mockFormatControl;
|
||||||
|
if (hasControls && qstrcmp(name,QVideoEncoderControl_iid) == 0)
|
||||||
|
return mockVideoEncoderControl;
|
||||||
|
if (hasControls && qstrcmp(name, QMetaDataWriterControl_iid) == 0)
|
||||||
|
return mockMetaDataControl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void releaseControl(QMediaControl*)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaControl *mockControl;
|
||||||
|
QAudioEndpointSelector *mockAudioEndpointSelector;
|
||||||
|
QAudioEncoderControl *mockAudioEncoderControl;
|
||||||
|
QMediaContainerControl *mockFormatControl;
|
||||||
|
QVideoEncoderControl *mockVideoEncoderControl;
|
||||||
|
MockMetaDataWriterControl *mockMetaDataControl;
|
||||||
|
bool hasControls;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKSERVICE_H
|
||||||
66
tests/auto/qmultimedia_common/mockmediaservice.h
Normal file
66
tests/auto/qmultimedia_common/mockmediaservice.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKMEDIASERVICE_H
|
||||||
|
#define MOCKMEDIASERVICE_H
|
||||||
|
|
||||||
|
#include "qmediaservice.h"
|
||||||
|
|
||||||
|
class MockMediaService : public QMediaService
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MockMediaService(QObject *parent, QMediaControl *control):
|
||||||
|
QMediaService(parent),
|
||||||
|
mockControl(control) {}
|
||||||
|
|
||||||
|
QMediaControl* requestControl(const char *)
|
||||||
|
{
|
||||||
|
return mockControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void releaseControl(QMediaControl*) {}
|
||||||
|
|
||||||
|
QMediaControl *mockControl;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // MOCKMEDIASERVICE_H
|
||||||
73
tests/auto/qmultimedia_common/mockmediaserviceprovider.h
Normal file
73
tests/auto/qmultimedia_common/mockmediaserviceprovider.h
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKMEDIASERVICEPROVIDER_H
|
||||||
|
#define MOCKMEDIASERVICEPROVIDER_H
|
||||||
|
|
||||||
|
#include "qmediaserviceprovider.h"
|
||||||
|
|
||||||
|
// Simple provider that lets you set the service
|
||||||
|
class MockMediaServiceProvider : public QMediaServiceProvider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MockMediaServiceProvider(QMediaService* s = 0, bool del=false)
|
||||||
|
: service(s), deleteServiceOnRelease(del)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaService *requestService(const QByteArray &, const QMediaServiceProviderHint &)
|
||||||
|
{
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
void releaseService(QMediaService *service)
|
||||||
|
{
|
||||||
|
if (deleteServiceOnRelease) {
|
||||||
|
delete service;
|
||||||
|
service = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaService *service;
|
||||||
|
bool deleteServiceOnRelease;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKMEDIASERVICEPROVIDER_H
|
||||||
78
tests/auto/qmultimedia_common/mockmediastreamscontrol.h
Normal file
78
tests/auto/qmultimedia_common/mockmediastreamscontrol.h
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKMEDIASTREAMSCONTROL_H
|
||||||
|
#define MOCKMEDIASTREAMSCONTROL_H
|
||||||
|
|
||||||
|
#include "qmediastreamscontrol.h"
|
||||||
|
|
||||||
|
class MockStreamsControl : public QMediaStreamsControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MockStreamsControl(QObject *parent = 0) : QMediaStreamsControl(parent) {}
|
||||||
|
|
||||||
|
int streamCount() { return _streams.count(); }
|
||||||
|
void setStreamCount(int count) { _streams.resize(count); }
|
||||||
|
|
||||||
|
StreamType streamType(int index) { return _streams.at(index).type; }
|
||||||
|
void setStreamType(int index, StreamType type) { _streams[index].type = type; }
|
||||||
|
|
||||||
|
QVariant metaData(int index, QtMultimediaKit::MetaData key) {
|
||||||
|
return _streams.at(index).metaData.value(key); }
|
||||||
|
void setMetaData(int index, QtMultimediaKit::MetaData key, const QVariant &value) {
|
||||||
|
_streams[index].metaData.insert(key, value); }
|
||||||
|
|
||||||
|
bool isActive(int index) { return _streams.at(index).active; }
|
||||||
|
void setActive(int index, bool state) { _streams[index].active = state; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Stream
|
||||||
|
{
|
||||||
|
Stream() : type(UnknownStream), active(false) {}
|
||||||
|
StreamType type;
|
||||||
|
QMap<QtMultimediaKit::MetaData, QVariant> metaData;
|
||||||
|
bool active;
|
||||||
|
};
|
||||||
|
|
||||||
|
QVector<Stream> _streams;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKMEDIASTREAMSCONTROL_H
|
||||||
98
tests/auto/qmultimedia_common/mockmetadatareadercontrol.h
Normal file
98
tests/auto/qmultimedia_common/mockmetadatareadercontrol.h
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKMETADATAREADERCONTROL_H
|
||||||
|
#define MOCKMETADATAREADERCONTROL_H
|
||||||
|
|
||||||
|
#include "qmetadatareadercontrol.h"
|
||||||
|
|
||||||
|
class MockMetaDataReaderControl : public QMetaDataReaderControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MockMetaDataReaderControl(QObject *parent = 0)
|
||||||
|
: QMetaDataReaderControl(parent)
|
||||||
|
, m_available(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isMetaDataAvailable() const
|
||||||
|
{
|
||||||
|
return m_available;
|
||||||
|
}
|
||||||
|
void setMetaDataAvailable(bool available)
|
||||||
|
{
|
||||||
|
if (m_available != available)
|
||||||
|
emit metaDataAvailableChanged(m_available = available);
|
||||||
|
}
|
||||||
|
QList<QtMultimediaKit::MetaData> availableMetaData() const
|
||||||
|
{
|
||||||
|
return m_data.keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant metaData(QtMultimediaKit::MetaData key) const
|
||||||
|
{
|
||||||
|
return m_data.value(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant extendedMetaData(const QString &key) const
|
||||||
|
{
|
||||||
|
return m_extendedData.value(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList availableExtendedMetaData() const
|
||||||
|
{
|
||||||
|
return m_extendedData.keys();
|
||||||
|
}
|
||||||
|
|
||||||
|
using QMetaDataReaderControl::metaDataChanged;
|
||||||
|
|
||||||
|
void populateMetaData()
|
||||||
|
{
|
||||||
|
m_available = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool m_available;
|
||||||
|
QMap<QtMultimediaKit::MetaData, QVariant> m_data;
|
||||||
|
QMap<QString, QVariant> m_extendedData;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKMETADATAREADERCONTROL_H
|
||||||
107
tests/auto/qmultimedia_common/mockmetadatawritercontrol.h
Normal file
107
tests/auto/qmultimedia_common/mockmetadatawritercontrol.h
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKMETADATAWRITERCONTROL_H
|
||||||
|
#define MOCKMETADATAWRITERCONTROL_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
#include "qmetadatawritercontrol.h"
|
||||||
|
|
||||||
|
class MockMetaDataWriterControl : public QMetaDataWriterControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MockMetaDataWriterControl(QObject *parent = 0)
|
||||||
|
: QMetaDataWriterControl(parent)
|
||||||
|
, m_available(false)
|
||||||
|
, m_writable(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isMetaDataAvailable() const { return m_available; }
|
||||||
|
void setMetaDataAvailable(bool available)
|
||||||
|
{
|
||||||
|
if (m_available != available)
|
||||||
|
emit metaDataAvailableChanged(m_available = available);
|
||||||
|
}
|
||||||
|
QList<QtMultimediaKit::MetaData> availableMetaData() const { return m_data.keys(); }
|
||||||
|
|
||||||
|
bool isWritable() const { return m_writable; }
|
||||||
|
void setWritable(bool writable) { emit writableChanged(m_writable = writable); }
|
||||||
|
|
||||||
|
QVariant metaData(QtMultimediaKit::MetaData key) const { return m_data.value(key); }//Getting the metadata from Multimediakit
|
||||||
|
void setMetaData(QtMultimediaKit::MetaData key, const QVariant &value)
|
||||||
|
{
|
||||||
|
m_data.insert(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant extendedMetaData(const QString &key) const { return m_extendedData.value(key); }
|
||||||
|
void setExtendedMetaData(const QString &key, const QVariant &value)
|
||||||
|
{
|
||||||
|
m_extendedData.insert(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList availableExtendedMetaData() const { return m_extendedData.keys(); }
|
||||||
|
|
||||||
|
using QMetaDataWriterControl::metaDataChanged;
|
||||||
|
|
||||||
|
void populateMetaData()
|
||||||
|
{
|
||||||
|
m_available = true;
|
||||||
|
}
|
||||||
|
void setWritable()
|
||||||
|
{
|
||||||
|
emit writableChanged(true);
|
||||||
|
}
|
||||||
|
void setMetaDataAvailable()
|
||||||
|
{
|
||||||
|
emit metaDataAvailableChanged(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool m_available;
|
||||||
|
bool m_writable;
|
||||||
|
QMap<QtMultimediaKit::MetaData, QVariant> m_data;
|
||||||
|
QMap<QString, QVariant> m_extendedData;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKMETADATAWRITERCONTROL_H
|
||||||
12
tests/auto/qmultimedia_common/mockplayer.pri
Normal file
12
tests/auto/qmultimedia_common/mockplayer.pri
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
INCLUDEPATH *= $$PWD \
|
||||||
|
../../../src/multimedia \
|
||||||
|
../../../src/multimedia/audio \
|
||||||
|
../../../src/multimedia/video \
|
||||||
|
|
||||||
|
HEADERS *= \
|
||||||
|
../qmultimedia_common/mockmediaplayerservice.h \
|
||||||
|
../qmultimedia_common/mockmediaplayercontrol.h \
|
||||||
|
../qmultimedia_common/mockmediastreamscontrol.h \
|
||||||
|
../qmultimedia_common/mockmedianetworkaccesscontrol.h
|
||||||
|
|
||||||
|
include(mockvideo.pri)
|
||||||
8
tests/auto/qmultimedia_common/mockplaylist.pri
Normal file
8
tests/auto/qmultimedia_common/mockplaylist.pri
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
INCLUDEPATH *= $$PWD \
|
||||||
|
../../../src/multimedia \
|
||||||
|
|
||||||
|
HEADERS *= \
|
||||||
|
../qmultimedia_common/mockmediaplaylistsourcecontrol.h \
|
||||||
|
../qmultimedia_common/mockmediaplaylistcontrol.h \
|
||||||
|
../qmultimedia_common/mockreadonlyplaylistprovider.h \
|
||||||
|
../qmultimedia_common/mockplaylistservice.h
|
||||||
77
tests/auto/qmultimedia_common/mockplaylistservice.h
Normal file
77
tests/auto/qmultimedia_common/mockplaylistservice.h
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKPLAYLISTSERVICE_H
|
||||||
|
#define MOCKPLAYLISTSERVICE_H
|
||||||
|
|
||||||
|
#include "qmediaservice.h"
|
||||||
|
#include "mockmediaplaylistcontrol.h"
|
||||||
|
|
||||||
|
class MockPlaylistService : public QMediaService
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MockPlaylistService():QMediaService(0)
|
||||||
|
{
|
||||||
|
mockControl = new MockMediaPlaylistControl(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
~MockPlaylistService()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QMediaControl* requestControl(const char *iid)
|
||||||
|
{
|
||||||
|
if (qstrcmp(iid, QMediaPlaylistControl_iid) == 0)
|
||||||
|
return mockControl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void releaseControl(QMediaControl *)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MockMediaPlaylistControl *mockControl;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // MOCKPLAYLISTSERVICE_H
|
||||||
7
tests/auto/qmultimedia_common/mockradio.pri
Normal file
7
tests/auto/qmultimedia_common/mockradio.pri
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
# Radio related mock backend files
|
||||||
|
|
||||||
|
INCLUDEPATH += .
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
../qmultimedia_common/mockradiotunercontrol.h
|
||||||
249
tests/auto/qmultimedia_common/mockradiotunercontrol.h
Normal file
249
tests/auto/qmultimedia_common/mockradiotunercontrol.h
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKRADIOTUNERCONTROL_H
|
||||||
|
#define MOCKRADIOTUNERCONTROL_H
|
||||||
|
|
||||||
|
#include "qradiotunercontrol.h"
|
||||||
|
|
||||||
|
class MockRadioTunerControl : public QRadioTunerControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MockRadioTunerControl(QObject *parent):
|
||||||
|
QRadioTunerControl(parent),
|
||||||
|
m_active(false),
|
||||||
|
m_searching(false),m_muted(false),m_stereo(true),
|
||||||
|
m_volume(100),m_signal(0),m_frequency(0),
|
||||||
|
m_band(QRadioTuner::FM),m_err(QRadioTuner::NoError),
|
||||||
|
m_errstr("")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
using QRadioTunerControl::error;
|
||||||
|
|
||||||
|
QRadioTuner::State state() const
|
||||||
|
{
|
||||||
|
return m_active ? QRadioTuner::ActiveState : QRadioTuner::StoppedState;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isAvailable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
QtMultimediaKit::AvailabilityError availabilityError() const
|
||||||
|
{
|
||||||
|
return QtMultimediaKit::NoError;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRadioTuner::Band band() const
|
||||||
|
{
|
||||||
|
return m_band;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBand(QRadioTuner::Band b)
|
||||||
|
{
|
||||||
|
if (b == QRadioTuner::FM2 || b == QRadioTuner::LW) {
|
||||||
|
m_err = QRadioTuner::OutOfRangeError;
|
||||||
|
m_errstr.clear();
|
||||||
|
m_errstr = QString("band and range not supported");
|
||||||
|
} else {
|
||||||
|
m_err = QRadioTuner::NoError;
|
||||||
|
m_errstr.clear();
|
||||||
|
m_band = b;
|
||||||
|
emit bandChanged(m_band);
|
||||||
|
}
|
||||||
|
emit error(m_err);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isBandSupported(QRadioTuner::Band b) const
|
||||||
|
{
|
||||||
|
if (b == QRadioTuner::FM || b == QRadioTuner::AM)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int frequency() const
|
||||||
|
{
|
||||||
|
return m_frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair<int,int> frequencyRange(QRadioTuner::Band) const
|
||||||
|
{
|
||||||
|
return qMakePair<int,int>(1,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int frequencyStep(QRadioTuner::Band) const
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFrequency(int frequency)
|
||||||
|
{
|
||||||
|
if (frequency >= 148500000) {
|
||||||
|
m_err = QRadioTuner::OutOfRangeError;
|
||||||
|
m_errstr.clear();
|
||||||
|
m_errstr = QString("band and range not supported");
|
||||||
|
} else {
|
||||||
|
m_err = QRadioTuner::NoError;
|
||||||
|
m_errstr.clear();
|
||||||
|
m_frequency = frequency;
|
||||||
|
emit frequencyChanged(m_frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit error(m_err);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isStereo() const
|
||||||
|
{
|
||||||
|
return m_stereo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setStereo(bool stereo)
|
||||||
|
{
|
||||||
|
emit stereoStatusChanged(m_stereo = stereo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QRadioTuner::StereoMode stereoMode() const
|
||||||
|
{
|
||||||
|
return m_stereoMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setStereoMode(QRadioTuner::StereoMode mode)
|
||||||
|
{
|
||||||
|
m_stereoMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRadioTuner::Error error() const
|
||||||
|
{
|
||||||
|
return m_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString errorString() const
|
||||||
|
{
|
||||||
|
return m_errstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int signalStrength() const
|
||||||
|
{
|
||||||
|
return m_signal;
|
||||||
|
}
|
||||||
|
|
||||||
|
int volume() const
|
||||||
|
{
|
||||||
|
return m_volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setVolume(int volume)
|
||||||
|
{
|
||||||
|
m_volume = volume;
|
||||||
|
emit volumeChanged(m_volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isMuted() const
|
||||||
|
{
|
||||||
|
return m_muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setMuted(bool muted)
|
||||||
|
{
|
||||||
|
m_muted = muted;
|
||||||
|
emit mutedChanged(m_muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSearching() const
|
||||||
|
{
|
||||||
|
return m_searching;
|
||||||
|
}
|
||||||
|
|
||||||
|
void searchForward()
|
||||||
|
{
|
||||||
|
m_searching = true;
|
||||||
|
emit searchingChanged(m_searching);
|
||||||
|
}
|
||||||
|
|
||||||
|
void searchBackward()
|
||||||
|
{
|
||||||
|
m_searching = true;
|
||||||
|
emit searchingChanged(m_searching);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cancelSearch()
|
||||||
|
{
|
||||||
|
m_searching = false;
|
||||||
|
emit searchingChanged(m_searching);
|
||||||
|
}
|
||||||
|
|
||||||
|
void start()
|
||||||
|
{
|
||||||
|
if (!m_active) {
|
||||||
|
m_active = true;
|
||||||
|
emit stateChanged(state());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop()
|
||||||
|
{
|
||||||
|
if (m_active) {
|
||||||
|
m_active = false;
|
||||||
|
emit stateChanged(state());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool m_active;
|
||||||
|
bool m_searching;
|
||||||
|
bool m_muted;
|
||||||
|
bool m_stereo;
|
||||||
|
int m_volume;
|
||||||
|
int m_signal;
|
||||||
|
int m_frequency;
|
||||||
|
QRadioTuner::StereoMode m_stereoMode;
|
||||||
|
QRadioTuner::Band m_band;
|
||||||
|
QRadioTuner::Error m_err;
|
||||||
|
QString m_errstr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKRADIOTUNERCONTROL_H
|
||||||
69
tests/auto/qmultimedia_common/mockreadonlyplaylistprovider.h
Normal file
69
tests/auto/qmultimedia_common/mockreadonlyplaylistprovider.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKREADONLYPLAYLISTPROVIDER_H
|
||||||
|
#define MOCKREADONLYPLAYLISTPROVIDER_H
|
||||||
|
|
||||||
|
#include "qmediaplaylistprovider.h"
|
||||||
|
|
||||||
|
class MockReadOnlyPlaylistProvider : public QMediaPlaylistProvider
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MockReadOnlyPlaylistProvider(QObject *parent)
|
||||||
|
:QMediaPlaylistProvider(parent)
|
||||||
|
{
|
||||||
|
m_items.append(QMediaContent(QUrl(QLatin1String("file:///1"))));
|
||||||
|
m_items.append(QMediaContent(QUrl(QLatin1String("file:///2"))));
|
||||||
|
m_items.append(QMediaContent(QUrl(QLatin1String("file:///3"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
int mediaCount() const { return m_items.size(); }
|
||||||
|
QMediaContent media(int index) const
|
||||||
|
{
|
||||||
|
return index >=0 && index < mediaCount() ? m_items.at(index) : QMediaContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<QMediaContent> m_items;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKREADONLYPLAYLISTPROVIDER_H
|
||||||
14
tests/auto/qmultimedia_common/mockrecorder.pri
Normal file
14
tests/auto/qmultimedia_common/mockrecorder.pri
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
INCLUDEPATH *= $$PWD \
|
||||||
|
../../../src/multimedia \
|
||||||
|
../../../src/multimedia/audio \
|
||||||
|
../../../src/multimedia/video \
|
||||||
|
|
||||||
|
HEADERS *= \
|
||||||
|
../qmultimedia_common/mockmediarecorderservice.h \
|
||||||
|
../qmultimedia_common/mockmediarecordercontrol.h \
|
||||||
|
../qmultimedia_common/mockvideoencodercontrol.h \
|
||||||
|
../qmultimedia_common/mockaudioencodercontrol.h \
|
||||||
|
../qmultimedia_common/mockaudioendpointselector.h \
|
||||||
|
|
||||||
|
# We also need all the container/metadata bits
|
||||||
|
include(mockcontainer.pri)
|
||||||
10
tests/auto/qmultimedia_common/mockvideo.pri
Normal file
10
tests/auto/qmultimedia_common/mockvideo.pri
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# video related mock backend files
|
||||||
|
INCLUDEPATH += $$PWD \
|
||||||
|
../../../src/multimedia \
|
||||||
|
../../../src/multimedia/video
|
||||||
|
|
||||||
|
HEADERS *= \
|
||||||
|
../qmultimedia_common/mockvideosurface.h \
|
||||||
|
../qmultimedia_common/mockvideorenderercontrol.h \
|
||||||
|
../qmultimedia_common/mockvideowindowcontrol.h
|
||||||
|
|
||||||
112
tests/auto/qmultimedia_common/mockvideoencodercontrol.h
Normal file
112
tests/auto/qmultimedia_common/mockvideoencodercontrol.h
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKVIDEOENCODERCONTROL_H
|
||||||
|
#define MOCKVIDEOENCODERCONTROL_H
|
||||||
|
|
||||||
|
#include "qvideoencodercontrol.h"
|
||||||
|
|
||||||
|
class MockVideoEncoderControl : public QVideoEncoderControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MockVideoEncoderControl(QObject *parent):
|
||||||
|
QVideoEncoderControl(parent)
|
||||||
|
{
|
||||||
|
m_supportedEncodeOptions.insert("video/3gpp", QStringList() << "quantizer" << "me");
|
||||||
|
m_supportedEncodeOptions.insert("video/H264", QStringList() << "quantizer" << "me" << "bframes");
|
||||||
|
m_videoCodecs << "video/3gpp" << "video/H264";
|
||||||
|
m_sizes << QSize(320,240) << QSize(640,480);
|
||||||
|
m_framerates << 30 << 15 << 1;
|
||||||
|
}
|
||||||
|
~MockVideoEncoderControl() {}
|
||||||
|
|
||||||
|
QVideoEncoderSettings videoSettings() const { return m_videoSettings; }
|
||||||
|
void setVideoSettings(const QVideoEncoderSettings &settings) { m_videoSettings = settings; };
|
||||||
|
|
||||||
|
QList<QSize> supportedResolutions(const QVideoEncoderSettings & = QVideoEncoderSettings(),
|
||||||
|
bool *continuous = 0) const
|
||||||
|
{
|
||||||
|
if (continuous)
|
||||||
|
*continuous = true;
|
||||||
|
|
||||||
|
return m_sizes;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<qreal> supportedFrameRates(const QVideoEncoderSettings & = QVideoEncoderSettings(),
|
||||||
|
bool *continuous = 0) const
|
||||||
|
{
|
||||||
|
if (continuous)
|
||||||
|
*continuous = false;
|
||||||
|
|
||||||
|
return m_framerates;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList supportedVideoCodecs() const { return m_videoCodecs; }
|
||||||
|
QString videoCodecDescription(const QString &codecName) const { return 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:
|
||||||
|
QVideoEncoderSettings m_videoSettings;
|
||||||
|
|
||||||
|
QMap<QString, QStringList> m_supportedEncodeOptions;
|
||||||
|
QMap< QString, QMap<QString, QVariant> > m_encodeOptions;
|
||||||
|
|
||||||
|
QStringList m_videoCodecs;
|
||||||
|
QList<QSize> m_sizes;
|
||||||
|
QList<qreal> m_framerates;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKVIDEOENCODERCONTROL_H
|
||||||
58
tests/auto/qmultimedia_common/mockvideorenderercontrol.h
Normal file
58
tests/auto/qmultimedia_common/mockvideorenderercontrol.h
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKVIDEORENDERERCONTROL_H
|
||||||
|
#define MOCKVIDEORENDERERCONTROL_H
|
||||||
|
|
||||||
|
#include "qvideorenderercontrol.h"
|
||||||
|
|
||||||
|
class MockVideoRendererControl : public QVideoRendererControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MockVideoRendererControl(QObject *parent = 0) : QVideoRendererControl(parent), m_surface(0) {}
|
||||||
|
|
||||||
|
QAbstractVideoSurface *surface() const { return m_surface; }
|
||||||
|
void setSurface(QAbstractVideoSurface *surface) { m_surface = surface; }
|
||||||
|
|
||||||
|
QAbstractVideoSurface *m_surface;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKVIDEORENDERERCONTROL_H
|
||||||
59
tests/auto/qmultimedia_common/mockvideosurface.h
Normal file
59
tests/auto/qmultimedia_common/mockvideosurface.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKVIDEOSURFACE_H
|
||||||
|
#define MOCKVIDEOSURFACE_H
|
||||||
|
|
||||||
|
#include "qabstractvideosurface.h"
|
||||||
|
|
||||||
|
class MockVideoSurface : public QAbstractVideoSurface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||||
|
const QAbstractVideoBuffer::HandleType) const
|
||||||
|
{
|
||||||
|
return QList<QVideoFrame::PixelFormat>();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool present(const QVideoFrame &) { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKVIDEOSURFACE_H
|
||||||
71
tests/auto/qmultimedia_common/mockvideowindowcontrol.h
Normal file
71
tests/auto/qmultimedia_common/mockvideowindowcontrol.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 MOCKVIDEOWINDOWCONTROL_H
|
||||||
|
#define MOCKVIDEOWINDOWCONTROL_H
|
||||||
|
|
||||||
|
#include "qvideowindowcontrol.h"
|
||||||
|
|
||||||
|
class MockVideoWindowControl : public QVideoWindowControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MockVideoWindowControl(QObject *parent = 0) : QVideoWindowControl(parent) {}
|
||||||
|
WId winId() const { return 0; }
|
||||||
|
void setWinId(WId) {}
|
||||||
|
QRect displayRect() const { return QRect(); }
|
||||||
|
void setDisplayRect(const QRect &) {}
|
||||||
|
bool isFullScreen() const { return false; }
|
||||||
|
void setFullScreen(bool) {}
|
||||||
|
void repaint() {}
|
||||||
|
QSize nativeSize() const { return QSize(); }
|
||||||
|
Qt::AspectRatioMode aspectRatioMode() const { return Qt::KeepAspectRatio; }
|
||||||
|
void setAspectRatioMode(Qt::AspectRatioMode) {}
|
||||||
|
int brightness() const { return 0; }
|
||||||
|
void setBrightness(int) {}
|
||||||
|
int contrast() const { return 0; }
|
||||||
|
void setContrast(int) {}
|
||||||
|
int hue() const { return 0; }
|
||||||
|
void setHue(int) {}
|
||||||
|
int saturation() const { return 0; }
|
||||||
|
void setSaturation(int) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MOCKVIDEOWINDOWCONTROL_H
|
||||||
@@ -8,3 +8,5 @@ QT += multimediakit-private
|
|||||||
HEADERS += tst_qradiotuner.h
|
HEADERS += tst_qradiotuner.h
|
||||||
SOURCES += main.cpp tst_qradiotuner.cpp
|
SOURCES += main.cpp tst_qradiotuner.cpp
|
||||||
|
|
||||||
|
include (../qmultimedia_common/mock.pri)
|
||||||
|
include (../qmultimedia_common/mockradio.pri)
|
||||||
|
|||||||
@@ -50,16 +50,19 @@ void tst_QRadioTuner::initTestCase()
|
|||||||
qRegisterMetaType<QRadioTuner::State>("QRadioTuner::State");
|
qRegisterMetaType<QRadioTuner::State>("QRadioTuner::State");
|
||||||
qRegisterMetaType<QRadioTuner::Band>("QRadioTuner::Band");
|
qRegisterMetaType<QRadioTuner::Band>("QRadioTuner::Band");
|
||||||
|
|
||||||
mock = new MockControl(this);
|
mock = new MockRadioTunerControl(this);
|
||||||
service = new MockService(this, mock);
|
service = new MockMediaService(this, mock);
|
||||||
provider = new MockProvider(service);
|
provider = new MockMediaServiceProvider(service);
|
||||||
radio = new QRadioTuner(0,provider);
|
radio = new QRadioTuner(0,provider);
|
||||||
QVERIFY(radio->service() != 0);
|
QVERIFY(radio->service() != 0);
|
||||||
|
QVERIFY(radio->isAvailable());
|
||||||
|
QVERIFY(radio->availabilityError() == QtMultimediaKit::NoError);
|
||||||
|
|
||||||
QSignalSpy stateSpy(radio, SIGNAL(stateChanged(QRadioTuner::State)));
|
QSignalSpy stateSpy(radio, SIGNAL(stateChanged(QRadioTuner::State)));
|
||||||
|
|
||||||
QCOMPARE(radio->state(), QRadioTuner::StoppedState);
|
QCOMPARE(radio->state(), QRadioTuner::StoppedState);
|
||||||
radio->start();
|
radio->start();
|
||||||
|
QVERIFY(radio->availabilityError() == QtMultimediaKit::NoError);
|
||||||
QCOMPARE(radio->state(), QRadioTuner::ActiveState);
|
QCOMPARE(radio->state(), QRadioTuner::ActiveState);
|
||||||
|
|
||||||
QCOMPARE(stateSpy.count(), 1);
|
QCOMPARE(stateSpy.count(), 1);
|
||||||
@@ -74,6 +77,7 @@ void tst_QRadioTuner::cleanupTestCase()
|
|||||||
QSignalSpy stateSpy(radio, SIGNAL(stateChanged(QRadioTuner::State)));
|
QSignalSpy stateSpy(radio, SIGNAL(stateChanged(QRadioTuner::State)));
|
||||||
|
|
||||||
radio->stop();
|
radio->stop();
|
||||||
|
QVERIFY(radio->availabilityError() == QtMultimediaKit::NoError);
|
||||||
QCOMPARE(radio->state(), QRadioTuner::StoppedState);
|
QCOMPARE(radio->state(), QRadioTuner::StoppedState);
|
||||||
QCOMPARE(stateSpy.count(), 1);
|
QCOMPARE(stateSpy.count(), 1);
|
||||||
|
|
||||||
@@ -88,9 +92,9 @@ void tst_QRadioTuner::testNullService()
|
|||||||
{
|
{
|
||||||
const QPair<int, int> nullRange(0, 0);
|
const QPair<int, int> nullRange(0, 0);
|
||||||
|
|
||||||
MockProvider provider(0);
|
MockMediaServiceProvider provider(0);
|
||||||
QRadioTuner radio(0, &provider);
|
QRadioTuner radio(0, &provider);
|
||||||
|
QVERIFY(!radio.isAvailable());
|
||||||
radio.start();
|
radio.start();
|
||||||
QCOMPARE(radio.error(), QRadioTuner::ResourceError);
|
QCOMPARE(radio.error(), QRadioTuner::ResourceError);
|
||||||
QCOMPARE(radio.errorString(), QString());
|
QCOMPARE(radio.errorString(), QString());
|
||||||
@@ -115,10 +119,10 @@ void tst_QRadioTuner::testNullControl()
|
|||||||
{
|
{
|
||||||
const QPair<int, int> nullRange(0, 0);
|
const QPair<int, int> nullRange(0, 0);
|
||||||
|
|
||||||
MockService service(0, 0);
|
MockMediaService service(0, 0);
|
||||||
MockProvider provider(&service);
|
MockMediaServiceProvider provider(&service);
|
||||||
QRadioTuner radio(0, &provider);
|
QRadioTuner radio(0, &provider);
|
||||||
|
QVERIFY(!radio.isAvailable());
|
||||||
radio.start();
|
radio.start();
|
||||||
|
|
||||||
QCOMPARE(radio.error(), QRadioTuner::ResourceError);
|
QCOMPARE(radio.error(), QRadioTuner::ResourceError);
|
||||||
@@ -269,7 +273,47 @@ void tst_QRadioTuner::testSignal()
|
|||||||
|
|
||||||
void tst_QRadioTuner::testStereo()
|
void tst_QRadioTuner::testStereo()
|
||||||
{
|
{
|
||||||
|
/* no set function to toggle stereo status;
|
||||||
|
cannot emit stereoStatusChanged() signal */
|
||||||
|
|
||||||
QVERIFY(radio->isStereo());
|
QVERIFY(radio->isStereo());
|
||||||
radio->setStereoMode(QRadioTuner::ForceMono);
|
radio->setStereoMode(QRadioTuner::ForceMono);
|
||||||
QVERIFY(radio->stereoMode() == QRadioTuner::ForceMono);
|
QVERIFY(radio->stereoMode() == QRadioTuner::ForceMono);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QRadioTuner's errorsignal
|
||||||
|
void tst_QRadioTuner::errorSignal()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<QRadioTuner::Error>("QRadioTuner::Error");
|
||||||
|
QObject obj;
|
||||||
|
MockRadioTunerControl dctrl(&obj);
|
||||||
|
MockMediaService service(&obj, &dctrl);
|
||||||
|
MockMediaServiceProvider provider(&service);
|
||||||
|
QRadioTuner radio(0,&provider);
|
||||||
|
QSignalSpy spy(&radio, SIGNAL(error(QRadioTuner::Error)));
|
||||||
|
QVERIFY(radio.service() != 0);
|
||||||
|
QVERIFY(radio.isAvailable());
|
||||||
|
radio.start();
|
||||||
|
radio.setBand(QRadioTuner::FM);
|
||||||
|
QVERIFY(spy.count() == 1);
|
||||||
|
QVERIFY(qvariant_cast<QRadioTuner::Error>(spy.at(0).at(0)) == QRadioTuner::NoError);
|
||||||
|
QVERIFY(radio.error() == QRadioTuner::NoError);
|
||||||
|
QVERIFY(radio.error() != QRadioTuner::OpenError);
|
||||||
|
QVERIFY(radio.errorString().isEmpty());
|
||||||
|
spy.clear();
|
||||||
|
|
||||||
|
/* emits QRadioTuner::OutOfRangeError if band is set to FM2 or LW
|
||||||
|
and frequency set to >= 148500000 */
|
||||||
|
|
||||||
|
radio.setBand(QRadioTuner::LW);
|
||||||
|
radio.setBand(QRadioTuner::FM2);
|
||||||
|
radio.setFrequency(148500000);
|
||||||
|
QVERIFY(spy.count() == 3);
|
||||||
|
QVERIFY(qvariant_cast<QRadioTuner::Error>(spy.at(0).at(0)) == QRadioTuner::OutOfRangeError);
|
||||||
|
QVERIFY(qvariant_cast<QRadioTuner::Error>(spy.at(1).at(0)) == QRadioTuner::OutOfRangeError);
|
||||||
|
QVERIFY(qvariant_cast<QRadioTuner::Error>(spy.at(2).at(0)) == QRadioTuner::OutOfRangeError);
|
||||||
|
QVERIFY(radio.error() == QRadioTuner::OutOfRangeError);
|
||||||
|
QVERIFY2(!radio.errorString().isEmpty(), "band and range not supported");
|
||||||
|
spy.clear();
|
||||||
|
radio.stop();
|
||||||
|
}
|
||||||
|
|||||||
@@ -51,211 +51,11 @@
|
|||||||
#include <qradiotunercontrol.h>
|
#include <qradiotunercontrol.h>
|
||||||
#include <qradiotuner.h>
|
#include <qradiotuner.h>
|
||||||
|
|
||||||
|
#include "mockmediaserviceprovider.h"
|
||||||
|
#include "mockmediaservice.h"
|
||||||
|
#include "mockradiotunercontrol.h"
|
||||||
|
|
||||||
QT_USE_NAMESPACE
|
QT_USE_NAMESPACE
|
||||||
class MockControl : public QRadioTunerControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MockControl(QObject *parent):
|
|
||||||
QRadioTunerControl(parent),
|
|
||||||
m_active(false),
|
|
||||||
m_searching(false),m_muted(false),m_stereo(true),
|
|
||||||
m_volume(100),m_signal(0),m_frequency(0),
|
|
||||||
m_band(QRadioTuner::FM) {}
|
|
||||||
|
|
||||||
QRadioTuner::State state() const
|
|
||||||
{
|
|
||||||
return m_active ? QRadioTuner::ActiveState : QRadioTuner::StoppedState;
|
|
||||||
}
|
|
||||||
bool isAvailable() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
QtMultimediaKit::AvailabilityError availabilityError() const
|
|
||||||
{
|
|
||||||
return QtMultimediaKit::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRadioTuner::Band band() const
|
|
||||||
{
|
|
||||||
return m_band;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBand(QRadioTuner::Band b)
|
|
||||||
{
|
|
||||||
m_band = b;
|
|
||||||
emit bandChanged(m_band);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isBandSupported(QRadioTuner::Band b) const
|
|
||||||
{
|
|
||||||
if(b == QRadioTuner::FM || b == QRadioTuner::AM) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int frequency() const
|
|
||||||
{
|
|
||||||
return m_frequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<int,int> frequencyRange(QRadioTuner::Band) const
|
|
||||||
{
|
|
||||||
return qMakePair<int,int>(1,2);
|
|
||||||
}
|
|
||||||
|
|
||||||
int frequencyStep(QRadioTuner::Band) const
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFrequency(int frequency)
|
|
||||||
{
|
|
||||||
m_frequency = frequency;
|
|
||||||
emit frequencyChanged(m_frequency);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isStereo() const
|
|
||||||
{
|
|
||||||
return m_stereo;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setStereo(bool stereo)
|
|
||||||
{
|
|
||||||
emit stereoStatusChanged(m_stereo = stereo);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QRadioTuner::StereoMode stereoMode() const
|
|
||||||
{
|
|
||||||
return m_stereoMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setStereoMode(QRadioTuner::StereoMode mode)
|
|
||||||
{
|
|
||||||
m_stereoMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRadioTuner::Error error() const
|
|
||||||
{
|
|
||||||
return QRadioTuner::NoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString errorString() const
|
|
||||||
{
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
int signalStrength() const
|
|
||||||
{
|
|
||||||
return m_signal;
|
|
||||||
}
|
|
||||||
|
|
||||||
int volume() const
|
|
||||||
{
|
|
||||||
return m_volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setVolume(int volume)
|
|
||||||
{
|
|
||||||
m_volume = volume;
|
|
||||||
emit volumeChanged(m_volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isMuted() const
|
|
||||||
{
|
|
||||||
return m_muted;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setMuted(bool muted)
|
|
||||||
{
|
|
||||||
m_muted = muted;
|
|
||||||
emit mutedChanged(m_muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isSearching() const
|
|
||||||
{
|
|
||||||
return m_searching;
|
|
||||||
}
|
|
||||||
|
|
||||||
void searchForward()
|
|
||||||
{
|
|
||||||
m_searching = true;
|
|
||||||
emit searchingChanged(m_searching);
|
|
||||||
}
|
|
||||||
|
|
||||||
void searchBackward()
|
|
||||||
{
|
|
||||||
m_searching = true;
|
|
||||||
emit searchingChanged(m_searching);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cancelSearch()
|
|
||||||
{
|
|
||||||
m_searching = false;
|
|
||||||
emit searchingChanged(m_searching);
|
|
||||||
}
|
|
||||||
|
|
||||||
void start()
|
|
||||||
{
|
|
||||||
if (!m_active) {
|
|
||||||
m_active = true;
|
|
||||||
emit stateChanged(state());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void stop()
|
|
||||||
{
|
|
||||||
if (m_active) {
|
|
||||||
m_active = false;
|
|
||||||
emit stateChanged(state());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool m_active;
|
|
||||||
bool m_searching;
|
|
||||||
bool m_muted;
|
|
||||||
bool m_stereo;
|
|
||||||
int m_volume;
|
|
||||||
int m_signal;
|
|
||||||
int m_frequency;
|
|
||||||
QRadioTuner::StereoMode m_stereoMode;
|
|
||||||
QRadioTuner::Band m_band;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockService : public QMediaService
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
MockService(QObject *parent, QMediaControl *control):
|
|
||||||
QMediaService(parent),
|
|
||||||
mockControl(control) {}
|
|
||||||
|
|
||||||
QMediaControl* requestControl(const char *)
|
|
||||||
{
|
|
||||||
return mockControl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void releaseControl(QMediaControl*) {}
|
|
||||||
|
|
||||||
QMediaControl *mockControl;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MockProvider : public QMediaServiceProvider
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MockProvider(MockService *service):mockService(service) {}
|
|
||||||
QMediaService *requestService(const QByteArray &, const QMediaServiceProviderHint &)
|
|
||||||
{
|
|
||||||
return mockService;
|
|
||||||
}
|
|
||||||
|
|
||||||
void releaseService(QMediaService *) {}
|
|
||||||
|
|
||||||
MockService *mockService;
|
|
||||||
};
|
|
||||||
|
|
||||||
class tst_QRadioTuner: public QObject
|
class tst_QRadioTuner: public QObject
|
||||||
{
|
{
|
||||||
@@ -275,11 +75,12 @@ private slots:
|
|||||||
void testVolume();
|
void testVolume();
|
||||||
void testSignal();
|
void testSignal();
|
||||||
void testStereo();
|
void testStereo();
|
||||||
|
void errorSignal();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MockControl *mock;
|
MockRadioTunerControl *mock;
|
||||||
MockService *service;
|
MockMediaService *service;
|
||||||
MockProvider *provider;
|
MockMediaServiceProvider *provider;
|
||||||
QRadioTuner *radio;
|
QRadioTuner *radio;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
5
tests/auto/qvideodevicecontrol/qvideodevicecontrol.pro
Normal file
5
tests/auto/qvideodevicecontrol/qvideodevicecontrol.pro
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
load(qttest_p4)
|
||||||
|
|
||||||
|
QT += multimediakit-private
|
||||||
|
|
||||||
|
SOURCES += tst_qvideodevicecontrol.cpp
|
||||||
110
tests/auto/qvideodevicecontrol/tst_qvideodevicecontrol.cpp
Normal file
110
tests/auto/qvideodevicecontrol/tst_qvideodevicecontrol.cpp
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "qvideodevicecontrol.h"
|
||||||
|
class TestClass: public QVideoDeviceControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TestClass(QObject *parent = 0 ):QVideoDeviceControl(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
~TestClass(){}
|
||||||
|
|
||||||
|
virtual int deviceCount() const { return 0; }
|
||||||
|
|
||||||
|
QString deviceName(int index) const
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString deviceDescription(int index) const
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon deviceIcon(int index) const
|
||||||
|
{
|
||||||
|
QIcon icon;
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
int defaultDevice() const { return 0; }
|
||||||
|
int selectedDevice() const { return 0; }
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void setSelectedDevice(int index)
|
||||||
|
{
|
||||||
|
emit devicesChanged();
|
||||||
|
emit selectedDeviceChanged(index);
|
||||||
|
emit selectedDeviceChanged("abc");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class tst_QVideoDeviceControl : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
tst_QVideoDeviceControl(){}
|
||||||
|
~tst_QVideoDeviceControl(){}
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void testQVideoDeviceControl();
|
||||||
|
};
|
||||||
|
|
||||||
|
//MaemoAPI-1859:QVideoDeviceControl constructor
|
||||||
|
void tst_QVideoDeviceControl::testQVideoDeviceControl()
|
||||||
|
{
|
||||||
|
TestClass *testClass = new TestClass(this);
|
||||||
|
QVERIFY(testClass != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTEST_MAIN(tst_QVideoDeviceControl)
|
||||||
|
#include "tst_qvideodevicecontrol.moc"
|
||||||
7
tests/auto/qvideoencodercontrol/qvideoencodercontrol.pro
Normal file
7
tests/auto/qvideoencodercontrol/qvideoencodercontrol.pro
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
load(qttest_p4)
|
||||||
|
|
||||||
|
QT += multimediakit-private
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
tst_qvideoencodercontrol.cpp
|
||||||
|
|
||||||
139
tests/auto/qvideoencodercontrol/tst_qvideoencodercontrol.cpp
Normal file
139
tests/auto/qvideoencodercontrol/tst_qvideoencodercontrol.cpp
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** 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 "qvideoencodercontrol.h"
|
||||||
|
class MyVideEncoderControl: public QVideoEncoderControl
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MyVideEncoderControl(QObject *parent = 0 ):QVideoEncoderControl(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
~MyVideEncoderControl()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QSize> supportedResolutions(const QVideoEncoderSettings &settings,bool *continuous = 0) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(settings);
|
||||||
|
Q_UNUSED(continuous);
|
||||||
|
|
||||||
|
return (QList<QSize>());
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<qreal> supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous = 0) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(settings);
|
||||||
|
Q_UNUSED(continuous);
|
||||||
|
|
||||||
|
return (QList<qreal>());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList supportedVideoCodecs() const
|
||||||
|
{
|
||||||
|
return QStringList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString videoCodecDescription(const QString &codecName) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(codecName)
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QVideoEncoderSettings videoSettings() const
|
||||||
|
{
|
||||||
|
return QVideoEncoderSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setVideoSettings(const QVideoEncoderSettings &settings)
|
||||||
|
{
|
||||||
|
Q_UNUSED(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList supportedEncodingOptions(const QString &codec) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(codec);
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant encodingOption(const QString &codec, const QString &name) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(codec);
|
||||||
|
Q_UNUSED(name);
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setEncodingOption(const QString &codec, const QString &name, const QVariant &value)
|
||||||
|
{
|
||||||
|
Q_UNUSED(codec);
|
||||||
|
Q_UNUSED(name);
|
||||||
|
Q_UNUSED(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class tst_QVideoEncoderControl: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private slots:
|
||||||
|
void constructor();
|
||||||
|
};
|
||||||
|
|
||||||
|
void tst_QVideoEncoderControl::constructor()
|
||||||
|
{
|
||||||
|
QObject parent;
|
||||||
|
MyVideEncoderControl control(&parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTEST_MAIN(tst_QVideoEncoderControl)
|
||||||
|
#include "tst_qvideoencodercontrol.moc"
|
||||||
|
|
||||||
|
|
||||||
@@ -83,6 +83,10 @@ private slots:
|
|||||||
void imageDetach();
|
void imageDetach();
|
||||||
void formatConversion_data();
|
void formatConversion_data();
|
||||||
void formatConversion();
|
void formatConversion();
|
||||||
|
|
||||||
|
void isMapped();
|
||||||
|
void isReadable();
|
||||||
|
void isWritable();
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QImage::Format)
|
Q_DECLARE_METATYPE(QImage::Format)
|
||||||
@@ -344,6 +348,27 @@ void tst_QVideoFrame::copy_data()
|
|||||||
<< QVideoFrame::TopField
|
<< QVideoFrame::TopField
|
||||||
<< qint64(63641740)
|
<< qint64(63641740)
|
||||||
<< qint64(63641954);
|
<< qint64(63641954);
|
||||||
|
QTest::newRow("64x64 ARGB32")
|
||||||
|
<< QAbstractVideoBuffer::GLTextureHandle
|
||||||
|
<< QSize(64, 64)
|
||||||
|
<< QVideoFrame::Format_ARGB32
|
||||||
|
<< QVideoFrame::BottomField
|
||||||
|
<< qint64(63641740)
|
||||||
|
<< qint64(63641954);
|
||||||
|
QTest::newRow("32x256 YUV420P")
|
||||||
|
<< QAbstractVideoBuffer::UserHandle
|
||||||
|
<< QSize(32, 256)
|
||||||
|
<< QVideoFrame::Format_YUV420P
|
||||||
|
<< QVideoFrame::InterlacedFrame
|
||||||
|
<< qint64(12345)
|
||||||
|
<< qint64(12389);
|
||||||
|
QTest::newRow("1052x756 ARGB32")
|
||||||
|
<< QAbstractVideoBuffer::NoHandle
|
||||||
|
<< QSize(1052, 756)
|
||||||
|
<< QVideoFrame::Format_ARGB32
|
||||||
|
<< QVideoFrame::ProgressiveFrame
|
||||||
|
<< qint64(12345)
|
||||||
|
<< qint64(12389);
|
||||||
QTest::newRow("32x256 YUV420P")
|
QTest::newRow("32x256 YUV420P")
|
||||||
<< QAbstractVideoBuffer::UserHandle
|
<< QAbstractVideoBuffer::UserHandle
|
||||||
<< QSize(32, 256)
|
<< QSize(32, 256)
|
||||||
@@ -782,12 +807,98 @@ void tst_QVideoFrame::formatConversion()
|
|||||||
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
|
QFETCH(QVideoFrame::PixelFormat, pixelFormat);
|
||||||
|
|
||||||
QCOMPARE(QVideoFrame::pixelFormatFromImageFormat(imageFormat) == pixelFormat,
|
QCOMPARE(QVideoFrame::pixelFormatFromImageFormat(imageFormat) == pixelFormat,
|
||||||
imageFormat != QImage::Format_Invalid);
|
imageFormat != QImage::Format_Invalid);
|
||||||
|
|
||||||
QCOMPARE(QVideoFrame::imageFormatFromPixelFormat(pixelFormat) == imageFormat,
|
QCOMPARE(QVideoFrame::imageFormatFromPixelFormat(pixelFormat) == imageFormat,
|
||||||
pixelFormat != QVideoFrame::Format_Invalid);
|
pixelFormat != QVideoFrame::Format_Invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TEST_MAPPED(frame, mode) \
|
||||||
|
do { \
|
||||||
|
QVERIFY(frame.bits()); \
|
||||||
|
QVERIFY(frame.isMapped()); \
|
||||||
|
QCOMPARE(frame.mappedBytes(), 16384); \
|
||||||
|
QCOMPARE(frame.bytesPerLine(), 256); \
|
||||||
|
QCOMPARE(frame.mapMode(), mode); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define TEST_UNMAPPED(frame) \
|
||||||
|
do { \
|
||||||
|
QVERIFY(!frame.bits()); \
|
||||||
|
QVERIFY(!frame.isMapped()); \
|
||||||
|
QCOMPARE(frame.mappedBytes(), 0); \
|
||||||
|
QCOMPARE(frame.bytesPerLine(), 0); \
|
||||||
|
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
void tst_QVideoFrame::isMapped()
|
||||||
|
{
|
||||||
|
QVideoFrame frame(16384, QSize(64, 64), 256, QVideoFrame::Format_ARGB32);
|
||||||
|
TEST_UNMAPPED(frame);
|
||||||
|
|
||||||
|
QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly));
|
||||||
|
TEST_MAPPED(frame, QAbstractVideoBuffer::ReadOnly);
|
||||||
|
frame.unmap();
|
||||||
|
TEST_UNMAPPED(frame);
|
||||||
|
|
||||||
|
QVERIFY(frame.map(QAbstractVideoBuffer::WriteOnly));
|
||||||
|
TEST_MAPPED(frame, QAbstractVideoBuffer::WriteOnly);
|
||||||
|
frame.unmap();
|
||||||
|
TEST_UNMAPPED(frame);
|
||||||
|
|
||||||
|
QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite));
|
||||||
|
TEST_MAPPED(frame, QAbstractVideoBuffer::ReadWrite);
|
||||||
|
frame.unmap();
|
||||||
|
TEST_UNMAPPED(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QVideoFrame::isReadable()
|
||||||
|
{
|
||||||
|
QVideoFrame frame(16384, QSize(64, 64), 256, QVideoFrame::Format_ARGB32);
|
||||||
|
|
||||||
|
QVERIFY(!frame.isMapped());
|
||||||
|
QVERIFY(!frame.isReadable());
|
||||||
|
|
||||||
|
QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly));
|
||||||
|
QVERIFY(frame.isMapped());
|
||||||
|
QVERIFY(frame.isReadable());
|
||||||
|
frame.unmap();
|
||||||
|
|
||||||
|
QVERIFY(frame.map(QAbstractVideoBuffer::WriteOnly));
|
||||||
|
QVERIFY(frame.isMapped());
|
||||||
|
QVERIFY(!frame.isReadable());
|
||||||
|
frame.unmap();
|
||||||
|
|
||||||
|
QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite));
|
||||||
|
QVERIFY(frame.isMapped());
|
||||||
|
QVERIFY(frame.isReadable());
|
||||||
|
frame.unmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QVideoFrame::isWritable()
|
||||||
|
{
|
||||||
|
QVideoFrame frame(16384, QSize(64, 64), 256, QVideoFrame::Format_ARGB32);
|
||||||
|
|
||||||
|
QVERIFY(!frame.isMapped());
|
||||||
|
QVERIFY(!frame.isWritable());
|
||||||
|
|
||||||
|
QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly));
|
||||||
|
QVERIFY(frame.isMapped());
|
||||||
|
QVERIFY(!frame.isWritable());
|
||||||
|
frame.unmap();
|
||||||
|
|
||||||
|
QVERIFY(frame.map(QAbstractVideoBuffer::WriteOnly));
|
||||||
|
QVERIFY(frame.isMapped());
|
||||||
|
QVERIFY(frame.isWritable());
|
||||||
|
frame.unmap();
|
||||||
|
|
||||||
|
QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite));
|
||||||
|
QVERIFY(frame.isMapped());
|
||||||
|
QVERIFY(frame.isWritable());
|
||||||
|
frame.unmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QTEST_MAIN(tst_QVideoFrame)
|
QTEST_MAIN(tst_QVideoFrame)
|
||||||
|
|
||||||
#include "tst_qvideoframe.moc"
|
#include "tst_qvideoframe.moc"
|
||||||
|
|||||||
@@ -81,6 +81,12 @@ private slots:
|
|||||||
void compare();
|
void compare();
|
||||||
void copy();
|
void copy();
|
||||||
void assign();
|
void assign();
|
||||||
|
|
||||||
|
void isValid();
|
||||||
|
void yCbCrColorSpaceEnum_data();
|
||||||
|
void yCbCrColorSpaceEnum ();
|
||||||
|
void copyAllParameters ();
|
||||||
|
void assignAllParameters ();
|
||||||
};
|
};
|
||||||
|
|
||||||
tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat()
|
tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat()
|
||||||
@@ -733,6 +739,133 @@ void tst_QVideoSurfaceFormat::assign()
|
|||||||
QCOMPARE(original != copy, true);
|
QCOMPARE(original != copy, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Test case for Enum YCbCr_BT601, YCbCr_xvYCC709 */
|
||||||
|
void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QVideoSurfaceFormat::YCbCrColorSpace>("colorspace");
|
||||||
|
|
||||||
|
QTest::newRow("YCbCr_BT601")
|
||||||
|
<< QVideoSurfaceFormat::YCbCr_BT601;
|
||||||
|
QTest::newRow("YCbCr_xvYCC709")
|
||||||
|
<< QVideoSurfaceFormat::YCbCr_xvYCC709;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test case for Enum YCbCr_BT601, YCbCr_xvYCC709 */
|
||||||
|
void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum()
|
||||||
|
{
|
||||||
|
QFETCH(QVideoSurfaceFormat::YCbCrColorSpace, colorspace);
|
||||||
|
|
||||||
|
{
|
||||||
|
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||||
|
format.setYCbCrColorSpace(colorspace);
|
||||||
|
|
||||||
|
QCOMPARE(format.yCbCrColorSpace(), colorspace);
|
||||||
|
QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")),
|
||||||
|
colorspace);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||||
|
format.setProperty("yCbCrColorSpace", qVariantFromValue(colorspace));
|
||||||
|
|
||||||
|
QCOMPARE(format.yCbCrColorSpace(), colorspace);
|
||||||
|
QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")),
|
||||||
|
colorspace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test case for api isValid */
|
||||||
|
void tst_QVideoSurfaceFormat::isValid()
|
||||||
|
{
|
||||||
|
/* When both pixel format and framesize is not valid */
|
||||||
|
QVideoSurfaceFormat format;
|
||||||
|
QVERIFY(!format.isValid());
|
||||||
|
|
||||||
|
/* When framesize is valid and pixel format is not valid */
|
||||||
|
format.setFrameSize(64,64);
|
||||||
|
QVERIFY(format.frameSize() == QSize(64,64));
|
||||||
|
QVERIFY(!format.pixelFormat());
|
||||||
|
QVERIFY(!format.isValid());
|
||||||
|
|
||||||
|
/* When both the pixel format and framesize is valid. */
|
||||||
|
QVideoSurfaceFormat format1(QSize(32, 32), QVideoFrame::Format_AYUV444);
|
||||||
|
QVERIFY(format1.isValid());
|
||||||
|
|
||||||
|
/* When pixel format is valid and frame size is not valid */
|
||||||
|
format1.setFrameSize(-1,-1);
|
||||||
|
QVERIFY(!format1.frameSize().isValid());
|
||||||
|
QVERIFY(!format1.isValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test case for copy constructor with all the parameters. */
|
||||||
|
void tst_QVideoSurfaceFormat::copyAllParameters()
|
||||||
|
{
|
||||||
|
/* Create the instance and set all the parameters. */
|
||||||
|
QVideoSurfaceFormat original(
|
||||||
|
QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
|
||||||
|
|
||||||
|
original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
|
||||||
|
original.setViewport(QRect(0, 0, 1024, 1024));
|
||||||
|
original.setFrameRate(qreal(15.0));
|
||||||
|
original.setPixelAspectRatio(QSize(320,480));
|
||||||
|
original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709);
|
||||||
|
|
||||||
|
/* Copy the original instance to copy and verify if both the instances
|
||||||
|
have the same parameters. */
|
||||||
|
QVideoSurfaceFormat copy(original);
|
||||||
|
|
||||||
|
QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle);
|
||||||
|
QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32);
|
||||||
|
QCOMPARE(copy.frameSize(), QSize(1024, 768));
|
||||||
|
QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
|
||||||
|
QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024));
|
||||||
|
QCOMPARE(copy.frameRate(), qreal(15.0));
|
||||||
|
QCOMPARE(copy.pixelAspectRatio(), QSize(320,480));
|
||||||
|
QCOMPARE(copy.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709);
|
||||||
|
|
||||||
|
/* Verify if both the instances are eqaul */
|
||||||
|
QCOMPARE(original == copy, true);
|
||||||
|
QCOMPARE(original != copy, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test case for copy constructor with all the parameters. */
|
||||||
|
void tst_QVideoSurfaceFormat::assignAllParameters()
|
||||||
|
{
|
||||||
|
/* Create the instance and set all the parameters. */
|
||||||
|
QVideoSurfaceFormat copy(
|
||||||
|
QSize(64, 64), QVideoFrame::Format_AYUV444, QAbstractVideoBuffer::UserHandle);
|
||||||
|
copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom);
|
||||||
|
copy.setViewport(QRect(0, 0, 640, 320));
|
||||||
|
copy.setFrameRate(qreal(7.5));
|
||||||
|
copy.setPixelAspectRatio(QSize(640,320));
|
||||||
|
copy.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT601);
|
||||||
|
|
||||||
|
/* Create the instance and set all the parameters. */
|
||||||
|
QVideoSurfaceFormat original(
|
||||||
|
QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
|
||||||
|
original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
|
||||||
|
original.setViewport(QRect(0, 0, 1024, 1024));
|
||||||
|
original.setFrameRate(qreal(15.0));
|
||||||
|
original.setPixelAspectRatio(QSize(320,480));
|
||||||
|
original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709);
|
||||||
|
|
||||||
|
/* Assign the original instance to copy and verify if both the instancess
|
||||||
|
have the same parameters. */
|
||||||
|
copy = original;
|
||||||
|
|
||||||
|
QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle);
|
||||||
|
QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32);
|
||||||
|
QCOMPARE(copy.frameSize(), QSize(1024, 768));
|
||||||
|
QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
|
||||||
|
QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024));
|
||||||
|
QCOMPARE(copy.frameRate(), qreal(15.0));
|
||||||
|
QCOMPARE(copy.pixelAspectRatio(), QSize(320,480));
|
||||||
|
QCOMPARE(copy.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709);
|
||||||
|
|
||||||
|
/* Verify if both the instances are eqaul */
|
||||||
|
QCOMPARE(original == copy, true);
|
||||||
|
QCOMPARE(original != copy, false);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QVideoSurfaceFormat)
|
QTEST_MAIN(tst_QVideoSurfaceFormat)
|
||||||
|
|
||||||
#include "tst_qvideosurfaceformat.moc"
|
#include "tst_qvideosurfaceformat.moc"
|
||||||
|
|||||||
Reference in New Issue
Block a user