| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the test suite of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | |
| 29 | //TESTED_COMPONENT=src/multimedia |
| 30 | |
| 31 | #include <QtTest/QtTest> |
| 32 | |
| 33 | #include <QtMultimedia/qaudio.h> |
| 34 | |
| 35 | // Adds an enum, and the stringized version |
| 36 | #define ADD_ENUM_TEST(x) \ |
| 37 | QTest::newRow(#x) \ |
| 38 | << QAudio::x \ |
| 39 | << QString(QLatin1String(#x)); |
| 40 | |
| 41 | class tst_QAudioNamespace : public QObject |
| 42 | { |
| 43 | Q_OBJECT |
| 44 | |
| 45 | private slots: |
| 46 | void debugError(); |
| 47 | void debugError_data(); |
| 48 | void debugState(); |
| 49 | void debugState_data(); |
| 50 | void debugMode(); |
| 51 | void debugMode_data(); |
| 52 | void debugVolumeScale(); |
| 53 | void debugVolumeScale_data(); |
| 54 | void convertVolume(); |
| 55 | void convertVolume_data(); |
| 56 | }; |
| 57 | |
| 58 | void tst_QAudioNamespace::debugError_data() |
| 59 | { |
| 60 | QTest::addColumn<QAudio::Error>(name: "error" ); |
| 61 | QTest::addColumn<QString>(name: "stringized" ); |
| 62 | |
| 63 | ADD_ENUM_TEST(NoError); |
| 64 | ADD_ENUM_TEST(OpenError); |
| 65 | ADD_ENUM_TEST(IOError); |
| 66 | ADD_ENUM_TEST(UnderrunError); |
| 67 | ADD_ENUM_TEST(FatalError); |
| 68 | } |
| 69 | |
| 70 | void tst_QAudioNamespace::debugError() |
| 71 | { |
| 72 | QFETCH(QAudio::Error, error); |
| 73 | QFETCH(QString, stringized); |
| 74 | |
| 75 | QTest::ignoreMessage(type: QtDebugMsg, message: stringized.toLatin1().constData()); |
| 76 | qDebug() << error; |
| 77 | } |
| 78 | |
| 79 | void tst_QAudioNamespace::debugState_data() |
| 80 | { |
| 81 | QTest::addColumn<QAudio::State>(name: "state" ); |
| 82 | QTest::addColumn<QString>(name: "stringized" ); |
| 83 | |
| 84 | ADD_ENUM_TEST(ActiveState); |
| 85 | ADD_ENUM_TEST(SuspendedState); |
| 86 | ADD_ENUM_TEST(StoppedState); |
| 87 | ADD_ENUM_TEST(IdleState); |
| 88 | } |
| 89 | |
| 90 | void tst_QAudioNamespace::debugState() |
| 91 | { |
| 92 | QFETCH(QAudio::State, state); |
| 93 | QFETCH(QString, stringized); |
| 94 | |
| 95 | QTest::ignoreMessage(type: QtDebugMsg, message: stringized.toLatin1().constData()); |
| 96 | qDebug() << state; |
| 97 | } |
| 98 | |
| 99 | void tst_QAudioNamespace::debugMode_data() |
| 100 | { |
| 101 | QTest::addColumn<QAudio::Mode>(name: "mode" ); |
| 102 | QTest::addColumn<QString>(name: "stringized" ); |
| 103 | |
| 104 | ADD_ENUM_TEST(AudioInput); |
| 105 | ADD_ENUM_TEST(AudioOutput); |
| 106 | } |
| 107 | |
| 108 | void tst_QAudioNamespace::debugMode() |
| 109 | { |
| 110 | QFETCH(QAudio::Mode, mode); |
| 111 | QFETCH(QString, stringized); |
| 112 | |
| 113 | QTest::ignoreMessage(type: QtDebugMsg, message: stringized.toLatin1().constData()); |
| 114 | qDebug() << mode; |
| 115 | } |
| 116 | |
| 117 | void tst_QAudioNamespace::debugVolumeScale_data() |
| 118 | { |
| 119 | QTest::addColumn<QAudio::VolumeScale>(name: "volumeScale" ); |
| 120 | QTest::addColumn<QString>(name: "stringized" ); |
| 121 | |
| 122 | ADD_ENUM_TEST(LinearVolumeScale); |
| 123 | ADD_ENUM_TEST(CubicVolumeScale); |
| 124 | ADD_ENUM_TEST(DecibelVolumeScale); |
| 125 | } |
| 126 | |
| 127 | void tst_QAudioNamespace::debugVolumeScale() |
| 128 | { |
| 129 | QFETCH(QAudio::VolumeScale, volumeScale); |
| 130 | QFETCH(QString, stringized); |
| 131 | |
| 132 | QTest::ignoreMessage(type: QtDebugMsg, message: stringized.toLatin1().constData()); |
| 133 | qDebug() << volumeScale; |
| 134 | } |
| 135 | |
| 136 | void tst_QAudioNamespace::convertVolume_data() |
| 137 | { |
| 138 | QTest::addColumn<qreal>(name: "input" ); |
| 139 | QTest::addColumn<QAudio::VolumeScale>(name: "from" ); |
| 140 | QTest::addColumn<QAudio::VolumeScale>(name: "to" ); |
| 141 | QTest::addColumn<qreal>(name: "expectedOutput" ); |
| 142 | |
| 143 | QTest::newRow(dataTag: "-1.0 from linear to linear" ) << qreal(-1.0) << QAudio::LinearVolumeScale << QAudio::LinearVolumeScale << qreal(0.0); |
| 144 | QTest::newRow(dataTag: "0.0 from linear to linear" ) << qreal(0.0) << QAudio::LinearVolumeScale << QAudio::LinearVolumeScale << qreal(0.0); |
| 145 | QTest::newRow(dataTag: "0.5 from linear to linear" ) << qreal(0.5) << QAudio::LinearVolumeScale << QAudio::LinearVolumeScale << qreal(0.5); |
| 146 | QTest::newRow(dataTag: "1.0 from linear to linear" ) << qreal(1.0) << QAudio::LinearVolumeScale << QAudio::LinearVolumeScale << qreal(1.0); |
| 147 | |
| 148 | QTest::newRow(dataTag: "-1.0 from linear to cubic" ) << qreal(-1.0) << QAudio::LinearVolumeScale << QAudio::CubicVolumeScale << qreal(0.0); |
| 149 | QTest::newRow(dataTag: "0.0 from linear to cubic" ) << qreal(0.0) << QAudio::LinearVolumeScale << QAudio::CubicVolumeScale << qreal(0.0); |
| 150 | QTest::newRow(dataTag: "0.33 from linear to cubic" ) << qreal(0.33) << QAudio::LinearVolumeScale << QAudio::CubicVolumeScale << qreal(0.69); |
| 151 | QTest::newRow(dataTag: "0.5 from linear to cubic" ) << qreal(0.5) << QAudio::LinearVolumeScale << QAudio::CubicVolumeScale << qreal(0.79); |
| 152 | QTest::newRow(dataTag: "0.72 from linear to cubic" ) << qreal(0.72) << QAudio::LinearVolumeScale << QAudio::CubicVolumeScale << qreal(0.89); |
| 153 | QTest::newRow(dataTag: "1.0 from linear to cubic" ) << qreal(1.0) << QAudio::LinearVolumeScale << QAudio::CubicVolumeScale << qreal(1.0); |
| 154 | |
| 155 | QTest::newRow(dataTag: "-1.0 from linear to logarithmic" ) << qreal(-1.0) << QAudio::LinearVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.0); |
| 156 | QTest::newRow(dataTag: "0.0 from linear to logarithmic" ) << qreal(0.0) << QAudio::LinearVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.0); |
| 157 | QTest::newRow(dataTag: "0.33 from linear to logarithmic" ) << qreal(0.33) << QAudio::LinearVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.78); |
| 158 | QTest::newRow(dataTag: "0.5 from linear to logarithmic" ) << qreal(0.5) << QAudio::LinearVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.9); |
| 159 | QTest::newRow(dataTag: "0.72 from linear to logarithmic" ) << qreal(0.72) << QAudio::LinearVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.96); |
| 160 | QTest::newRow(dataTag: "1.0 from linear to logarithmic" ) << qreal(1.0) << QAudio::LinearVolumeScale << QAudio::LogarithmicVolumeScale << qreal(1.0); |
| 161 | |
| 162 | QTest::newRow(dataTag: "-1.0 from linear to decibel" ) << qreal(-1.0) << QAudio::LinearVolumeScale << QAudio::DecibelVolumeScale << qreal(-200); |
| 163 | QTest::newRow(dataTag: "0.0 from linear to decibel" ) << qreal(0.0) << QAudio::LinearVolumeScale << QAudio::DecibelVolumeScale << qreal(-200); |
| 164 | QTest::newRow(dataTag: "0.33 from linear to decibel" ) << qreal(0.33) << QAudio::LinearVolumeScale << QAudio::DecibelVolumeScale << qreal(-9.63); |
| 165 | QTest::newRow(dataTag: "0.5 from linear to decibel" ) << qreal(0.5) << QAudio::LinearVolumeScale << QAudio::DecibelVolumeScale << qreal(-6.02); |
| 166 | QTest::newRow(dataTag: "0.72 from linear to decibel" ) << qreal(0.72) << QAudio::LinearVolumeScale << QAudio::DecibelVolumeScale << qreal(-2.85); |
| 167 | QTest::newRow(dataTag: "1.0 from linear to decibel" ) << qreal(1.0) << QAudio::LinearVolumeScale << QAudio::DecibelVolumeScale << qreal(0); |
| 168 | |
| 169 | QTest::newRow(dataTag: "-1.0 from cubic to linear" ) << qreal(-1.0) << QAudio::CubicVolumeScale << QAudio::LinearVolumeScale << qreal(0.0); |
| 170 | QTest::newRow(dataTag: "0.0 from cubic to linear" ) << qreal(0.0) << QAudio::CubicVolumeScale << QAudio::LinearVolumeScale << qreal(0.0); |
| 171 | QTest::newRow(dataTag: "0.33 from cubic to linear" ) << qreal(0.33) << QAudio::CubicVolumeScale << QAudio::LinearVolumeScale << qreal(0.04); |
| 172 | QTest::newRow(dataTag: "0.5 from cubic to linear" ) << qreal(0.5) << QAudio::CubicVolumeScale << QAudio::LinearVolumeScale << qreal(0.13); |
| 173 | QTest::newRow(dataTag: "0.72 from cubic to linear" ) << qreal(0.72) << QAudio::CubicVolumeScale << QAudio::LinearVolumeScale << qreal(0.37); |
| 174 | QTest::newRow(dataTag: "1.0 from cubic to linear" ) << qreal(1.0) << QAudio::CubicVolumeScale << QAudio::LinearVolumeScale << qreal(1.0); |
| 175 | |
| 176 | QTest::newRow(dataTag: "-1.0 from cubic to cubic" ) << qreal(-1.0) << QAudio::CubicVolumeScale << QAudio::CubicVolumeScale << qreal(0.0); |
| 177 | QTest::newRow(dataTag: "0.0 from cubic to cubic" ) << qreal(0.0) << QAudio::CubicVolumeScale << QAudio::CubicVolumeScale << qreal(0.0); |
| 178 | QTest::newRow(dataTag: "0.5 from cubic to cubic" ) << qreal(0.5) << QAudio::CubicVolumeScale << QAudio::CubicVolumeScale << qreal(0.5); |
| 179 | QTest::newRow(dataTag: "1.0 from cubic to cubic" ) << qreal(1.0) << QAudio::CubicVolumeScale << QAudio::CubicVolumeScale << qreal(1.0); |
| 180 | |
| 181 | QTest::newRow(dataTag: "-1.0 from cubic to logarithmic" ) << qreal(-1.0) << QAudio::CubicVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.0); |
| 182 | QTest::newRow(dataTag: "0.0 from cubic to logarithmic" ) << qreal(0.0) << QAudio::CubicVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.0); |
| 183 | QTest::newRow(dataTag: "0.33 from cubic to logarithmic" ) << qreal(0.33) << QAudio::CubicVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.15); |
| 184 | QTest::newRow(dataTag: "0.5 from cubic to logarithmic" ) << qreal(0.5) << QAudio::CubicVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.44); |
| 185 | QTest::newRow(dataTag: "0.72 from cubic to logarithmic" ) << qreal(0.72) << QAudio::CubicVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.82); |
| 186 | QTest::newRow(dataTag: "1.0 from cubic to logarithmic" ) << qreal(1.0) << QAudio::CubicVolumeScale << QAudio::LogarithmicVolumeScale << qreal(1.0); |
| 187 | |
| 188 | QTest::newRow(dataTag: "-1.0 from cubic to decibel" ) << qreal(-1.0) << QAudio::CubicVolumeScale << QAudio::DecibelVolumeScale << qreal(-200); |
| 189 | QTest::newRow(dataTag: "0.0 from cubic to decibel" ) << qreal(0.0) << QAudio::CubicVolumeScale << QAudio::DecibelVolumeScale << qreal(-200); |
| 190 | QTest::newRow(dataTag: "0.33 from cubic to decibel" ) << qreal(0.33) << QAudio::CubicVolumeScale << QAudio::DecibelVolumeScale << qreal(-28.89); |
| 191 | QTest::newRow(dataTag: "0.5 from cubic to decibel" ) << qreal(0.5) << QAudio::CubicVolumeScale << QAudio::DecibelVolumeScale << qreal(-18.06); |
| 192 | QTest::newRow(dataTag: "0.72 from cubic to decibel" ) << qreal(0.72) << QAudio::CubicVolumeScale << QAudio::DecibelVolumeScale << qreal(-8.56); |
| 193 | QTest::newRow(dataTag: "1.0 from cubic to decibel" ) << qreal(1.0) << QAudio::CubicVolumeScale << QAudio::DecibelVolumeScale << qreal(0); |
| 194 | |
| 195 | QTest::newRow(dataTag: "-1.0 from logarithmic to linear" ) << qreal(-1.0) << QAudio::LogarithmicVolumeScale << QAudio::LinearVolumeScale << qreal(0.0); |
| 196 | QTest::newRow(dataTag: "0.0 from logarithmic to linear" ) << qreal(0.0) << QAudio::LogarithmicVolumeScale << QAudio::LinearVolumeScale << qreal(0.0); |
| 197 | QTest::newRow(dataTag: "0.33 from logarithmic to linear" ) << qreal(0.33) << QAudio::LogarithmicVolumeScale << QAudio::LinearVolumeScale << qreal(0.09); |
| 198 | QTest::newRow(dataTag: "0.5 from logarithmic to linear" ) << qreal(0.5) << QAudio::LogarithmicVolumeScale << QAudio::LinearVolumeScale << qreal(0.15); |
| 199 | QTest::newRow(dataTag: "0.72 from logarithmic to linear" ) << qreal(0.72) << QAudio::LogarithmicVolumeScale << QAudio::LinearVolumeScale << qreal(0.28); |
| 200 | QTest::newRow(dataTag: "1.0 from logarithmic to linear" ) << qreal(1.0) << QAudio::LogarithmicVolumeScale << QAudio::LinearVolumeScale << qreal(1.0); |
| 201 | |
| 202 | QTest::newRow(dataTag: "-1.0 from logarithmic to cubic" ) << qreal(-1.0) << QAudio::LogarithmicVolumeScale << QAudio::CubicVolumeScale << qreal(0.0); |
| 203 | QTest::newRow(dataTag: "0.0 from logarithmic to cubic" ) << qreal(0.0) << QAudio::LogarithmicVolumeScale << QAudio::CubicVolumeScale << qreal(0.0); |
| 204 | QTest::newRow(dataTag: "0.33 from logarithmic to cubic" ) << qreal(0.33) << QAudio::LogarithmicVolumeScale << QAudio::CubicVolumeScale << qreal(0.44); |
| 205 | QTest::newRow(dataTag: "0.5 from logarithmic to cubic" ) << qreal(0.5) << QAudio::LogarithmicVolumeScale << QAudio::CubicVolumeScale << qreal(0.53); |
| 206 | QTest::newRow(dataTag: "0.72 from logarithmic to cubic" ) << qreal(0.72) << QAudio::LogarithmicVolumeScale << QAudio::CubicVolumeScale << qreal(0.65); |
| 207 | QTest::newRow(dataTag: "1.0 from logarithmic to cubic" ) << qreal(1.0) << QAudio::LogarithmicVolumeScale << QAudio::CubicVolumeScale << qreal(1.0); |
| 208 | |
| 209 | QTest::newRow(dataTag: "-1.0 from logarithmic to logarithmic" ) << qreal(-1.0) << QAudio::LogarithmicVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.0); |
| 210 | QTest::newRow(dataTag: "0.0 from logarithmic to logarithmic" ) << qreal(0.0) << QAudio::LogarithmicVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.0); |
| 211 | QTest::newRow(dataTag: "0.5 from logarithmic to logarithmic" ) << qreal(0.5) << QAudio::LogarithmicVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.5); |
| 212 | QTest::newRow(dataTag: "1.0 from logarithmic to logarithmic" ) << qreal(1.0) << QAudio::LogarithmicVolumeScale << QAudio::LogarithmicVolumeScale << qreal(1.0); |
| 213 | |
| 214 | QTest::newRow(dataTag: "-1.0 from logarithmic to decibel" ) << qreal(-1.0) << QAudio::LogarithmicVolumeScale << QAudio::DecibelVolumeScale << qreal(-200); |
| 215 | QTest::newRow(dataTag: "0.0 from logarithmic to decibel" ) << qreal(0.0) << QAudio::LogarithmicVolumeScale << QAudio::DecibelVolumeScale << qreal(-200); |
| 216 | QTest::newRow(dataTag: "0.33 from logarithmic to decibel" ) << qreal(0.33) << QAudio::LogarithmicVolumeScale << QAudio::DecibelVolumeScale << qreal(-21.21); |
| 217 | QTest::newRow(dataTag: "0.5 from logarithmic to decibel" ) << qreal(0.5) << QAudio::LogarithmicVolumeScale << QAudio::DecibelVolumeScale << qreal(-16.45); |
| 218 | QTest::newRow(dataTag: "0.72 from logarithmic to decibel" ) << qreal(0.72) << QAudio::LogarithmicVolumeScale << QAudio::DecibelVolumeScale << qreal(-11.17); |
| 219 | QTest::newRow(dataTag: "1.0 from logarithmic to decibel" ) << qreal(1.0) << QAudio::LogarithmicVolumeScale << QAudio::DecibelVolumeScale << qreal(0); |
| 220 | |
| 221 | QTest::newRow(dataTag: "-1000 from decibel to linear" ) << qreal(-1000.0) << QAudio::DecibelVolumeScale << QAudio::LinearVolumeScale << qreal(0.0); |
| 222 | QTest::newRow(dataTag: "-200 from decibel to linear" ) << qreal(-200.0) << QAudio::DecibelVolumeScale << QAudio::LinearVolumeScale << qreal(0.0); |
| 223 | QTest::newRow(dataTag: "-40 from decibel to linear" ) << qreal(-40.0) << QAudio::DecibelVolumeScale << QAudio::LinearVolumeScale << qreal(0.01); |
| 224 | QTest::newRow(dataTag: "-10 from decibel to linear" ) << qreal(-10.0) << QAudio::DecibelVolumeScale << QAudio::LinearVolumeScale << qreal(0.32); |
| 225 | QTest::newRow(dataTag: "-5 from decibel to linear" ) << qreal(-5.0) << QAudio::DecibelVolumeScale << QAudio::LinearVolumeScale << qreal(0.56); |
| 226 | QTest::newRow(dataTag: "0 from decibel to linear" ) << qreal(0.0) << QAudio::DecibelVolumeScale << QAudio::LinearVolumeScale << qreal(1.0); |
| 227 | |
| 228 | QTest::newRow(dataTag: "-1000 from decibel to cubic" ) << qreal(-1000.0) << QAudio::DecibelVolumeScale << QAudio::CubicVolumeScale << qreal(0.0); |
| 229 | QTest::newRow(dataTag: "-200 from decibel to cubic" ) << qreal(-200.0) << QAudio::DecibelVolumeScale << QAudio::CubicVolumeScale << qreal(0.0); |
| 230 | QTest::newRow(dataTag: "-40 from decibel to cubic" ) << qreal(-40.0) << QAudio::DecibelVolumeScale << QAudio::CubicVolumeScale << qreal(0.22); |
| 231 | QTest::newRow(dataTag: "-10 from decibel to cubic" ) << qreal(-10.0) << QAudio::DecibelVolumeScale << QAudio::CubicVolumeScale << qreal(0.68); |
| 232 | QTest::newRow(dataTag: "-5 from decibel to cubic" ) << qreal(-5.0) << QAudio::DecibelVolumeScale << QAudio::CubicVolumeScale << qreal(0.83); |
| 233 | QTest::newRow(dataTag: "0 from decibel to cubic" ) << qreal(0.0) << QAudio::DecibelVolumeScale << QAudio::CubicVolumeScale << qreal(1.0); |
| 234 | |
| 235 | QTest::newRow(dataTag: "-1000 from decibel to logarithmic" ) << qreal(-1000.0) << QAudio::DecibelVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.0); |
| 236 | QTest::newRow(dataTag: "-200 from decibel to logarithmic" ) << qreal(-200.0) << QAudio::DecibelVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.0); |
| 237 | QTest::newRow(dataTag: "-40 from decibel to logarithmic" ) << qreal(-40.0) << QAudio::DecibelVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.05); |
| 238 | QTest::newRow(dataTag: "-10 from decibel to logarithmic" ) << qreal(-10.0) << QAudio::DecibelVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.77); |
| 239 | QTest::newRow(dataTag: "-5 from decibel to logarithmic" ) << qreal(-5.0) << QAudio::DecibelVolumeScale << QAudio::LogarithmicVolumeScale << qreal(0.92); |
| 240 | QTest::newRow(dataTag: "0 from decibel to logarithmic" ) << qreal(0.0) << QAudio::DecibelVolumeScale << QAudio::LogarithmicVolumeScale << qreal(1.0); |
| 241 | |
| 242 | QTest::newRow(dataTag: "-1000 from decibel to decibel" ) << qreal(-1000.0) << QAudio::DecibelVolumeScale << QAudio::DecibelVolumeScale << qreal(-1000.0); |
| 243 | QTest::newRow(dataTag: "-200 from decibel to decibel" ) << qreal(-200.0) << QAudio::DecibelVolumeScale << QAudio::DecibelVolumeScale << qreal(-200.0); |
| 244 | QTest::newRow(dataTag: "-30 from decibel to decibel" ) << qreal(-30.0) << QAudio::DecibelVolumeScale << QAudio::DecibelVolumeScale << qreal(-30.0); |
| 245 | QTest::newRow(dataTag: "0 from decibel to decibel" ) << qreal(0.0) << QAudio::DecibelVolumeScale << QAudio::DecibelVolumeScale << qreal(0.0); |
| 246 | } |
| 247 | |
| 248 | void tst_QAudioNamespace::convertVolume() |
| 249 | { |
| 250 | QFETCH(qreal, input); |
| 251 | QFETCH(QAudio::VolumeScale, from); |
| 252 | QFETCH(QAudio::VolumeScale, to); |
| 253 | QFETCH(qreal, expectedOutput); |
| 254 | |
| 255 | qreal actualOutput = QAudio::convertVolume(volume: input, from, to); |
| 256 | QVERIFY2(qAbs(actualOutput - expectedOutput) < 0.01, |
| 257 | QString("actual: %1, expected: %2" ).arg(actualOutput).arg(expectedOutput).toLocal8Bit().constData()); |
| 258 | } |
| 259 | |
| 260 | QTEST_MAIN(tst_QAudioNamespace) |
| 261 | |
| 262 | #include "tst_qaudionamespace.moc" |
| 263 | |