diff options
author | Piotr Srebrny <piotr.srebrny@qt.io> | 2022-08-16 16:05:29 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-08-16 21:07:13 +0000 |
commit | 4a553355ddac0ccdb08648e026aae0f0ad617411 (patch) | |
tree | 20d96c9fdebb39247f0757b91a912c45821e1219 /tests | |
parent | f0278957b54d62136fea9f05de6e8841429559f4 (diff) |
Provide mock cameras from QMockIntegration
During refactoring of QPlatformMediaDevices, the list of system cameras
has been moved to QPlatformIntegration. However, this has not been done
for the mock, which this patch completes.
Change-Id: Ibe51a2c4bbb2ef3d31f10f9eff231238acb8bdad
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit 6e238e9130f7f3665aab459c194994d1f20513d1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/unit/mockbackend/qmockintegration.cpp | 53 | ||||
-rw-r--r-- | tests/auto/unit/mockbackend/qmockmediadevices.cpp | 40 | ||||
-rw-r--r-- | tests/auto/unit/mockbackend/qmockmediadevices_p.h | 2 |
3 files changed, 53 insertions, 42 deletions
diff --git a/tests/auto/unit/mockbackend/qmockintegration.cpp b/tests/auto/unit/mockbackend/qmockintegration.cpp index 3282614de..dd64bd5ae 100644 --- a/tests/auto/unit/mockbackend/qmockintegration.cpp +++ b/tests/auto/unit/mockbackend/qmockintegration.cpp @@ -9,12 +9,65 @@ #include "qmockvideosink.h" #include "qmockimagecapture.h" #include "qmockaudiooutput.h" +#include <private/qcameradevice_p.h> +#include <private/qplatformvideodevices_p.h> QT_BEGIN_NAMESPACE +class QMockVideoDevices : public QPlatformVideoDevices +{ +public: + QMockVideoDevices(QPlatformMediaIntegration *pmi) + : QPlatformVideoDevices(pmi) + { + QCameraDevicePrivate *info = new QCameraDevicePrivate; + info->description = QString::fromUtf8("defaultCamera"); + info->id = "default"; + info->isDefault = true; + auto *f = new QCameraFormatPrivate{ + QSharedData(), + QVideoFrameFormat::Format_ARGB8888, + QSize(640, 480), + 0, + 30 + }; + info->videoFormats << f->create(); + m_cameraDevices.append(info->create()); + info = new QCameraDevicePrivate; + info->description = QString::fromUtf8("frontCamera"); + info->id = "front"; + info->isDefault = false; + info->position = QCameraDevice::FrontFace; + f = new QCameraFormatPrivate{ + QSharedData(), + QVideoFrameFormat::Format_XRGB8888, + QSize(1280, 720), + 0, + 30 + }; + info->videoFormats << f->create(); + m_cameraDevices.append(info->create()); + info = new QCameraDevicePrivate; + info->description = QString::fromUtf8("backCamera"); + info->id = "back"; + info->isDefault = false; + info->position = QCameraDevice::BackFace; + m_cameraDevices.append(info->create()); + } + + QList<QCameraDevice> videoDevices() const override + { + return m_cameraDevices; + } + +private: + QList<QCameraDevice> m_cameraDevices; +}; + QMockIntegration::QMockIntegration() { setIntegration(this); + m_videoDevices = new QMockVideoDevices(this); } QMockIntegration::~QMockIntegration() diff --git a/tests/auto/unit/mockbackend/qmockmediadevices.cpp b/tests/auto/unit/mockbackend/qmockmediadevices.cpp index ff9580ca3..0a17dfa57 100644 --- a/tests/auto/unit/mockbackend/qmockmediadevices.cpp +++ b/tests/auto/unit/mockbackend/qmockmediadevices.cpp @@ -10,41 +10,6 @@ QMockMediaDevices::QMockMediaDevices() : QPlatformMediaDevices() { setDevices(this); - - QCameraDevicePrivate *info = new QCameraDevicePrivate; - info->description = QString::fromUtf8("defaultCamera"); - info->id = "default"; - info->isDefault = true; - auto *f = new QCameraFormatPrivate{ - QSharedData(), - QVideoFrameFormat::Format_ARGB8888, - QSize(640, 480), - 0, - 30 - }; - info->videoFormats << f->create(); - m_cameraDevices.append(info->create()); - info = new QCameraDevicePrivate; - info->description = QString::fromUtf8("frontCamera"); - info->id = "front"; - info->isDefault = false; - info->position = QCameraDevice::FrontFace; - f = new QCameraFormatPrivate{ - QSharedData(), - QVideoFrameFormat::Format_XRGB8888, - QSize(1280, 720), - 0, - 30 - }; - info->videoFormats << f->create(); - m_cameraDevices.append(info->create()); - info = new QCameraDevicePrivate; - info->description = QString::fromUtf8("backCamera"); - info->id = "back"; - info->isDefault = false; - info->position = QCameraDevice::BackFace; - m_cameraDevices.append(info->create()); - } QMockMediaDevices::~QMockMediaDevices() = default; @@ -59,11 +24,6 @@ QList<QAudioDevice> QMockMediaDevices::audioOutputs() const return m_outputDevices; } -QList<QCameraDevice> QMockMediaDevices::videoInputs() const -{ - return m_cameraDevices; -} - QPlatformAudioSource *QMockMediaDevices::createAudioSource(const QAudioDevice &info) { Q_UNUSED(info); diff --git a/tests/auto/unit/mockbackend/qmockmediadevices_p.h b/tests/auto/unit/mockbackend/qmockmediadevices_p.h index 3ca3ebdce..2483f5e10 100644 --- a/tests/auto/unit/mockbackend/qmockmediadevices_p.h +++ b/tests/auto/unit/mockbackend/qmockmediadevices_p.h @@ -32,14 +32,12 @@ public: QList<QAudioDevice> audioInputs() const override; QList<QAudioDevice> audioOutputs() const override; - QList<QCameraDevice> videoInputs() const override; QPlatformAudioSource *createAudioSource(const QAudioDevice &info) override; QPlatformAudioSink *createAudioSink(const QAudioDevice &info) override; private: QList<QAudioDevice> m_inputDevices; QList<QAudioDevice> m_outputDevices; - QList<QCameraDevice> m_cameraDevices; }; QT_END_NAMESPACE |