From 4b221ef0d1b7c3b77e5dffd026018cffb7fa1413 Mon Sep 17 00:00:00 2001 From: evgeny Date: Wed, 28 Oct 2026 14:35:46 +0100 Subject: [PATCH] Verify growing call preview and emphasized metric values --- tools/chatgui/src/callwindow.cpp | 1 + tools/chatgui/tests/test_call_commands.cpp | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tools/chatgui/src/callwindow.cpp b/tools/chatgui/src/callwindow.cpp index 3a94aae5..c85d82d6 100644 --- a/tools/chatgui/src/callwindow.cpp +++ b/tools/chatgui/src/callwindow.cpp @@ -344,6 +344,7 @@ CallWindow::CallWindow(QWidget* parent) m_connectionLabel->setStyleSheet("color: gray; font-size: 13px;"); setConnectionType(0, 0); m_statsLabel = new QLabel(this); + m_statsLabel->setObjectName("callAudioStats"); m_statsLabel->setAlignment(Qt::AlignCenter); m_statsLabel->setWordWrap(true); m_statsLabel->setStyleSheet("color: gray; font-size: 11px;"); diff --git a/tools/chatgui/tests/test_call_commands.cpp b/tools/chatgui/tests/test_call_commands.cpp index da3ba6af..babd0976 100644 --- a/tools/chatgui/tests/test_call_commands.cpp +++ b/tools/chatgui/tests/test_call_commands.cpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include #include @@ -202,6 +204,11 @@ private slots: QVERIFY(!diagnostics->isVisible()); diagnosticButton->click(); QVERIFY(diagnostics->isVisible()); QVERIFY(bar->isVisible()); QVERIFY(avatar->isHidden()); window.setAudioStats(41, 81, 100, 1, 0, 50, 90, 10); QVERIFY(diagnostics->isVisible()); + auto* stats = window.findChild("callAudioStats"); QVERIFY(stats); + QTextDocument metrics; metrics.setHtml(stats->text()); + auto metric = metrics.find("81 ms"); QVERIFY(!metric.isNull()); QVERIFY(metric.charFormat().fontWeight() >= QFont::Bold); + QCOMPARE(metric.charFormat().foreground().color(), window.palette().color(QPalette::WindowText)); + auto caption = metrics.find("Buffer:"); QVERIFY(!caption.isNull()); QVERIFY(caption.charFormat().fontWeight() < QFont::Bold); const QString diagnosticScreenshot = qEnvironmentVariable("UTUN_TEST_CALL_DIAGNOSTICS_SCREENSHOT"); if (!diagnosticScreenshot.isEmpty()) { QCoreApplication::processEvents(); QVERIFY(window.grab().save(diagnosticScreenshot)); } diagnosticButton->click(); window.setAudioStats(42, 82, 100, 1, 0, 50, 90, 10); QVERIFY(!diagnostics->isVisible()); @@ -233,6 +240,22 @@ private slots: settings->click(); QVERIFY(!bar->isVisible()); QVERIFY(!avatar->isHidden()); QImage frame(160, 90, QImage::Format_RGB32); frame.fill(Qt::darkGreen); blocked.unblock(); emit engine->localImageChanged(frame); blocked.reblock(); QVERIFY(avatar->isHidden()); + auto* preview = window.findChild("callLocalPreview"); QVERIFY(preview); + auto* previewArea = window.findChild("callPreviewArea"); QVERIFY(previewArea); + QCoreApplication::processEvents(); QVERIFY(preview->isVisible()); + QCOMPARE(preview->size(), previewArea->contentsRect().size()); QCOMPARE(preview->width(), window.width() - 24); + window.resize(900, 700); QCoreApplication::processEvents(); QVERIFY(preview->width() > 640); + QCOMPARE(preview->size(), previewArea->contentsRect().size()); + QCOMPARE(window.rect().bottom() - footer->geometry().bottom(), 12); + QImage previewImage = preview->grab().toImage(); QRect frameBounds; + for (int y = 0; y < previewImage.height(); y++) for (int x = 0; x < previewImage.width(); x++) { + QColor color = previewImage.pixelColor(x, y); + if (color.green() > 80 && color.red() < 10 && color.blue() < 10) frameBounds |= QRect(x, y, 1, 1); + } + QVERIFY(frameBounds.width() == previewImage.width() || frameBounds.height() == previewImage.height()); + QVERIFY(std::abs(frameBounds.width() * frame.height() - frameBounds.height() * frame.width()) <= frame.width()); + const QString previewScreenshot = qEnvironmentVariable("UTUN_TEST_CALL_PREVIEW_SCREENSHOT"); + if (!previewScreenshot.isEmpty()) QVERIFY(window.grab().save(previewScreenshot)); blocked.unblock(); emit engine->localImageChanged({}); blocked.reblock(); QVERIFY(!avatar->isHidden()); blocked.unblock(); emit engine->imageChanged(frame, 0); blocked.reblock(); QVERIFY(avatar->isHidden()); blocked.unblock(); emit engine->imageChanged({}, 0); blocked.reblock(); QVERIFY(!avatar->isHidden());