diff options
author | Tim Blechmann <tim@klingt.org> | 2024-04-18 13:44:34 +0800 |
---|---|---|
committer | Tim Blechmann <tim@klingt.org> | 2024-04-23 16:51:26 +0800 |
commit | 9b526fcd66282ecb47ddfdc0e3b34341ce965c19 (patch) | |
tree | 42f8f7b66a3f713f01b394f91b78fdb3e2e1e593 | |
parent | 71ed67972a929a4776cd6b781426a56679629e63 (diff) |
QMediaPlayer: add test for un-connected audio/video output
Task-number: QTBUG-124501
Pick-to: 6.5 6.7
Change-Id: I9d10151f2b439d2f21916942b14ba7b2227dae5d
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
-rw-r--r-- | tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp | 51 | ||||
-rw-r--r-- | tests/auto/integration/shared/mediabackendutils.h | 6 |
2 files changed, 56 insertions, 1 deletions
diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp index 4c5c16624..80b52cada 100644 --- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp +++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp @@ -117,6 +117,8 @@ private slots: void playAndSetSource_emitsExpectedSignalsAndStopsPlayback_whenSetSourceWasCalledWithEmptyUrl(); void play_createsFramesWithExpectedContentAndIncreasingFrameTime_whenPlayingRtspMediaStream(); void play_waitsForLastFrameEnd_whenPlayingVideoWithLongFrames(); + void play_startsPlayback_withAndWithoutOutputsConnected(); + void play_startsPlayback_withAndWithoutOutputsConnected_data(); void stop_entersStoppedState_whenPlayerWasPaused(); void stop_setsPositionToZero_afterPlayingToEndOfMedia(); @@ -603,7 +605,6 @@ void tst_QMediaPlayerBackend::setSource_stopsAndEntersErrorState_whenPlayerWasPl QCOMPARE(m_fixture->framesCount, savedFramesCount); } - void tst_QMediaPlayerBackend::setSource_loadsAudioTrack_whenCalledWithValidWavFile() { CHECK_SELECTED_URL(m_localWavFile); @@ -1153,6 +1154,54 @@ void tst_QMediaPlayerBackend::play_waitsForLastFrameEnd_whenPlayingVideoWithLong QCOMPARE(m_fixture->surface.m_totalFrames, 2); } +void tst_QMediaPlayerBackend::play_startsPlayback_withAndWithoutOutputsConnected() +{ + QSKIP_GSTREAMER("QTBUG-124501: Fails with gstreamer"); + + QFETCH(const bool, audioConnected); + QFETCH(const bool, videoConnected); + + CHECK_SELECTED_URL(m_localVideoFile3ColorsWithSound); + + if (!videoConnected && !audioConnected) + QSKIP_FFMPEG("FFMPEG backend playback fails when no output is connected"); + + // Arrange + m_fixture->player.setSource(*m_localVideoFile3ColorsWithSound); + if (!audioConnected) + m_fixture->player.setAudioOutput(nullptr); + + if (!videoConnected) + m_fixture->player.setVideoOutput(nullptr); + + m_fixture->clearSpies(); + + // Act + m_fixture->player.play(); + + // Assert + QTRY_VERIFY(!m_fixture->mediaStatusChanged.empty() + && m_fixture->mediaStatusChanged.back() + == QList<QVariant>{ QMediaPlayer::EndOfMedia }); + + QTRY_COMPARE_EQ(m_fixture->playbackStateChanged, + SignalList({ + { QMediaPlayer::PlayingState }, + { QMediaPlayer::StoppedState }, + })); +} + +void tst_QMediaPlayerBackend::play_startsPlayback_withAndWithoutOutputsConnected_data() +{ + QTest::addColumn<bool>("videoConnected"); + QTest::addColumn<bool>("audioConnected"); + + QTest::addRow("all connected") << true << true; + QTest::addRow("video connected") << true << false; + QTest::addRow("audio connected") << false << true; + QTest::addRow("no output connected") << false << false; +} + void tst_QMediaPlayerBackend::stop_entersStoppedState_whenPlayerWasPaused() { CHECK_SELECTED_URL(m_localWavFile); diff --git a/tests/auto/integration/shared/mediabackendutils.h b/tests/auto/integration/shared/mediabackendutils.h index 6c538d7de..3279f7044 100644 --- a/tests/auto/integration/shared/mediabackendutils.h +++ b/tests/auto/integration/shared/mediabackendutils.h @@ -38,6 +38,12 @@ inline bool isWindowsPlatform() QSKIP(message); \ } while (0) +#define QSKIP_FFMPEG(message) \ + do { \ + if (isFFMPEGPlatform()) \ + QSKIP(message); \ + } while (0) + #define QEXPECT_FAIL_GSTREAMER(dataIndex, comment, mode) \ do { \ if (isGStreamerPlatform()) \ |