diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_spinbox.qml | 16 | ||||
-rw-r--r-- | tests/auto/customization/data/styles/identified/AbstractButton.qml | 3 | ||||
-rw-r--r-- | tests/auto/customization/tst_customization.cpp | 36 |
3 files changed, 50 insertions, 5 deletions
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index d3a0d8bb..22dbb352 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -658,4 +658,20 @@ TestCase { compare(control.displayText, data.displayTexts[i]) } } + + Component { + id: overriddenSpinBox + SpinBox { + value: 50 + up.indicator: Rectangle { + property string s: "this is the one" + } + } + } + + function test_indicatorOverridden() { + var control = createTemporaryObject(overriddenSpinBox, testCase) + verify(control) + compare(control.up.indicator.s, "this is the one"); + } } diff --git a/tests/auto/customization/data/styles/identified/AbstractButton.qml b/tests/auto/customization/data/styles/identified/AbstractButton.qml index b9656f7a..cd2b5bdc 100644 --- a/tests/auto/customization/data/styles/identified/AbstractButton.qml +++ b/tests/auto/customization/data/styles/identified/AbstractButton.qml @@ -58,15 +58,18 @@ T.AbstractButton { indicator: Item { id: indicator objectName: "abstractbutton-indicator-identified" + Accessible.name: objectName } contentItem: Item { id: contentItem objectName: "abstractbutton-contentItem-identified" + Accessible.name: objectName } background: Item { id: background objectName: "abstractbutton-background-identified" + Accessible.name: objectName } } diff --git a/tests/auto/customization/tst_customization.cpp b/tests/auto/customization/tst_customization.cpp index 41efc2a6..cce74b41 100644 --- a/tests/auto/customization/tst_customization.cpp +++ b/tests/auto/customization/tst_customization.cpp @@ -42,6 +42,7 @@ #include <QtQuick/qquickitem.h> #include <QtQuick/qquickwindow.h> #include <QtQuickControls2/qquickstyle.h> +#include <QtQuickTemplates2/private/qquickcontrol_p_p.h> #include "../shared/visualtestutil.h" using namespace QQuickVisualTestUtil; @@ -439,11 +440,36 @@ void tst_customization::override() QVERIFY2(qt_createdQObjects()->isEmpty(), qPrintable("unexpectedly created: " + qt_createdQObjects->join(", "))); if (!nonDeferred.isEmpty()) { - for (QString delegate : qAsConst(delegates)) { - if (!delegate.contains("-")) - delegate.append("-" + nonDeferred); - delegate.prepend(type.toLower() + "-"); - QVERIFY2(qt_destroyedQObjects()->removeOne(delegate), qPrintable(delegate + " was not destroyed as expected")); + // There were items for which deferred execution was not possible. + for (QString delegateName : qAsConst(delegates)) { + if (!delegateName.contains("-")) + delegateName.append("-" + nonDeferred); + delegateName.prepend(type.toLower() + "-"); + + const int delegateIndex = qt_destroyedQObjects()->indexOf(delegateName); + QVERIFY2(delegateIndex == -1, qPrintable(delegateName + " was unexpectedly destroyed")); + + const auto controlChildren = control->children(); + const auto childIt = std::find_if(controlChildren.constBegin(), controlChildren.constEnd(), [delegateName](const QObject *child) { + return child->objectName() == delegateName; + }); + // We test other delegates (like the background) here, so make sure we don't end up with XPASSes by using the wrong delegate. + if (delegateName.contains(QLatin1String("handle"))) { + QEXPECT_FAIL("identified:RangeSlider", "For some reason, items that are belong to grouped properties fail here", Abort); + QEXPECT_FAIL("overidentified:RangeSlider", "For some reason, items that are belong to grouped properties fail here", Abort); + } + if (delegateName.contains(QLatin1String("indicator"))) { + QEXPECT_FAIL("identified:SpinBox", "For some reason, items that are belong to grouped properties fail here", Abort); + QEXPECT_FAIL("overidentified:SpinBox", "For some reason, items that are belong to grouped properties fail here", Abort); + } + QVERIFY2(childIt != controlChildren.constEnd(), qPrintable(QString::fromLatin1( + "Expected delegate \"%1\" to still be a QObject child of \"%2\"").arg(delegateName).arg(controlName))); + + const auto *delegate = qobject_cast<QQuickItem*>(*childIt); + // Ensure that the item is hidden, etc. + QVERIFY(delegate); + QCOMPARE(delegate->isVisible(), false); + QCOMPARE(delegate->parentItem(), nullptr); } } |