From e5a2e17778ef4cdad656f7dcffe8bb79511e45a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Fri, 24 Apr 2020 12:44:21 +0200 Subject: Fix missing QWebEnginePage::audioMutedChanged signal Change-Id: Ie02da939a37575dd2b0a43440978748fd79874e4 Reviewed-by: Allan Sandfeld Jensen --- .../widgets/qwebenginepage/tst_qwebenginepage.cpp | 19 +++++++++++++++++++ .../qwebengineprofile/tst_qwebengineprofile.cpp | 12 ------------ tests/auto/widgets/util.h | 13 +++++++++++++ 3 files changed, 32 insertions(+), 12 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index a6b3e0905..39bbc96de 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -228,6 +228,7 @@ private Q_SLOTS: void renderProcessCrashed(); void renderProcessPid(); void backgroundColor(); + void audioMuted(); private: static QPoint elementCenter(QWebEnginePage *page, const QString &id); @@ -4433,6 +4434,24 @@ void tst_QWebEnginePage::backgroundColor() QTRY_COMPARE(view.grab().toImage().pixelColor(center), Qt::green); } +void tst_QWebEnginePage::audioMuted() +{ + QWebEngineProfile profile; + QWebEnginePage page(&profile); + QSignalSpy spy(&page, &QWebEnginePage::audioMutedChanged); + + QCOMPARE(page.isAudioMuted(), false); + page.setAudioMuted(true); + loadSync(&page, QUrl("about:blank")); + QCOMPARE(page.isAudioMuted(), true); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy[0][0], QVariant(true)); + page.setAudioMuted(false); + QCOMPARE(page.isAudioMuted(), false); + QCOMPARE(spy.count(), 2); + QCOMPARE(spy[1][0], QVariant(false)); +} + static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")}; W_QTEST_MAIN(tst_QWebEnginePage, params) diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp index 6350c8510..935babe81 100644 --- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp +++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp @@ -222,18 +222,6 @@ private: } }; -static bool loadSync(QWebEnginePage *page, const QUrl &url, bool ok = true) -{ - QSignalSpy spy(page, &QWebEnginePage::loadFinished); - page->load(url); - return (!spy.empty() || spy.wait(20000)) && (spy.front().value(0).toBool() == ok); -} - -static bool loadSync(QWebEngineView *view, const QUrl &url, bool ok = true) -{ - return loadSync(view->page(), url, ok); -} - void tst_QWebEngineProfile::clearDataFromCache() { TestServer server; diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h index ca03c5833..cb58f4243 100644 --- a/tests/auto/widgets/util.h +++ b/tests/auto/widgets/util.h @@ -36,6 +36,7 @@ #include #include #include +#include #if !defined(TESTS_SOURCE_DIR) #define TESTS_SOURCE_DIR "" @@ -160,6 +161,18 @@ static inline QUrl baseUrlSync(QWebEnginePage *page) return spy.waitForResult().toUrl(); } +static inline bool loadSync(QWebEnginePage *page, const QUrl &url, bool ok = true) +{ + QSignalSpy spy(page, &QWebEnginePage::loadFinished); + page->load(url); + return (!spy.empty() || spy.wait(20000)) && (spy.front().value(0).toBool() == ok); +} + +static inline bool loadSync(QWebEngineView *view, const QUrl &url, bool ok = true) +{ + return loadSync(view->page(), url, ok); +} + #define W_QSKIP(a, b) QSKIP(a) #define W_QTEST_MAIN(TestObject, params) \ -- cgit v1.2.3