summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSergio Ahumada <sahumada@blackberry.com>2014-03-11 09:26:50 +0100
committerSergio Ahumada <sahumada@blackberry.com>2014-03-11 09:26:50 +0100
commitcd7882b760ae34034b1b5b53c6e7970eb05f2bc2 (patch)
tree15e248503495182aa2cf80da1fc4054585c97380 /tests
parented43209f42d1b420c0cf69330807df5177a583e8 (diff)
parent4bb51fef0a5da88a75d5ba593557367b990ccab5 (diff)
Merge remote-tracking branch 'origin/stable' into dev
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp77
-rw-r--r--tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp8
-rw-r--r--tests/auto/integration/qsoundeffect/tst_qsoundeffect.cpp76
-rw-r--r--tests/auto/unit/multimedia.pro1
-rw-r--r--tests/auto/unit/qcamera/tst_qcamera.cpp100
-rw-r--r--tests/auto/unit/qcamerainfo/qcamerainfo.pro10
-rw-r--r--tests/auto/unit/qcamerainfo/tst_qcamerainfo.cpp217
-rw-r--r--tests/auto/unit/qmediaobject/tst_qmediaobject.cpp2
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.cpp19
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.cpp41
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.json2
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.cpp118
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.json4
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.pro23
-rw-r--r--tests/auto/unit/qmediaserviceprovider/qmediaserviceprovider.pro1
-rw-r--r--tests/auto/unit/qmediaserviceprovider/tst_qmediaserviceprovider.cpp116
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcamera.pri2
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h85
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcameraservice.h12
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h36
-rw-r--r--tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h99
21 files changed, 1000 insertions, 49 deletions
diff --git a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp
index 602fbf3ee..89096912a 100644
--- a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp
+++ b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp
@@ -58,6 +58,7 @@
#include <qcameracapturedestinationcontrol.h>
#include <qmediaservice.h>
#include <qcamera.h>
+#include <qcamerainfo.h>
#include <qcameraimagecapture.h>
#include <qvideorenderercontrol.h>
#include <private/qmediaserviceprovider_p.h>
@@ -82,7 +83,10 @@ public slots:
private slots:
void testAvailableDevices();
void testDeviceDescription();
+ void testCameraInfo();
void testCtorWithDevice();
+ void testCtorWithCameraInfo();
+ void testCtorWithPosition();
void testCameraStates();
void testCaptureMode();
@@ -126,6 +130,23 @@ void tst_QCameraBackend::testDeviceDescription()
}
}
+void tst_QCameraBackend::testCameraInfo()
+{
+ int deviceCount = QMediaServiceProvider::defaultServiceProvider()->devices(QByteArray(Q_MEDIASERVICE_CAMERA)).count();
+ QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
+ QCOMPARE(cameras.count(), deviceCount);
+ if (cameras.isEmpty()) {
+ QVERIFY(QCameraInfo::defaultCamera().isNull());
+ QSKIP("Camera selection is not supported");
+ }
+
+ foreach (const QCameraInfo &info, cameras) {
+ QVERIFY(!info.deviceName().isEmpty());
+ QVERIFY(!info.description().isEmpty());
+ QVERIFY(info.orientation() % 90 == 0);
+ }
+}
+
void tst_QCameraBackend::testCtorWithDevice()
{
if (QCamera::availableDevices().isEmpty())
@@ -142,6 +163,58 @@ void tst_QCameraBackend::testCtorWithDevice()
delete camera;
}
+void tst_QCameraBackend::testCtorWithCameraInfo()
+{
+ if (QCameraInfo::availableCameras().isEmpty())
+ QSKIP("Camera selection not supported");
+
+ {
+ QCameraInfo info = QCameraInfo::defaultCamera();
+ QCamera camera(info);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(QCameraInfo(camera), info);
+ }
+ {
+ QCameraInfo info = QCameraInfo::availableCameras().first();
+ QCamera camera(info);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(QCameraInfo(camera), info);
+ }
+ {
+ // loading an invalid CameraInfo should fail
+ QCamera *camera = new QCamera(QCameraInfo());
+ QCOMPARE(camera->error(), QCamera::ServiceMissingError);
+ QVERIFY(QCameraInfo(*camera).isNull());
+ delete camera;
+ }
+ {
+ // loading non existing camera should fail
+ QCamera camera(QCameraInfo(QUuid::createUuid().toByteArray()));
+ QCOMPARE(camera.error(), QCamera::ServiceMissingError);
+ QVERIFY(QCameraInfo(camera).isNull());
+ }
+}
+
+void tst_QCameraBackend::testCtorWithPosition()
+{
+ {
+ QCamera camera(QCamera::UnspecifiedPosition);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ }
+ {
+ QCamera camera(QCamera::FrontFace);
+ // even if no camera is available at this position, it should not fail
+ // and load the default camera
+ QCOMPARE(camera.error(), QCamera::NoError);
+ }
+ {
+ QCamera camera(QCamera::BackFace);
+ // even if no camera is available at this position, it should not fail
+ // and load the default camera
+ QCOMPARE(camera.error(), QCamera::NoError);
+ }
+}
+
void tst_QCameraBackend::testCameraStates()
{
QCamera camera;
@@ -283,7 +356,7 @@ void tst_QCameraBackend::testCameraCapture()
QSignalSpy capturedSignal(&imageCapture, SIGNAL(imageCaptured(int,QImage)));
QSignalSpy savedSignal(&imageCapture, SIGNAL(imageSaved(int,QString)));
- QSignalSpy errorSignal(&imageCapture, SIGNAL(error(int, QCameraImageCapture::Error,QString)));
+ QSignalSpy errorSignal(&imageCapture, SIGNAL(error(int,QCameraImageCapture::Error,QString)));
imageCapture.capture();
QTRY_COMPARE(errorSignal.size(), 1);
@@ -354,7 +427,7 @@ void tst_QCameraBackend::testCaptureToBuffer()
QSignalSpy capturedSignal(&imageCapture, SIGNAL(imageCaptured(int,QImage)));
QSignalSpy imageAvailableSignal(&imageCapture, SIGNAL(imageAvailable(int,QVideoFrame)));
QSignalSpy savedSignal(&imageCapture, SIGNAL(imageSaved(int,QString)));
- QSignalSpy errorSignal(&imageCapture, SIGNAL(error(int, QCameraImageCapture::Error,QString)));
+ QSignalSpy errorSignal(&imageCapture, SIGNAL(error(int,QCameraImageCapture::Error,QString)));
camera.start();
QTRY_VERIFY(imageCapture.isReadyForCapture());
diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
index 380e344db..689843e52 100644
--- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
+++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
@@ -736,9 +736,9 @@ void tst_QMediaPlayerBackend::probes()
QAudioProbe *audioProbe = new QAudioProbe;
ProbeDataHandler probeHandler;
- connect(videoProbe, SIGNAL(videoFrameProbed(const QVideoFrame&)), &probeHandler, SLOT(processFrame(QVideoFrame)));
+ connect(videoProbe, SIGNAL(videoFrameProbed(QVideoFrame)), &probeHandler, SLOT(processFrame(QVideoFrame)));
connect(videoProbe, SIGNAL(flush()), &probeHandler, SLOT(flushVideo()));
- connect(audioProbe, SIGNAL(audioBufferProbed(const QAudioBuffer&)), &probeHandler, SLOT(processBuffer(QAudioBuffer)));
+ connect(audioProbe, SIGNAL(audioBufferProbed(QAudioBuffer)), &probeHandler, SLOT(processBuffer(QAudioBuffer)));
connect(audioProbe, SIGNAL(flush()), &probeHandler, SLOT(flushAudio()));
QVERIFY(videoProbe->setSource(player));
@@ -762,8 +762,8 @@ void tst_QMediaPlayerBackend::playlist()
{
QMediaPlayer player;
- QSignalSpy mediaSpy(&player, SIGNAL(mediaChanged(const QMediaContent&)));
- QSignalSpy currentMediaSpy(&player, SIGNAL(currentMediaChanged(const QMediaContent&)));
+ QSignalSpy mediaSpy(&player, SIGNAL(mediaChanged(QMediaContent)));
+ QSignalSpy currentMediaSpy(&player, SIGNAL(currentMediaChanged(QMediaContent)));
QSignalSpy stateSpy(&player, SIGNAL(stateChanged(QMediaPlayer::State)));
QSignalSpy errorSpy(&player, SIGNAL(error(QMediaPlayer::Error)));
diff --git a/tests/auto/integration/qsoundeffect/tst_qsoundeffect.cpp b/tests/auto/integration/qsoundeffect/tst_qsoundeffect.cpp
index d113d595a..c56b08dfd 100644
--- a/tests/auto/integration/qsoundeffect/tst_qsoundeffect.cpp
+++ b/tests/auto/integration/qsoundeffect/tst_qsoundeffect.cpp
@@ -152,16 +152,86 @@ void tst_QSoundEffect::testLooping()
sound->setLoopCount(5);
sound->setVolume(0.1f);
- QCOMPARE(sound->loopCount(),5);
- QCOMPARE(readSignal_Count.count(),1);
+ QCOMPARE(sound->loopCount(), 5);
+ QCOMPARE(readSignal_Count.count(), 1);
+ QCOMPARE(sound->loopsRemaining(), 0);
+ QCOMPARE(readSignal_Remaining.count(), 0);
sound->play();
+ QCOMPARE(sound->loopsRemaining(), 5);
+ QCOMPARE(readSignal_Remaining.count(), 1);
// test.wav is about 200ms, wait until it has finished playing 5 times
QTestEventLoop::instance().enterLoop(3);
QTRY_COMPARE(sound->loopsRemaining(), 0);
- QCOMPARE(readSignal_Remaining.count(),5);
+ QVERIFY(readSignal_Remaining.count() >= 6);
+ QTRY_VERIFY(!sound->isPlaying());
+
+ // QTBUG-36643 (setting the loop count while playing should work)
+ {
+ readSignal_Count.clear();
+ readSignal_Remaining.clear();
+
+ sound->setLoopCount(30);
+ QCOMPARE(sound->loopCount(), 30);
+ QCOMPARE(readSignal_Count.count(), 1);
+ QCOMPARE(sound->loopsRemaining(), 0);
+ QCOMPARE(readSignal_Remaining.count(), 0);
+
+ sound->play();
+ QCOMPARE(sound->loopsRemaining(), 30);
+ QCOMPARE(readSignal_Remaining.count(), 1);
+
+ // wait for the sound to be played several times
+ QTRY_COMPARE(sound->loopsRemaining(), 20);
+ QVERIFY(readSignal_Remaining.count() >= 10);
+ readSignal_Count.clear();
+ readSignal_Remaining.clear();
+
+ // change the loop count while playing
+ sound->setLoopCount(5);
+ QCOMPARE(sound->loopCount(), 5);
+ QCOMPARE(readSignal_Count.count(), 1);
+ QCOMPARE(sound->loopsRemaining(), 5);
+ QCOMPARE(readSignal_Remaining.count(), 1);
+
+ // wait for all the loops to be completed
+ QTRY_COMPARE(sound->loopsRemaining(), 0);
+ QVERIFY(readSignal_Remaining.count() >= 6);
+ QTRY_VERIFY(!sound->isPlaying());
+ }
+
+ {
+ readSignal_Count.clear();
+ readSignal_Remaining.clear();
+
+ sound->setLoopCount(QSoundEffect::Infinite);
+ QCOMPARE(sound->loopCount(), int(QSoundEffect::Infinite));
+ QCOMPARE(readSignal_Count.count(), 1);
+ QCOMPARE(sound->loopsRemaining(), 0);
+ QCOMPARE(readSignal_Remaining.count(), 0);
+
+ sound->play();
+ QCOMPARE(sound->loopsRemaining(), int(QSoundEffect::Infinite));
+ QCOMPARE(readSignal_Remaining.count(), 1);
+
+ QTest::qWait(1500);
+ QVERIFY(sound->isPlaying());
+ readSignal_Count.clear();
+ readSignal_Remaining.clear();
+
+ // Setting the loop count to 0 should play it one last time
+ sound->setLoopCount(0);
+ QCOMPARE(sound->loopCount(), 1);
+ QCOMPARE(readSignal_Count.count(), 1);
+ QCOMPARE(sound->loopsRemaining(), 1);
+ QCOMPARE(readSignal_Remaining.count(), 1);
+
+ QTRY_COMPARE(sound->loopsRemaining(), 0);
+ QVERIFY(readSignal_Remaining.count() >= 2);
+ QTRY_VERIFY(!sound->isPlaying());
+ }
}
void tst_QSoundEffect::testVolume()
diff --git a/tests/auto/unit/multimedia.pro b/tests/auto/unit/multimedia.pro
index f9bf0f35f..5c9a831eb 100644
--- a/tests/auto/unit/multimedia.pro
+++ b/tests/auto/unit/multimedia.pro
@@ -7,6 +7,7 @@ SUBDIRS += \
qaudioformat \
qaudionamespace \
qcamera \
+ qcamerainfo \
qcameraimagecapture \
qmediabindableinterface \
qmediacontainercontrol \
diff --git a/tests/auto/unit/qcamera/tst_qcamera.cpp b/tests/auto/unit/qcamera/tst_qcamera.cpp
index e61c140b9..61dd05b09 100644
--- a/tests/auto/unit/qcamera/tst_qcamera.cpp
+++ b/tests/auto/unit/qcamera/tst_qcamera.cpp
@@ -57,6 +57,7 @@
#include <qcameracapturedestinationcontrol.h>
#include <qmediaservice.h>
#include <qcamera.h>
+#include <qcamerainfo.h>
#include <qcameraimagecapture.h>
#include <qvideorenderercontrol.h>
@@ -101,7 +102,7 @@ private slots:
void testCaptureDestination();
void testCaptureFormat();
- void testConstructorWithDefaultProvider();
+ void testConstructor();
void testCaptureMode();
void testIsCaptureModeSupported();
void testRequestedLocks();
@@ -330,7 +331,7 @@ void tst_QCamera::testSimpleCameraCapture()
QCOMPARE(imageCapture.error(), QCameraImageCapture::NoError);
QVERIFY(imageCapture.errorString().isEmpty());
- QSignalSpy errorSignal(&imageCapture, SIGNAL(error(int, QCameraImageCapture::Error,QString)));
+ QSignalSpy errorSignal(&imageCapture, SIGNAL(error(int,QCameraImageCapture::Error,QString)));
imageCapture.capture(QString::fromLatin1("/dev/null"));
QCOMPARE(errorSignal.size(), 1);
QCOMPARE(imageCapture.error(), QCameraImageCapture::NotSupportedFeatureError);
@@ -348,7 +349,7 @@ void tst_QCamera::testSimpleCameraLock()
QSignalSpy lockedSignal(&camera, SIGNAL(locked()));
QSignalSpy lockFailedSignal(&camera, SIGNAL(lockFailed()));
- QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)));
+ QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)));
camera.searchAndLock();
QCOMPARE(camera.lockStatus(), QCamera::Locked);
@@ -460,7 +461,7 @@ void tst_QCamera::testCameraCapture()
QVERIFY(!imageCapture.isReadyForCapture());
QSignalSpy capturedSignal(&imageCapture, SIGNAL(imageCaptured(int,QImage)));
- QSignalSpy errorSignal(&imageCapture, SIGNAL(error(int, QCameraImageCapture::Error,QString)));
+ QSignalSpy errorSignal(&imageCapture, SIGNAL(error(int,QCameraImageCapture::Error,QString)));
imageCapture.capture(QString::fromLatin1("/dev/null"));
QCOMPARE(capturedSignal.size(), 0);
@@ -941,7 +942,7 @@ void tst_QCamera::testCameraLockCancel()
QSignalSpy lockedSignal(&camera, SIGNAL(locked()));
QSignalSpy lockFailedSignal(&camera, SIGNAL(lockFailed()));
- QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)));
+ QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)));
camera.searchAndLock();
QCOMPARE(camera.lockStatus(), QCamera::Searching);
QCOMPARE(lockedSignal.count(), 0);
@@ -1141,6 +1142,8 @@ void tst_QCamera::testEnumDebug()
qDebug() << QCamera::NoLock;
QTest::ignoreMessage(QtDebugMsg, "QCamera::LockExposure");
qDebug() << QCamera::LockExposure;
+ QTest::ignoreMessage(QtDebugMsg, "QCamera::FrontFace ");
+ qDebug() << QCamera::FrontFace;
}
void tst_QCamera::testCameraControl()
@@ -1149,13 +1152,75 @@ void tst_QCamera::testCameraControl()
QVERIFY(m_cameraControl != NULL);
}
-/* Test case for constructor with default provider */
-void tst_QCamera::testConstructorWithDefaultProvider()
+void tst_QCamera::testConstructor()
{
- QCamera *camera = new QCamera(0);
- QVERIFY(camera != NULL);
- QCOMPARE(camera->state(), QCamera::UnloadedState);
- delete camera;
+ // Service doesn't implement QVideoDeviceSelectorControl
+ provider->service = mockSimpleCameraService;
+
+ {
+ QCamera camera;
+ QCOMPARE(camera.availability(), QMultimedia::Available);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ }
+
+ {
+ // Requesting a camera at a specific position from a service which doesn't implement
+ // the QVideoDeviceSelectorControl should result in loading the default camera
+ QCamera camera(QCamera::FrontFace);
+ QCOMPARE(camera.availability(), QMultimedia::Available);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ }
+
+ // Service implements QVideoDeviceSelectorControl
+ provider->service = mockCameraService;
+
+ {
+ QCamera camera;
+ QCOMPARE(camera.availability(), QMultimedia::Available);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 1); // default is 1
+ }
+
+ {
+ QCamera camera(QCameraInfo::defaultCamera());
+ QCOMPARE(camera.availability(), QMultimedia::Available);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 1);
+ QCOMPARE(QCameraInfo(camera), QCameraInfo::defaultCamera());
+ }
+
+ {
+ QCameraInfo cameraInfo = QCameraInfo::availableCameras().at(0);
+ QCamera camera(cameraInfo);
+ QCOMPARE(camera.availability(), QMultimedia::Available);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 0);
+ QCOMPARE(QCameraInfo(camera), cameraInfo);
+ }
+
+ {
+ // Requesting a camera at a position which is not available should result in
+ // loading the default camera
+ QCamera camera(QCamera::FrontFace);
+ QCOMPARE(camera.availability(), QMultimedia::Available);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 1);
+ }
+
+ {
+ QCamera camera(QCamera::BackFace);
+ QCOMPARE(camera.availability(), QMultimedia::Available);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 0);
+ }
+
+ {
+ // Should load the default camera when UnspecifiedPosition is requested
+ QCamera camera(QCamera::UnspecifiedPosition);
+ QCOMPARE(camera.availability(), QMultimedia::Available);
+ QCOMPARE(camera.error(), QCamera::NoError);
+ QCOMPARE(mockCameraService->mockVideoDeviceSelectorControl->selectedDevice(), 1);
+ }
}
/* captureModeChanged Signal test case. */
@@ -1257,8 +1322,8 @@ void tst_QCamera::testSearchAndLockWithLockTypes()
/* Spy the signals */
QSignalSpy lockedSignal(&camera, SIGNAL(locked()));
QSignalSpy lockFailedSignal(&camera, SIGNAL(lockFailed()));
- QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)));
- QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus, QCamera::LockChangeReason)));
+ QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)));
+ QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
/* search and lock the camera with QCamera::LockExposure and verify if the signal is emitted correctly */
camera.searchAndLock(QCamera::LockExposure);
@@ -1292,8 +1357,8 @@ void tst_QCamera::testUnlockWithType()
/* Spy the signal */
QSignalSpy lockedSignal(&camera, SIGNAL(locked()));
QSignalSpy lockFailedSignal(&camera, SIGNAL(lockFailed()));
- QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)));
- QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus, QCamera::LockChangeReason)));
+ QSignalSpy lockStatusChangedSignal(&camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)));
+ QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
/* lock the camera with QCamera::LockExposure and Verify if the signal is emitted correctly */
camera.searchAndLock(QCamera::LockExposure);
@@ -1373,7 +1438,7 @@ void tst_QCamera::testLockStatusChangedWithTypesSignal()
QCOMPARE(camera.lockStatus(), QCamera::Unlocked);
/* Spy the signal lockStatusChanged(QCamera::LockType,QCamera::LockStatus, QCamera::LockChangeReason) */
- QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus, QCamera::LockChangeReason)));
+ QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
/* Lock the camera with type QCamera::LockExposure */
camera.searchAndLock(QCamera::LockExposure);
@@ -1519,7 +1584,7 @@ void tst_QCamera::testLockChangeReason()
QCamera camera;
- QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus, QCamera::LockChangeReason)));
+ QSignalSpy lockStatusChangedSignalWithType(&camera, SIGNAL(lockStatusChanged(QCamera::LockType,QCamera::LockStatus,QCamera::LockChangeReason)));
/* Set the lockChangeReason */
service.mockLocksControl->setLockChangeReason(QCamera::LockAcquired);
@@ -1530,6 +1595,7 @@ void tst_QCamera::testLockChangeReason()
QVERIFY(LockChangeReason == QCamera::LockAcquired);
}
+
/* All the enums test case for QCameraControl class*/
void tst_QCamera::testEnumsOfQCameraControl()
{
diff --git a/tests/auto/unit/qcamerainfo/qcamerainfo.pro b/tests/auto/unit/qcamerainfo/qcamerainfo.pro
new file mode 100644
index 000000000..70cea2ded
--- /dev/null
+++ b/tests/auto/unit/qcamerainfo/qcamerainfo.pro
@@ -0,0 +1,10 @@
+CONFIG += testcase
+TARGET = tst_qcamerainfo
+
+QT += multimedia-private testlib
+
+include (../qmultimedia_common/mock.pri)
+include (../qmultimedia_common/mockcamera.pri)
+
+SOURCES += tst_qcamerainfo.cpp
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/unit/qcamerainfo/tst_qcamerainfo.cpp b/tests/auto/unit/qcamerainfo/tst_qcamerainfo.cpp
new file mode 100644
index 000000000..4fa6169ab
--- /dev/null
+++ b/tests/auto/unit/qcamerainfo/tst_qcamerainfo.cpp
@@ -0,0 +1,217 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QDebug>
+
+#include <qcamera.h>
+#include <qcamerainfo.h>
+
+#include "mockcameraservice.h"
+#include "mockmediaserviceprovider.h"
+
+QT_USE_NAMESPACE
+
+class tst_QCameraInfo: public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void initTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void constructor();
+ void defaultCamera();
+ void availableCameras();
+ void equality_operators();
+
+private:
+ MockSimpleCameraService *mockSimpleCameraService;
+ MockCameraService *mockCameraService;
+ MockMediaServiceProvider *provider;
+};
+
+void tst_QCameraInfo::initTestCase()
+{
+}
+
+void tst_QCameraInfo::init()
+{
+ provider = new MockMediaServiceProvider;
+ mockSimpleCameraService = new MockSimpleCameraService;
+ mockCameraService = new MockCameraService;
+
+ provider->service = mockCameraService;
+ QMediaServiceProvider::setDefaultServiceProvider(provider);
+}
+
+void tst_QCameraInfo::cleanup()
+{
+ delete provider;
+ delete mockCameraService;
+ delete mockSimpleCameraService;
+}
+
+void tst_QCameraInfo::constructor()
+{
+ // Service doesn't implement QVideoDeviceSelectorControl
+ // QCameraInfo should not be valid in this case
+ provider->service = mockSimpleCameraService;
+
+ {
+ QCamera camera;
+ QCameraInfo info(camera);
+ QVERIFY(info.isNull());
+ QVERIFY(info.deviceName().isEmpty());
+ QVERIFY(info.description().isEmpty());
+ QCOMPARE(info.position(), QCamera::UnspecifiedPosition);
+ QCOMPARE(info.orientation(), 0);
+ }
+
+ // Service implements QVideoDeviceSelectorControl
+ provider->service = mockCameraService;
+
+ {
+ // default camera
+ QCamera camera;
+ QCameraInfo info(camera);
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.deviceName(), QStringLiteral("othercamera"));
+ QCOMPARE(info.description(), QStringLiteral("othercamera desc"));
+ QCOMPARE(info.position(), QCamera::UnspecifiedPosition);
+ QCOMPARE(info.orientation(), 0);
+ }
+
+ QCamera camera("backcamera");
+ QCameraInfo info(camera);
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.deviceName(), QStringLiteral("backcamera"));
+ QCOMPARE(info.description(), QStringLiteral("backcamera desc"));
+ QCOMPARE(info.position(), QCamera::BackFace);
+ QCOMPARE(info.orientation(), 90);
+
+ QCameraInfo info2(info);
+ QVERIFY(!info2.isNull());
+ QCOMPARE(info2.deviceName(), QStringLiteral("backcamera"));
+ QCOMPARE(info2.description(), QStringLiteral("backcamera desc"));
+ QCOMPARE(info2.position(), QCamera::BackFace);
+ QCOMPARE(info2.orientation(), 90);
+}
+
+void tst_QCameraInfo::defaultCamera()
+{
+ provider->service = mockCameraService;
+
+ QCameraInfo info = QCameraInfo::defaultCamera();
+
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.deviceName(), QStringLiteral("othercamera"));
+ QCOMPARE(info.description(), QStringLiteral("othercamera desc"));
+ QCOMPARE(info.position(), QCamera::UnspecifiedPosition);
+ QCOMPARE(info.orientation(), 0);
+
+ QCamera camera(info);
+ QCOMPARE(QCameraInfo(camera), info);
+}
+
+void tst_QCameraInfo::availableCameras()
+{
+ provider->service = mockCameraService;
+
+ QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
+ QCOMPARE(cameras.count(), 2);
+
+ QCameraInfo info = cameras.at(0);
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.deviceName(), QStringLiteral("backcamera"));
+ QCOMPARE(info.description(), QStringLiteral("backcamera desc"));
+ QCOMPARE(info.position(), QCamera::BackFace);
+ QCOMPARE(info.orientation(), 90);
+
+ info = cameras.at(1);
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.deviceName(), QStringLiteral("othercamera"));
+ QCOMPARE(info.description(), QStringLiteral("othercamera desc"));
+ QCOMPARE(info.position(), QCamera::UnspecifiedPosition);
+ QCOMPARE(info.orientation(), 0);
+
+ cameras = QCameraInfo::availableCameras(QCamera::BackFace);
+ QCOMPARE(cameras.count(), 1);
+ info = cameras.at(0);
+ QVERIFY(!info.isNull());
+ QCOMPARE(info.deviceName(), QStringLiteral("backcamera"));
+ QCOMPARE(info.description(), QStringLiteral("backcamera desc"));
+ QCOMPARE(info.position(), QCamera::BackFace);
+ QCOMPARE(info.orientation(), 90);
+
+ cameras = QCameraInfo::availableCameras(QCamera::FrontFace);
+ QCOMPARE(cameras.count(), 0);
+}
+
+void tst_QCameraInfo::equality_operators()
+{
+ provider->service = mockCameraService;
+
+ QCameraInfo defaultCamera = QCameraInfo::defaultCamera();
+ QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
+
+ QVERIFY(defaultCamera == cameras.at(1));
+ QVERIFY(defaultCamera != cameras.at(0));
+ QVERIFY(cameras.at(0) != cameras.at(1));
+
+ {
+ QCamera camera(defaultCamera);
+ QVERIFY(QCameraInfo(camera) == defaultCamera);
+ QVERIFY(QCameraInfo(camera) == cameras.at(1));
+ }
+
+ {
+ QCamera camera(cameras.at(0));
+ QVERIFY(QCameraInfo(camera) == cameras.at(0));
+ }
+}
+
+
+QTEST_MAIN(tst_QCameraInfo)
+
+#include "tst_qcamerainfo.moc"
diff --git a/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp b/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp
index 8d0bf889e..ca7e4935f 100644
--- a/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp
+++ b/tests/auto/unit/qmediaobject/tst_qmediaobject.cpp
@@ -380,7 +380,7 @@ void tst_QMediaObject::metaDataChanged()
QtTestMediaObject object(&service);
QSignalSpy changedSpy(&object, SIGNAL(metaDataChanged()));
- QSignalSpy changedWithValueSpy(&object, SIGNAL(metaDataChanged(QString, QVariant)));
+ QSignalSpy changedWithValueSpy(&object, SIGNAL(metaDataChanged(QString,QVariant)));
service.metaData.setMetaData("key", "Value");
QCOMPARE(changedSpy.count(), 1);
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.cpp b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.cpp
index ba63ac34f..b4469e71c 100644
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.cpp
+++ b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin1/mockserviceplugin1.cpp
@@ -44,12 +44,10 @@
#include "../mockservice.h"
class MockServicePlugin1 : public QMediaServiceProviderPlugin,
- public QMediaServiceSupportedFormatsInterface,
- public QMediaServiceSupportedDevicesInterface
+ public QMediaServiceSupportedFormatsInterface
{
Q_OBJECT
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
- Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mockserviceplugin1.json")
public:
QStringList keys() const
@@ -87,21 +85,6 @@ public:
{
return QStringList("audio/ogg");
}
-
- QList<QByteArray> devices(const QByteArray &service) const
- {
- Q_UNUSED(service);
- QList<QByteArray> res;
- return res;
- }
-
- QString deviceDescription(const QByteArray &service, const QByteArray &device)
- {
- if (devices(service).contains(device))
- return QString(device)+" description";
- else
- return QString();
- }
};
#include "mockserviceplugin1.moc"
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.cpp b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.cpp
index fe7d49210..592afdec3 100644
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.cpp
+++ b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.cpp
@@ -44,17 +44,22 @@
#include "../mockservice.h"
class MockServicePlugin3 : public QMediaServiceProviderPlugin,
- public QMediaServiceSupportedDevicesInterface
+ public QMediaServiceSupportedDevicesInterface,
+ public QMediaServiceDefaultDeviceInterface,
+ public QMediaServiceCameraInfoInterface
{
Q_OBJECT
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
+ Q_INTERFACES(QMediaServiceDefaultDeviceInterface)
+ Q_INTERFACES(QMediaServiceCameraInfoInterface)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mockserviceplugin3.json")
public:
QStringList keys() const
{
return QStringList() <<
QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER) <<
- QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE);
+ QLatin1String(Q_MEDIASERVICE_AUDIOSOURCE) <<
+ QLatin1String(Q_MEDIASERVICE_CAMERA);
}
QMediaService* create(QString const& key)
@@ -70,12 +75,26 @@ public:
delete service;
}
+ QByteArray defaultDevice(const QByteArray &service) const
+ {
+ if (service == Q_MEDIASERVICE_AUDIOSOURCE)
+ return "audiosource1";
+
+ if (service == Q_MEDIASERVICE_CAMERA)
+ return "frontcamera";
+
+ return QByteArray();
+ }
+
QList<QByteArray> devices(const QByteArray &service) const
{
QList<QByteArray> res;
- if (service == QByteArray(Q_MEDIASERVICE_AUDIOSOURCE))
+ if (service == Q_MEDIASERVICE_AUDIOSOURCE)
res << "audiosource1" << "audiosource2";
+ if (service == Q_MEDIASERVICE_CAMERA)
+ res << "frontcamera";
+
return res;
}
@@ -86,6 +105,22 @@ public:
else
return QString();
}
+
+ QCamera::Position cameraPosition(const QByteArray &device) const
+ {
+ if (device == "frontcamera")
+ return QCamera::FrontFace;
+
+ return QCamera::UnspecifiedPosition;
+ }
+
+ int cameraOrientation(const QByteArray &device) const
+ {
+ if (device == "frontcamera")
+ return 270;
+
+ return 0;
+ }
};
#include "mockserviceplugin3.moc"
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.json b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.json
index 591a02e51..ab55b5d1d 100644
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.json
+++ b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin3/mockserviceplugin3.json
@@ -1,4 +1,4 @@
{
"Keys": ["mockserviceplugin3"],
- "Services": ["org.qt-project.qt.mediaplayer", "org.qt-project.qt.audiosource"]
+ "Services": ["org.qt-project.qt.mediaplayer", "org.qt-project.qt.audiosource", "org.qt-project.qt.camera"]
}
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.cpp b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.cpp
new file mode 100644
index 000000000..c255914e7
--- /dev/null
+++ b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.cpp
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qmediaserviceproviderplugin.h>
+#include <qmediaservice.h>
+#include "../mockservice.h"
+
+class MockServicePlugin5 : public QMediaServiceProviderPlugin,
+ public QMediaServiceSupportedDevicesInterface,
+ public QMediaServiceDefaultDeviceInterface,
+ public QMediaServiceCameraInfoInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
+ Q_INTERFACES(QMediaServiceDefaultDeviceInterface)
+ Q_INTERFACES(QMediaServiceCameraInfoInterface)
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "mockserviceplugin5.json")
+public:
+ QStringList keys() const
+ {
+ return QStringList() << QLatin1String(Q_MEDIASERVICE_CAMERA);
+ }
+
+ QMediaService* create(QString const& key)
+ {
+ if (keys().contains(key))
+ return new MockMediaService("MockServicePlugin5");
+ else
+ return 0;
+ }
+
+ void release(QMediaService *service)
+ {
+ delete service;
+ }
+
+ QByteArray defaultDevice(const QByteArray &service) const
+ {
+ if (service == Q_MEDIASERVICE_CAMERA)
+ return "backcamera";
+
+ return QByteArray();
+ }
+
+ QList<QByteArray> devices(const QByteArray &service) const
+ {
+ QList<QByteArray> res;
+ if (service == Q_MEDIASERVICE_CAMERA)
+ res << "backcamera" << "somecamera";
+
+ return res;
+ }
+
+ QString deviceDescription(const QByteArray &service, const QByteArray &device)
+ {
+ if (devices(service).contains(device))
+ return QString(device)+" description";
+ else
+ return QString();
+ }
+
+ QCamera::Position cameraPosition(const QByteArray &device) const
+ {
+ if (device == "backcamera")
+ return QCamera::BackFace;
+
+ return QCamera::UnspecifiedPosition;
+ }
+
+ int cameraOrientation(const QByteArray &device) const
+ {
+ if (device == "backcamera")
+ return 90;
+
+ return 0;
+ }
+};
+
+#include "mockserviceplugin5.moc"
+
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.json b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.json
new file mode 100644
index 000000000..cc6f4816c
--- /dev/null
+++ b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.json
@@ -0,0 +1,4 @@
+{
+ "Keys": ["mockserviceplugin5"],
+ "Services": ["org.qt-project.qt.camera"]
+}
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.pro b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.pro
new file mode 100644
index 000000000..9657e3cc1
--- /dev/null
+++ b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin5/mockserviceplugin5.pro
@@ -0,0 +1,23 @@
+TARGET = mockserviceplugin5
+QT += multimedia-private
+
+PLUGIN_TYPE=mediaservice
+PLUGIN_CLASS_NAME = MockServicePlugin5
+load(qt_plugin)
+
+DESTDIR = ../$${PLUGIN_TYPE}
+win32 {
+ CONFIG(debug, debug|release) {
+ DESTDIR = ../debug/$${PLUGIN_TYPE}
+ } else {
+ DESTDIR = ../release/$${PLUGIN_TYPE}
+ }
+}
+
+HEADERS += ../mockservice.h
+SOURCES += mockserviceplugin5.cpp
+OTHER_FILES += mockserviceplugin5.json
+
+target.path = $$[QT_INSTALL_TESTS]/tst_qmediaserviceprovider/$${PLUGIN_TYPE}
+
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/unit/qmediaserviceprovider/qmediaserviceprovider.pro b/tests/auto/unit/qmediaserviceprovider/qmediaserviceprovider.pro
index dbe878f39..cea19e212 100644
--- a/tests/auto/unit/qmediaserviceprovider/qmediaserviceprovider.pro
+++ b/tests/auto/unit/qmediaserviceprovider/qmediaserviceprovider.pro
@@ -6,6 +6,7 @@ SUBDIRS += \
mockserviceplugin2 \
mockserviceplugin3 \
mockserviceplugin4 \
+ mockserviceplugin5 \
test
# no special install rule for subdir
diff --git a/tests/auto/unit/qmediaserviceprovider/tst_qmediaserviceprovider.cpp b/tests/auto/unit/qmediaserviceprovider/tst_qmediaserviceprovider.cpp
index e39070d5f..3ad787130 100644
--- a/tests/auto/unit/qmediaserviceprovider/tst_qmediaserviceprovider.cpp
+++ b/tests/auto/unit/qmediaserviceprovider/tst_qmediaserviceprovider.cpp
@@ -52,6 +52,8 @@
#include <qmediaservice.h>
#include <qmediaplayer.h>
#include <qaudiorecorder.h>
+#include <qcamera.h>
+#include <qcamerainfo.h>
QT_USE_NAMESPACE
@@ -83,6 +85,9 @@ private slots:
void testHasSupport();
void testSupportedMimeTypes();
void testProviderHints();
+ void testDefaultDevice();
+ void testAvailableDevices();
+ void testCameraInfo();
private:
QObjectList plugins;
@@ -195,6 +200,7 @@ void tst_QMediaServiceProvider::testProviderHints()
QVERIFY(hint.isNull());
QCOMPARE(hint.type(), QMediaServiceProviderHint::Null);
QVERIFY(hint.device().isEmpty());
+ QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
QVERIFY(hint.mimeType().isEmpty());
QVERIFY(hint.codecs().isEmpty());
QCOMPARE(hint.features(), 0);
@@ -206,6 +212,18 @@ void tst_QMediaServiceProvider::testProviderHints()
QVERIFY(!hint.isNull());
QCOMPARE(hint.type(), QMediaServiceProviderHint::Device);
QCOMPARE(hint.device(), deviceName);
+ QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
+ QVERIFY(hint.mimeType().isEmpty());
+ QVERIFY(hint.codecs().isEmpty());
+ QCOMPARE(hint.features(), 0);
+ }
+
+ {
+ QMediaServiceProviderHint hint(QCamera::FrontFace);
+ QVERIFY(!hint.isNull());
+ QCOMPARE(hint.type(), QMediaServiceProviderHint::CameraPosition);
+ QVERIFY(hint.device().isEmpty());
+ QCOMPARE(hint.cameraPosition(), QCamera::FrontFace);
QVERIFY(hint.mimeType().isEmpty());
QVERIFY(hint.codecs().isEmpty());
QCOMPARE(hint.features(), 0);
@@ -216,6 +234,7 @@ void tst_QMediaServiceProvider::testProviderHints()
QVERIFY(!hint.isNull());
QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures);
QVERIFY(hint.device().isEmpty());
+ QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
QVERIFY(hint.mimeType().isEmpty());
QVERIFY(hint.codecs().isEmpty());
QCOMPARE(hint.features(), QMediaServiceProviderHint::LowLatencyPlayback);
@@ -226,6 +245,7 @@ void tst_QMediaServiceProvider::testProviderHints()
QVERIFY(!hint.isNull());
QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures);
QVERIFY(hint.device().isEmpty());
+ QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
QVERIFY(hint.mimeType().isEmpty());
QVERIFY(hint.codecs().isEmpty());
QCOMPARE(hint.features(), QMediaServiceProviderHint::RecordingSupport);
@@ -240,6 +260,7 @@ void tst_QMediaServiceProvider::testProviderHints()
QVERIFY(!hint.isNull());
QCOMPARE(hint.type(), QMediaServiceProviderHint::ContentType);
QVERIFY(hint.device().isEmpty());
+ QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
QCOMPARE(hint.mimeType(), mimeType);
QCOMPARE(hint.codecs(), codecs);
@@ -248,6 +269,7 @@ void tst_QMediaServiceProvider::testProviderHints()
QVERIFY(!hint2.isNull());
QCOMPARE(hint2.type(), QMediaServiceProviderHint::ContentType);
QVERIFY(hint2.device().isEmpty());
+ QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
QCOMPARE(hint2.mimeType(), mimeType);
QCOMPARE(hint2.codecs(), codecs);
@@ -257,6 +279,7 @@ void tst_QMediaServiceProvider::testProviderHints()
QVERIFY(!hint3.isNull());
QCOMPARE(hint3.type(), QMediaServiceProviderHint::ContentType);
QVERIFY(hint3.device().isEmpty());
+ QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition);
QCOMPARE(hint3.mimeType(), mimeType);
QCOMPARE(hint3.codecs(), codecs);
@@ -271,6 +294,99 @@ void tst_QMediaServiceProvider::testProviderHints()
}
}
+void tst_QMediaServiceProvider::testDefaultDevice()
+{
+ QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
+
+ if (provider == 0)
+ QSKIP("No default provider");
+
+ QCOMPARE(provider->defaultDevice(Q_MEDIASERVICE_AUDIOSOURCE), QByteArray("audiosource1"));
+ QCOMPARE(provider->defaultDevice(Q_MEDIASERVICE_CAMERA), QByteArray("frontcamera"));
+}
+
+void tst_QMediaServiceProvider::testAvailableDevices()
+{
+ QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
+
+ if (provider == 0)
+ QSKIP("No default provider");
+
+ QList<QByteArray> devices = provider->devices(Q_MEDIASERVICE_AUDIOSOURCE);
+ QCOMPARE(devices.count(), 2);
+ QCOMPARE(devices.at(0), QByteArray("audiosource1"));
+ QCOMPARE(devices.at(1), QByteArray("audiosource2"));
+
+ devices = provider->devices(Q_MEDIASERVICE_CAMERA);
+ QCOMPARE(devices.count(), 3);
+ QCOMPARE(devices.at(0), QByteArray("frontcamera"));
+ QCOMPARE(devices.at(1), QByteArray("backcamera"));
+ QCOMPARE(devices.at(2), QByteArray("somecamera"));
+}
+
+void tst_QMediaServiceProvider::testCameraInfo()
+{
+ QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider();
+
+ if (provider == 0)
+ QSKIP("No default provider");
+
+ QCOMPARE(provider->cameraPosition("backcamera"), QCamera::BackFace);
+ QCOMPARE(provider->cameraOrientation("backcamera"), 90);
+ QCOMPARE(provider->cameraPosition("frontcamera"), QCamera::FrontFace);
+ QCOMPARE(provider->cameraOrientation("frontcamera"), 270);
+ QCOMPARE(provider->cameraPosition("somecamera"), QCamera::UnspecifiedPosition);
+ QCOMPARE(provider->cameraOrientation("somecamera"), 0);
+
+ {
+ QCamera camera;
+ QVERIFY(camera.service());
+ QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3"));
+ }
+
+ {
+ QCamera camera(QCameraInfo::defaultCamera());
+ QVERIFY(camera.service());
+ QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3"));
+ }
+
+ {
+ QCamera camera(QCameraInfo::availableCameras().at(0));
+ QVERIFY(camera.service());
+ QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3"));
+ }
+
+ {
+ QCamera camera(QCameraInfo::availableCameras().at(1));
+ QVERIFY(camera.service());
+ QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5"));
+ }
+
+ {
+ QCamera camera(QCameraInfo::availableCameras().at(2));
+ QVERIFY(camera.service());
+ QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5"));
+ }
+
+ {
+ QCamera camera(QCamera::FrontFace);
+ QVERIFY(camera.service());
+ QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3"));
+ }
+
+ {
+ QCamera camera(QCamera::BackFace);
+ QVERIFY(camera.service());
+ QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5"));
+ }
+
+ {
+ QCamera camera(QCamera::UnspecifiedPosition);
+ QVERIFY(camera.service());
+ QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3"));
+ }
+}
+
QTEST_MAIN(tst_QMediaServiceProvider)
#include "tst_qmediaserviceprovider.moc"
diff --git a/tests/auto/unit/qmultimedia_common/mockcamera.pri b/tests/auto/unit/qmultimedia_common/mockcamera.pri
index 22a9dc155..c12ac3c62 100644
--- a/tests/auto/unit/qmultimedia_common/mockcamera.pri
+++ b/tests/auto/unit/qmultimedia_common/mockcamera.pri
@@ -17,6 +17,8 @@ HEADERS *= \
../qmultimedia_common/mockcameracapturebuffercontrol.h \
../qmultimedia_common/mockimageencodercontrol.h \
../qmultimedia_common/mockcameracontrol.h \
+ ../qmultimedia_common/mockvideodeviceselectorcontrol.h \
+ ../qmultimedia_common/mockcamerainfocontrol.h
include(mockvideo.pri)
diff --git a/tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h b/tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h
new file mode 100644
index 000000000..65b29d48e
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcamerainfocontrol.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKCAMERAINFOCONTROL_H
+#define MOCKCAMERAINFOCONTROL_H
+
+#include <qcamerainfocontrol.h>
+
+class MockCameraInfoControl : public QCameraInfoControl
+{
+ Q_OBJECT
+public:
+ MockCameraInfoControl(QObject *parent)
+ : QCameraInfoControl(parent)
+ {
+ }
+
+ ~MockCameraInfoControl() { }
+
+ QCamera::Position cameraPosition(const QString &deviceName) const
+ {
+ return position(deviceName.toLatin1());
+ }
+
+ int cameraOrientation(const QString &deviceName) const
+ {
+ return orientation(deviceName.toLatin1());
+ }
+
+ static QCamera::Position position(const QByteArray &camera)
+ {
+ if (camera == "backcamera")
+ return QCamera::BackFace;
+ else
+ return QCamera::UnspecifiedPosition;
+ }
+
+ static int orientation(const QByteArray &camera)
+ {
+ if (camera == "backcamera")
+ return 90;
+ else
+ return 0;
+ }
+};
+
+#endif // MOCKCAMERAINFOCONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockcameraservice.h b/tests/auto/unit/qmultimedia_common/mockcameraservice.h
index 633b28488..f12b0eab0 100644
--- a/tests/auto/unit/qmultimedia_common/mockcameraservice.h
+++ b/tests/auto/unit/qmultimedia_common/mockcameraservice.h
@@ -57,6 +57,8 @@
#include "../qmultimedia_common/mockvideosurface.h"
#include "../qmultimedia_common/mockvideorenderercontrol.h"
#include "../qmultimedia_common/mockvideowindowcontrol.h"
+#include "../qmultimedia_common/mockvideodeviceselectorcontrol.h"
+#include "../qmultimedia_common/mockcamerainfocontrol.h"
class MockSimpleCameraService : public QMediaService
{
@@ -105,6 +107,8 @@ public:
mockImageEncoderControl = new MockImageEncoderControl(this);
rendererControl = new MockVideoRendererControl(this);
windowControl = new MockVideoWindowControl(this);
+ mockVideoDeviceSelectorControl = new MockVideoDeviceSelectorControl(this);
+ mockCameraInfoControl = new MockCameraInfoControl(this);
rendererRef = 0;
windowRef = 0;
}
@@ -148,6 +152,12 @@ public:
if (qstrcmp(iid, QImageEncoderControl_iid) == 0)
return mockImageEncoderControl;
+ if (qstrcmp(iid, QVideoDeviceSelectorControl_iid) == 0)
+ return mockVideoDeviceSelectorControl;
+
+ if (qstrcmp(iid, QCameraInfoControl_iid) == 0)
+ return mockCameraInfoControl;
+
if (qstrcmp(iid, QVideoRendererControl_iid) == 0) {
if (rendererRef == 0) {
rendererRef += 1;
@@ -184,6 +194,8 @@ public:
MockImageEncoderControl *mockImageEncoderControl;
MockVideoRendererControl *rendererControl;
MockVideoWindowControl *windowControl;
+ MockVideoDeviceSelectorControl *mockVideoDeviceSelectorControl;
+ MockCameraInfoControl *mockCameraInfoControl;
int rendererRef;
int windowRef;
};
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h b/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h
index d582ea319..6bf221c50 100644
--- a/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h
+++ b/tests/auto/unit/qmultimedia_common/mockmediaserviceprovider.h
@@ -44,6 +44,8 @@
#include "private/qmediaserviceprovider_p.h"
#include "qmediaservice.h"
+#include "mockvideodeviceselectorcontrol.h"
+#include "mockcamerainfocontrol.h"
// Simple provider that lets you set the service
class MockMediaServiceProvider : public QMediaServiceProvider
@@ -67,6 +69,40 @@ public:
}
}
+ QByteArray defaultDevice(const QByteArray &serviceType) const
+ {
+ if (serviceType == Q_MEDIASERVICE_CAMERA)
+ return MockVideoDeviceSelectorControl::defaultCamera();
+
+ return QByteArray();
+ }
+
+ QList<QByteArray> devices(const QByteArray &serviceType) const
+ {
+ if (serviceType == Q_MEDIASERVICE_CAMERA)
+ return MockVideoDeviceSelectorControl::availableCameras();
+
+ return QList<QByteArray>();
+ }
+
+ QString deviceDescription(const QByteArray &serviceType, const QByteArray &device)
+ {
+ if (serviceType == Q_MEDIASERVICE_CAMERA)
+ return MockVideoDeviceSelectorControl::cameraDescription(device);
+
+ return QString();
+ }
+
+ QCamera::Position cameraPosition(const QByteArray &device) const
+ {
+ return MockCameraInfoControl::position(device);
+ }
+
+ int cameraOrientation(const QByteArray &device) const
+ {
+ return MockCameraInfoControl::orientation(device);
+ }
+
QMediaService *service;
bool deleteServiceOnRelease;
};
diff --git a/tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h b/tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h
new file mode 100644
index 000000000..04aec6f7b
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockvideodeviceselectorcontrol.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKVIDEODEVICESELECTORCONTROL_H
+#define MOCKVIDEODEVICESELECTORCONTROL_H
+
+#include <qvideodeviceselectorcontrol.h>
+
+class MockVideoDeviceSelectorControl : public QVideoDeviceSelectorControl
+{
+ Q_OBJECT
+public:
+ MockVideoDeviceSelectorControl(QObject *parent)
+ : QVideoDeviceSelectorControl(parent)
+ , m_selectedDevice(1)
+ {
+ }
+
+ ~MockVideoDeviceSelectorControl() { }
+
+ int deviceCount() const { return availableCameras().count(); }
+
+ QString deviceName(int index) const { return QString::fromLatin1(availableCameras().at(index)); }
+ QString deviceDescription(int index) const { return cameraDescription(availableCameras().at(index)); }
+
+ int defaultDevice() const { return availableCameras().indexOf(defaultCamera()); }
+ int selectedDevice() const { return m_selectedDevice; }
+ void setSelectedDevice(int index)
+ {
+ m_selectedDevice = index;
+ emit selectedDeviceChanged(m_selectedDevice);
+ emit selectedDeviceChanged(deviceName(m_selectedDevice));
+ }
+
+ static QByteArray defaultCamera()
+ {
+ return "othercamera";
+ }
+
+ static QList<QByteArray> availableCameras()
+ {
+ return QList<QByteArray>() << "backcamera" << "othercamera";
+ }
+
+ static QString cameraDescription(const QByteArray &camera)
+ {
+ if (camera == "backcamera")
+ return QStringLiteral("backcamera desc");
+ else if (camera == "othercamera")
+ return QStringLiteral("othercamera desc");
+ else
+ return QString();
+ }
+
+private:
+ int m_selectedDevice;
+ QStringList m_devices;
+ QStringList m_descriptions;
+};
+
+#endif // MOCKVIDEODEVICESELECTORCONTROL_H