summaryrefslogtreecommitdiffstats
path: root/tests/auto/integration
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2014-01-22 16:18:42 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-28 14:10:00 +0100
commitb28ee24628f77fced393cacc45500be6761e4497 (patch)
tree811173f8a2caf84e0fa386010283ccfd32c6ad0d /tests/auto/integration
parentd964388b38ec4762e315d86aacb779604bcdca1b (diff)
New QCameraInfo class.
The class allows to get the list of available cameras on the system as well as getting some static information about them such as their unique ID, display name, physical position and sensor orientation. This makes QCamera::availableDevices() and QCamera::deviceDescription() obsolete. This patch contains the API, documentation and auto-tests but not the actual implementation by each backend (except for retrieving the default camera device). [ChangeLog][QtMultimedia] Added new QCameraInfo class [ChangeLog][QtMultimedia] QCamera: availableDevices() and deviceDescription() are deprecated, use QCameraInfo instead Change-Id: I64fd65729ab26a789468979ed5444ee90bb82cd0 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Diffstat (limited to 'tests/auto/integration')
-rw-r--r--tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp
index 602fbf3ee..137377c70 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;