diff options
author | Artem Dyomin <artem.dyomin@qt.io> | 2023-04-17 16:17:59 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-05-30 18:57:28 +0000 |
commit | 6064deaab7f42642d5efc6aa9c0b60d62c2ddf94 (patch) | |
tree | 1423edd0ff72f6c19e54c8879aac5f1cda4a39c2 | |
parent | 295c1eeba18ec05730363877331825c1fe1ccbb9 (diff) |
Fix some qmediaplayer tests flackiness
Outputs should be removed after QMediaPlayer to
avoid having broken references inside the player.
Handling of the outputs deleting will be done under
the task QTBUG-114072 with new specific unit test case.
This patch fixes tests flakiness that improves CI behavior.
Task-number: QTBUG-114072
Change-Id: I0f4f4a2e9152a2a4dd9572d8060586ee6fb1d647
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit f93fa5ab5196aa5135bd404d15bf5884546a6feb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
6 files changed, 37 insertions, 29 deletions
diff --git a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp index 0f9ebab6f..0a5faf4aa 100644 --- a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp +++ b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp @@ -662,8 +662,8 @@ void tst_QCameraBackend::testNativeMetadata() // QMediaRecorder::metaData() can only test that QMediaMetaData is set properly on the recorder. // Use QMediaPlayer to test that the native metadata is properly set on the track - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; player.setAudioOutput(&output); QSignalSpy metadataChangedSpy(&player, SIGNAL(metaDataChanged())); diff --git a/tests/auto/integration/qmediacapturesession/tst_qmediacapturesession.cpp b/tests/auto/integration/qmediacapturesession/tst_qmediacapturesession.cpp index 1c63560e6..b91688b9f 100644 --- a/tests/auto/integration/qmediacapturesession/tst_qmediacapturesession.cpp +++ b/tests/auto/integration/qmediacapturesession/tst_qmediacapturesession.cpp @@ -334,6 +334,8 @@ void tst_QMediaCaptureSession::can_move_AudioOutput_between_sessions_and_player( if (QMediaDevices::audioOutputs().isEmpty()) QSKIP("No audio output available"); + QAudioOutput output; + QMediaCaptureSession session0; QMediaCaptureSession session1; QMediaPlayer player; @@ -341,7 +343,6 @@ void tst_QMediaCaptureSession::can_move_AudioOutput_between_sessions_and_player( QSignalSpy audioOutputChanged1(&session1, SIGNAL(audioOutputChanged())); QSignalSpy audioOutputChangedPlayer(&player, SIGNAL(audioOutputChanged())); - QAudioOutput output; { QMediaCaptureSession session2; QSignalSpy audioOutputChanged2(&session2, SIGNAL(audioOutputChanged())); diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp index 7bcffe14d..f083b8577 100644 --- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp +++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp @@ -245,9 +245,9 @@ void tst_QMediaPlayerBackend::loadInvalidMedia() if (!isWavSupported()) QSKIP("Sound format is not supported"); - QMediaPlayer player; QAudioOutput output; TestVideoSink surface; + QMediaPlayer player; QSignalSpy stateSpy(&player, &QMediaPlayer::playbackStateChanged); QSignalSpy errorSpy(&player, &QMediaPlayer::errorOccurred); @@ -286,8 +286,8 @@ void tst_QMediaPlayerBackend::loadMedia() if (!isWavSupported()) QSKIP("Sound format is not supported"); - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; player.setAudioOutput(&output); QCOMPARE(player.playbackState(), QMediaPlayer::StoppedState); @@ -321,8 +321,8 @@ void tst_QMediaPlayerBackend::unloadMedia() if (!isWavSupported()) QSKIP("Sound format is not supported"); - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; player.setAudioOutput(&output); QSignalSpy stateSpy(&player, SIGNAL(playbackStateChanged(QMediaPlayer::PlaybackState))); @@ -371,8 +371,9 @@ void tst_QMediaPlayerBackend::loadMediaInLoadingState() if (!isWavSupported()) QSKIP("Sound format is not supported"); - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; + player.setAudioOutput(&output); player.setSource(localWavFile2); QCOMPARE(player.mediaStatus(), QMediaPlayer::LoadingMedia); @@ -393,8 +394,8 @@ void tst_QMediaPlayerBackend::playPauseStop() if (!isWavSupported()) QSKIP("Sound format is not supported"); - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; player.setAudioOutput(&output); QSignalSpy stateSpy(&player, SIGNAL(playbackStateChanged(QMediaPlayer::PlaybackState))); @@ -557,8 +558,9 @@ void tst_QMediaPlayerBackend::processEOS() if (!isWavSupported()) QSKIP("Sound format is not supported"); - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; + player.setAudioOutput(&output); QSignalSpy stateSpy(&player, SIGNAL(playbackStateChanged(QMediaPlayer::PlaybackState))); @@ -718,9 +720,9 @@ void tst_QMediaPlayerBackend::deleteLaterAtEOS() void tst_QMediaPlayerBackend::volumeAndMuted() { - //volume and muted properties should be independent - QMediaPlayer player; + // volume and muted properties should be independent QAudioOutput output; + QMediaPlayer player; player.setAudioOutput(&output); QCOMPARE(output.volume(), 1.); QVERIFY(!output.isMuted()); @@ -784,8 +786,9 @@ void tst_QMediaPlayerBackend::volumeAcrossFiles() QFETCH(bool, muted); float vol = volume/100.; - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; + player.setAudioOutput(&output); //volume and muted should not be preserved between player instances @@ -827,8 +830,8 @@ void tst_QMediaPlayerBackend::initialVolume() QSKIP("Sound format is not supported"); { - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; player.setAudioOutput(&output); output.setVolume(1); player.setSource(localWavFile); @@ -839,8 +842,8 @@ void tst_QMediaPlayerBackend::initialVolume() } { - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; player.setAudioOutput(&output); player.setSource(localWavFile); QCOMPARE(output.volume(), 1); @@ -858,13 +861,14 @@ void tst_QMediaPlayerBackend::seekPauseSeek() if (localVideoFile.isEmpty()) QSKIP("No supported video file"); - QMediaPlayer player; + TestVideoSink surface; QAudioOutput output; + QMediaPlayer player; + player.setAudioOutput(&output); QSignalSpy positionSpy(&player, SIGNAL(positionChanged(qint64))); - TestVideoSink surface; player.setVideoOutput(&surface); player.setSource(localVideoFile); @@ -933,10 +937,11 @@ void tst_QMediaPlayerBackend::seekInStoppedState() if (localVideoFile.isEmpty()) QSKIP("No supported video file"); - QMediaPlayer player; + TestVideoSink surface(false); QAudioOutput output; + QMediaPlayer player; + player.setAudioOutput(&output); - TestVideoSink surface(false); player.setVideoOutput(&surface); QSignalSpy stateSpy(&player, SIGNAL(playbackStateChanged(QMediaPlayer::PlaybackState))); @@ -1053,8 +1058,8 @@ void tst_QMediaPlayerBackend::subsequentPlayback() if (localCompressedSoundFile.isEmpty()) QSKIP("Sound format is not supported"); - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; player.setAudioOutput(&output); player.setSource(localCompressedSoundFile); QTRY_COMPARE(player.mediaStatus(), QMediaPlayer::LoadedMedia); @@ -1093,9 +1098,9 @@ void tst_QMediaPlayerBackend::multipleMediaPlayback() if (localVideoFile.isEmpty() || localVideoFile2.isEmpty()) QSKIP("Video format is not supported"); + QAudioOutput output; TestVideoSink surface(false); QMediaPlayer player; - QAudioOutput output; player.setVideoOutput(&surface); player.setAudioOutput(&output); @@ -1404,9 +1409,9 @@ void tst_QMediaPlayerBackend::surfaceTest() if (localVideoFile.isEmpty()) QSKIP("No supported video file"); + QAudioOutput output; TestVideoSink surface(false); QMediaPlayer player; - QAudioOutput output; player.setAudioOutput(&output); player.setVideoOutput(&surface); player.setSource(localVideoFile); @@ -1440,8 +1445,8 @@ void tst_QMediaPlayerBackend::metadata() if (localFileWithMetadata.isEmpty()) QSKIP("No supported media file"); - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; player.setAudioOutput(&output); QSignalSpy metadataChangedSpy(&player, SIGNAL(metaDataChanged())); @@ -1468,8 +1473,8 @@ void tst_QMediaPlayerBackend::playerStateAtEOS() if (!isWavSupported()) QSKIP("Sound format is not supported"); - QMediaPlayer player; QAudioOutput output; + QMediaPlayer player; player.setAudioOutput(&output); bool endOfMediaReceived = false; diff --git a/tests/auto/integration/qscreencapture_integration/tst_qscreencapture_integration.cpp b/tests/auto/integration/qscreencapture_integration/tst_qscreencapture_integration.cpp index ba878295f..376faf35e 100644 --- a/tests/auto/integration/qscreencapture_integration/tst_qscreencapture_integration.cpp +++ b/tests/auto/integration/qscreencapture_integration/tst_qscreencapture_integration.cpp @@ -391,6 +391,7 @@ void tst_QScreenCaptureIntegration::recordToFile() QVERIFY(!fileName.isEmpty()); QVERIFY(QFileInfo(fileName).size() > 0); + TestVideoSink sink; QMediaPlayer player; player.setSource(fileName); QCOMPARE_EQ(player.metaData().value(QMediaMetaData::Resolution).toSize(), QSize(videoResolution)); @@ -398,7 +399,6 @@ void tst_QScreenCaptureIntegration::recordToFile() QCOMPARE_LT(player.duration(), 650); // Convert video frames to QImages - TestVideoSink sink; player.setVideoSink(&sink); sink.setStoreImagesEnabled(); player.setPlaybackRate(10); diff --git a/tests/auto/integration/shared/mediafileselector.h b/tests/auto/integration/shared/mediafileselector.h index 7afc3687f..12d1ad9d5 100644 --- a/tests/auto/integration/shared/mediafileselector.h +++ b/tests/auto/integration/shared/mediafileselector.h @@ -15,11 +15,12 @@ QT_BEGIN_NAMESPACE namespace MediaFileSelector { -static QUrl selectMediaFile(const QStringList& mediaCandidates) +// TODO: refactor or remove the function +inline QUrl selectMediaFile(const QStringList &mediaCandidates) { - QMediaPlayer player; QAudioOutput audioOutput; QVideoSink videoOutput; + QMediaPlayer player; player.setAudioOutput(&audioOutput); player.setVideoOutput(&videoOutput); diff --git a/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp index 8e7a958a8..87462df00 100644 --- a/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp +++ b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp @@ -104,8 +104,8 @@ void tst_QVideoWidget::show() void tst_QVideoWidget::aspectRatio() { - QMediaPlayer player; QtTestVideoWidget widget; + QMediaPlayer player; player.setVideoOutput(&widget); // Test the aspect ratio defaults to keeping the aspect ratio. @@ -160,8 +160,9 @@ void tst_QVideoWidget::sizeHint() QFETCH(QSize, expectedSize); QMockIntegration mock; - QMediaPlayer player; QtTestVideoWidget widget; + QMediaPlayer player; + player.setVideoOutput(&widget); auto mockSink = mock.lastVideoSink(); @@ -175,8 +176,8 @@ void tst_QVideoWidget::sizeHint() void tst_QVideoWidget::fullScreen() { - QMediaPlayer player; QtTestVideoWidget widget; + QMediaPlayer player; player.setVideoOutput(&widget); widget.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&widget)); @@ -243,8 +244,8 @@ static const uchar rgb32ImageData[] = void tst_QVideoWidget::paint() { - QMediaPlayer player; QtTestVideoWidget widget; + QMediaPlayer player; player.setVideoOutput(&widget); widget.resize(640,480); widget.show(); |