From b414fc953844c0bc30e0c170496811eeeb49e680 Mon Sep 17 00:00:00 2001 From: evgeny Date: Sun, 1 Nov 2026 22:23:49 +0100 Subject: [PATCH] Verify the bottom player bar and logarithmic volume output --- tools/chatgui/src/streamplayer_window.cpp | 3 +- tools/chatgui/tests/test_stream_view.cpp | 35 +++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/tools/chatgui/src/streamplayer_window.cpp b/tools/chatgui/src/streamplayer_window.cpp index edeac275a..cc74b59c6 100644 --- a/tools/chatgui/src/streamplayer_window.cpp +++ b/tools/chatgui/src/streamplayer_window.cpp @@ -201,7 +201,8 @@ StreamPlayerWindow::StreamPlayerWindow(uint64_t group, uint64_t source, uint64_t volumeLayout->setContentsMargins(0, 0, 0, 0); volumeLayout->setSpacing(0); auto* volume = new StreamVolumeSlider(volumeBox); volume->setObjectName(QStringLiteral("streamVolume")); volume->setAccessibleName(text("Stream volume")); volume->setToolTip(QStringLiteral("0 dB")); volumeLayout->addWidget(volume); - auto* volumeLabel = new QLabel(text("Volume"), volumeBox); volumeLabel->setAlignment(Qt::AlignCenter); + auto* volumeLabel = new QLabel(text("Volume"), volumeBox); volumeLabel->setObjectName(QStringLiteral("streamVolumeLabel")); + volumeLabel->setAlignment(Qt::AlignCenter); volumeLayout->addWidget(volumeLabel); controls->addWidget(volumeBox); m_fullscreen = new QPushButton(text("Fullscreen"), bar); m_fullscreen->setObjectName(QStringLiteral("streamFullscreen")); controls->addWidget(m_fullscreen); diff --git a/tools/chatgui/tests/test_stream_view.cpp b/tools/chatgui/tests/test_stream_view.cpp index b20415f42..420ab240e 100644 --- a/tools/chatgui/tests/test_stream_view.cpp +++ b/tools/chatgui/tests/test_stream_view.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -545,6 +546,12 @@ private slots: QTRY_VERIFY(stream_get_info(publisher, &info) == STREAM_OK && info.owners == 2); QTest::mouseClick(video, Qt::LeftButton); QTRY_COMPARE(grid.focusedSource(), inst->node_id); QVERIFY(grid.isFullScreen()); QVERIFY(ownTile->isHidden()); + auto* fullscreen = remote->findChild(QStringLiteral("streamFullscreen")); + auto* close = remote->findChild(QStringLiteral("streamClose")); + QVERIFY(fullscreen && fullscreen->isVisible()); QVERIFY(close && close->isVisible()); + QVERIFY(grid.findChild(QStringLiteral("streamGridControls"))->isHidden()); + QTest::mouseClick(fullscreen, Qt::LeftButton); QTRY_VERIFY(!grid.isFullScreen()); + QTest::mouseClick(fullscreen, Qt::LeftButton); QTRY_VERIFY(grid.isFullScreen()); auto* volume = remote->findChild(); QVERIFY(volume); volume->setFocus(); QTest::keyClick(volume, Qt::Key_Escape); QTRY_COMPARE(grid.focusedSource(), uint64_t(0)); @@ -552,7 +559,8 @@ private slots: QCOMPARE(grid.findChild(), remote.data()); QCOMPARE(stream_get_info(publisher, &info), STREAM_OK); QCOMPARE(info.owners, 2u); QTest::mouseClick(video, Qt::LeftButton); QTRY_COMPARE(grid.focusedSource(), inst->node_id); - QTest::mouseClick(video, Qt::LeftButton); QTRY_COMPARE(grid.focusedSource(), uint64_t(0)); + QTest::mouseClick(close, Qt::LeftButton); QTRY_COMPARE(grid.focusedSource(), uint64_t(0)); + QCOMPARE(grid.findChild(), remote.data()); video->setFrame(coordinateFrame()); zoomVideo(*video, 12000, video->rect().center()); dragVideo(*video, video->rect().center(), video->rect().center() + QPoint(40, 20)); QTest::qWait(20); QCOMPARE(grid.focusedSource(), uint64_t(0)); // Pan не считается кликом. @@ -793,6 +801,21 @@ private slots: QVERIFY(telemetry); QVERIFY(telemetry->text().contains(QStringLiteral("text().contains(QStringLiteral("S")) || telemetry->text().contains(QStringLiteral("StoolTip().isEmpty()); + auto* bar = window.findChild(QStringLiteral("streamPlayerControls")); QVERIFY(bar); + auto* videoSurface = window.findChild(); QVERIFY(videoSurface); + QVERIFY(bar->geometry().top() > videoSurface->geometry().bottom()); + auto* caption = window.findChild(QStringLiteral("streamSourceName")); QVERIFY(caption); + auto* status = window.findChild(QStringLiteral("streamPlaybackStatus")); QVERIFY(status); + QVERIFY(caption->mapTo(&window, QPoint()).y() >= bar->geometry().top()); + QVERIFY(status->mapTo(&window, QPoint()).y() > caption->mapTo(&window, caption->rect().bottomLeft()).y()); + auto* scale = window.findChild(QStringLiteral("streamVolume")); QVERIFY(scale); + auto* volumeLabel = window.findChild(QStringLiteral("streamVolumeLabel")); QVERIFY(volumeLabel); + QVERIFY(volumeLabel->mapTo(&window, QPoint()).y() > scale->mapTo(&window, scale->rect().bottomLeft()).y()); + QTest::mouseClick(scale, Qt::LeftButton, {}, QPoint(scale->width() / 2, 5)); QCOMPARE(scale->value(), 50); + QCOMPARE(scale->toolTip(), QStringLiteral("-30.0 dB")); + const QString screenshot = qEnvironmentVariable("UTUN_TEST_STREAM_VIEW_SCREENSHOT"); + if (!screenshot.isEmpty()) QVERIFY(window.grab().save(screenshot)); + scale->setValue(100); #ifdef TEST_NULL_AUDIO uint64_t gapsBefore = silenceGaps.load(); #endif @@ -842,7 +865,15 @@ private slots: static_cast(leftEnergy.load()) / rightEnergy.load()); QVERIFY2(leftEnergy.load() > rightEnergy.load() * 8 && leftEnergy.load() < rightEnergy.load() * 25, "Independent stereo channels must reach the playback device without downmix"); - auto* volume = window.findChild(); QVERIFY(volume); volume->setValue(0); + auto* volume = window.findChild(); QVERIFY(volume); + leftEnergy = 0; QTest::qWait(200); const auto fullVolumeEnergy = leftEnergy.load(); + volume->setValue(50); QTest::qWait(50); leftEnergy = 0; QTest::qWait(200); + const auto halfScaleEnergy = leftEnergy.load(); + QVERIFY(fullVolumeEnergy > 0 && halfScaleEnergy > 0); + QVERIFY(halfScaleEnergy * 300 < fullVolumeEnergy && halfScaleEnergy * 3000 > fullVolumeEnergy); + DEBUG_INFO(DEBUG_CATEGORY_STREAM, "fixture logarithmic volume full_energy=%llu half_scale_energy=%llu gain_db=-30", + (unsigned long long)fullVolumeEnergy, (unsigned long long)halfScaleEnergy); + volume->setValue(0); QTest::qWait(50); uint64_t played = nonzeroSamples.load(); QTest::qWait(100); QCOMPARE(nonzeroSamples.load(), played); #endif sender.stop(); window.close(); QTest::qWait(20);