summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2020-04-24 12:44:21 +0200
committerJüri Valdmann <juri.valdmann@qt.io>2020-04-29 10:59:28 +0200
commite5a2e17778ef4cdad656f7dcffe8bb79511e45a7 (patch)
tree44b0a48b54da65883d3623a4f9c01c2d19cf4c3c /tests/auto
parent75412200db05ddc5ee2b9aea367b580d8b0c438e (diff)
Fix missing QWebEnginePage::audioMutedChanged signal
Change-Id: Ie02da939a37575dd2b0a43440978748fd79874e4 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp19
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp12
-rw-r--r--tests/auto/widgets/util.h13
3 files changed, 32 insertions, 12 deletions
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 <QSignalSpy>
#include <QTimer>
#include <qwebenginepage.h>
+#include <qwebengineview.h>
#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) \