summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2020-05-31 20:41:43 +0200
committerChristian Strømme <christian.stromme@qt.io>2020-06-10 18:29:22 +0000
commitba2f42c2548a5175126497d2d69eef95c2a849ba (patch)
tree0570570b5c997186b74396ddb6e9cd330209e859 /tests
parent3d909ba8ac0f43af6d70830a5c95df3e741f1221 (diff)
Remove Radio support
Fixes: QTBUG-84592 Change-Id: I3b9e51689fd542c35cb57cf6c51a141aec3034df Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/unit/multimedia.pro2
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp3
-rw-r--r--tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.json2
-rw-r--r--tests/auto/unit/qmultimedia_common/mockradio.pri8
-rw-r--r--tests/auto/unit/qmultimedia_common/mockradiodatacontrol.h135
-rw-r--r--tests/auto/unit/qmultimedia_common/mockradiotunercontrol.h253
-rw-r--r--tests/auto/unit/qradiodata/qradiodata.pro7
-rw-r--r--tests/auto/unit/qradiodata/tst_qradiodata.cpp195
-rw-r--r--tests/auto/unit/qradiotuner/qradiotuner.pro7
-rw-r--r--tests/auto/unit/qradiotuner/tst_qradiotuner.cpp388
10 files changed, 2 insertions, 998 deletions
diff --git a/tests/auto/unit/multimedia.pro b/tests/auto/unit/multimedia.pro
index 94a6dba89..3e0311a66 100644
--- a/tests/auto/unit/multimedia.pro
+++ b/tests/auto/unit/multimedia.pro
@@ -23,8 +23,6 @@ SUBDIRS += \
qmediatimerange \
qmetadatareadercontrol \
qmetadatawritercontrol \
- qradiodata \
- qradiotuner \
qvideoencodersettingscontrol \
qvideoframe \
qvideosurfaceformat \
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp
index 4167b18ea..b44c704f4 100644
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp
+++ b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.cpp
@@ -41,8 +41,7 @@ class MockServicePlugin2 : public QMediaServiceProviderPlugin,
public:
QStringList keys() const
{
- return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER)
- << QLatin1String(Q_MEDIASERVICE_RADIO);
+ return QStringList() << QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER);
}
QMediaService* create(QString const& key)
diff --git a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.json b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.json
index 15d8ed505..07f9cae7a 100644
--- a/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.json
+++ b/tests/auto/unit/qmediaserviceprovider/mockserviceplugin2/mockserviceplugin2.json
@@ -1,4 +1,4 @@
{
"Keys": ["mockserviceplugin2"],
- "Services": ["org.qt-project.qt.mediaplayer", "org.qt-project.qt.radio"]
+ "Services": ["org.qt-project.qt.mediaplayer"]
}
diff --git a/tests/auto/unit/qmultimedia_common/mockradio.pri b/tests/auto/unit/qmultimedia_common/mockradio.pri
deleted file mode 100644
index 0f7f84a2f..000000000
--- a/tests/auto/unit/qmultimedia_common/mockradio.pri
+++ /dev/null
@@ -1,8 +0,0 @@
-
-# Radio related mock backend files
-
-INCLUDEPATH += .
-
-HEADERS += \
- ../qmultimedia_common/mockradiotunercontrol.h \
- ../qmultimedia_common/mockradiodatacontrol.h
diff --git a/tests/auto/unit/qmultimedia_common/mockradiodatacontrol.h b/tests/auto/unit/qmultimedia_common/mockradiodatacontrol.h
deleted file mode 100644
index c51bafc30..000000000
--- a/tests/auto/unit/qmultimedia_common/mockradiodatacontrol.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** 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 MOCKRADIODATACONTROL_H
-#define MOCKRADIODATACONTROL_H
-
-#include "qradiodatacontrol.h"
-
-class MockRadioDataControl : public QRadioDataControl
-{
- Q_OBJECT
-
-public:
- MockRadioDataControl(QObject *parent):
- QRadioDataControl(parent), m_err(QRadioData::NoError),
- m_errstr("")
- {
- }
-
- using QRadioDataControl::error;
-
- QRadioData::Error error() const
- {
- return m_err;
- }
-
- QString errorString() const
- {
- return m_errstr;
- }
-
- QString stationId() const
- {
- return m_stationId;
- }
-
- QRadioData::ProgramType programType() const
- {
- return m_programType;
- }
-
- QString programTypeName() const
- {
- return m_programTypeName;
- }
-
- QString stationName() const
- {
- return m_stationName;
- }
-
- QString radioText() const
- {
- return m_radioText;
- }
-
- void setAlternativeFrequenciesEnabled(bool enabled)
- {
- m_alternativeFrequenciesEnabled = enabled;
- emit alternativeFrequenciesEnabledChanged(m_alternativeFrequenciesEnabled);
- }
-
- bool isAlternativeFrequenciesEnabled() const
- {
- return m_alternativeFrequenciesEnabled;
- }
-
- void forceRT( QString text )
- {
- m_radioText = text;
- emit radioTextChanged(m_radioText);
- }
-
- void forceProgramType( int pty )
- {
- m_programType = static_cast<QRadioData::ProgramType>(pty);
- emit programTypeChanged(m_programType);
- }
-
- void forcePTYN( QString ptyn )
- {
- m_programTypeName = ptyn;
- emit programTypeNameChanged(m_programTypeName);
- }
-
- void forcePI( QString pi )
- {
- m_stationId = pi;
- emit stationIdChanged(m_stationId);
- }
-
- void forcePS( QString ps )
- {
- m_stationName = ps;
- emit stationNameChanged(m_stationName);
- }
-
-public:
- QString m_radioText;
- QRadioData::ProgramType m_programType;
- QString m_programTypeName;
- QString m_stationId;
- QString m_stationName;
- bool m_alternativeFrequenciesEnabled;
-
- QRadioData::Error m_err;
- QString m_errstr;
-};
-
-#endif // MOCKRADIODATACONTROL_H
diff --git a/tests/auto/unit/qmultimedia_common/mockradiotunercontrol.h b/tests/auto/unit/qmultimedia_common/mockradiotunercontrol.h
deleted file mode 100644
index 254d0f3d5..000000000
--- a/tests/auto/unit/qmultimedia_common/mockradiotunercontrol.h
+++ /dev/null
@@ -1,253 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** 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 MOCKRADIOTUNERCONTROL_H
-#define MOCKRADIOTUNERCONTROL_H
-
-#include "qradiotunercontrol.h"
-
-class MockRadioTunerControl : public QRadioTunerControl
-{
- Q_OBJECT
-
-public:
- MockRadioTunerControl(QObject *parent):
- QRadioTunerControl(parent),
- m_active(false),
- m_searching(false),m_muted(false),m_stereo(true),
- m_volume(100),m_signal(0),m_frequency(0),
- m_band(QRadioTuner::FM),m_err(QRadioTuner::NoError),
- m_errstr("")
- {
- }
-
- using QRadioTunerControl::error;
-
- QRadioTuner::State state() const
- {
- return m_active ? QRadioTuner::ActiveState : QRadioTuner::StoppedState;
- }
-
- QRadioTuner::Band band() const
- {
- return m_band;
- }
-
- void setBand(QRadioTuner::Band b)
- {
- if (b == QRadioTuner::FM2 || b == QRadioTuner::LW) {
- m_err = QRadioTuner::OutOfRangeError;
- m_errstr.clear();
- m_errstr = QString("band and range not supported");
- } else {
- m_err = QRadioTuner::NoError;
- m_errstr.clear();
- m_band = b;
- emit bandChanged(m_band);
- }
- emit error(m_err);
-
- }
-
- bool isBandSupported(QRadioTuner::Band b) const
- {
- if (b == QRadioTuner::FM || b == QRadioTuner::AM)
- return true;
-
- return false;
- }
-
- int frequency() const
- {
- return m_frequency;
- }
-
- QPair<int,int> frequencyRange(QRadioTuner::Band) const
- {
- return qMakePair<int,int>(1,2);
- }
-
- int frequencyStep(QRadioTuner::Band) const
- {
- return 1;
- }
-
- void setFrequency(int frequency)
- {
- if (frequency >= 148500000) {
- m_err = QRadioTuner::OutOfRangeError;
- m_errstr.clear();
- m_errstr = QString("band and range not supported");
- } else {
- m_err = QRadioTuner::NoError;
- m_errstr.clear();
- m_frequency = frequency;
- emit frequencyChanged(m_frequency);
- }
-
- emit error(m_err);
- }
-
- bool isStereo() const
- {
- return m_stereo;
- }
-
- void setStereo(bool stereo)
- {
- emit stereoStatusChanged(m_stereo = stereo);
- }
-
-
- QRadioTuner::StereoMode stereoMode() const
- {
- return m_stereoMode;
- }
-
- void setStereoMode(QRadioTuner::StereoMode mode)
- {
- m_stereoMode = mode;
- }
-
- QRadioTuner::Error error() const
- {
- return m_err;
- }
-
- QString errorString() const
- {
- return m_errstr;
- }
-
- int signalStrength() const
- {
- return m_signal;
- }
-
- int volume() const
- {
- return m_volume;
- }
-
- void setVolume(int volume)
- {
- m_volume = volume;
- emit volumeChanged(m_volume);
- }
-
- bool isMuted() const
- {
- return m_muted;
- }
-
- void setMuted(bool muted)
- {
- m_muted = muted;
- emit mutedChanged(m_muted);
- }
-
- bool isSearching() const
- {
- return m_searching;
- }
-
- void searchForward()
- {
- m_searching = true;
- emit searchingChanged(m_searching);
- }
-
- void searchBackward()
- {
- m_searching = true;
- emit searchingChanged(m_searching);
- }
-
- void cancelSearch()
- {
- m_searching = false;
- emit searchingChanged(m_searching);
- }
-
- void findNewStation( int frequency, QString stationId )
- {
- setFrequency(frequency);
- emit stationFound( frequency, stationId );
- }
-
- void searchAllStations(QRadioTuner::SearchMode searchMode = QRadioTuner::SearchFast)
- {
- QString programmeIdentifiers[3] = { "", "", "" };
-
- if ( searchMode == QRadioTuner::SearchGetStationId ) {
- programmeIdentifiers[0] = QString("MockProgramPI1");
- programmeIdentifiers[1] = QString("MockProgramPI2");
- programmeIdentifiers[2] = QString("MockProgramPI3");
- }
- m_searching = true;
- emit searchingChanged(m_searching);
-
- findNewStation(88300000, programmeIdentifiers[0]);
- findNewStation(95100000, programmeIdentifiers[1]);
- findNewStation(103100000, programmeIdentifiers[2]);
-
- m_searching = false;
- emit searchingChanged(m_searching);
- }
-
- void start()
- {
- if (!m_active) {
- m_active = true;
- emit stateChanged(state());
- }
- }
-
- void stop()
- {
- if (m_active) {
- m_active = false;
- emit stateChanged(state());
- }
- }
-
-public:
- bool m_active;
- bool m_searching;
- bool m_muted;
- bool m_stereo;
- int m_volume;
- int m_signal;
- int m_frequency;
- QRadioTuner::StereoMode m_stereoMode;
- QRadioTuner::Band m_band;
- QRadioTuner::Error m_err;
- QString m_errstr;
-};
-
-#endif // MOCKRADIOTUNERCONTROL_H
diff --git a/tests/auto/unit/qradiodata/qradiodata.pro b/tests/auto/unit/qradiodata/qradiodata.pro
deleted file mode 100644
index b08262d70..000000000
--- a/tests/auto/unit/qradiodata/qradiodata.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qradiodata
-QT += multimedia-private testlib
-SOURCES += tst_qradiodata.cpp
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockradio.pri)
diff --git a/tests/auto/unit/qradiodata/tst_qradiodata.cpp b/tests/auto/unit/qradiodata/tst_qradiodata.cpp
deleted file mode 100644
index afc19113e..000000000
--- a/tests/auto/unit/qradiodata/tst_qradiodata.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** 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$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include <QDebug>
-#include <QTimer>
-#include <QtCore/QMap>
-
-#include <qmediaobject.h>
-#include <qmediacontrol.h>
-#include <qmediaservice.h>
-#include <qradiodatacontrol.h>
-#include <qradiodata.h>
-#include <qradiotuner.h>
-
-#include "mockmediaserviceprovider.h"
-#include "mockmediaservice.h"
-#include "mockavailabilitycontrol.h"
-#include "mockradiotunercontrol.h"
-#include "mockradiodatacontrol.h"
-
-QT_USE_NAMESPACE
-
-class tst_QRadioData: public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
-
-private slots:
- void testNullService();
- void testNullControl();
- void testAlternativeFrequencies();
- void testRadioDataUpdates();
-
-private:
- MockAvailabilityControl *mockAvailability;
- MockRadioTunerControl *mockTuner;
- MockRadioDataControl *mockData;
- MockMediaService *service;
- MockMediaServiceProvider *provider;
- QRadioTuner * radio;
- QRadioData *radioData;
-};
-
-void tst_QRadioData::initTestCase()
-{
- qRegisterMetaType<QRadioData::ProgramType>("QRadioData::ProgramType");
-
- mockAvailability = new MockAvailabilityControl(QMultimedia::Available);
- mockTuner = new MockRadioTunerControl(this);
- mockData = new MockRadioDataControl(this);
-
- QMap<QString, QMediaControl *> map;
- map.insert(QRadioTunerControl_iid, mockTuner);
- map.insert(QRadioDataControl_iid, mockData);
- map.insert(QMediaAvailabilityControl_iid, mockAvailability);
-
- service = new MockMediaService(this, map);
- provider = new MockMediaServiceProvider(service);
- QMediaServiceProvider::setDefaultServiceProvider(provider);
-
- radio = new QRadioTuner;
- radioData = radio->radioData();
-
- QVERIFY(radioData->availability() == QMultimedia::Available);
-}
-
-void tst_QRadioData::cleanupTestCase()
-{
- QVERIFY(radioData->error() == QRadioData::NoError);
- QVERIFY(radioData->errorString().isEmpty());
-
- delete radio;
- delete service;
- delete provider;
- delete mockAvailability;
-}
-
-void tst_QRadioData::testNullService()
-{
- const QPair<int, int> nullRange(0, 0);
-
- MockMediaServiceProvider nullProvider(0);
- QMediaServiceProvider::setDefaultServiceProvider(&nullProvider);
- QRadioTuner radio;
- QRadioData *nullRadioData = radio.radioData();
-
- QVERIFY(nullRadioData == 0);
-
- QRadioData radioData(&radio);
-
- QCOMPARE(radioData.error(), QRadioData::ResourceError);
- QCOMPARE(radioData.errorString(), QString());
- QCOMPARE(radioData.stationId(), QString());
- QCOMPARE(radioData.programType(), QRadioData::Undefined);
- QCOMPARE(radioData.programTypeName(), QString());
- QCOMPARE(radioData.stationName(), QString());
- QCOMPARE(radioData.radioText(), QString());
- QCOMPARE(radioData.isAlternativeFrequenciesEnabled(), false);
-
-}
-
-void tst_QRadioData::testNullControl()
-{
- const QPair<int, int> nullRange(0, 0);
-
- MockMediaService service(0, 0);
- MockMediaServiceProvider provider(&service);
- QMediaServiceProvider::setDefaultServiceProvider(&provider);
- QRadioTuner radio;
- QRadioData *radioData = radio.radioData();
- QCOMPARE(radioData->error(), QRadioData::ResourceError);
- QCOMPARE(radioData->errorString(), QString());
-
- QCOMPARE(radioData->stationId(), QString());
- QCOMPARE(radioData->programType(), QRadioData::Undefined);
- QCOMPARE(radioData->programTypeName(), QString());
- QCOMPARE(radioData->stationName(), QString());
- QCOMPARE(radioData->radioText(), QString());
- QCOMPARE(radioData->isAlternativeFrequenciesEnabled(), false);
- {
- QSignalSpy spy(radioData, SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
-
- radioData->setAlternativeFrequenciesEnabled(true);
- QCOMPARE(radioData->isAlternativeFrequenciesEnabled(), false);
- QCOMPARE(spy.count(), 0);
- }
-}
-
-void tst_QRadioData::testAlternativeFrequencies()
-{
- QSignalSpy readSignal(radioData, SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
- radioData->setAlternativeFrequenciesEnabled(true);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(radioData->isAlternativeFrequenciesEnabled() == true);
- QVERIFY(readSignal.count() == 1);
-}
-
-void tst_QRadioData::testRadioDataUpdates()
-{
- QSignalSpy rtSpy(radioData, SIGNAL(radioTextChanged(QString)));
- QSignalSpy ptyPTYSpy(radioData, SIGNAL(programTypeChanged(QRadioData::ProgramType)));
- QSignalSpy ptynSpy(radioData, SIGNAL(programTypeNameChanged(QString)));
- QSignalSpy piSpy(radioData, SIGNAL(stationIdChanged(QString)));
- QSignalSpy psSpy(radioData, SIGNAL(stationNameChanged(QString)));
- mockData->forceRT("Mock Radio Text");
- mockData->forceProgramType(static_cast<int>(QRadioData::Sport));
- mockData->forcePTYN("Mock Programme Type Name");
- mockData->forcePI("Mock Programme Identification");
- mockData->forcePS("Mock Programme Service");
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(rtSpy.count() == 1);
- QVERIFY(ptyPTYSpy.count() == 1);
- QVERIFY(ptynSpy.count() == 1);
- QVERIFY(piSpy.count() == 1);
- QVERIFY(psSpy.count() == 1);
- QCOMPARE(radioData->radioText(), QString("Mock Radio Text"));
- QCOMPARE(radioData->programType(), QRadioData::Sport);
- QCOMPARE(radioData->programTypeName(), QString("Mock Programme Type Name"));
- QCOMPARE(radioData->stationId(), QString("Mock Programme Identification"));
- QCOMPARE(radioData->stationName(), QString("Mock Programme Service"));
-}
-
-QTEST_GUILESS_MAIN(tst_QRadioData)
-#include "tst_qradiodata.moc"
diff --git a/tests/auto/unit/qradiotuner/qradiotuner.pro b/tests/auto/unit/qradiotuner/qradiotuner.pro
deleted file mode 100644
index d15c4c6a2..000000000
--- a/tests/auto/unit/qradiotuner/qradiotuner.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qradiotuner
-QT += multimedia-private testlib
-SOURCES += tst_qradiotuner.cpp
-
-include (../qmultimedia_common/mock.pri)
-include (../qmultimedia_common/mockradio.pri)
diff --git a/tests/auto/unit/qradiotuner/tst_qradiotuner.cpp b/tests/auto/unit/qradiotuner/tst_qradiotuner.cpp
deleted file mode 100644
index 02e4ef6e9..000000000
--- a/tests/auto/unit/qradiotuner/tst_qradiotuner.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** 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$
-**
-****************************************************************************/
-
-//TESTED_COMPONENT=src/multimedia
-
-#include <QtTest/QtTest>
-#include <QDebug>
-#include <QTimer>
-#include <QtCore/QMap>
-
-#include <qmediaobject.h>
-#include <qmediacontrol.h>
-#include <qmediaservice.h>
-#include <qradiotunercontrol.h>
-#include <qradiotuner.h>
-
-#include "mockmediaserviceprovider.h"
-#include "mockmediaservice.h"
-#include "mockradiotunercontrol.h"
-#include "mockavailabilitycontrol.h"
-
-QT_USE_NAMESPACE
-
-class tst_QRadioTuner: public QObject
-{
- Q_OBJECT
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
-
-private slots:
- void testNullService();
- void testNullControl();
- void testBand();
- void testFrequency();
- void testMute();
- void testSearch();
- void testVolume();
- void testSignal();
- void testStereo();
- void testSearchAllStations();
- void errorSignal();
-
-private:
- MockRadioTunerControl *mock;
- MockAvailabilityControl *mockAvailability;
- MockMediaService *service;
- MockMediaServiceProvider *provider;
- QRadioTuner *radio;
-};
-
-void tst_QRadioTuner::initTestCase()
-{
- qRegisterMetaType<QRadioTuner::State>("QRadioTuner::State");
- qRegisterMetaType<QRadioTuner::Band>("QRadioTuner::Band");
-
- mock = new MockRadioTunerControl(this);
- mockAvailability = new MockAvailabilityControl(QMultimedia::Available);
-
- QMap<QString, QMediaControl *> map;
- map.insert(QRadioTunerControl_iid, mock);
- map.insert(QMediaAvailabilityControl_iid, mockAvailability);
-
- service = new MockMediaService(this, map);
- provider = new MockMediaServiceProvider(service);
- QMediaServiceProvider::setDefaultServiceProvider(provider);
-
- radio = new QRadioTuner;
- QVERIFY(radio->service() != 0);
- QVERIFY(radio->isAvailable());
- QVERIFY(radio->availability() == QMultimedia::Available);
-
- QSignalSpy stateSpy(radio, SIGNAL(stateChanged(QRadioTuner::State)));
-
- QCOMPARE(radio->state(), QRadioTuner::StoppedState);
- radio->start();
- QVERIFY(radio->availability() == QMultimedia::Available);
- QCOMPARE(radio->state(), QRadioTuner::ActiveState);
-
- QCOMPARE(stateSpy.count(), 1);
- QCOMPARE(stateSpy.first()[0].value<QRadioTuner::State>(), QRadioTuner::ActiveState);
-}
-
-void tst_QRadioTuner::cleanupTestCase()
-{
- QVERIFY(radio->error() == QRadioTuner::NoError);
- QVERIFY(radio->errorString().isEmpty());
-
- QSignalSpy stateSpy(radio, SIGNAL(stateChanged(QRadioTuner::State)));
-
- radio->stop();
- QVERIFY(radio->availability() == QMultimedia::Available);
- QCOMPARE(radio->state(), QRadioTuner::StoppedState);
- QCOMPARE(stateSpy.count(), 1);
-
- QCOMPARE(stateSpy.first()[0].value<QRadioTuner::State>(), QRadioTuner::StoppedState);
-
- delete radio;
- delete service;
- delete provider;
- delete mockAvailability;
-}
-
-void tst_QRadioTuner::init()
-{
- QMediaServiceProvider::setDefaultServiceProvider(provider);
-}
-
-void tst_QRadioTuner::testNullService()
-{
- const QPair<int, int> nullRange(0, 0);
-
- MockMediaServiceProvider provider(0);
- QMediaServiceProvider::setDefaultServiceProvider(&provider);
-
- QRadioTuner radio;
- QVERIFY(!radio.isAvailable());
- radio.start();
- QCOMPARE(radio.error(), QRadioTuner::ResourceError);
- QCOMPARE(radio.errorString(), QString());
- QCOMPARE(radio.band(), QRadioTuner::FM);
- QCOMPARE(radio.isBandSupported(QRadioTuner::AM), false);
- QCOMPARE(radio.isBandSupported(QRadioTuner::FM), false);
- QCOMPARE(radio.frequency(), 0);
- QCOMPARE(radio.frequencyStep(QRadioTuner::AM), 0);
- QCOMPARE(radio.frequencyStep(QRadioTuner::FM), 0);
- QCOMPARE(radio.frequencyRange(QRadioTuner::AM), nullRange);
- QCOMPARE(radio.frequencyRange(QRadioTuner::FM), nullRange);
- QCOMPARE(radio.isStereo(), false);
- QCOMPARE(radio.stereoMode(), QRadioTuner::Auto);
- QCOMPARE(radio.signalStrength(), 0);
- QCOMPARE(radio.volume(), 0);
- QCOMPARE(radio.isMuted(), false);
- QCOMPARE(radio.isSearching(), false);
- radio.stop();
-}
-
-void tst_QRadioTuner::testNullControl()
-{
- const QPair<int, int> nullRange(0, 0);
-
- MockMediaService service(0, 0);
- MockMediaServiceProvider provider(&service);
- QMediaServiceProvider::setDefaultServiceProvider(&provider);
- QRadioTuner radio;
- QVERIFY(!radio.isAvailable());
- radio.start();
-
- QCOMPARE(radio.error(), QRadioTuner::ResourceError);
- QCOMPARE(radio.errorString(), QString());
-
- QCOMPARE(radio.band(), QRadioTuner::FM);
- QCOMPARE(radio.isBandSupported(QRadioTuner::AM), false);
- QCOMPARE(radio.isBandSupported(QRadioTuner::FM), false);
- QCOMPARE(radio.frequency(), 0);
- QCOMPARE(radio.frequencyStep(QRadioTuner::AM), 0);
- QCOMPARE(radio.frequencyStep(QRadioTuner::FM), 0);
- QCOMPARE(radio.frequencyRange(QRadioTuner::AM), nullRange);
- QCOMPARE(radio.frequencyRange(QRadioTuner::FM), nullRange);
- {
- QSignalSpy bandSpy(&radio, SIGNAL(bandChanged(QRadioTuner::Band)));
- QSignalSpy frequencySpy(&radio, SIGNAL(frequencyChanged(int)));
-
- radio.setFrequency(107500);
- QCOMPARE(radio.band(), QRadioTuner::FM);
- QCOMPARE(radio.frequency(), 0);
- QCOMPARE(bandSpy.count(), 0);
- QCOMPARE(frequencySpy.count(), 0);
-
- radio.setBand(QRadioTuner::AM);
- QCOMPARE(radio.band(), QRadioTuner::FM);
- QCOMPARE(radio.frequency(), 0);
- QCOMPARE(bandSpy.count(), 0);
- QCOMPARE(frequencySpy.count(), 0);
- }
- QCOMPARE(radio.isStereo(), false);
- QCOMPARE(radio.stereoMode(), QRadioTuner::Auto);
-
- radio.setStereoMode(QRadioTuner::ForceStereo);
- QCOMPARE(radio.stereoMode(), QRadioTuner::Auto);
-
- QCOMPARE(radio.signalStrength(), 0);
-
- QCOMPARE(radio.volume(), 0);
- QCOMPARE(radio.isMuted(), false);
- {
- QSignalSpy volumeSpy(&radio, SIGNAL(volumeChanged(int)));
- QSignalSpy muteSpy(&radio, SIGNAL(mutedChanged(bool)));
-
- radio.setVolume(76);
- QCOMPARE(radio.volume(), 0);
- QCOMPARE(volumeSpy.count(), 0);
-
- radio.setMuted(true);
- QCOMPARE(radio.isMuted(), false);
- QCOMPARE(muteSpy.count(), 0);
- }
- QCOMPARE(radio.isSearching(), false);
- {
- QSignalSpy spy(&radio, SIGNAL(searchingChanged(bool)));
-
- radio.searchBackward();
- QCOMPARE(radio.isSearching(), false);
- QCOMPARE(spy.count(), 0);
-
- radio.searchForward();
- QCOMPARE(radio.isSearching(), false);
- QCOMPARE(spy.count(), 0);
-
- radio.searchAllStations();
- QCOMPARE(radio.isSearching(), false);
- QCOMPARE(spy.count(), 0);
-
- radio.cancelSearch();
- QCOMPARE(radio.isSearching(), false);
- QCOMPARE(spy.count(), 0);
- }
-
- radio.stop();
-}
-
-void tst_QRadioTuner::testBand()
-{
- QVERIFY(radio->isBandSupported(QRadioTuner::FM));
- QVERIFY(!radio->isBandSupported(QRadioTuner::SW));
-
- if(radio->isBandSupported(QRadioTuner::AM)) {
- QSignalSpy readSignal(radio, SIGNAL(bandChanged(QRadioTuner::Band)));
- radio->setBand(QRadioTuner::AM);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(radio->band() == QRadioTuner::AM);
- QVERIFY(readSignal.count() == 1);
- }
-}
-
-void tst_QRadioTuner::testFrequency()
-{
- QSignalSpy readSignal(radio, SIGNAL(frequencyChanged(int)));
- radio->setFrequency(104500000);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(radio->frequency() == 104500000);
- QVERIFY(readSignal.count() == 1);
-
- QVERIFY(radio->frequencyStep(QRadioTuner::FM) == 1);
- QPair<int,int> test = radio->frequencyRange(QRadioTuner::FM);
- QVERIFY(test.first == 1);
- QVERIFY(test.second == 2);
-}
-
-void tst_QRadioTuner::testMute()
-{
- QSignalSpy readSignal(radio, SIGNAL(mutedChanged(bool)));
- radio->setMuted(true);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(radio->isMuted());
- QVERIFY(readSignal.count() == 1);
-}
-
-void tst_QRadioTuner::testSearch()
-{
- QSignalSpy readSignal(radio, SIGNAL(searchingChanged(bool)));
- QVERIFY(!radio->isSearching());
-
- radio->searchForward();
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(radio->isSearching());
- QVERIFY(readSignal.count() == 1);
-
- radio->cancelSearch();
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(!radio->isSearching());
- QVERIFY(readSignal.count() == 2);
-
- radio->searchBackward();
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(radio->isSearching());
- QVERIFY(readSignal.count() == 3);
-
- radio->cancelSearch();
- QVERIFY(!radio->isSearching());
-}
-
-void tst_QRadioTuner::testVolume()
-{
- QVERIFY(radio->volume() == 100);
- QSignalSpy readSignal(radio, SIGNAL(volumeChanged(int)));
- radio->setVolume(50);
- QTestEventLoop::instance().enterLoop(1);
- QVERIFY(radio->volume() == 50);
- QVERIFY(readSignal.count() == 1);
-}
-
-void tst_QRadioTuner::testSignal()
-{
- QVERIFY(radio->signalStrength() == 0);
- // There is no set of this only a get, do nothing else.
-}
-
-void tst_QRadioTuner::testStereo()
-{
- /* no set function to toggle stereo status;
- cannot emit stereoStatusChanged() signal */
-
- QVERIFY(radio->isStereo());
- radio->setStereoMode(QRadioTuner::ForceMono);
- QVERIFY(radio->stereoMode() == QRadioTuner::ForceMono);
-}
-
-void tst_QRadioTuner::testSearchAllStations()
-{
- QSignalSpy foundSpy(radio, SIGNAL(stationFound(int,QString)));
- QSignalSpy completeSpy(radio, SIGNAL(searchingChanged(bool)));
- radio->searchAllStations(QRadioTuner::SearchGetStationId);
- QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(radio->frequency(), 103100000 );
- QCOMPARE(foundSpy.count(), 3);
- QVERIFY(qvariant_cast<int>(foundSpy.at(2).at(0)) == 103100000 );
- QVERIFY(qvariant_cast<QString>(foundSpy.at(2).at(1)) == QString("MockProgramPI3") );
- QCOMPARE(completeSpy.count(), 2);
-}
-
-// QRadioTuner's errorsignal
-void tst_QRadioTuner::errorSignal()
-{
- qRegisterMetaType<QRadioTuner::Error>("QRadioTuner::Error");
- QObject obj;
- MockRadioTunerControl dctrl(&obj);
- MockMediaService service(&obj, &dctrl);
- MockMediaServiceProvider provider(&service);
- QMediaServiceProvider::setDefaultServiceProvider(&provider);
- QRadioTuner radio;
- QSignalSpy spy(&radio, SIGNAL(error(QRadioTuner::Error)));
- QVERIFY(radio.service() != 0);
- QVERIFY(radio.isAvailable());
- radio.start();
- radio.setBand(QRadioTuner::FM);
- QVERIFY(spy.count() == 1);
- QVERIFY(qvariant_cast<QRadioTuner::Error>(spy.at(0).at(0)) == QRadioTuner::NoError);
- QVERIFY(radio.error() == QRadioTuner::NoError);
- QVERIFY(radio.error() != QRadioTuner::OpenError);
- QVERIFY(radio.errorString().isEmpty());
- spy.clear();
-
- /* emits QRadioTuner::OutOfRangeError if band is set to FM2 or LW
- and frequency set to >= 148500000 */
-
- radio.setBand(QRadioTuner::LW);
- radio.setBand(QRadioTuner::FM2);
- radio.setFrequency(148500000);
- QVERIFY(spy.count() == 3);
- QVERIFY(qvariant_cast<QRadioTuner::Error>(spy.at(0).at(0)) == QRadioTuner::OutOfRangeError);
- QVERIFY(qvariant_cast<QRadioTuner::Error>(spy.at(1).at(0)) == QRadioTuner::OutOfRangeError);
- QVERIFY(qvariant_cast<QRadioTuner::Error>(spy.at(2).at(0)) == QRadioTuner::OutOfRangeError);
- QVERIFY(radio.error() == QRadioTuner::OutOfRangeError);
- QVERIFY2(!radio.errorString().isEmpty(), "band and range not supported");
- spy.clear();
- radio.stop();
-}
-
-QTEST_GUILESS_MAIN(tst_QRadioTuner)
-#include "tst_qradiotuner.moc"