aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest/quicktestresult.cpp
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2022-05-27 14:57:53 +0800
committerMitch Curtis <mitch.curtis@qt.io>2022-06-06 09:18:17 +0800
commita72b4cd733cc1d82e7c0d877b75f93b96aa980bd (patch)
treed086534f24d0801ae8d7f2c98f89f3ea760832fa /src/qmltest/quicktestresult.cpp
parent21a17fbd891fedfc47be9c0cf260f7c76b884935 (diff)
TestCase: add API for checking for polish at window level
These were introduced to the C++ QQuickTest namespace in 36c6c1ea57ad503a2f42fe81a12d1254fcd38cca. QML-only tests should also have access to them. [ChangeLog][QtQuickTest][TestCase] Added waitForPolish() and made isPolishScheduled() also take a Window, making it possible to verify that updatePolish() was called on one or more items managed by a window. [ChangeLog][QtQuickTest][TestCase] Deprecated waitForItemPolished(). Use the new waitForPolish() function instead. Task-number: QTBUG-93757 Change-Id: Ie53389c2d49e096ebf382b902714c9dd4c8d5685 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/qmltest/quicktestresult.cpp')
-rw-r--r--src/qmltest/quicktestresult.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp
index b0eaaa0db3..16a3d3f987 100644
--- a/src/qmltest/quicktestresult.cpp
+++ b/src/qmltest/quicktestresult.cpp
@@ -800,14 +800,30 @@ QObject *QuickTestResult::findChild(QObject *parent, const QString &objectName)
return parent ? parent->findChild<QObject*>(objectName) : 0;
}
-bool QuickTestResult::isPolishScheduled(QQuickItem *item) const
+bool QuickTestResult::isPolishScheduled(QObject *itemOrWindow) const
{
- return QQuickTest::qIsPolishScheduled(item);
+ if (auto item = qobject_cast<QQuickItem*>(itemOrWindow))
+ return QQuickTest::qIsPolishScheduled(item);
+
+ if (auto window = qobject_cast<QQuickWindow*>(itemOrWindow))
+ return QQuickTest::qIsPolishScheduled(window);
+
+ qmlWarning(this) << "isPolishScheduled() expects either an Item or Window, but got"
+ << QDebug::toString(itemOrWindow);
+ return false;
}
-bool QuickTestResult::waitForItemPolished(QQuickItem *item, int timeout)
+bool QuickTestResult::waitForPolish(QObject *itemOrWindow, int timeout) const
{
- return QQuickTest::qWaitForPolish(item, timeout);
+ if (auto item = qobject_cast<QQuickItem*>(itemOrWindow))
+ return QQuickTest::qWaitForPolish(item, timeout);
+
+ if (auto window = qobject_cast<QQuickWindow*>(itemOrWindow))
+ return QQuickTest::qWaitForPolish(window, timeout);
+
+ qmlWarning(this) << "waitForItemPolish() expects either an Item or Window, but got"
+ << QDebug::toString(itemOrWindow);
+ return false;
}
namespace QTest {