diff options
Diffstat (limited to 'tests/auto/integration/qaudiodevice/tst_qaudiodevice.cpp')
-rw-r--r-- | tests/auto/integration/qaudiodevice/tst_qaudiodevice.cpp | 49 |
1 files changed, 10 insertions, 39 deletions
diff --git a/tests/auto/integration/qaudiodevice/tst_qaudiodevice.cpp b/tests/auto/integration/qaudiodevice/tst_qaudiodevice.cpp index af48c4f3a..cd686bd08 100644 --- a/tests/auto/integration/qaudiodevice/tst_qaudiodevice.cpp +++ b/tests/auto/integration/qaudiodevice/tst_qaudiodevice.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtTest/QtTest> @@ -35,8 +10,6 @@ #include <QList> #include <QMediaDevices> -//TESTED_COMPONENT=src/multimedia - class tst_QAudioDevice : public QObject { Q_OBJECT @@ -45,7 +18,6 @@ public: private slots: void initTestCase(); - void cleanupTestCase(); void checkAvailableDefaultInput(); void checkAvailableDefaultOutput(); void channels(); @@ -59,7 +31,7 @@ private slots: void equalityOperator(); private: - QAudioDevice* device; + std::unique_ptr<QAudioDevice> device; }; void tst_QAudioDevice::initTestCase() @@ -69,21 +41,18 @@ void tst_QAudioDevice::initTestCase() if (devices.size() == 0) { QSKIP("NOTE: no audio output device found, no tests will be performed"); } else { - device = new QAudioDevice(devices.at(0)); + device = std::make_unique<QAudioDevice>(devices.at(0)); } } -void tst_QAudioDevice::cleanupTestCase() -{ - delete device; -} - void tst_QAudioDevice::checkAvailableDefaultInput() { // Only perform tests if audio input device exists! QList<QAudioDevice> devices = QMediaDevices::audioInputs(); if (devices.size() > 0) { - QVERIFY(!QMediaDevices::defaultAudioInput().isNull()); + auto defaultInput = QMediaDevices::defaultAudioInput(); + QVERIFY(!defaultInput.isNull()); + QCOMPARE(std::count(devices.begin(), devices.end(), defaultInput), 1); } } @@ -92,7 +61,9 @@ void tst_QAudioDevice::checkAvailableDefaultOutput() // Only perform tests if audio input device exists! QList<QAudioDevice> devices = QMediaDevices::audioOutputs(); if (devices.size() > 0) { - QVERIFY(!QMediaDevices::defaultAudioOutput().isNull()); + auto defaultOutput = QMediaDevices::defaultAudioOutput(); + QVERIFY(!defaultOutput.isNull()); + QCOMPARE(std::count(devices.begin(), devices.end(), defaultOutput), 1); } } |