summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesus Fernandez <jesus.fernandez@qt.io>2018-09-07 11:29:17 +0200
committerJesus Fernandez <Jesus.Fernandez@qt.io>2018-09-11 10:36:57 +0000
commit93946a3c2391d2e7260e310db0999b7f87e16083 (patch)
treeb5b7f1f71db7af4ea2eb4eeb42adb48ac2d8bee6
parent64f6bf45187a449986b5a5153abcc75ce987e9e0 (diff)
Add findSwapBuffers function
To avoid repeating the same code in similar test cases coming in later commits. Change-Id: Ife2065629ee7c1cb9ea0ab509364af5c3e66e46f Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r--tests/plugins/platforms/webgl/tst_webgl.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/plugins/platforms/webgl/tst_webgl.cpp b/tests/plugins/platforms/webgl/tst_webgl.cpp
index 306d6fd..d7bb6bb 100644
--- a/tests/plugins/platforms/webgl/tst_webgl.cpp
+++ b/tests/plugins/platforms/webgl/tst_webgl.cpp
@@ -60,6 +60,8 @@ class tst_WebGL : public QObject
QStringList functions;
QProcess process;
+ bool findSwapBuffers(const QSignalSpy &spy);
+
signals:
void command(const QString &name, const QVariantList &parameters);
void queryCommand(const QString &name, int id, const QVariantList &parameters);
@@ -81,6 +83,14 @@ private slots:
void waitForSwapBuffers();
};
+bool tst_WebGL::findSwapBuffers(const QSignalSpy &spy)
+{
+ return std::find_if(spy.cbegin(), spy.cend(), [](const QList<QVariant> &list) {
+ // Our connect message changed the scene's size, forcing a swapBuffers() call.
+ return list.first() == QLatin1String("swapBuffers");
+ }) != spy.cend();
+}
+
void tst_WebGL::parseTextMessage(const QString &text)
{
const auto document = QJsonDocument::fromJson(text.toUtf8());
@@ -275,10 +285,7 @@ void tst_WebGL::waitForSwapBuffers_data()
void tst_WebGL::waitForSwapBuffers()
{
QSignalSpy spy(this, &tst_WebGL::queryCommand);
- QTRY_VERIFY(std::find_if(spy.cbegin(), spy.cend(), [](const QList<QVariant> &list) {
- // Our connect message changed the scene's size, forcing a swapBuffers() call.
- return list.first() == QLatin1String("swapBuffers");
- }) != spy.cend());
+ QTRY_VERIFY(findSwapBuffers(spy));
}
QTEST_MAIN(tst_WebGL)