summaryrefslogtreecommitdiffstats
path: root/tests/auto/util
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/util')
-rw-r--r--tests/auto/util/qt_webengine_quicktest.h2
-rw-r--r--tests/auto/util/quickutil.h10
-rw-r--r--tests/auto/util/testwindow.h2
-rw-r--r--tests/auto/util/util.h34
-rw-r--r--tests/auto/util/widgetutil.h7
5 files changed, 41 insertions, 14 deletions
diff --git a/tests/auto/util/qt_webengine_quicktest.h b/tests/auto/util/qt_webengine_quicktest.h
index bd98693de..4d68f90f0 100644
--- a/tests/auto/util/qt_webengine_quicktest.h
+++ b/tests/auto/util/qt_webengine_quicktest.h
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QT_WEBENGINE_QUICKTEST_H
#define QT_WEBENGINE_QUICKTEST_H
diff --git a/tests/auto/util/quickutil.h b/tests/auto/util/quickutil.h
index f7e08f842..87fd527f7 100644
--- a/tests/auto/util/quickutil.h
+++ b/tests/auto/util/quickutil.h
@@ -1,8 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
-#ifndef UTIL_H
-#define UTIL_H
+#ifndef QUICKUTIL_H
+#define QUICKUTIL_H
#include <QEventLoop>
#include <QQmlEngine>
@@ -113,7 +113,7 @@ inline QPoint elementCenter(QQuickWebEngineView *view, const QString &id)
"})()");
QVariantList rectList = evaluateJavaScriptSync(view, jsCode).toList();
- if (rectList.count() != 2) {
+ if (rectList.size() != 2) {
qWarning("elementCenter failed.");
return QPoint();
}
@@ -162,5 +162,5 @@ int main(int argc, char *argv[]) \
QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
}
-#endif /* UTIL_H */
+#endif /* QUICKUTIL_H */
diff --git a/tests/auto/util/testwindow.h b/tests/auto/util/testwindow.h
index f9ffd381a..dfce32b43 100644
--- a/tests/auto/util/testwindow.h
+++ b/tests/auto/util/testwindow.h
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef TESTWINDOW_H
#define TESTWINDOW_H
diff --git a/tests/auto/util/util.h b/tests/auto/util/util.h
index 455dff20c..5013bb5fa 100644
--- a/tests/auto/util/util.h
+++ b/tests/auto/util/util.h
@@ -1,5 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef UTIL_H
+#define UTIL_H
// Functions and macros that really need to be in QTestLib
@@ -43,7 +46,7 @@ public:
bool ensureSignalEmitted()
{
- bool result = count() > 0;
+ bool result = size() > 0;
if (!result)
result = wait();
clear();
@@ -145,11 +148,28 @@ static inline QUrl baseUrlSync(QWebEnginePage *page)
return spy.waitForResult().toUrl();
}
-static inline bool loadSync(QWebEnginePage *page, const QUrl &url, bool ok = true)
+static inline bool loadSync(QWebEnginePage *page, const QUrl &url, bool ok = true,
+ int timeout = 20000)
{
QSignalSpy spy(page, &QWebEnginePage::loadFinished);
page->load(url);
- return (!spy.empty() || spy.wait(20000)) && (spy.front().value(0).toBool() == ok);
+ return (!spy.empty() || spy.wait(timeout)) && (spy.front().value(0).toBool() == ok);
+}
+
+static inline bool setHtmlSync(QWebEnginePage *page, const QString &html,
+ const QUrl &baseUrl = QUrl())
+{
+ QSignalSpy spy(page, &QWebEnginePage::loadFinished);
+ page->setHtml(html, baseUrl);
+ return (!spy.empty() || spy.wait(20000)) && spy.front().value(0).toBool();
+}
+
+static inline bool webActionLoadSync(QWebEnginePage *page, QWebEnginePage::WebAction action,
+ bool ok = true, int timeout = 20000)
+{
+ QSignalSpy spy(page, &QWebEnginePage::loadFinished);
+ page->triggerAction(action);
+ return (!spy.empty() || spy.wait(timeout)) && (spy.front().value(0).toBool() == ok);
}
static inline QRect elementGeometry(QWebEnginePage *page, const QString &id)
@@ -162,8 +182,8 @@ static inline QRect elementGeometry(QWebEnginePage *page, const QString &id)
"})()");
QVariantList coords = evaluateJavaScriptSync(page, jsCode).toList();
- if (coords.count() != 4) {
- qWarning("elementGeometry faield.");
+ if (coords.size() != 4) {
+ qWarning("elementGeometry failed.");
return QRect();
}
@@ -176,3 +196,5 @@ static inline QPoint elementCenter(QWebEnginePage *page, const QString &id)
}
#define W_QSKIP(a, b) QSKIP(a)
+
+#endif /* UTIL_H */
diff --git a/tests/auto/util/widgetutil.h b/tests/auto/util/widgetutil.h
index 67d09ee4f..356d3c826 100644
--- a/tests/auto/util/widgetutil.h
+++ b/tests/auto/util/widgetutil.h
@@ -1,5 +1,8 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef WIDGETUTIL_H
+#define WIDGETUTIL_H
// Functions and macros that really need to be in QTestLib
@@ -26,3 +29,5 @@ int main(int argc, char *argv[]) \
QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
}
+
+#endif /* WIDGETUTIL_H */