diff options
author | Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com> | 2012-05-01 13:10:33 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-02 03:15:01 +0200 |
commit | b7935a84d71b479f5320e5b062274d344835ba26 (patch) | |
tree | e72ac1774590d91f621ed9b21cf0c0ab2c87903b /tests/auto/unit | |
parent | af932e8653b024c93ed49ba30d6f06839ecfced6 (diff) | |
download | qtmultimedia-b7935a84d71b479f5320e5b062274d344835ba26.tar.gz |
Added QMediaRecorder::status property
QMediaRecorder::state property represents the user request and
changed synchronously during record(), pause() or stop() calls.
Recorder status is changed asynchronously
and represents the actual status of media recorder.
This also makes API more consistent with QMediaPlayer and QCamera.
Change-Id: I80b4aaa70bb88e555c492908da8c29d0fc5ed5ea
Reviewed-by: Ling Hu <ling.hu@nokia.com>
Diffstat (limited to 'tests/auto/unit')
-rw-r--r-- | tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp | 32 | ||||
-rw-r--r-- | tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h | 13 |
2 files changed, 41 insertions, 4 deletions
diff --git a/tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp b/tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp index b26164d0c..aad7b873d 100644 --- a/tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp +++ b/tests/auto/unit/qmediarecorder/tst_qmediarecorder.cpp @@ -307,26 +307,50 @@ void tst_QMediaRecorder::testSink() void tst_QMediaRecorder::testRecord() { QSignalSpy stateSignal(capture,SIGNAL(stateChanged(QMediaRecorder::State))); + QSignalSpy statusSignal(capture,SIGNAL(statusChanged(QMediaRecorder::Status))); QSignalSpy progressSignal(capture, SIGNAL(durationChanged(qint64))); capture->record(); QCOMPARE(capture->state(), QMediaRecorder::RecordingState); QCOMPARE(capture->error(), QMediaRecorder::NoError); QCOMPARE(capture->errorString(), QString()); - QTestEventLoop::instance().enterLoop(1); + QCOMPARE(stateSignal.count(), 1); QCOMPARE(stateSignal.last()[0].value<QMediaRecorder::State>(), QMediaRecorder::RecordingState); + + QTestEventLoop::instance().enterLoop(1); + + QCOMPARE(capture->status(), QMediaRecorder::RecordingStatus); + QVERIFY(!statusSignal.isEmpty()); + QCOMPARE(statusSignal.last()[0].value<QMediaRecorder::Status>(), QMediaRecorder::RecordingStatus); + statusSignal.clear(); + QVERIFY(progressSignal.count() > 0); + capture->pause(); + QCOMPARE(capture->state(), QMediaRecorder::PausedState); - QTestEventLoop::instance().enterLoop(1); + QCOMPARE(stateSignal.count(), 2); + + QTestEventLoop::instance().enterLoop(1); + QCOMPARE(capture->status(), QMediaRecorder::PausedStatus); + QVERIFY(!statusSignal.isEmpty()); + QCOMPARE(statusSignal.last()[0].value<QMediaRecorder::Status>(), QMediaRecorder::PausedStatus); + statusSignal.clear(); + capture->stop(); + QCOMPARE(capture->state(), QMediaRecorder::StoppedState); - QTestEventLoop::instance().enterLoop(1); QCOMPARE(stateSignal.count(), 3); + + QTestEventLoop::instance().enterLoop(1); + QCOMPARE(capture->status(), QMediaRecorder::LoadedStatus); + QVERIFY(!statusSignal.isEmpty()); + QCOMPARE(statusSignal.last()[0].value<QMediaRecorder::Status>(), QMediaRecorder::LoadedStatus); + statusSignal.clear(); + mock->stop(); QCOMPARE(stateSignal.count(), 3); - } void tst_QMediaRecorder::testMute() diff --git a/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h b/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h index 3f622fe61..68723a714 100644 --- a/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h +++ b/tests/auto/unit/qmultimedia_common/mockmediarecordercontrol.h @@ -54,6 +54,7 @@ public: MockMediaRecorderControl(QObject *parent = 0): QMediaRecorderControl(parent), m_state(QMediaRecorder::StoppedState), + m_status(QMediaRecorder::LoadedStatus), m_position(0), m_muted(false), m_settingAppliedCount(0) @@ -76,6 +77,11 @@ public: return m_state; } + QMediaRecorder::Status status() const + { + return m_status; + } + qint64 duration() const { return m_position; @@ -97,8 +103,10 @@ public slots: void record() { m_state = QMediaRecorder::RecordingState; + m_status = QMediaRecorder::RecordingStatus; m_position=1; emit stateChanged(m_state); + emit statusChanged(m_status); emit durationChanged(m_position); QUrl actualLocation = m_sink.isEmpty() ? QUrl::fromLocalFile("default_name.mp4") : m_sink; @@ -108,14 +116,18 @@ public slots: void pause() { m_state = QMediaRecorder::PausedState; + m_status = QMediaRecorder::PausedStatus; emit stateChanged(m_state); + emit statusChanged(m_status); } void stop() { m_position=0; m_state = QMediaRecorder::StoppedState; + m_status = QMediaRecorder::LoadedStatus; emit stateChanged(m_state); + emit statusChanged(m_status); } void setMuted(bool muted) @@ -127,6 +139,7 @@ public slots: public: QUrl m_sink; QMediaRecorder::State m_state; + QMediaRecorder::Status m_status; qint64 m_position; bool m_muted; int m_settingAppliedCount; |