summaryrefslogtreecommitdiffstats
path: root/tests/auto/unit/qmultimedia_common
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/unit/qmultimedia_common')
-rw-r--r--tests/auto/unit/qmultimedia_common/mock.pri7
-rw-r--r--tests/auto/unit/qmultimedia_common/mockaudioencodercontrol.h127
-rw-r--r--tests/auto/unit/qmultimedia_common/mockaudioendpointselector.h117
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcamera.pri22
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameracapturebuffercontrol.h83
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameracapturedestinationcontrol.h80
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameracontrol.h145
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h282
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraflashcontrol.h89
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcamerafocuscontrol.h199
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraimagecapturecontrol.h130
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraimageprocessingcontrol.h156
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameralockscontrol.h144
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraservice.h196
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcontainer.pri7
-rw-r--r--tests/auto/unit/qmultimedia_common/mockimageencodercontrol.h103
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h97
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmedianetworkaccesscontrol.h83
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaobject.h57
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaplayercontrol.h118
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h176
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h112
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaplaylistsourcecontrol.h74
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h125
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediarecorderservice.h101
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaservice.h66
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h74
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediastreamscontrol.h78
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmetadatareadercontrol.h98
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmetadatawritercontrol.h107
-rw-r--r--tests/auto/unit/qmultimedia_common/mockplayer.pri12
-rw-r--r--tests/auto/unit/qmultimedia_common/mockplaylist.pri8
-rw-r--r--tests/auto/unit/qmultimedia_common/mockplaylistservice.h77
-rw-r--r--tests/auto/unit/qmultimedia_common/mockradio.pri8
-rw-r--r--tests/auto/unit/qmultimedia_common/mockradiodatacontrol.h157
-rw-r--r--tests/auto/unit/qmultimedia_common/mockradiotunercontrol.h275
-rw-r--r--tests/auto/unit/qmultimedia_common/mockreadonlyplaylistprovider.h69
-rw-r--r--tests/auto/unit/qmultimedia_common/mockrecorder.pri14
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideo.pri14
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideoencodercontrol.h112
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideorenderercontrol.h58
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideosurface.h59
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideowindowcontrol.h74
43 files changed, 4190 insertions, 0 deletions
diff --git a/tests/auto/unit/qmultimedia_common/mock.pri b/tests/auto/unit/qmultimedia_common/mock.pri
new file mode 100644
index 000000000..8b8f3e7fa
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mock.pri
@@ -0,0 +1,7 @@
+INCLUDEPATH += $$PWD \
+ ../../../src/multimedia \
+
+HEADERS *= \
+ ../qmultimedia_common/mockmediaserviceprovider.h \
+ ../qmultimedia_common/mockmediaservice.h \
+ ../qmultimedia_common/mockmediaobject.h
diff --git a/tests/auto/unit/qmultimedia_common/mockaudioencodercontrol.h b/tests/auto/unit/qmultimedia_common/mockaudioencodercontrol.h
new file mode 100644
index 000000000..85d18664a
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockaudioencodercontrol.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockaudioendpointselector.h b/tests/auto/unit/qmultimedia_common/mockaudioendpointselector.h
new file mode 100644
index 000000000..2bc118d89
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockaudioendpointselector.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockcamera.pri b/tests/auto/unit/qmultimedia_common/mockcamera.pri
new file mode 100644
index 000000000..233d5b8a2
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcamera.pri
@@ -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)
+
diff --git a/tests/auto/unit/qmultimedia_common/mockcameracapturebuffercontrol.h b/tests/auto/unit/qmultimedia_common/mockcameracapturebuffercontrol.h
new file mode 100644
index 000000000..d71794635
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcameracapturebuffercontrol.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 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
diff --git a/tests/auto/unit/qmultimedia_common/mockcameracapturedestinationcontrol.h b/tests/auto/unit/qmultimedia_common/mockcameracapturedestinationcontrol.h
new file mode 100644
index 000000000..3f7697d1c
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcameracapturedestinationcontrol.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
diff --git a/tests/auto/unit/qmultimedia_common/mockcameracontrol.h b/tests/auto/unit/qmultimedia_common/mockcameracontrol.h
new file mode 100644
index 000000000..893ecbfd8
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcameracontrol.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h
new file mode 100644
index 000000000..d89762d43
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcameraexposurecontrol.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraflashcontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraflashcontrol.h
new file mode 100644
index 000000000..f7a795055
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcameraflashcontrol.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockcamerafocuscontrol.h b/tests/auto/unit/qmultimedia_common/mockcamerafocuscontrol.h
new file mode 100644
index 000000000..a0fb48199
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcamerafocuscontrol.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraimagecapturecontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraimagecapturecontrol.h
new file mode 100644
index 000000000..5fb3cb19d
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcameraimagecapturecontrol.h
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKCAMERACAPTURECONTROL_H
+#define MOCKCAMERACAPTURECONTROL_H
+
+#include <QDateTime>
+#include <QTimer>
+
+#include "qcameraimagecapturecontrol.h"
+#include "qcameracontrol.h"
+#include "mockcameracontrol.h"
+
+class MockCaptureControl : public QCameraImageCaptureControl
+{
+ Q_OBJECT
+public:
+ MockCaptureControl(MockCameraControl *cameraControl, QObject *parent = 0)
+ : QCameraImageCaptureControl(parent), m_cameraControl(cameraControl), m_captureRequest(0), m_ready(true), m_captureCanceled(false)
+ {
+ }
+
+ ~MockCaptureControl()
+ {
+ }
+
+ QCameraImageCapture::DriveMode driveMode() const { return QCameraImageCapture::SingleImageCapture; }
+ void setDriveMode(QCameraImageCapture::DriveMode) {}
+
+ bool isReadyForCapture() const { return m_ready && m_cameraControl->state() == QCamera::ActiveState; }
+
+ int capture(const QString &fileName)
+ {
+ if (isReadyForCapture()) {
+ m_fileName = fileName;
+ m_captureRequest++;
+ emit readyForCaptureChanged(m_ready = false);
+ QTimer::singleShot(5, this, SLOT(captured()));
+ return m_captureRequest;
+ } else {
+ emit error(-1, QCameraImageCapture::NotReadyError,
+ QLatin1String("Could not capture in stopped state"));
+ }
+
+ return -1;
+ }
+
+ void cancelCapture()
+ {
+ m_captureCanceled = true;
+ }
+
+private Q_SLOTS:
+ void captured()
+ {
+ if (!m_captureCanceled) {
+ emit imageCaptured(m_captureRequest, QImage());
+
+ emit imageMetadataAvailable(m_captureRequest,
+ QtMultimedia::FocalLengthIn35mmFilm,
+ QVariant(50));
+
+ emit imageMetadataAvailable(m_captureRequest,
+ QtMultimedia::DateTimeOriginal,
+ QVariant(QDateTime::currentDateTime()));
+
+ emit imageMetadataAvailable(m_captureRequest,
+ QLatin1String("Answer to the Ultimate Question of Life, the Universe, and Everything"),
+ QVariant(42));
+ }
+
+ if (!m_ready)
+ {
+ emit readyForCaptureChanged(m_ready = true);
+ emit imageExposed(m_captureRequest);
+ }
+
+ if (!m_captureCanceled)
+ emit imageSaved(m_captureRequest, m_fileName);
+
+ m_captureCanceled = false;
+ }
+
+private:
+ MockCameraControl *m_cameraControl;
+ QString m_fileName;
+ int m_captureRequest;
+ bool m_ready;
+ bool m_captureCanceled;
+};
+
+#endif // MOCKCAMERACAPTURECONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraimageprocessingcontrol.h b/tests/auto/unit/qmultimedia_common/mockcameraimageprocessingcontrol.h
new file mode 100644
index 000000000..f02f2b404
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcameraimageprocessingcontrol.h
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKCAMERAIMAGEPROCESSINGCONTROL_H
+#define MOCKCAMERAIMAGEPROCESSINGCONTROL_H
+
+#include "qcameraimageprocessingcontrol.h"
+
+class MockImageProcessingControl : public QCameraImageProcessingControl
+{
+ Q_OBJECT
+public:
+ MockImageProcessingControl(QObject *parent = 0)
+ : QCameraImageProcessingControl(parent)
+ {
+ m_supportedWhiteBalance.insert(QCameraImageProcessing::WhiteBalanceAuto);
+ }
+
+ QCameraImageProcessing::WhiteBalanceMode whiteBalanceMode() const
+ {
+ return m_whiteBalanceMode;
+ }
+ void setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode)
+ {
+ m_whiteBalanceMode = mode;
+ }
+
+ bool isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const
+ {
+ return m_supportedWhiteBalance.contains(mode);
+ }
+
+ void setSupportedWhiteBalanceModes(QSet<QCameraImageProcessing::WhiteBalanceMode> modes)
+ {
+ m_supportedWhiteBalance = modes;
+ }
+
+ bool isProcessingParameterSupported(ProcessingParameter parameter) const
+ {
+ //return parameter == Contrast || parameter == Sharpening || parameter == ColorTemperature;
+ switch (parameter)
+ {
+ case Contrast:
+ case Brightness:
+ case Sharpening:
+ case Saturation:
+ case Denoising:
+ case ColorTemperature:
+ case ExtendedParameter:
+ return true;
+ default :
+ return false;
+ }
+ }
+ QVariant processingParameter(ProcessingParameter parameter) const
+ {
+ switch (parameter) {
+ case Contrast:
+ return m_contrast;
+ case Saturation:
+ return m_saturation;
+ case Brightness:
+ return m_brightness;
+ case Sharpening:
+ return m_sharpeningLevel;
+ case Denoising:
+ return m_denoising;
+ case ColorTemperature:
+ return m_manualWhiteBalance;
+ case ExtendedParameter:
+ return m_extendedParameter;
+ default:
+ return QVariant();
+ }
+ }
+ void setProcessingParameter(ProcessingParameter parameter, QVariant value)
+ {
+ switch (parameter) {
+ case Contrast:
+ m_contrast = value;
+ break;
+ case Saturation:
+ m_saturation = value;
+ break;
+ case Brightness:
+ m_brightness = value;
+ break;
+ case Sharpening:
+ m_sharpeningLevel = value;
+ break;
+ case Denoising:
+ m_denoising = value;
+ break;
+ case ColorTemperature:
+ m_manualWhiteBalance = value;
+ break;
+ case ExtendedParameter:
+ m_extendedParameter = value;
+ break;
+ default:
+ break;
+ }
+ }
+
+
+private:
+ QCameraImageProcessing::WhiteBalanceMode m_whiteBalanceMode;
+ QSet<QCameraImageProcessing::WhiteBalanceMode> m_supportedWhiteBalance;
+ QVariant m_manualWhiteBalance;
+ QVariant m_contrast;
+ QVariant m_sharpeningLevel;
+ QVariant m_saturation;
+ QVariant m_brightness;
+ QVariant m_denoising;
+ QVariant m_extendedParameter;
+};
+
+#endif // MOCKCAMERAIMAGEPROCESSINGCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameralockscontrol.h b/tests/auto/unit/qmultimedia_common/mockcameralockscontrol.h
new file mode 100644
index 000000000..87c40947d
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcameralockscontrol.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraservice.h b/tests/auto/unit/qmultimedia_common/mockcameraservice.h
new file mode 100644
index 000000000..ea0620a13
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcameraservice.h
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKCAMERASERVICE_H
+#define MOCKCAMERASERVICE_H
+
+#include "qmediaservice.h"
+#include "../qmultimedia_common/mockcameraflashcontrol.h"
+#include "../qmultimedia_common/mockcameralockscontrol.h"
+#include "../qmultimedia_common/mockcamerafocuscontrol.h"
+#include "../qmultimedia_common/mockcameraimageprocessingcontrol.h"
+#include "../qmultimedia_common/mockcameraimagecapturecontrol.h"
+#include "../qmultimedia_common/mockcameraexposurecontrol.h"
+#include "../qmultimedia_common/mockcameracapturedestinationcontrol.h"
+#include "../qmultimedia_common/mockcameracapturebuffercontrol.h"
+#include "../qmultimedia_common/mockimageencodercontrol.h"
+#include "../qmultimedia_common/mockcameracontrol.h"
+#include "../qmultimedia_common/mockvideosurface.h"
+#include "../qmultimedia_common/mockvideorenderercontrol.h"
+
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+#include "../qmultimedia_common/mockvideowindowcontrol.h"
+#endif
+
+class MockSimpleCameraService : public QMediaService
+{
+ Q_OBJECT
+
+public:
+ MockSimpleCameraService(): QMediaService(0)
+ {
+ mockControl = new MockCameraControl(this);
+ }
+
+ ~MockSimpleCameraService()
+ {
+ }
+
+ QMediaControl* requestControl(const char *iid)
+ {
+ if (qstrcmp(iid, QCameraControl_iid) == 0)
+ return mockControl;
+ return 0;
+ }
+
+ void releaseControl(QMediaControl*) {}
+
+ MockCameraControl *mockControl;
+};
+
+
+class MockCameraService : public QMediaService
+{
+ Q_OBJECT
+
+public:
+ MockCameraService(): QMediaService(0)
+ {
+ mockControl = new MockCameraControl(this);
+ mockLocksControl = new MockCameraLocksControl(this);
+ mockExposureControl = new MockCameraExposureControl(this);
+ mockFlashControl = new MockCameraFlashControl(this);
+ mockFocusControl = new MockCameraFocusControl(this);
+ mockCaptureControl = new MockCaptureControl(mockControl, this);
+ mockCaptureBufferControl = new MockCaptureBufferFormatControl(this);
+ mockCaptureDestinationControl = new MockCaptureDestinationControl(this);
+ mockImageProcessingControl = new MockImageProcessingControl(this);
+ mockImageEncoderControl = new MockImageEncoderControl(this);
+ rendererControl = new MockVideoRendererControl(this);
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+ windowControl = new MockVideoWindowControl(this);
+#endif
+ rendererRef = 0;
+ windowRef = 0;
+ }
+
+ ~MockCameraService()
+ {
+ }
+
+ QMediaControl* requestControl(const char *iid)
+ {
+ if (qstrcmp(iid, QCameraControl_iid) == 0)
+ return mockControl;
+
+ if (qstrcmp(iid, QCameraLocksControl_iid) == 0)
+ return mockLocksControl;
+
+ if (qstrcmp(iid, QCameraExposureControl_iid) == 0)
+ return mockExposureControl;
+
+ if (qstrcmp(iid, QCameraFlashControl_iid) == 0)
+ return mockFlashControl;
+
+ if (qstrcmp(iid, QCameraFocusControl_iid) == 0)
+ return mockFocusControl;
+
+ if (qstrcmp(iid, QCameraImageCaptureControl_iid) == 0)
+ return mockCaptureControl;
+
+ if (qstrcmp(iid, QCameraCaptureBufferFormatControl_iid) == 0)
+ return mockCaptureBufferControl;
+
+ if (qstrcmp(iid, QCameraCaptureDestinationControl_iid) == 0)
+ return mockCaptureDestinationControl;
+
+ if (qstrcmp(iid, QCameraImageProcessingControl_iid) == 0)
+ return mockImageProcessingControl;
+
+ if (qstrcmp(iid, QImageEncoderControl_iid) == 0)
+ return mockImageEncoderControl;
+
+ if (qstrcmp(iid, QVideoRendererControl_iid) == 0) {
+ if (rendererRef == 0) {
+ rendererRef += 1;
+ return rendererControl;
+ }
+ }
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+ if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
+ if (windowRef == 0) {
+ windowRef += 1;
+ return windowControl;
+ }
+ }
+#endif
+ return 0;
+ }
+
+ void releaseControl(QMediaControl *control)
+ {
+ if (control == rendererControl)
+ rendererRef -= 1;
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+ if (control == windowControl)
+ windowRef -= 1;
+#endif
+ }
+
+ MockCameraControl *mockControl;
+ MockCameraLocksControl *mockLocksControl;
+ MockCaptureControl *mockCaptureControl;
+ MockCaptureBufferFormatControl *mockCaptureBufferControl;
+ MockCaptureDestinationControl *mockCaptureDestinationControl;
+ MockCameraExposureControl *mockExposureControl;
+ MockCameraFlashControl *mockFlashControl;
+ MockCameraFocusControl *mockFocusControl;
+ MockImageProcessingControl *mockImageProcessingControl;
+ MockImageEncoderControl *mockImageEncoderControl;
+ MockVideoRendererControl *rendererControl;
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+ MockVideoWindowControl *windowControl;
+#endif
+ int rendererRef;
+ int windowRef;
+};
+
+#endif // MOCKCAMERASERVICE_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcontainer.pri b/tests/auto/unit/qmultimedia_common/mockcontainer.pri
new file mode 100644
index 000000000..e4a345adb
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcontainer.pri
@@ -0,0 +1,7 @@
+INCLUDEPATH *= $$PWD \
+ ../../../src/multimedia \
+
+HEADERS *= \
+ ../qmultimedia_common/mockmediacontainercontrol.h \
+ ../qmultimedia_common/mockmetadatawritercontrol.h \
+ ../qmultimedia_common/mockmetadatareadercontrol.h
diff --git a/tests/auto/unit/qmultimedia_common/mockimageencodercontrol.h b/tests/auto/unit/qmultimedia_common/mockimageencodercontrol.h
new file mode 100644
index 000000000..c63ecd617
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockimageencodercontrol.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKIMAGEENCODERCONTROL_H
+#define MOCKIMAGEENCODERCONTROL_H
+
+#include "qimageencodercontrol.h"
+
+class MockImageEncoderControl : public QImageEncoderControl
+{
+public:
+ MockImageEncoderControl(QObject *parent = 0)
+ : QImageEncoderControl(parent)
+ {
+ m_settings = QImageEncoderSettings();
+ }
+
+ QList<QSize> supportedResolutions(const QImageEncoderSettings & settings = QImageEncoderSettings(),
+ bool *continuous = 0) const
+ {
+ if (continuous)
+ *continuous = true;
+
+ QList<QSize> resolutions;
+ if (settings.resolution().isValid()) {
+ if (settings.resolution() == QSize(160,160) ||
+ settings.resolution() == QSize(320,240))
+ resolutions << settings.resolution();
+
+ if (settings.quality() == QtMultimedia::HighQuality && settings.resolution() == QSize(640,480))
+ resolutions << settings.resolution();
+ } else {
+ resolutions << QSize(160, 120);
+ resolutions << QSize(320, 240);
+ if (settings.quality() == QtMultimedia::HighQuality)
+ resolutions << QSize(640, 480);
+ }
+
+ return resolutions;
+ }
+
+ QStringList supportedImageCodecs() const
+ {
+ QStringList codecs;
+ codecs << "PNG" << "JPEG";
+ return codecs;
+ }
+
+ QString imageCodecDescription(const QString &codecName) const {
+ if (codecName == "PNG")
+ return QString("Portable Network Graphic");
+ if (codecName == "JPEG")
+ return QString("Joint Photographic Expert Group");
+ return QString();
+ }
+
+ QImageEncoderSettings imageSettings() const { return m_settings; }
+ void setImageSettings(const QImageEncoderSettings &settings) { m_settings = settings; }
+
+private:
+ QImageEncoderSettings m_settings;
+};
+
+
+#endif // MOCKIMAGEENCODERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h b/tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h
new file mode 100644
index 000000000..2a8832de2
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKMEDIACONTAINERCONTROL_H
+#define MOCKMEDIACONTAINERCONTROL_H
+
+#include <QObject>
+#include "qmediacontainercontrol.h"
+#include <QMap>
+#include <QString>
+#include <QStringList>
+
+QT_USE_NAMESPACE
+class MockMediaContainerControl : public QMediaContainerControl
+{
+ Q_OBJECT
+public:
+ MockMediaContainerControl(QObject *parent):
+ QMediaContainerControl(parent)
+ {
+ m_supportedContainers.append("wav");
+ m_supportedContainers.append("mp3");
+ m_supportedContainers.append("mov");
+
+ m_descriptions.insert("wav", "WAV format");
+ m_descriptions.insert("mp3", "MP3 format");
+ m_descriptions.insert("mov", "MOV format");
+ }
+
+ virtual ~MockMediaContainerControl() {};
+
+ QStringList supportedContainers() const
+ {
+ return m_supportedContainers;
+ }
+
+ QString containerMimeType() const
+ {
+ return m_format;
+ }
+
+ void setContainerMimeType(const QString &formatMimeType)
+ {
+ if (m_supportedContainers.contains(formatMimeType))
+ m_format = formatMimeType;
+ }
+
+ QString containerDescription(const QString &formatMimeType) const
+ {
+ return m_descriptions.value(formatMimeType);
+ }
+
+private:
+ QStringList m_supportedContainers;
+ QMap<QString, QString> m_descriptions;
+ QString m_format;
+};
+
+#endif // MOCKMEDIACONTAINERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmedianetworkaccesscontrol.h b/tests/auto/unit/qmultimedia_common/mockmedianetworkaccesscontrol.h
new file mode 100644
index 000000000..472a30fc7
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmedianetworkaccesscontrol.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
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaobject.h b/tests/auto/unit/qmultimedia_common/mockmediaobject.h
new file mode 100644
index 000000000..fcc5c3731
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmediaobject.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaplayercontrol.h b/tests/auto/unit/qmultimedia_common/mockmediaplayercontrol.h
new file mode 100644
index 000000000..d88409ca5
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmediaplayercontrol.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h b/tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h
new file mode 100644
index 000000000..fb0f1b28d
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** 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"
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+#include "mockvideowindowcontrol.h"
+#endif
+
+class MockMediaPlayerService : public QMediaService
+{
+ Q_OBJECT
+
+public:
+ MockMediaPlayerService():QMediaService(0)
+ {
+ mockControl = new MockMediaPlayerControl;
+ mockStreamsControl = new MockStreamsControl;
+ mockNetworkControl = new MockNetworkAccessControl;
+ rendererControl = new MockVideoRendererControl;
+ rendererRef = 0;
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+ windowControl = new MockVideoWindowControl;
+ windowRef = 0;
+#endif
+ }
+
+ ~MockMediaPlayerService()
+ {
+ delete mockControl;
+ delete mockStreamsControl;
+ delete mockNetworkControl;
+ delete rendererControl;
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+ delete windowControl;
+#endif
+ }
+
+ 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;
+ }
+ }
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+ if (qstrcmp(iid, QVideoWindowControl_iid) == 0) {
+ if (windowRef == 0) {
+ windowRef += 1;
+ return windowControl;
+ }
+ }
+#endif
+
+ if (qstrcmp(iid, QMediaNetworkAccessControl_iid) == 0)
+ return mockNetworkControl;
+ return 0;
+ }
+
+ void releaseControl(QMediaControl *control)
+ {
+ if (control == rendererControl)
+ rendererRef -= 1;
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+ if (control == windowControl)
+ windowRef -= 1;
+#endif
+ }
+
+ 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;
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+ MockVideoWindowControl *windowControl;
+ int windowRef;
+#endif
+ int rendererRef;
+};
+
+
+
+#endif // MOCKPLAYERSERVICE_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h b/tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h
new file mode 100644
index 000000000..186db69f1
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmediaplaylistcontrol.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaplaylistsourcecontrol.h b/tests/auto/unit/qmultimedia_common/mockmediaplaylistsourcecontrol.h
new file mode 100644
index 000000000..c43ef9b5d
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmediaplaylistsourcecontrol.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
diff --git a/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h b/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h
new file mode 100644
index 000000000..77c1378a8
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockmediarecorderservice.h b/tests/auto/unit/qmultimedia_common/mockmediarecorderservice.h
new file mode 100644
index 000000000..fa8c29a5a
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmediarecorderservice.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaservice.h b/tests/auto/unit/qmultimedia_common/mockmediaservice.h
new file mode 100644
index 000000000..3ceb1ad74
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmediaservice.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h b/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h
new file mode 100644
index 000000000..4573d7f96
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.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 MOCKMEDIASERVICEPROVIDER_H
+#define MOCKMEDIASERVICEPROVIDER_H
+
+#include "qmediaserviceprovider.h"
+#include "qmediaservice.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
diff --git a/tests/auto/unit/qmultimedia_common/mockmediastreamscontrol.h b/tests/auto/unit/qmultimedia_common/mockmediastreamscontrol.h
new file mode 100644
index 000000000..d1d967df6
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmediastreamscontrol.h
@@ -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, QtMultimedia::MetaData key) {
+ return _streams.at(index).metaData.value(key); }
+ void setMetaData(int index, QtMultimedia::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<QtMultimedia::MetaData, QVariant> metaData;
+ bool active;
+ };
+
+ QVector<Stream> _streams;
+};
+
+#endif // MOCKMEDIASTREAMSCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmetadatareadercontrol.h b/tests/auto/unit/qmultimedia_common/mockmetadatareadercontrol.h
new file mode 100644
index 000000000..f0847622f
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmetadatareadercontrol.h
@@ -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<QtMultimedia::MetaData> availableMetaData() const
+ {
+ return m_data.keys();
+ }
+
+ QVariant metaData(QtMultimedia::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<QtMultimedia::MetaData, QVariant> m_data;
+ QMap<QString, QVariant> m_extendedData;
+};
+
+#endif // MOCKMETADATAREADERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmetadatawritercontrol.h b/tests/auto/unit/qmultimedia_common/mockmetadatawritercontrol.h
new file mode 100644
index 000000000..e9f7c7573
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockmetadatawritercontrol.h
@@ -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<QtMultimedia::MetaData> availableMetaData() const { return m_data.keys(); }
+
+ bool isWritable() const { return m_writable; }
+ void setWritable(bool writable) { emit writableChanged(m_writable = writable); }
+
+ QVariant metaData(QtMultimedia::MetaData key) const { return m_data.value(key); }//Getting the metadata from Multimediakit
+ void setMetaData(QtMultimedia::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<QtMultimedia::MetaData, QVariant> m_data;
+ QMap<QString, QVariant> m_extendedData;
+};
+
+#endif // MOCKMETADATAWRITERCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockplayer.pri b/tests/auto/unit/qmultimedia_common/mockplayer.pri
new file mode 100644
index 000000000..a5040ac80
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockplayer.pri
@@ -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)
diff --git a/tests/auto/unit/qmultimedia_common/mockplaylist.pri b/tests/auto/unit/qmultimedia_common/mockplaylist.pri
new file mode 100644
index 000000000..c27c839c5
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockplaylist.pri
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockplaylistservice.h b/tests/auto/unit/qmultimedia_common/mockplaylistservice.h
new file mode 100644
index 000000000..3e1210c28
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockplaylistservice.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockradio.pri b/tests/auto/unit/qmultimedia_common/mockradio.pri
new file mode 100644
index 000000000..0f7f84a2f
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockradio.pri
@@ -0,0 +1,8 @@
+
+# Radio related mock backend files
+
+INCLUDEPATH += .
+
+HEADERS += \
+ ../qmultimedia_common/mockradiotunercontrol.h \
+ ../qmultimedia_common/mockradiodatacontrol.h
diff --git a/tests/auto/unit/qmultimedia_common/mockradiodatacontrol.h b/tests/auto/unit/qmultimedia_common/mockradiodatacontrol.h
new file mode 100644
index 000000000..ca6eb4020
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockradiodatacontrol.h
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** 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 MOCKRADIODATACONTROL_H
+#define MOCKRADIODATACONTROL_H
+
+#include "qradiodatacontrol.h"
+
+class MockRadioDataControl : public QRadioDataControl
+{
+ Q_OBJECT
+
+public:
+ MockRadioDataControl(QObject *parent):
+ QRadioDataControl(parent), m_err(QRadioData::NoError),
+ m_errstr("")
+ {
+ }
+
+ using QRadioDataControl::error;
+
+ bool isAvailable() const
+ {
+ return true;
+ }
+ QtMultimedia::AvailabilityError availabilityError() const
+ {
+ return QtMultimedia::NoError;
+ }
+
+ QRadioData::Error error() const
+ {
+ return m_err;
+ }
+
+ QString errorString() const
+ {
+ return m_errstr;
+ }
+
+ QString stationId() const
+ {
+ return m_stationId;
+ }
+
+ QRadioData::ProgramType programType() const
+ {
+ return m_programType;
+ }
+
+ QString programTypeName() const
+ {
+ return m_programTypeName;
+ }
+
+ QString stationName() const
+ {
+ return m_stationName;
+ }
+
+ QString radioText() const
+ {
+ return m_radioText;
+ }
+
+ void setAlternativeFrequenciesEnabled(bool enabled)
+ {
+ m_alternativeFrequenciesEnabled = enabled;
+ emit alternativeFrequenciesEnabledChanged(m_alternativeFrequenciesEnabled);
+ }
+
+ bool isAlternativeFrequenciesEnabled() const
+ {
+ return m_alternativeFrequenciesEnabled;
+ }
+
+ void forceRT( QString text )
+ {
+ m_radioText = text;
+ emit radioTextChanged(m_radioText);
+ }
+
+ void forceProgramType( int pty )
+ {
+ m_programType = static_cast<QRadioData::ProgramType>(pty);
+ emit programTypeChanged(m_programType);
+ }
+
+ void forcePTYN( QString ptyn )
+ {
+ m_programTypeName = ptyn;
+ emit programTypeNameChanged(m_programTypeName);
+ }
+
+ void forcePI( QString pi )
+ {
+ m_stationId = pi;
+ emit stationIdChanged(m_stationId);
+ }
+
+ void forcePS( QString ps )
+ {
+ m_stationName = ps;
+ emit stationNameChanged(m_stationName);
+ }
+
+public:
+ QString m_radioText;
+ QRadioData::ProgramType m_programType;
+ QString m_programTypeName;
+ QString m_stationId;
+ QString m_stationName;
+ bool m_alternativeFrequenciesEnabled;
+
+ QRadioData::Error m_err;
+ QString m_errstr;
+};
+
+#endif // MOCKRADIODATACONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockradiotunercontrol.h b/tests/auto/unit/qmultimedia_common/mockradiotunercontrol.h
new file mode 100644
index 000000000..664825356
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockradiotunercontrol.h
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** 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;
+ }
+ QtMultimedia::AvailabilityError availabilityError() const
+ {
+ return QtMultimedia::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 findNewStation( int frequency, QString stationId )
+ {
+ setFrequency(frequency);
+ emit stationFound( frequency, stationId );
+ }
+
+ void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast)
+ {
+ QString programmeIdentifiers[3] = { "", "", "" };
+
+ if ( searchMode == QRadioTuner::SearchGetStationId ) {
+ programmeIdentifiers[0] = QString("MockProgramPI1");
+ programmeIdentifiers[1] = QString("MockProgramPI2");
+ programmeIdentifiers[2] = QString("MockProgramPI3");
+ }
+ m_searching = true;
+ emit searchingChanged(m_searching);
+
+ findNewStation(88300000, programmeIdentifiers[0]);
+ findNewStation(95100000, programmeIdentifiers[1]);
+ findNewStation(103100000, programmeIdentifiers[2]);
+
+ 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
diff --git a/tests/auto/unit/qmultimedia_common/mockreadonlyplaylistprovider.h b/tests/auto/unit/qmultimedia_common/mockreadonlyplaylistprovider.h
new file mode 100644
index 000000000..12e48e03a
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockreadonlyplaylistprovider.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockrecorder.pri b/tests/auto/unit/qmultimedia_common/mockrecorder.pri
new file mode 100644
index 000000000..6f8438d8f
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockrecorder.pri
@@ -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)
diff --git a/tests/auto/unit/qmultimedia_common/mockvideo.pri b/tests/auto/unit/qmultimedia_common/mockvideo.pri
new file mode 100644
index 000000000..ea991661f
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockvideo.pri
@@ -0,0 +1,14 @@
+# video related mock backend files
+INCLUDEPATH += $$PWD \
+ ../../../src/multimedia \
+ ../../../src/multimedia/video
+
+contains(QT,multimediawidgets)|contains(QT,multimediawidgets-private) {
+ HEADERS *= ../qmultimedia_common/mockvideowindowcontrol.h
+ DEFINES *= QT_MULTIMEDIA_MOCK_WIDGETS
+}
+
+HEADERS *= \
+ ../qmultimedia_common/mockvideosurface.h \
+ ../qmultimedia_common/mockvideorenderercontrol.h
+
diff --git a/tests/auto/unit/qmultimedia_common/mockvideoencodercontrol.h b/tests/auto/unit/qmultimedia_common/mockvideoencodercontrol.h
new file mode 100644
index 000000000..f628c6730
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockvideoencodercontrol.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockvideorenderercontrol.h b/tests/auto/unit/qmultimedia_common/mockvideorenderercontrol.h
new file mode 100644
index 000000000..c98dd761a
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockvideorenderercontrol.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockvideosurface.h b/tests/auto/unit/qmultimedia_common/mockvideosurface.h
new file mode 100644
index 000000000..bbfe35448
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockvideosurface.h
@@ -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
diff --git a/tests/auto/unit/qmultimedia_common/mockvideowindowcontrol.h b/tests/auto/unit/qmultimedia_common/mockvideowindowcontrol.h
new file mode 100644
index 000000000..83255e24c
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockvideowindowcontrol.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 MOCKVIDEOWINDOWCONTROL_H
+#define MOCKVIDEOWINDOWCONTROL_H
+
+#if defined(QT_MULTIMEDIA_MOCK_WIDGETS)
+
+#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 // QT_MULTIMEDIA_MOCK_WIDGETS
+#endif // MOCKVIDEOWINDOWCONTROL_H