From 969a724352dfe3250efb871c70f9482d7b780165 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 5 Jun 2020 10:28:16 +0200 Subject: QQuickApplicationHelper: don't use QTest macros outside test functions This has no effect. Task-number: QTBUG-66320 Pick-to: 5.15 5.12 Change-Id: Ie6efb26243178c4044ac0bc721c21ad89769c982 Reviewed-by: Richard Moe Gustavsen --- tests/auto/cursor/tst_cursor.cpp | 1 + tests/auto/qquickdrawer/tst_qquickdrawer.cpp | 18 +++++++++++ .../tst_qquickmaterialstyleconf.cpp | 2 ++ tests/auto/qquickmenu/tst_qquickmenu.cpp | 27 +++++++++++++++++ tests/auto/qquickpopup/tst_qquickpopup.cpp | 24 +++++++++++++++ .../tst_qquickuniversalstyleconf.cpp | 1 + tests/auto/shared/visualtestutil.h | 35 ++++++++++++++++++---- 7 files changed, 103 insertions(+), 5 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/cursor/tst_cursor.cpp b/tests/auto/cursor/tst_cursor.cpp index 2491a972..ed5db5b1 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 7644cacf..108cd4a1 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(); @@ -628,6 +635,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)); @@ -690,6 +698,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)); @@ -834,6 +843,7 @@ void tst_QQuickDrawer::touch() QFETCH(QPoint, to); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -868,6 +878,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)); @@ -981,6 +992,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)); @@ -1025,6 +1037,7 @@ void tst_QQuickDrawer::interactive() { QFETCH(QString, source); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1087,6 +1100,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)); @@ -1143,6 +1157,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)); @@ -1199,6 +1214,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)); @@ -1282,6 +1298,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)); @@ -1325,6 +1342,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 37d1e5ac..9d29c675 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(); 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(); 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); @@ -247,6 +250,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(); @@ -271,6 +275,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); @@ -456,6 +461,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); @@ -520,6 +526,7 @@ void tst_QQuickMenu::mnemonics() #endif QQuickApplicationHelper helper(this, QLatin1String("mnemonics.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -567,6 +574,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(); @@ -593,6 +601,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)); @@ -614,6 +623,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); @@ -691,6 +701,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)); @@ -735,6 +746,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)); @@ -756,6 +768,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); @@ -912,6 +925,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)); @@ -980,6 +994,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)); @@ -1037,6 +1052,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); @@ -1143,6 +1159,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); @@ -1205,6 +1222,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); @@ -1327,6 +1345,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); @@ -1403,6 +1422,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. @@ -1524,6 +1544,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 162a48ba..184d8ad8 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -118,6 +118,7 @@ void tst_QQuickPopup::visible() { QFETCH(QString, source); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -151,6 +152,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(); @@ -212,6 +214,7 @@ void tst_QQuickPopup::overlay() QFETCH(bool, dim); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -374,6 +377,7 @@ void tst_QQuickPopup::zOrder() { QFETCH(QString, source); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -483,6 +487,7 @@ void tst_QQuickPopup::closePolicy() QFETCH(QQuickPopup::ClosePolicy, closePolicy); QQuickApplicationHelper helper(this, source); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -567,6 +572,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(); @@ -610,6 +616,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(); @@ -646,6 +653,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(); @@ -677,6 +685,7 @@ void tst_QQuickPopup::activeFocusOnClosingSeveralPopups() { // Test that active focus isn't lost when multiple popup closing simultaneously QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClosingSeveralPopups.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickApplicationWindow *window = helper.appWindow; window->show(); window->requestActivate(); @@ -738,6 +747,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(); @@ -812,6 +822,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)); @@ -882,6 +893,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)); @@ -909,6 +921,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)); @@ -961,6 +974,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; centerOnScreen(window); moveMouseAway(window); @@ -1018,6 +1032,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)); @@ -1081,6 +1096,7 @@ void tst_QQuickPopup::closeOnEscapeWithNestedPopups() void tst_QQuickPopup::closeOnEscapeWithVisiblePopup() { QQuickApplicationHelper helper(this, QStringLiteral("closeOnEscapeWithVisiblePopup.qml")); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -1131,6 +1147,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); @@ -1170,6 +1187,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(); @@ -1206,6 +1224,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(); @@ -1251,6 +1270,7 @@ void tst_QQuickPopup::disabledParentPalette() void tst_QQuickPopup::countChanged() { QQuickApplicationHelper helper(this, "countChanged.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1273,6 +1293,7 @@ void tst_QQuickPopup::toolTipCrashOnClose() QSKIP("Test requires QtGraphicalEffects"); QQuickApplicationHelper helper(this, "toolTipCrashOnClose.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1293,6 +1314,7 @@ void tst_QQuickPopup::setOverlayParentToNull() QSKIP("Test requires QtGraphicalEffects"); QQuickApplicationHelper helper(this, "toolTipCrashOnClose.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1313,6 +1335,7 @@ void tst_QQuickPopup::tabFence() QSKIP("This platform only allows tab focus for text controls"); QQuickApplicationHelper helper(this, "tabFence.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; window->show(); @@ -1366,6 +1389,7 @@ void tst_QQuickPopup::tabFence() void tst_QQuickPopup::invisibleToolTipOpen() { QQuickApplicationHelper helper(this, "invisibleToolTipOpen.qml"); + QVERIFY2(helper.ready, helper.failureMessage()); QQuickWindow *window = helper.window; centerOnScreen(window); 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..e3f4075d 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(rootObject); appWindow = qobject_cast(rootObject); - QVERIFY(window); - QVERIFY(!window->isVisible()); + if (!window) { + errorMessage = QString::fromUtf8("Root object %1 must be a QQuickWindow subclass").arg(QDebug::toString(window)).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 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()); -- cgit v1.2.3