summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-01-21 12:40:17 +0100
committerLars Knoll <lars.knoll@qt.io>2021-01-29 08:49:42 +0000
commit80156a94bf0cfcacb1f98dd84429cc96f3f38b30 (patch)
tree913953d2651d22ba6ce5f387c8e4c10316ad430c /tests
parentf97250e06a14ebcde6ad3b7c824686a7fde0c142 (diff)
Start refactoring the mock backend code
Refactor the mock backend code so that it can work in the new infrastructure as a way to test our frontend APIs. Change-Id: Ica1bd9665b9121197f95861173171f9da8cccc58 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/unit/mockbackend/mockbackend.pro2
-rw-r--r--tests/auto/unit/mockbackend/mockmediaplayerservice.h18
-rw-r--r--tests/auto/unit/mockbackend/qmockdevicemanager.cpp82
-rw-r--r--tests/auto/unit/mockbackend/qmockdevicemanager_p.h85
-rw-r--r--tests/auto/unit/mockbackend/qmockintegration.cpp68
-rw-r--r--tests/auto/unit/mockbackend/qmockintegration_p.h75
6 files changed, 327 insertions, 3 deletions
diff --git a/tests/auto/unit/mockbackend/mockbackend.pro b/tests/auto/unit/mockbackend/mockbackend.pro
index 8347c37bc..7e9ffe8b7 100644
--- a/tests/auto/unit/mockbackend/mockbackend.pro
+++ b/tests/auto/unit/mockbackend/mockbackend.pro
@@ -8,3 +8,5 @@ include(capture.pri)
include(common.pri)
include(player.pri)
+SOURCES += qmockdevicemanager.cpp qmockintegration.cpp
+HEADERS += qmockdevicemanager_p.h qmockintegration_p.h
diff --git a/tests/auto/unit/mockbackend/mockmediaplayerservice.h b/tests/auto/unit/mockbackend/mockmediaplayerservice.h
index 0ae7050e8..483d21e8e 100644
--- a/tests/auto/unit/mockbackend/mockmediaplayerservice.h
+++ b/tests/auto/unit/mockbackend/mockmediaplayerservice.h
@@ -29,7 +29,7 @@
#ifndef MOCKPLAYERSERVICE_H
#define MOCKPLAYERSERVICE_H
-#include "qmediaservice.h"
+#include "private/qmediaplatformplayerinterface_p.h"
#include "mockmediaplayercontrol.h"
#include "mockmediastreamscontrol.h"
@@ -37,12 +37,12 @@
#include "mockvideoprobecontrol.h"
#include "mockvideowindowcontrol.h"
-class MockMediaPlayerService : public QMediaService
+class MockMediaPlayerService : public QMediaPlatformPlayerInterface
{
Q_OBJECT
public:
- MockMediaPlayerService():QMediaService(0)
+ MockMediaPlayerService()
{
mockControl = new MockMediaPlayerControl;
mockStreamsControl = new MockStreamsControl;
@@ -92,6 +92,18 @@ public:
windowRef -= 1;
}
+ QMediaPlayerControl *player() { return mockControl; }
+ QMetaDataReaderControl *dataReader() { return nullptr; } // ###
+
+ QMediaStreamsControl *streams() { return nullptr; } // ###
+ QMediaVideoProbeControl *videoProbe() { return mockVideoProbeControl; }
+ void releaseVideoProbe(QMediaVideoProbeControl *) {}
+ QMediaAudioProbeControl *audioProbe() { return nullptr; } // ###
+ void releaseAudioProbe(QMediaAudioProbeControl *) {}
+
+ virtual QVideoRendererControl *createVideoRenderer() { return rendererControl; }
+ virtual QVideoWindowControl *createVideoWindow() { return windowControl; };
+
void setState(QMediaPlayer::State state) { emit mockControl->stateChanged(mockControl->_state = state); }
void setState(QMediaPlayer::State state, QMediaPlayer::MediaStatus status) {
mockControl->_state = state;
diff --git a/tests/auto/unit/mockbackend/qmockdevicemanager.cpp b/tests/auto/unit/mockbackend/qmockdevicemanager.cpp
new file mode 100644
index 000000000..f8b7c5c90
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockdevicemanager.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmockdevicemanager_p.h"
+#include "private/qcamerainfo_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QMockDeviceManager::QMockDeviceManager()
+ : QMediaPlatformDeviceManager()
+{
+}
+
+QMockDeviceManager::~QMockDeviceManager()
+{
+}
+
+QList<QAudioDeviceInfo> QMockDeviceManager::audioInputs() const
+{
+ return m_inputDevices;
+}
+
+QList<QAudioDeviceInfo> QMockDeviceManager::audioOutputs() const
+{
+ return m_outputDevices;
+}
+
+QList<QCameraInfo> QMockDeviceManager::videoInputs() const
+{
+ return m_cameraDevices;
+}
+
+QAbstractAudioInput *QMockDeviceManager::createAudioInputDevice(const QAudioDeviceInfo &info)
+{
+ Q_UNUSED(info);
+ return nullptr;// ###
+}
+
+QAbstractAudioOutput *QMockDeviceManager::createAudioOutputDevice(const QAudioDeviceInfo &info)
+{
+ Q_UNUSED(info);
+ return nullptr; //###
+}
+
+
+QT_END_NAMESPACE
diff --git a/tests/auto/unit/mockbackend/qmockdevicemanager_p.h b/tests/auto/unit/mockbackend/qmockdevicemanager_p.h
new file mode 100644
index 000000000..1eb6018fb
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockdevicemanager_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMOCKDEVICEMANAGER_H
+#define QMOCKDEVICEMANAGER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qmediaplatformdevicemanager_p.h>
+#include <qelapsedtimer.h>
+#include <qaudiodeviceinfo.h>
+#include <qcamerainfo.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_FORWARD_DECLARE_OBJC_CLASS(AVCaptureDeviceDiscoverySession);
+
+class QCameraInfo;
+
+class QMockDeviceManager : public QMediaPlatformDeviceManager
+{
+public:
+ QMockDeviceManager();
+ ~QMockDeviceManager();
+
+ QList<QAudioDeviceInfo> audioInputs() const override;
+ QList<QAudioDeviceInfo> audioOutputs() const override;
+ QList<QCameraInfo> videoInputs() const override;
+ QAbstractAudioInput *createAudioInputDevice(const QAudioDeviceInfo &info) override;
+ QAbstractAudioOutput *createAudioOutputDevice(const QAudioDeviceInfo &info) override;
+
+private:
+ QList<QAudioDeviceInfo> m_inputDevices;
+ QList<QAudioDeviceInfo> m_outputDevices;
+ QList<QCameraInfo> m_cameraDevices;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/unit/mockbackend/qmockintegration.cpp b/tests/auto/unit/mockbackend/qmockintegration.cpp
new file mode 100644
index 000000000..9d2d2f95b
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockintegration.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmockintegration_p.h"
+#include "qmockdevicemanager_p.h"
+#include "mockmediaplayerservice.h"
+
+QT_BEGIN_NAMESPACE
+
+QMockIntegration::QMockIntegration()
+{
+
+}
+
+QMockIntegration::~QMockIntegration()
+{
+ delete m_manager;
+}
+
+QMediaPlatformDeviceManager *QMockIntegration::deviceManager()
+{
+ if (!m_manager)
+ m_manager = new QMockDeviceManager();
+ return m_manager;
+}
+
+QMediaPlatformPlayerInterface *QMockIntegration::createPlayerInterface()
+{
+ return new MockMediaPlayerService;
+}
+
+QT_END_NAMESPACE
diff --git a/tests/auto/unit/mockbackend/qmockintegration_p.h b/tests/auto/unit/mockbackend/qmockintegration_p.h
new file mode 100644
index 000000000..1bdb41383
--- /dev/null
+++ b/tests/auto/unit/mockbackend/qmockintegration_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMOCKINTEGRATION_H
+#define QMOCKINTEGRATION_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qmediaplatformintegration_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QMockDeviceManager;
+
+class QMockIntegration : public QMediaPlatformIntegration
+{
+public:
+ QMockIntegration();
+ ~QMockIntegration();
+
+ QMediaPlatformDeviceManager *deviceManager() override;
+
+ QMediaPlatformPlayerInterface *createPlayerInterface() override;
+
+ QMockDeviceManager *m_manager = nullptr;
+};
+
+QT_END_NAMESPACE
+
+#endif