|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the test suite of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 |
|
43 #include <QtTest/QtTest> |
|
44 #include <QtCore/qlocale.h> |
|
45 #include <qaudioformat.h> |
|
46 |
|
47 #include <QStringList> |
|
48 #include <QList> |
|
49 |
|
50 |
|
51 class tst_QAudioFormat : public QObject |
|
52 { |
|
53 Q_OBJECT |
|
54 |
|
55 public: |
|
56 tst_QAudioFormat(QObject* parent=0) : QObject(parent) {} |
|
57 |
|
58 private slots: |
|
59 void checkNull(); |
|
60 void checkFrequency(); |
|
61 void checkChannels(); |
|
62 void checkSampleSize(); |
|
63 void checkCodec(); |
|
64 void checkByteOrder(); |
|
65 void checkSampleType(); |
|
66 void checkEquality(); |
|
67 void checkAssignment(); |
|
68 }; |
|
69 |
|
70 void tst_QAudioFormat::checkNull() |
|
71 { |
|
72 // Default constructed QAudioFormat is null. |
|
73 QAudioFormat audioFormat0; |
|
74 QVERIFY(audioFormat0.isNull()); |
|
75 |
|
76 // Null is transferred |
|
77 QAudioFormat audioFormat1(audioFormat0); |
|
78 QVERIFY(audioFormat1.isNull()); |
|
79 |
|
80 // Null is voided on activity |
|
81 audioFormat0.setFrequency(44100); |
|
82 QVERIFY(!audioFormat0.isNull()); |
|
83 } |
|
84 |
|
85 void tst_QAudioFormat::checkFrequency() |
|
86 { |
|
87 QAudioFormat audioFormat; |
|
88 audioFormat.setFrequency(44100); |
|
89 QVERIFY(audioFormat.frequency() == 44100); |
|
90 } |
|
91 |
|
92 void tst_QAudioFormat::checkChannels() |
|
93 { |
|
94 QAudioFormat audioFormat; |
|
95 audioFormat.setChannels(2); |
|
96 QVERIFY(audioFormat.channels() == 2); |
|
97 } |
|
98 |
|
99 void tst_QAudioFormat::checkSampleSize() |
|
100 { |
|
101 QAudioFormat audioFormat; |
|
102 audioFormat.setSampleSize(16); |
|
103 QVERIFY(audioFormat.sampleSize() == 16); |
|
104 } |
|
105 |
|
106 void tst_QAudioFormat::checkCodec() |
|
107 { |
|
108 QAudioFormat audioFormat; |
|
109 audioFormat.setCodec(QString::fromLatin1("audio/pcm")); |
|
110 QVERIFY(audioFormat.codec() == QString::fromLatin1("audio/pcm")); |
|
111 } |
|
112 |
|
113 void tst_QAudioFormat::checkByteOrder() |
|
114 { |
|
115 QAudioFormat audioFormat; |
|
116 audioFormat.setByteOrder(QAudioFormat::LittleEndian); |
|
117 QVERIFY(audioFormat.byteOrder() == QAudioFormat::LittleEndian); |
|
118 } |
|
119 |
|
120 void tst_QAudioFormat::checkSampleType() |
|
121 { |
|
122 QAudioFormat audioFormat; |
|
123 audioFormat.setSampleType(QAudioFormat::SignedInt); |
|
124 QVERIFY(audioFormat.sampleType() == QAudioFormat::SignedInt); |
|
125 } |
|
126 |
|
127 void tst_QAudioFormat::checkEquality() |
|
128 { |
|
129 QAudioFormat audioFormat0; |
|
130 QAudioFormat audioFormat1; |
|
131 |
|
132 // Null formats are equivalent |
|
133 QVERIFY(audioFormat0 == audioFormat1); |
|
134 QVERIFY(!(audioFormat0 != audioFormat1)); |
|
135 |
|
136 // on filled formats |
|
137 audioFormat0.setFrequency(8000); |
|
138 audioFormat0.setChannels(1); |
|
139 audioFormat0.setSampleSize(8); |
|
140 audioFormat0.setCodec("audio/pcm"); |
|
141 audioFormat0.setByteOrder(QAudioFormat::LittleEndian); |
|
142 audioFormat0.setSampleType(QAudioFormat::UnSignedInt); |
|
143 |
|
144 audioFormat1.setFrequency(8000); |
|
145 audioFormat1.setChannels(1); |
|
146 audioFormat1.setSampleSize(8); |
|
147 audioFormat1.setCodec("audio/pcm"); |
|
148 audioFormat1.setByteOrder(QAudioFormat::LittleEndian); |
|
149 audioFormat1.setSampleType(QAudioFormat::UnSignedInt); |
|
150 |
|
151 QVERIFY(audioFormat0 == audioFormat1); |
|
152 QVERIFY(!(audioFormat0 != audioFormat1)); |
|
153 |
|
154 audioFormat0.setFrequency(44100); |
|
155 QVERIFY(audioFormat0 != audioFormat1); |
|
156 QVERIFY(!(audioFormat0 == audioFormat1)); |
|
157 } |
|
158 |
|
159 void tst_QAudioFormat::checkAssignment() |
|
160 { |
|
161 QAudioFormat audioFormat0; |
|
162 QAudioFormat audioFormat1; |
|
163 |
|
164 audioFormat0.setFrequency(8000); |
|
165 audioFormat0.setChannels(1); |
|
166 audioFormat0.setSampleSize(8); |
|
167 audioFormat0.setCodec("audio/pcm"); |
|
168 audioFormat0.setByteOrder(QAudioFormat::LittleEndian); |
|
169 audioFormat0.setSampleType(QAudioFormat::UnSignedInt); |
|
170 |
|
171 audioFormat1 = audioFormat0; |
|
172 QVERIFY(audioFormat1 == audioFormat0); |
|
173 |
|
174 QAudioFormat audioFormat2(audioFormat0); |
|
175 QVERIFY(audioFormat2 == audioFormat0); |
|
176 } |
|
177 |
|
178 QTEST_MAIN(tst_QAudioFormat) |
|
179 |
|
180 #include "tst_qaudioformat.moc" |