aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2020-06-05 10:28:16 +0200
committerMitch Curtis <mitch.curtis@qt.io>2020-06-18 13:09:57 +0200
commitce46d7374acd0ba46379618563e10e013d524841 (patch)
tree0e77c643fe6e309dc94b2b54bff0cfddf1f17e60
parent82cdac46bfbd672fae7c70d2cb8bf50b490e35e5 (diff)
QQuickApplicationHelper: don't use QTest macros outside test functions
This has no effect. Task-number: QTBUG-66320 Change-Id: Ie6efb26243178c4044ac0bc721c21ad89769c982 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 969a724352dfe3250efb871c70f9482d7b780165) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--tests/auto/cursor/tst_cursor.cpp1
-rw-r--r--tests/auto/qquickdrawer/tst_qquickdrawer.cpp18
-rw-r--r--tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp2
-rw-r--r--tests/auto/qquickmenu/tst_qquickmenu.cpp27
-rw-r--r--tests/auto/qquickpopup/tst_qquickpopup.cpp19
-rw-r--r--tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp1
-rw-r--r--tests/auto/shared/visualtestutil.h35
7 files changed, 98 insertions, 5 deletions
diff --git a/tests/auto/cursor/tst_cursor.cpp b/tests/auto/cursor/tst_cursor.cpp
index d59e7091..6f361a16 100644
--- a/tests/auto/cursor/tst_cursor.cpp
+++ b/tests/auto/cursor/tst_cursor.cpp
@@ -182,6 +182,7 @@ void tst_cursor::scrollBar()
// Ensure that the mouse cursor has the correct shape when over a scrollbar
// which is itself over a text area with IBeamCursor.
QQuickApplicationHelper helper(this, QStringLiteral("scrollbar.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
diff --git a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp
index 4cf0dabe..005c5ee4 100644
--- a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp
+++ b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp
@@ -180,6 +180,7 @@ void tst_QQuickDrawer::visible()
{
QFETCH(QString, source);
QQuickApplicationHelper helper(this, source);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -220,6 +221,7 @@ void tst_QQuickDrawer::visible()
void tst_QQuickDrawer::state()
{
QQuickApplicationHelper helper(this, "applicationwindow.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -340,6 +342,7 @@ void tst_QQuickDrawer::position()
QFETCH(qreal, position);
QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
@@ -387,6 +390,7 @@ void tst_QQuickDrawer::dragMargin()
QFETCH(qreal, dragFromRight);
QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
@@ -433,6 +437,7 @@ static QRectF geometry(const QQuickItem *item)
void tst_QQuickDrawer::reposition()
{
QQuickApplicationHelper helper(this, QStringLiteral("reposition.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
@@ -491,6 +496,7 @@ void tst_QQuickDrawer::reposition()
void tst_QQuickDrawer::header()
{
QQuickApplicationHelper helper(this, QStringLiteral("header.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
@@ -545,6 +551,7 @@ void tst_QQuickDrawer::hover()
QFETCH(bool, modal);
QQuickApplicationHelper helper(this, source);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
window->requestActivate();
@@ -626,6 +633,7 @@ void tst_QQuickDrawer::wheel()
QFETCH(bool, modal);
QQuickApplicationHelper helper(this, source);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -688,6 +696,7 @@ void tst_QQuickDrawer::wheel()
void tst_QQuickDrawer::multiple()
{
QQuickApplicationHelper helper(this, QStringLiteral("multiple.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -832,6 +841,7 @@ void tst_QQuickDrawer::touch()
QFETCH(QPoint, to);
QQuickApplicationHelper helper(this, source);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -866,6 +876,7 @@ void tst_QQuickDrawer::touch()
void tst_QQuickDrawer::multiTouch()
{
QQuickApplicationHelper helper(this, QStringLiteral("multiTouch.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -979,6 +990,7 @@ void tst_QQuickDrawer::multiTouch()
void tst_QQuickDrawer::grabber()
{
QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -1023,6 +1035,7 @@ void tst_QQuickDrawer::interactive()
{
QFETCH(QString, source);
QQuickApplicationHelper helper(this, source);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -1085,6 +1098,7 @@ void tst_QQuickDrawer::flickable()
QFETCH(QPoint, to);
QQuickApplicationHelper helper(this, QStringLiteral("flickable.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -1141,6 +1155,7 @@ void tst_QQuickDrawer::dragOverModalShadow()
QFETCH(bool, mouse);
QQuickApplicationHelper helper(this, QStringLiteral("dragOverModalShadow.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -1197,6 +1212,7 @@ void tst_QQuickDrawer::nonModal()
QFETCH(bool, mouse);
QQuickApplicationHelper helper(this, QStringLiteral("window.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -1280,6 +1296,7 @@ void tst_QQuickDrawer::slider()
QFETCH(int, delta);
QQuickApplicationHelper helper(this, QStringLiteral("slider.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -1323,6 +1340,7 @@ void tst_QQuickDrawer::slider()
void tst_QQuickDrawer::topEdgeScreenEdge()
{
QQuickApplicationHelper helper(this, QStringLiteral("topEdgeScreenEdge.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
diff --git a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp
index 72136445..7612b99b 100644
--- a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp
+++ b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp
@@ -57,6 +57,7 @@ private slots:
void tst_qquickmaterialstyleconf::conf()
{
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QFont customFont;
customFont.setFamily("Courier");
@@ -101,6 +102,7 @@ void tst_qquickmaterialstyleconf::variants()
qputenv("QT_QUICK_CONTROLS_CONF", confPath);
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
diff --git a/tests/auto/qquickmenu/tst_qquickmenu.cpp b/tests/auto/qquickmenu/tst_qquickmenu.cpp
index 2fe47477..092f1b75 100644
--- a/tests/auto/qquickmenu/tst_qquickmenu.cpp
+++ b/tests/auto/qquickmenu/tst_qquickmenu.cpp
@@ -106,6 +106,7 @@ private slots:
void tst_QQuickMenu::defaults()
{
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickMenu *emptyMenu = helper.appWindow->property("emptyMenu").value<QQuickMenu*>();
QCOMPARE(emptyMenu->isVisible(), false);
@@ -117,6 +118,7 @@ void tst_QQuickMenu::defaults()
void tst_QQuickMenu::count()
{
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickMenu *menu = helper.window->property("emptyMenu").value<QQuickMenu*>();
QVERIFY(menu);
@@ -149,6 +151,7 @@ void tst_QQuickMenu::mouse()
QSKIP("Mouse hovering not functional on offscreen/minimal platforms");
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
@@ -244,6 +247,7 @@ void tst_QQuickMenu::mouse()
void tst_QQuickMenu::pressAndHold()
{
QQuickApplicationHelper helper(this, QLatin1String("pressAndHold.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -268,6 +272,7 @@ void tst_QQuickMenu::contextMenuKeyboard()
QSKIP("This platform only allows tab focus for text controls");
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
@@ -451,6 +456,7 @@ void tst_QQuickMenu::disabledMenuItemKeyNavigation()
QSKIP("This platform only allows tab focus for text controls");
QQuickApplicationHelper helper(this, QLatin1String("disabledMenuItemKeyNavigation.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
@@ -515,6 +521,7 @@ void tst_QQuickMenu::mnemonics()
#endif
QQuickApplicationHelper helper(this, QLatin1String("mnemonics.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -562,6 +569,7 @@ void tst_QQuickMenu::menuButton()
QSKIP("This platform only allows tab focus for text controls");
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
@@ -588,6 +596,7 @@ void tst_QQuickMenu::menuButton()
void tst_QQuickMenu::addItem()
{
QQuickApplicationHelper helper(this, QLatin1String("addItem.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -609,6 +618,7 @@ void tst_QQuickMenu::addItem()
void tst_QQuickMenu::menuSeparator()
{
QQuickApplicationHelper helper(this, QLatin1String("menuSeparator.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
centerOnScreen(window);
moveMouseAway(window);
@@ -686,6 +696,7 @@ void tst_QQuickMenu::menuSeparator()
void tst_QQuickMenu::repeater()
{
QQuickApplicationHelper helper(this, QLatin1String("repeater.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -730,6 +741,7 @@ void tst_QQuickMenu::repeater()
void tst_QQuickMenu::order()
{
QQuickApplicationHelper helper(this, QLatin1String("order.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -751,6 +763,7 @@ void tst_QQuickMenu::order()
void tst_QQuickMenu::popup()
{
QQuickApplicationHelper helper(this, QLatin1String("popup.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
moveMouseAway(window);
@@ -907,6 +920,7 @@ void tst_QQuickMenu::popup()
void tst_QQuickMenu::actions()
{
QQuickApplicationHelper helper(this, QLatin1String("actions.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -975,6 +989,7 @@ void tst_QQuickMenu::actions()
void tst_QQuickMenu::removeTakeItem()
{
QQuickApplicationHelper helper(this, QLatin1String("removeTakeItem.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -1038,6 +1053,7 @@ void tst_QQuickMenu::subMenuMouse()
QFETCH(bool, cascade);
QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
moveMouseAway(window);
@@ -1144,6 +1160,7 @@ void tst_QQuickMenu::subMenuDisabledMouse()
QFETCH(bool, cascade);
QQuickApplicationHelper helper(this, QLatin1String("subMenuDisabled.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
moveMouseAway(window);
@@ -1206,6 +1223,7 @@ void tst_QQuickMenu::subMenuKeyboard()
QFETCH(bool, mirrored);
QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
moveMouseAway(window);
@@ -1328,6 +1346,7 @@ void tst_QQuickMenu::subMenuDisabledKeyboard()
QFETCH(bool, mirrored);
QQuickApplicationHelper helper(this, QLatin1String("subMenuDisabled.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
centerOnScreen(window);
moveMouseAway(window);
@@ -1404,6 +1423,7 @@ void tst_QQuickMenu::subMenuPosition()
QFETCH(qreal, overlap);
QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
// Ensure that the default size of the window fits three menus side by side.
@@ -1525,6 +1545,7 @@ void tst_QQuickMenu::subMenuPosition()
void tst_QQuickMenu::addRemoveSubMenus()
{
QQuickApplicationHelper helper(this, QLatin1String("subMenus.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -1595,6 +1616,7 @@ void tst_QQuickMenu::scrollable()
QFETCH(QString, qmlFilePath);
QQuickApplicationHelper helper(this, qmlFilePath);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -1634,6 +1656,7 @@ void tst_QQuickMenu::disableWhenTriggered()
QFETCH(int, subMenuItemIndex);
QQuickApplicationHelper helper(this, QLatin1String("disableWhenTriggered.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -1689,6 +1712,7 @@ void tst_QQuickMenu::menuItemWidth()
QFETCH(bool, mirrored);
QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -1717,6 +1741,7 @@ void tst_QQuickMenu::menuItemWidthAfterMenuWidthChanged()
QFETCH(bool, mirrored);
QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -1761,6 +1786,7 @@ void tst_QQuickMenu::menuItemWidthAfterImplicitWidthChanged()
QFETCH(bool, mirrored);
QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
@@ -1791,6 +1817,7 @@ void tst_QQuickMenu::menuItemWidthAfterImplicitWidthChanged()
void tst_QQuickMenu::menuItemWidthAfterRetranslate()
{
QQuickApplicationHelper helper(this, QLatin1String("menuItemWidths.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowActive(window));
diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp
index 24bfb771..7428cfe3 100644
--- a/tests/auto/qquickpopup/tst_qquickpopup.cpp
+++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp
@@ -109,6 +109,7 @@ void tst_QQuickPopup::visible()
{
QFETCH(QString, source);
QQuickApplicationHelper helper(this, source);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -142,6 +143,7 @@ void tst_QQuickPopup::visible()
void tst_QQuickPopup::state()
{
QQuickApplicationHelper helper(this, "applicationwindow.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -203,6 +205,7 @@ void tst_QQuickPopup::overlay()
QFETCH(bool, dim);
QQuickApplicationHelper helper(this, source);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -365,6 +368,7 @@ void tst_QQuickPopup::zOrder()
{
QFETCH(QString, source);
QQuickApplicationHelper helper(this, source);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -474,6 +478,7 @@ void tst_QQuickPopup::closePolicy()
QFETCH(QQuickPopup::ClosePolicy, closePolicy);
QQuickApplicationHelper helper(this, source);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -558,6 +563,7 @@ void tst_QQuickPopup::activeFocusOnClose1()
// Test that a popup that never sets focus: true (e.g. ToolTip) doesn't affect
// the active focus item when it closes.
QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose1.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
@@ -601,6 +607,7 @@ void tst_QQuickPopup::activeFocusOnClose2()
// calling forceActiveFocus() on another item) before it closes doesn't
// affect the active focus item when it closes.
QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose2.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
@@ -637,6 +644,7 @@ void tst_QQuickPopup::activeFocusOnClose3()
// Test that a closing popup that had focus doesn't steal focus from
// another popup that the focus was transferred to.
QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose3.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
window->requestActivate();
@@ -681,6 +689,7 @@ void tst_QQuickPopup::hover()
QFETCH(bool, modal);
QQuickApplicationHelper helper(this, source);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
window->requestActivate();
@@ -753,6 +762,7 @@ void tst_QQuickPopup::wheel()
QFETCH(bool, modal);
QQuickApplicationHelper helper(this, source);
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -823,6 +833,7 @@ void tst_QQuickPopup::parentDestroyed()
void tst_QQuickPopup::nested()
{
QQuickApplicationHelper helper(this, QStringLiteral("nested.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -850,6 +861,7 @@ void tst_QQuickPopup::nested()
void tst_QQuickPopup::grabber()
{
QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -902,6 +914,7 @@ void tst_QQuickPopup::cursorShape()
// Ensure that the mouse cursor has the correct shape when over a popup
// which is itself over an item with a different shape.
QQuickApplicationHelper helper(this, QStringLiteral("cursor.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -957,6 +970,7 @@ void tst_QQuickPopup::closeOnEscapeWithNestedPopups()
// Tests the scenario in the Gallery example, where there are nested popups that should
// close in the correct order when the Escape key is pressed.
QQuickApplicationHelper helper(this, QStringLiteral("closeOnEscapeWithNestedPopups.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickApplicationWindow *window = helper.appWindow;
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -1054,6 +1068,7 @@ void tst_QQuickPopup::orientation()
QFETCH(QPointF, position);
QQuickApplicationHelper helper(this, "orientation.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->reportContentOrientationChange(orientation);
@@ -1093,6 +1108,7 @@ void tst_QQuickPopup::qquickview()
void tst_QQuickPopup::disabledPalette()
{
QQuickApplicationHelper helper(this, "disabledPalette.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -1130,6 +1146,7 @@ void tst_QQuickPopup::disabledPalette()
void tst_QQuickPopup::disabledParentPalette()
{
QQuickApplicationHelper helper(this, "disabledPalette.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -1177,6 +1194,7 @@ void tst_QQuickPopup::disabledParentPalette()
void tst_QQuickPopup::toolTipCrashOnClose()
{
QQuickApplicationHelper helper(this, "toolTipCrashOnClose.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
@@ -1197,6 +1215,7 @@ void tst_QQuickPopup::toolTipCrashOnClose()
void tst_QQuickPopup::setOverlayParentToNull()
{
QQuickApplicationHelper helper(this, "toolTipCrashOnClose.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
QQuickWindow *window = helper.window;
window->show();
diff --git a/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp b/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp
index 51cc5883..08eae67c 100644
--- a/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp
+++ b/tests/auto/qquickuniversalstyleconf/tst_qquickuniversalstyleconf.cpp
@@ -54,6 +54,7 @@ private slots:
void tst_qquickuniversalstyleconf::conf()
{
QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
QFont customFont;
customFont.setFamily("Courier");
diff --git a/tests/auto/shared/visualtestutil.h b/tests/auto/shared/visualtestutil.h
index d5e651c5..ce737b1b 100644
--- a/tests/auto/shared/visualtestutil.h
+++ b/tests/auto/shared/visualtestutil.h
@@ -122,19 +122,44 @@ namespace QQuickVisualTestUtil
component.loadUrl(testCase->testFileUrl(testFilePath));
QObject *rootObject = component.create();
cleanup.reset(rootObject);
- QVERIFY2(rootObject, qPrintable(QString::fromLatin1("Failed to create window: %1").arg(component.errorString())));
+ if (!rootObject) {
+ errorMessage = QString::fromUtf8("Failed to create window: %1").arg(component.errorString()).toUtf8();
+ return;
+ }
window = qobject_cast<QQuickWindow*>(rootObject);
appWindow = qobject_cast<QQuickApplicationWindow*>(rootObject);
- QVERIFY(window);
- QVERIFY(!window->isVisible());
+ if (!window) {
+ errorMessage = QString::fromUtf8("Root object must be a QQuickWindow subclass").toUtf8();
+ return;
+ }
+
+ if (window->isVisible()) {
+ errorMessage = QString::fromUtf8("Expected window not to be visible, but it is").toUtf8();
+ return;
+ }
+
+ ready = true;
+ }
+
+ // Return a C-style string instead of QString because that's what QTest uses for error messages,
+ // so it saves code at the calling site.
+ inline const char *failureMessage() const
+ {
+ return errorMessage.constData();
}
QQmlEngine engine;
QQmlComponent component;
QScopedPointer<QObject> cleanup;
- QQuickApplicationWindow *appWindow;
- QQuickWindow *window;
+ QQuickApplicationWindow *appWindow = nullptr;
+ QQuickWindow *window = nullptr;
+
+ bool ready = false;
+ // Store as a byte array so that we can return its raw data safely;
+ // using qPrintable() in failureMessage() will construct a throwaway QByteArray
+ // that is destroyed before the function returns.
+ QByteArray errorMessage;
};
void addTestRowForEachControl(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skiplist = QStringList());