summaryrefslogtreecommitdiffstats
path: root/tests/auto/unit/qmultimedia_common
diff options
context:
space:
mode:
authorJames McDonnell <jmcdonnell@blackberry.com>2017-03-27 14:59:06 -0400
committerJames McDonnell <jmcdonnell@blackberry.com>2017-09-06 14:07:11 +0000
commitfec653b6f4402e70ee6d11f8beba070ece0b3d8d (patch)
tree4c64b85f6d818400beb869c884956607c506d1d9 /tests/auto/unit/qmultimedia_common
parenta523f9e117c5d402b83c4cdbf54d99004095616d (diff)
Add custom audio role API to QMediaPlayer
Allows use of audio roles beyond those known to Qt. [ChangeLog][QMediaPlayer] Added customAudioRole string property to enable use of audio roles beyond those available via the audioRole enum property. Change-Id: Id7ed5d7bc1af0c15910e699f25c97cfed2d48243 Reviewed-by: Christian Stromme <christian.stromme@qt.io> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'tests/auto/unit/qmultimedia_common')
-rw-r--r--tests/auto/unit/qmultimedia_common/mockaudiorolecontrol.h1
-rw-r--r--tests/auto/unit/qmultimedia_common/mockcustomaudiorolecontrol.h65
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h11
-rw-r--r--tests/auto/unit/qmultimedia_common/mockplayer.pri3
4 files changed, 78 insertions, 2 deletions
diff --git a/tests/auto/unit/qmultimedia_common/mockaudiorolecontrol.h b/tests/auto/unit/qmultimedia_common/mockaudiorolecontrol.h
index 299b8cf4c..06e914ba1 100644
--- a/tests/auto/unit/qmultimedia_common/mockaudiorolecontrol.h
+++ b/tests/auto/unit/qmultimedia_common/mockaudiorolecontrol.h
@@ -64,4 +64,3 @@ public:
};
#endif // MOCKAUDIOROLECONTROL_H
-
diff --git a/tests/auto/unit/qmultimedia_common/mockcustomaudiorolecontrol.h b/tests/auto/unit/qmultimedia_common/mockcustomaudiorolecontrol.h
new file mode 100644
index 000000000..f4031bb04
--- /dev/null
+++ b/tests/auto/unit/qmultimedia_common/mockcustomaudiorolecontrol.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 QNX Software Systems. All rights reserved.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** 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-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKCUSTOMAUDIOROLECONTROL_H
+#define MOCKCUSTOMAUDIOROLECONTROL_H
+
+#include <qcustomaudiorolecontrol.h>
+
+class MockCustomAudioRoleControl : public QCustomAudioRoleControl
+{
+ friend class MockMediaPlayerService;
+
+public:
+ MockCustomAudioRoleControl()
+ : QCustomAudioRoleControl()
+ , m_customAudioRole(QAudio::UnknownRole)
+ {
+ }
+
+ QString customAudioRole() const
+ {
+ return m_customAudioRole;
+ }
+
+ void setCustomAudioRole(const QString &role)
+ {
+ if (role != m_customAudioRole)
+ emit customAudioRoleChanged(m_customAudioRole = role);
+ }
+
+ QStringList supportedCustomAudioRoles() const
+ {
+ return QStringList() << QStringLiteral("customRole")
+ << QStringLiteral("customRole2");
+ }
+
+ QString m_customAudioRole;
+};
+
+#endif // MOCKCUSTOMAUDIOROLECONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h b/tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h
index 46b81899c..068bb84a9 100644
--- a/tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h
+++ b/tests/auto/unit/qmultimedia_common/mockmediaplayerservice.h
@@ -38,6 +38,7 @@
#include "mockvideoprobecontrol.h"
#include "mockvideowindowcontrol.h"
#include "mockaudiorolecontrol.h"
+#include "mockcustomaudiorolecontrol.h"
class MockMediaPlayerService : public QMediaService
{
@@ -48,6 +49,7 @@ public:
{
mockControl = new MockMediaPlayerControl;
mockAudioRoleControl = new MockAudioRoleControl;
+ mockCustomAudioRoleControl = new MockCustomAudioRoleControl;
mockStreamsControl = new MockStreamsControl;
mockNetworkControl = new MockNetworkAccessControl;
rendererControl = new MockVideoRendererControl;
@@ -56,12 +58,14 @@ public:
windowControl = new MockVideoWindowControl;
windowRef = 0;
enableAudioRole = true;
+ enableCustomAudioRole = true;
}
~MockMediaPlayerService()
{
delete mockControl;
delete mockAudioRoleControl;
+ delete mockCustomAudioRoleControl;
delete mockStreamsControl;
delete mockNetworkControl;
delete rendererControl;
@@ -88,6 +92,8 @@ public:
}
} else if (enableAudioRole && qstrcmp(iid, QAudioRoleControl_iid) == 0) {
return mockAudioRoleControl;
+ } else if (enableCustomAudioRole && qstrcmp(iid, QCustomAudioRoleControl_iid) == 0) {
+ return mockCustomAudioRoleControl;
}
if (qstrcmp(iid, QMediaNetworkAccessControl_iid) == 0)
@@ -127,6 +133,7 @@ public:
void selectCurrentConfiguration(QNetworkConfiguration config) { mockNetworkControl->setCurrentConfiguration(config); }
void setHasAudioRole(bool enable) { enableAudioRole = enable; }
+ void setHasCustomAudioRole(bool enable) { enableCustomAudioRole = enable; }
void reset()
{
@@ -148,6 +155,8 @@ public:
enableAudioRole = true;
mockAudioRoleControl->m_audioRole = QAudio::UnknownRole;
+ enableCustomAudioRole = true;
+ mockCustomAudioRoleControl->m_customAudioRole.clear();
mockNetworkControl->_current = QNetworkConfiguration();
mockNetworkControl->_configurations = QList<QNetworkConfiguration>();
@@ -155,6 +164,7 @@ public:
MockMediaPlayerControl *mockControl;
MockAudioRoleControl *mockAudioRoleControl;
+ MockCustomAudioRoleControl *mockCustomAudioRoleControl;
MockStreamsControl *mockStreamsControl;
MockNetworkAccessControl *mockNetworkControl;
MockVideoRendererControl *rendererControl;
@@ -163,6 +173,7 @@ public:
int windowRef;
int rendererRef;
bool enableAudioRole;
+ bool enableCustomAudioRole;
};
diff --git a/tests/auto/unit/qmultimedia_common/mockplayer.pri b/tests/auto/unit/qmultimedia_common/mockplayer.pri
index c43fb31e5..93cdbf3d8 100644
--- a/tests/auto/unit/qmultimedia_common/mockplayer.pri
+++ b/tests/auto/unit/qmultimedia_common/mockplayer.pri
@@ -9,6 +9,7 @@ HEADERS *= \
../qmultimedia_common/mockmediastreamscontrol.h \
../qmultimedia_common/mockmedianetworkaccesscontrol.h \
../qmultimedia_common/mockvideoprobecontrol.h \
- ../qmultimedia_common/mockaudiorolecontrol.h
+ ../qmultimedia_common/mockaudiorolecontrol.h \
+ ../qmultimedia_common/mockcustomaudiorolecontrol.h
include(mockvideo.pri)