diff options
author | Juha Vuolle <[email protected]> | 2025-04-25 10:34:59 +0300 |
---|---|---|
committer | Juha Vuolle <[email protected]> | 2025-05-02 08:26:12 +0300 |
commit | cc98876fea54e973f552ec33747c2e2a2fd32e08 (patch) | |
tree | ee9dbb3cd26c7003f9f8c74d0dc1cc6df9e4ac43 | |
parent | f4c2eeac6a01d2c9aea8f4281896e420399c19ae (diff) |
Fix QmltcTests compilation when tableview or gridview is disabled
Put two of the QML files behind appropriate feature flags (they
use TableView and GridView). Similarly guard the cpp side
includes and access to the genrated QML type.
As a drive-by add include guard when qml-table-model is disabled.
Task-number: QTBUG-136101
Pick-to: 6.9 6.8
Change-Id: Ic643ccb3f8346fc650afe5d863b575e8cec2f57a
Reviewed-by: Sami Shalayel <[email protected]>
Reviewed-by: Oliver Eftevaag <[email protected]>
-rw-r--r-- | tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt | 9 | ||||
-rw-r--r-- | tests/auto/qml/qmltc/tst_qmltc.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qml/qmltc/tst_qmltc.h | 5 |
3 files changed, 22 insertions, 2 deletions
diff --git a/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt b/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt index 3eab68a7e7..3bb8133e9b 100644 --- a/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt +++ b/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt @@ -33,9 +33,7 @@ set(qml_sources simpleQtQuickTypes.qml typeWithEnums.qml methods.qml - properties.qml ObjectWithId.qml - documentWithIds.qml importNamespace.qml gradients.qml qjsvalueAssignments.qml @@ -161,6 +159,13 @@ set(common_libraries Qt::Gui # QColor, QMatrix4x4, ... ) +if(QT_FEATURE_quick_tableview) + list(APPEND qml_sources properties.qml) + if(QT_FEATURE_quick_gridview) + list(APPEND qml_sources documentWithIds.qml) + endif() +endif() + if (QT_FEATURE_qml_table_model) list(APPEND qml_sources QmlTableModel.qml) list(APPEND common_libraries Qt::LabsQmlModelsPrivate) diff --git a/tests/auto/qml/qmltc/tst_qmltc.cpp b/tests/auto/qml/qmltc/tst_qmltc.cpp index 73ef03eaaf..d2fcab4658 100644 --- a/tests/auto/qml/qmltc/tst_qmltc.cpp +++ b/tests/auto/qml/qmltc/tst_qmltc.cpp @@ -9,9 +9,13 @@ #include "simpleqtquicktypes.h" #include "typewithenums.h" #include "methods.h" +#if QT_CONFIG(quick_tableview) #include "properties.h" +#endif #include "objectwithid.h" +#if QT_CONFIG(quick_gridview) #include "documentwithids.h" +#endif #include "importnamespace.h" #include "deferredproperties.h" #include "deferredproperties_group.h" @@ -87,7 +91,9 @@ #include "mysignals.h" #include "namespacedtypes.h" #include "type.h" +#if QT_CONFIG(qml_table_model) #include "qmltablemodel.h" +#endif #include "stringtourl.h" #include "signalconnections.h" #include "requiredproperties.h" @@ -334,6 +340,7 @@ void tst_qmltc::methods() QCOMPARE(metaTypedMethod.parameterNames(), QList<QByteArray>({ "a", "b" })); } +#if QT_CONFIG(quick_tableview) void tst_qmltc::properties() { QQmlEngine e; @@ -478,7 +485,9 @@ void tst_qmltc::properties() QVERIFY(sentinelForComponent); QCOMPARE(sentinelForComponent->property("text").toString(), u"should be correctly created"_s); } +#endif // QT_CONFIG(quick_tableview) +#if QT_CONFIG(quick_tableview) && QT_CONFIG(quick_gridview) void tst_qmltc::ids() { { @@ -575,6 +584,7 @@ void tst_qmltc::ids() verifyComponent(afterChild, QString(), u"afterDelegateDefaultPropertyText"_s); } } +#endif // QT_CONFIG(quick_tableview) && QT_CONFIG(quick_gridview) void tst_qmltc::importNamespace() { diff --git a/tests/auto/qml/qmltc/tst_qmltc.h b/tests/auto/qml/qmltc/tst_qmltc.h index 99abb60dc5..17a464bdb2 100644 --- a/tests/auto/qml/qmltc/tst_qmltc.h +++ b/tests/auto/qml/qmltc/tst_qmltc.h @@ -3,6 +3,7 @@ #include <qtest.h> #include <private/qtqmlmodelsglobal_p.h> +#include <private/qtquick-config_p.h> // For feature definitions using namespace Qt::StringLiterals; @@ -27,8 +28,12 @@ private slots: void qtQuickIncludes(); void enumerations(); void methods(); +#if QT_CONFIG(quick_tableview) void properties(); +#if QT_CONFIG(quick_gridview) void ids(); +#endif +#endif void importNamespace(); void deferredProperties(); void gradients(); // QTBUG-102560 |