summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>2012-01-31 10:08:49 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-01 08:10:20 +0100
commita22a0195f146e83174ee4eacffe33c161ab39e50 (patch)
treeecc72efc2790bce4238c8c1c9df223f54c0b3651 /tests/auto
parent9d3102efe29e294971b30aa2ce00be5cb7db5e05 (diff)
Split QMediaRecorder::setEncodingSettings to separate setters.
It's easier to change only the necessary part of encoding settings. The settings are applied during the next event loop or before recording starts. Change-Id: Ia2b5c93826a302212aa7f79a0c75e4cbaaf1dd7a Reviewed-by: Ling Hu <ling.hu@nokia.com> Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/unit/qmediacontainercontrol/tst_qmediacontainercontrol.cpp4
-rw-r--r--tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp56
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h4
-rw-r--r--tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h15
4 files changed, 65 insertions, 14 deletions
diff --git a/tests/auto/unit/qmediacontainercontrol/tst_qmediacontainercontrol.cpp b/tests/auto/unit/qmediacontainercontrol/tst_qmediacontainercontrol.cpp
index 96b71ac98..8eb59ad74 100644
--- a/tests/auto/unit/qmediacontainercontrol/tst_qmediacontainercontrol.cpp
+++ b/tests/auto/unit/qmediacontainercontrol/tst_qmediacontainercontrol.cpp
@@ -66,9 +66,9 @@ private slots:
QVERIFY(strlist[1]==strlist1[1]); //checking with "mp3" mime type
QVERIFY(strlist[2]==strlist1[2]); //checking with "mov" mime type
- control.setContainerMimeType("wav");
+ control.setContainerFormat("wav");
const QString str("wav");
- QVERIFY2(control.containerMimeType() == str,"Failed");
+ QVERIFY2(control.containerFormat() == str,"Failed");
const QString str1("WAV format");
QVERIFY2(control.containerDescription("wav") == str1,"FAILED");
diff --git a/tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp b/tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp
index f252aa4c8..550809ec7 100644
--- a/tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp
+++ b/tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp
@@ -83,6 +83,7 @@ private slots:
void testEncodingSettings();
void testAudioSettings();
void testVideoSettings();
+ void testSettingsApplied();
void nullMetaDataControl();
void isMetaDataAvailable();
@@ -171,7 +172,7 @@ void tst_QMediaRecorder::testNullService()
QCOMPARE(continuous, false);
QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
- QCOMPARE(recorder.containerMimeType(), QString());
+ QCOMPARE(recorder.containerFormat(), QString());
QVERIFY(!recorder.isMuted());
recorder.setMuted(true);
QVERIFY(!recorder.isMuted());
@@ -205,7 +206,7 @@ void tst_QMediaRecorder::testNullControls()
QCOMPARE(continuous, false);
QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
- QCOMPARE(recorder.containerMimeType(), QString());
+ QCOMPARE(recorder.containerFormat(), QString());
recorder.setOutputLocation(QUrl("file://test/save/file.mp4"));
QCOMPARE(recorder.outputLocation(), QUrl());
@@ -222,7 +223,7 @@ void tst_QMediaRecorder::testNullControls()
QCOMPARE(recorder.audioSettings(), QAudioEncoderSettings());
QCOMPARE(recorder.videoSettings(), QVideoEncoderSettings());
- QCOMPARE(recorder.containerMimeType(), QString());
+ QCOMPARE(recorder.containerFormat(), QString());
QSignalSpy spy(&recorder, SIGNAL(stateChanged(QMediaRecorder::State)));
@@ -410,7 +411,7 @@ void tst_QMediaRecorder::testEncodingSettings()
QCOMPARE(videoSettings.quality(), QtMultimedia::NormalQuality);
QCOMPARE(videoSettings.encodingMode(), QtMultimedia::ConstantQualityEncoding);
- QString format = capture->containerMimeType();
+ QString format = capture->containerFormat();
QCOMPARE(format, QString());
audioSettings.setCodec("audio/mpeg");
@@ -428,11 +429,13 @@ void tst_QMediaRecorder::testEncodingSettings()
format = QString("mov");
- capture->setEncodingSettings(audioSettings,videoSettings,format);
+ capture->setAudioSettings(audioSettings);
+ capture->setVideoSettings(videoSettings);
+ capture->setContainerFormat(format);
QCOMPARE(capture->audioSettings(), audioSettings);
QCOMPARE(capture->videoSettings(), videoSettings);
- QCOMPARE(capture->containerMimeType(), format);
+ QCOMPARE(capture->containerFormat(), format);
}
void tst_QMediaRecorder::testAudioSettings()
@@ -688,6 +691,47 @@ void tst_QMediaRecorder::testVideoSettings()
QVERIFY(settings1 != settings2);
}
+void tst_QMediaRecorder::testSettingsApplied()
+{
+ MockMediaRecorderControl recorderControl(0);
+ MockMediaRecorderService service(0, &recorderControl);
+ MockMediaObject object(0, &service);
+
+ //if the media recorder is not configured after construction
+ //the settings are applied in the next event loop
+ QMediaRecorder recorder(&object);
+ QCOMPARE(recorderControl.m_settingAppliedCount, 0);
+ QTest::qWait(10);
+ QCOMPARE(recorderControl.m_settingAppliedCount, 1);
+
+ QVideoEncoderSettings videoSettings;
+ videoSettings.setResolution(640,480);
+ recorder.setVideoSettings(videoSettings);
+
+ QAudioEncoderSettings audioSettings;
+ audioSettings.setQuality(QtMultimedia::HighQuality);
+ recorder.setAudioSettings(audioSettings);
+
+ recorder.setContainerFormat("mkv");
+
+ QCOMPARE(recorderControl.m_settingAppliedCount, 1);
+ QTest::qWait(10);
+ QCOMPARE(recorderControl.m_settingAppliedCount, 2);
+
+ //encoder settings are applied before recording if changed
+ audioSettings.setQuality(QtMultimedia::VeryHighQuality);
+ recorder.setAudioSettings(audioSettings);
+
+ QCOMPARE(recorderControl.m_settingAppliedCount, 2);
+ recorder.record();
+ QCOMPARE(recorderControl.m_settingAppliedCount, 3);
+
+ recorder.stop();
+
+ //applySettings is not called if setting has not changes
+ recorder.record();
+ QCOMPARE(recorderControl.m_settingAppliedCount, 3);
+}
void tst_QMediaRecorder::nullMetaDataControl()
{
diff --git a/tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h b/tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h
index 0864310bf..9c0167177 100644
--- a/tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h
+++ b/tests/auto/unit/qmultimedia_common/mockmediacontainercontrol.h
@@ -72,12 +72,12 @@ public:
return m_supportedContainers;
}
- QString containerMimeType() const
+ QString containerFormat() const
{
return m_format;
}
- void setContainerMimeType(const QString &formatMimeType)
+ void setContainerFormat(const QString &formatMimeType)
{
if (m_supportedContainers.contains(formatMimeType))
m_format = formatMimeType;
diff --git a/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h b/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h
index eb414f29b..577d09b29 100644
--- a/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h
+++ b/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h
@@ -53,9 +53,12 @@ class MockMediaRecorderControl : public QMediaRecorderControl
public:
MockMediaRecorderControl(QObject *parent = 0):
QMediaRecorderControl(parent),
- m_state(QMediaRecorder::StoppedState),
- m_position(0),
- m_muted(false) {}
+ m_state(QMediaRecorder::StoppedState),
+ m_position(0),
+ m_muted(false),
+ m_settingAppliedCount(0)
+ {
+ }
QUrl outputLocation() const
{
@@ -83,7 +86,10 @@ public:
return m_muted;
}
- void applySettings() {}
+ void applySettings()
+ {
+ m_settingAppliedCount++;
+ }
using QMediaRecorderControl::error;
@@ -120,6 +126,7 @@ public:
QMediaRecorder::State m_state;
qint64 m_position;
bool m_muted;
+ int m_settingAppliedCount;
};
#endif // MOCKRECORDERCONTROL_H