|
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 Qt Mobility Components. |
|
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 #include "tst_qmediarecorder_xa.h" |
|
43 #include "tst_qmediarecorder_xa_macros.h" |
|
44 |
|
45 void tst_QMediaRecorder::initTestCase() |
|
46 { |
|
47 qRegisterMetaType<QMediaRecorder::State>("QMediaRecorder::State"); |
|
48 qRegisterMetaType<QMediaRecorder::Error>("QMediaRecorder::Error"); |
|
49 |
|
50 captureSource = new QAudioCaptureSource; |
|
51 audiocapture = new QMediaRecorder(captureSource); |
|
52 |
|
53 //FIXME audioEndpoint = qobject_cast<QAudioEndpointSelector*>(audiocapture->service()->requestControl(QAudioEndpointSelector_iid)); |
|
54 //FIXME audioEncoder = qobject_cast<QAudioEncoderControl*>(audiocapture->service()->requestControl(QAudioEncoderControl_iid)); |
|
55 } |
|
56 |
|
57 void tst_QMediaRecorder::cleanupTestCase() |
|
58 { |
|
59 delete audiocapture; |
|
60 delete captureSource; |
|
61 } |
|
62 |
|
63 void tst_QMediaRecorder::testMediaRecorderObject() |
|
64 { |
|
65 //audioocontainer types |
|
66 QCOMPARE(audiocapture->audioCodecDescription("pcm"), QString("pcm")); |
|
67 QCOMPARE(audiocapture->audioCodecDescription("amr"), QString("amr")); |
|
68 QCOMPARE(audiocapture->audioCodecDescription("aac"), QString("aac")); |
|
69 QCOMPARE(audiocapture->containerDescription("audio/wav"), QString("wav container")); |
|
70 QCOMPARE(audiocapture->containerDescription("audio/amr"), QString("amr File format")); |
|
71 QCOMPARE(audiocapture->containerDescription("audio/mpeg"), QString("mpeg container")); |
|
72 QCOMPARE(audiocapture->containerMimeType(), QString("audio/wav")); |
|
73 QCOMPARE(audiocapture->error(), QMediaRecorder::NoError); |
|
74 QCOMPARE(audiocapture->errorString(), QString()); |
|
75 QCOMPARE(audiocapture->outputLocation().toLocalFile(), QString()); |
|
76 QCOMPARE(audiocapture->state(), QMediaRecorder::StoppedState); |
|
77 QCOMPARE(audiocapture->supportedAudioCodecs().count(), 3); // "pcm", "amr", "aac"); |
|
78 QAudioEncoderSettings settings; |
|
79 settings.setCodec("pcm"); |
|
80 QCOMPARE(audiocapture->supportedAudioSampleRates(settings).count(), 12); |
|
81 bool isContinuous; |
|
82 audiocapture->supportedAudioSampleRates(settings, &isContinuous); |
|
83 QCOMPARE(isContinuous, false); |
|
84 QCOMPARE(audiocapture->supportedContainers().count(), 3); // "audio/wav", "audio/amr", "audio/mpeg"); |
|
85 } |
|
86 |
|
87 void tst_QMediaRecorder::testAudioSink() |
|
88 { |
|
89 audiocapture->setOutputLocation(QUrl("test.wav")); |
|
90 QUrl s = audiocapture->outputLocation(); |
|
91 QCOMPARE(s.toString(), QString("test.wav")); |
|
92 } |
|
93 |
|
94 void tst_QMediaRecorder::testAudioEndPointSelector() |
|
95 { |
|
96 QSignalSpy audioSignal(audioEndpoint,SIGNAL(activeEndpointChanged(QString))); |
|
97 QVERIFY(audioEndpoint->availableEndpoints().count() == 1); |
|
98 QVERIFY(audioEndpoint->defaultEndpoint().compare("Default Mic") == 0); |
|
99 audioEndpoint->setActiveEndpoint("Default Mic"); |
|
100 QVERIFY(audioEndpoint->activeEndpoint().compare("Default Mic") == 0); |
|
101 QVERIFY(audioSignal.count() == 1); |
|
102 QVERIFY(audioEndpoint->endpointDescription("Default Mic").compare("Default Mic") == 0); |
|
103 } |
|
104 |
|
105 void tst_QMediaRecorder::testDefaultAudioEncodingSettings() |
|
106 { |
|
107 QAudioEncoderSettings audioSettings = audiocapture->audioSettings(); |
|
108 QCOMPARE(audioSettings.codec(), QString("pcm")); |
|
109 QCOMPARE(audiocapture->containerMimeType(), QString("audio/wav")); |
|
110 QCOMPARE(audioSettings.bitRate(), 0); |
|
111 QCOMPARE(audioSettings.channelCount(), 1); |
|
112 QCOMPARE(audioSettings.encodingMode(), QtMultimedia::ConstantQualityEncoding); |
|
113 QCOMPARE(audioSettings.quality(), QtMultimedia::VeryLowQuality); |
|
114 QCOMPARE(audioSettings.sampleRate(), 8000); |
|
115 } |
|
116 |
|
117 QUrl tst_QMediaRecorder::nextFileName(QDir outputDir, QString appendName, QString ext) |
|
118 { |
|
119 int lastImage = 0; |
|
120 int fileCount = 0; |
|
121 foreach( QString fileName, outputDir.entryList(QStringList() << "testclip_*." + ext) ) { |
|
122 int imgNumber = fileName.mid(5, fileName.size()-9).toInt(); |
|
123 lastImage = qMax(lastImage, imgNumber); |
|
124 if (outputDir.exists(fileName)) |
|
125 fileCount+=1; |
|
126 } |
|
127 lastImage+=fileCount; |
|
128 |
|
129 QUrl location(QDir::toNativeSeparators(outputDir.canonicalPath() + QString("/testclip_%1").arg(lastImage+1 , 4, 10, QLatin1Char('0')) + appendName + "." + ext)); |
|
130 return location; |
|
131 } |
|
132 |
|
133 QTEST_MAIN_S60(tst_QMediaRecorder) |
|
134 |
|
135 #include "moc_tst_qmediarecorder_xa.cpp" |