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#ifndef MOCKAUDIOINPUTSELECTOR_H
30#define MOCKAUDIOINPUTSELECTOR_H
31
32#include "qaudioinputselectorcontrol.h"
33
34class MockAudioInputSelector : public QAudioInputSelectorControl
35{
36 Q_OBJECT
37public:
38 MockAudioInputSelector(QObject *parent):
39 QAudioInputSelectorControl(parent)
40 {
41 m_names << "device1" << "device2" << "device3";
42 m_descriptions << "dev1 comment" << "dev2 comment" << "dev3 comment";
43 m_audioInput = "device1";
44 emit availableInputsChanged();
45 }
46 ~MockAudioInputSelector() {}
47
48 QList<QString> availableInputs() const
49 {
50 return m_names;
51 }
52
53 QString inputDescription(const QString& name) const
54 {
55 QString desc;
56
57 for (int i = 0; i < m_names.count(); i++) {
58 if (m_names.at(i).compare(s: name) == 0) {
59 desc = m_descriptions.at(i);
60 break;
61 }
62 }
63 return desc;
64 }
65
66 QString defaultInput() const
67 {
68 return m_names.at(i: 0);
69 }
70
71 QString activeInput() const
72 {
73 return m_audioInput;
74 }
75
76public Q_SLOTS:
77
78 void setActiveInput(const QString& name)
79 {
80 m_audioInput = name;
81 emit activeInputChanged(name);
82 }
83
84 void addInputs()
85 {
86 m_names << "device4";
87 emit availableInputsChanged();
88 }
89
90 void removeInputs()
91 {
92 m_names.clear();
93 emit availableInputsChanged();
94 }
95
96private:
97 QString m_audioInput;
98 QList<QString> m_names;
99 QList<QString> m_descriptions;
100};
101
102
103
104#endif // MOCKAUDIOINPUTSELECTOR_H
105

source code of qtmultimedia/tests/auto/unit/qmultimedia_common/mockaudioinputselector.h