diff options
author | Jari Helaakoski <[email protected]> | 2024-04-24 14:40:49 +0300 |
---|---|---|
committer | Jari Helaakoski <[email protected]> | 2024-04-30 09:00:03 +0000 |
commit | 4949768067cfc8a16c0cef958928e94147842bb8 (patch) | |
tree | d4138c6bc0ebbc9f5158fe667759287eee016967 /tests/auto | |
parent | 86cb97000b2acf1185634f9f9bdaa023e685b969 (diff) |
Fix test compilation issues with QtLite configuration
Now developer build tests compile, but some are not working.
Functional fix will come later via separate tasks.
Task-number: QTBUG-122999
Change-Id: I0a0dfcf7affb73f928b8be62b3576a6a51658488
Reviewed-by: Ulf Hermann <[email protected]>
Diffstat (limited to 'tests/auto')
13 files changed, 92 insertions, 8 deletions
diff --git a/tests/auto/core/CMakeLists.txt b/tests/auto/core/CMakeLists.txt index fefa6ff1c1..8a5e039673 100644 --- a/tests/auto/core/CMakeLists.txt +++ b/tests/auto/core/CMakeLists.txt @@ -3,4 +3,6 @@ add_subdirectory(qqmlstandardpaths) add_subdirectory(qqmlsysteminformation) -add_subdirectory(qqmlsettings) +if(QT_FEATURE_settings) + add_subdirectory(qqmlsettings) +endif() diff --git a/tests/auto/qml/CMakeLists.txt b/tests/auto/qml/CMakeLists.txt index 6302df235d..6b81f4c616 100644 --- a/tests/auto/qml/CMakeLists.txt +++ b/tests/auto/qml/CMakeLists.txt @@ -34,7 +34,9 @@ add_subdirectory(qqmlerror) add_subdirectory(qqmlincubator) add_subdirectory(qqmlinfo) add_subdirectory(qqmllistreference) -add_subdirectory(qqmllocale) +if(QT_FEATURE_qml_locale) + add_subdirectory(qqmllocale) +endif() add_subdirectory(qqmlmetaobject) if(NOT ANDROID) # QTBUG-100003 add_subdirectory(qqmlmoduleplugin) @@ -46,7 +48,9 @@ add_subdirectory(qqmlpromise) add_subdirectory(qtqmlmodules) add_subdirectory(qquickfolderlistmodel) add_subdirectory(qqmlapplicationengine) -add_subdirectory(qqmlsettings) +if(QT_FEATURE_settings) + add_subdirectory(qqmlsettings) +endif() if(NOT INTEGRITY) # There's no mounted filesystem on INTEGRITY therefore skipping qmldiskcache diff --git a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp index 76fa1328e7..450560833f 100644 --- a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp +++ b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp @@ -145,9 +145,11 @@ void tst_qjsonbinding::cppJsConversion() { QJSValue jsValue = eng.toScriptValue(jsonValue); +#if QT_DEPRECATED_SINCE(6, 9) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED QVERIFY(!jsValue.isVariant()); QT_WARNING_POP +#endif switch (jsonValue.type()) { case QJsonValue::Null: QVERIFY(jsValue.isNull()); diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 56140836bf..3c25d29dfb 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -36,8 +36,10 @@ public: private slots: void initTestCase() override; void rootContext(); +#if QT_CONFIG(qml_network) void networkAccessManager(); void synchronousNetworkAccessManager(); +#endif void baseUrl(); void contextForObject(); void offlineStoragePath(); @@ -153,6 +155,7 @@ void tst_qqmlengine::rootContext() QVERIFY(!engine.rootContext()->parentContext()); } +#if QT_CONFIG(qml_network) class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory { public: @@ -228,7 +231,7 @@ void tst_qqmlengine::synchronousNetworkAccessManager() // reply is finished, so should not be in loading state. QVERIFY(!c.isLoading()); } - +#endif void tst_qqmlengine::baseUrl() { diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp index 0e1bb1abc3..e57eb1b65a 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -131,7 +131,9 @@ void registerStaticPlugin(const char *uri) PluginType::metaData.append(char(QT_VERSION_MAJOR)); PluginType::metaData.append(char(QT_VERSION_MINOR)); PluginType::metaData.append(char(qPluginArchRequirements())); +#if QT_CONFIG(cborstreamwriter) PluginType::metaData.append(QCborValue(QCborMap::fromJsonObject(md)).toCbor()); +#endif auto rawMetaDataFunctor = []() -> QPluginMetaData { return {reinterpret_cast<const uchar *>(PluginType::metaData.constData()), size_t(PluginType::metaData.size())}; diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp index 710bbce17a..9fea41104d 100644 --- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -57,8 +57,10 @@ private slots: void alpha(); void tint(); void color(); +#if QT_CONFIG(desktopservices) void openUrlExternally(); void openUrlExternally_pragmaLibrary(); +#endif void md5(); void createComponent(); void createComponent_pragmaLibrary(); @@ -613,6 +615,7 @@ public slots: void noteCall(const QUrl &url) { called++; last = url; } }; +#if QT_CONFIG(desktopservices) void tst_qqmlqt::openUrlExternally() { MyUrlHandler handler; @@ -659,6 +662,7 @@ void tst_qqmlqt::openUrlExternally_pragmaLibrary() QCOMPARE(handler.called,2); QCOMPARE(handler.last, htmlTestFile); } +#endif void tst_qqmlqt::md5() { diff --git a/tests/auto/quick/qquickpixmapcache/CMakeLists.txt b/tests/auto/quick/qquickpixmapcache/CMakeLists.txt index 1e1d35a8af..97735172f2 100644 --- a/tests/auto/quick/qquickpixmapcache/CMakeLists.txt +++ b/tests/auto/quick/qquickpixmapcache/CMakeLists.txt @@ -24,7 +24,6 @@ qt_internal_add_test(tst_qquickpixmapcache tst_qquickpixmapcache.cpp deviceloadingimage.h deviceloadingimage.cpp LIBRARIES - Qt::Concurrent Qt::CorePrivate Qt::Gui Qt::GuiPrivate @@ -48,6 +47,11 @@ qt_internal_extend_target(tst_qquickpixmapcache CONDITION NOT ANDROID AND NOT IO QT_QMLTEST_DATADIR="${CMAKE_CURRENT_SOURCE_DIR}/data" ) +qt_internal_extend_target(tst_qquickpixmapcache CONDITION QT_FEATURE_concurrent + LIBRARIES + Qt::Concurrent +) + qt_policy(SET QTP0001 NEW) qt_add_qml_module(tst_qquickpixmapcache URI PixmapCacheTest diff --git a/tests/auto/quickcontrols/focus/tst_focus.cpp b/tests/auto/quickcontrols/focus/tst_focus.cpp index c6a82ebaba..5d745813dc 100644 --- a/tests/auto/quickcontrols/focus/tst_focus.cpp +++ b/tests/auto/quickcontrols/focus/tst_focus.cpp @@ -198,6 +198,7 @@ void tst_focus::policy() control->setFocus(false); QVERIFY(!control->hasActiveFocus()); +#if QT_CONFIG(wheelevent) // Qt::WheelFocus QWheelEvent wheelEvent(QPointF(control->width() / 2, control->height() / 2), QPointF(), QPoint(), QPoint(0, 10), Qt::NoButton, Qt::NoModifier, @@ -212,6 +213,7 @@ void tst_focus::policy() QGuiApplication::sendEvent(control, &wheelEvent); QVERIFY(control->hasActiveFocus()); QVERIFY(!control->hasVisualFocus()); +#endif } void tst_focus::reason() @@ -396,6 +398,7 @@ void tst_focus::reason() customItem->setFocusReason(Qt::NoFocusReason); customText->setFocusReason(Qt::NoFocusReason); +#if QT_CONFIG(wheelevent) // Wheel focus -> MouseFocusReason QWheelEvent wheelEvent(QPointF(customItem->width() / 2, customItem->height() / 2), QPointF(), QPoint(), QPoint(0, 10), Qt::NoButton, Qt::NoModifier, @@ -409,6 +412,7 @@ void tst_focus::reason() QTRY_VERIFY(!customItem->hasActiveFocus()); QCOMPARE(customItem->focusReason(), Qt::PopupFocusReason); QTest::keyClick(&view, Qt::Key_Escape); // close the popup +#endif } void tst_focus::visualFocus() @@ -502,6 +506,7 @@ void tst_focus::scope() QVERIFY(child->hasActiveFocus()); QVERIFY(control->hasActiveFocus()); +#if QT_CONFIG(wheelevent) // Qt::WheelFocus QWheelEvent wheelEvent(QPointF(control->width() / 2, control->height() / 2), QPointF(), QPoint(), QPoint(0, 10), Qt::NoButton, Qt::NoModifier, @@ -509,6 +514,7 @@ void tst_focus::scope() QGuiApplication::sendEvent(control, &wheelEvent); QVERIFY(!child->hasActiveFocus()); QVERIFY(control->hasActiveFocus()); +#endif } QTEST_MAIN(tst_focus) diff --git a/tests/auto/quickcontrols/platform/tst_platform.cpp b/tests/auto/quickcontrols/platform/tst_platform.cpp index eeb5e64486..dbcc383f03 100644 --- a/tests/auto/quickcontrols/platform/tst_platform.cpp +++ b/tests/auto/quickcontrols/platform/tst_platform.cpp @@ -10,14 +10,17 @@ class Setup : public QObject { Q_OBJECT Q_PROPERTY(bool shortcutsSupported READ areShortcutsSupported CONSTANT FINAL) - - Q_PROPERTY(int shortcutInt MEMBER m_shortcutInt CONSTANT FINAL) Q_PROPERTY(QString shortcutString MEMBER m_shortcutString CONSTANT FINAL) +#if QT_CONFIG(shortcut) + Q_PROPERTY(int shortcutInt MEMBER m_shortcutInt CONSTANT FINAL) Q_PROPERTY(QKeySequence shortcutKeySequence MEMBER m_shortcutKeySequence CONSTANT FINAL) +#endif - const int m_shortcutInt = QKeySequence::Print; const QString m_shortcutString = u"CTRL+P"_s; +#if QT_CONFIG(shortcut) + const int m_shortcutInt = QKeySequence::Print; const QKeySequence m_shortcutKeySequence{ Qt::CTRL | Qt::Key_P }; +#endif public: bool areShortcutsSupported() const diff --git a/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp index cefb494c6f..5eb3895849 100644 --- a/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp @@ -63,8 +63,10 @@ private slots: void hover_data(); void hover(); +#if QT_CONFIG(wheelevent) void wheel_data(); void wheel(); +#endif void multiple(); @@ -617,6 +619,7 @@ void tst_QQuickDrawer::hover() QVERIFY(!drawerItem->isHovered()); } +#if QT_CONFIG(wheelevent) void tst_QQuickDrawer::wheel_data() { QTest::addColumn<QString>("source"); @@ -703,6 +706,7 @@ void tst_QQuickDrawer::wheel() QVERIFY(qFuzzyCompare(drawerSlider->value(), oldDrawerValue)); // must not have moved } } +#endif void tst_QQuickDrawer::multiple() { diff --git a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp index e774d055e1..f894387672 100644 --- a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp @@ -68,12 +68,16 @@ private slots: void activeFocusItemAfterWindowInactive(); void hover_data(); void hover(); +#if QT_CONFIG(wheelevent) void wheel_data(); void wheel(); +#endif void parentDestroyed(); void nested(); +#if QT_CONFIG(wheelevent) void nestedWheel(); void nestedWheelWithOverlayParent(); +#endif void modelessOnModalOnModeless(); void grabber(); void cursorShape(); @@ -1068,6 +1072,7 @@ void tst_QQuickPopup::hover() QVERIFY(parentButton->isHovered()); } +#if QT_CONFIG(wheelevent) void tst_QQuickPopup::wheel_data() { QTest::addColumn<QString>("source"); @@ -1181,6 +1186,7 @@ void tst_QQuickPopup::wheel() QVERIFY(qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must not have moved } } +#endif void tst_QQuickPopup::parentDestroyed() { @@ -1219,6 +1225,7 @@ void tst_QQuickPopup::nested() QCOMPARE(modalPopup->isVisible(), true); } +#if QT_CONFIG(wheelevent) void tst_QQuickPopup::nestedWheel() { QQuickControlsApplicationHelper helper(this, QStringLiteral("nested-wheel.qml")); @@ -1283,6 +1290,7 @@ void tst_QQuickPopup::nestedWheelWithOverlayParent() // Wheel over the list view, verify that it scrolls QTRY_COMPARE(listView->contentY(), 72.); } +#endif void tst_QQuickPopup::modelessOnModalOnModeless() { diff --git a/tests/auto/quickdialogs/qquickfiledialogimpl/tst_qquickfiledialogimpl.cpp b/tests/auto/quickdialogs/qquickfiledialogimpl/tst_qquickfiledialogimpl.cpp index aa462da5dc..f7f2bd8c85 100644 --- a/tests/auto/quickdialogs/qquickfiledialogimpl/tst_qquickfiledialogimpl.cpp +++ b/tests/auto/quickdialogs/qquickfiledialogimpl/tst_qquickfiledialogimpl.cpp @@ -118,8 +118,10 @@ private: QDir oldCurrentDir; +#if QT_CONFIG(shortcut) const QKeySequence goUpKeySequence = QKeySequence(Qt::ALT | Qt::Key_Up); const QKeySequence editPathKeySequence = QKeySequence(Qt::CTRL | Qt::Key_L); +#endif }; QStringList tst_QQuickFileDialogImpl::tempDirExpectedVisibleFiles(DelegateOrderPolicy order) const @@ -391,6 +393,7 @@ void tst_QQuickFileDialogImpl::chooseFileViaTextEdit() // below fail due to it being hidden when it loses activeFocus. VERIFY_FILE_SELECTED_AND_FOCUSED(QUrl::fromLocalFile(tempDir.path()), QUrl::fromLocalFile(tempSubDir.path()), 0); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. QTest::keySequence(dialogHelper.window(), editPathKeySequence); auto breadcrumbBar = dialogHelper.quickDialog->findChild<QQuickFolderBreadcrumbBar*>(); @@ -410,6 +413,7 @@ void tst_QQuickFileDialogImpl::chooseFileViaTextEdit() COMPARE_URLS(dialogHelper.dialog->selectedFiles(), { QUrl::fromLocalFile(tempFile2->fileName()) }); QVERIFY(!dialogHelper.dialog->isVisible()); QTRY_VERIFY(!dialogHelper.quickDialog->isVisible()); +#endif } void tst_QQuickFileDialogImpl::chooseFileViaEnter() @@ -553,9 +557,11 @@ void tst_QQuickFileDialogImpl::chooseFolderViaTextEdit() // See comment in chooseFileViaTextEdit for why we check for this. VERIFY_FILE_SELECTED_AND_FOCUSED(QUrl::fromLocalFile(tempDir.path()), QUrl::fromLocalFile(tempSubDir.path()), 0); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. const auto editPathKeySequence = QKeySequence(Qt::CTRL | Qt::Key_L); QTest::keySequence(dialogHelper.window(), editPathKeySequence); +#endif auto breadcrumbBar = dialogHelper.quickDialog->findChild<QQuickFolderBreadcrumbBar*>(); QVERIFY(breadcrumbBar); QVERIFY(breadcrumbBar->textField()->isVisible()); @@ -614,8 +620,10 @@ void tst_QQuickFileDialogImpl::chooseFileAndThenFolderViaTextEdit() // See comment in chooseFileViaTextEdit for why we check for this. VERIFY_FILE_SELECTED_AND_FOCUSED(QUrl::fromLocalFile(tempDir.path()), QUrl::fromLocalFile(tempSubDir.path()), 0); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. QTest::keySequence(dialogHelper.window(), editPathKeySequence); +#endif auto breadcrumbBar = dialogHelper.quickDialog->findChild<QQuickFolderBreadcrumbBar*>(); QVERIFY(breadcrumbBar); QVERIFY(breadcrumbBar->textField()->isVisible()); @@ -642,8 +650,10 @@ void tst_QQuickFileDialogImpl::chooseFileAndThenFolderViaTextEdit() // The breadcrumbs should be visible after opening, not the text edit. QVERIFY(!breadcrumbBar->textField()->isVisible()); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. QTest::keySequence(dialogHelper.window(), editPathKeySequence); +#endif QVERIFY(breadcrumbBar->textField()->isVisible()); // The text edit should show the directory that contains the last file that was selected. QCOMPARE(breadcrumbBar->textField()->text(), tempDir.path()); @@ -677,8 +687,10 @@ void tst_QQuickFileDialogImpl::cancelDialogWhileTextEditHasFocus() // See comment in chooseFileViaTextEdit for why we check for this. VERIFY_FILE_SELECTED_AND_FOCUSED(QUrl::fromLocalFile(tempDir.path()), QUrl::fromLocalFile(tempSubDir.path()), 0); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. QTest::keySequence(dialogHelper.window(), editPathKeySequence); +#endif auto breadcrumbBar = dialogHelper.quickDialog->findChild<QQuickFolderBreadcrumbBar*>(); QVERIFY(breadcrumbBar); QVERIFY(breadcrumbBar->textField()->hasActiveFocus()); @@ -763,6 +775,7 @@ void tst_QQuickFileDialogImpl::goUp() int expectedCurrentIndex = showDirsFirst ? 0 : 2; VERIFY_FILE_SELECTED_AND_FOCUSED(QUrl::fromLocalFile(tempDir.path()), QUrl::fromLocalFile(tempSubDir.path()), expectedCurrentIndex); +#if QT_CONFIG(shortcut) // Go up a directory via the keyboard shortcut. QDir tempParentDir(tempDir.path()); QVERIFY(tempParentDir.cdUp()); @@ -775,6 +788,7 @@ void tst_QQuickFileDialogImpl::goUp() QVERIFY(expectedCurrentIndex != -1); VERIFY_FILE_SELECTED_AND_FOCUSED(QUrl::fromLocalFile(tempParentDir.path()), QUrl::fromLocalFile(tempDir.path()), expectedCurrentIndex); } +#endif } void tst_QQuickFileDialogImpl::goUpWhileTextEditHasFocus() @@ -786,8 +800,10 @@ void tst_QQuickFileDialogImpl::goUpWhileTextEditHasFocus() // See comment in chooseFileViaTextEdit for why we check for this. VERIFY_FILE_SELECTED_AND_FOCUSED(QUrl::fromLocalFile(tempSubDir.path()), QUrl::fromLocalFile(tempSubSubDir.path()), 0); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. QTest::keySequence(dialogHelper.window(), editPathKeySequence); +#endif auto breadcrumbBar = dialogHelper.quickDialog->findChild<QQuickFolderBreadcrumbBar*>(); QVERIFY(breadcrumbBar); QVERIFY(breadcrumbBar->textField()->hasActiveFocus()); @@ -854,6 +870,7 @@ void tst_QQuickFileDialogImpl::goUpIntoLargeFolder() VERIFY_FILE_SELECTED_AND_FOCUSED(QUrl::fromLocalFile(largeTempDirLargeSubDir.path()), QUrl::fromLocalFile(largeTempDirLargeSubDir.path() + "/sub-dir000"), 0); +#if QT_CONFIG(shortcut) // Go up a directory via the keyboard shortcut. QTest::keySequence(dialogHelper.window(), goUpKeySequence); QString failureMessage; @@ -861,6 +878,7 @@ void tst_QQuickFileDialogImpl::goUpIntoLargeFolder() largeTempDirPaths, failureMessage), qPrintable(failureMessage)); VERIFY_FILE_SELECTED_AND_FOCUSED(QUrl::fromLocalFile(largeTempDir.path()), QUrl::fromLocalFile(largeTempDirLargeSubDir.path()), largeTempDirLargeSubDirIndex); +#endif } void tst_QQuickFileDialogImpl::keyAndShortcutHandling() @@ -870,16 +888,20 @@ void tst_QQuickFileDialogImpl::keyAndShortcutHandling() OPEN_QUICK_DIALOG(); VERIFY_FILE_SELECTED_AND_FOCUSED(QUrl::fromLocalFile(tempDir.path()), QUrl::fromLocalFile(tempSubDir.path()), 0); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. QTest::keySequence(dialogHelper.window(), editPathKeySequence); +#endif auto breadcrumbBar = dialogHelper.quickDialog->findChild<QQuickFolderBreadcrumbBar*>(); QVERIFY(breadcrumbBar); QVERIFY(breadcrumbBar->textField()->isVisible()); QCOMPARE(breadcrumbBar->textField()->text(), dialogHelper.dialog->currentFolder().toLocalFile()); QCOMPARE(breadcrumbBar->textField()->selectedText(), breadcrumbBar->textField()->text()); +#if QT_CONFIG(shortcut) // Ctrl+L shouldn't hide it. QTest::keySequence(dialogHelper.window(), editPathKeySequence); +#endif QVERIFY(breadcrumbBar->textField()->isVisible()); // Cancel it with the escape key. @@ -887,8 +909,10 @@ void tst_QQuickFileDialogImpl::keyAndShortcutHandling() QVERIFY(!breadcrumbBar->textField()->isVisible()); QVERIFY(dialogHelper.dialog->isVisible()); +#if QT_CONFIG(shortcut) // Make it visible. QTest::keySequence(dialogHelper.window(), editPathKeySequence); +#endif QVERIFY(breadcrumbBar->textField()->isVisible()); // Cancel it with the escape key again. @@ -1187,10 +1211,12 @@ void tst_QQuickFileDialogImpl::itemsDisabledWhenNecessary() COMPARE_URL(dialogHelper.dialog->currentFolder(), QUrl::fromLocalFile(anotherTempDir.path())); COMPARE_URL(dialogHelper.quickDialog->currentFolder(), QUrl::fromLocalFile(anotherTempDir.path())); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. The Open button should now be disabled. QTest::keySequence(dialogHelper.window(), editPathKeySequence); QVERIFY(breadcrumbBar->textField()->isVisible()); QCOMPARE(openButton->isEnabled(), false); +#endif // Hide it with the escape key. The Open button should now be enabled. QTest::keyClick(dialogHelper.window(), Qt::Key_Escape); @@ -1254,8 +1280,10 @@ void tst_QQuickFileDialogImpl::fileMode() COMPARE_URLS(dialogHelper.dialog->currentFiles(), { QUrl::fromLocalFile(tempFile2->fileName()) }); } +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. QTest::keySequence(dialogHelper.window(), editPathKeySequence); +#endif auto breadcrumbBar = dialogHelper.quickDialog->findChild<QQuickFolderBreadcrumbBar*>(); QVERIFY(breadcrumbBar); QVERIFY(breadcrumbBar->textField()->isVisible()); diff --git a/tests/auto/quickdialogs/qquickfolderdialogimpl/tst_qquickfolderdialogimpl.cpp b/tests/auto/quickdialogs/qquickfolderdialogimpl/tst_qquickfolderdialogimpl.cpp index 0c29dad3da..2afcd81a44 100644 --- a/tests/auto/quickdialogs/qquickfolderdialogimpl/tst_qquickfolderdialogimpl.cpp +++ b/tests/auto/quickdialogs/qquickfolderdialogimpl/tst_qquickfolderdialogimpl.cpp @@ -344,6 +344,7 @@ void tst_QQuickFolderDialogImpl::changeFolderViaTextEdit() QVERIFY(dialogHelper.openDialog()); QTRY_VERIFY(dialogHelper.isQuickDialogOpen()); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. const auto editPathKeySequence = QKeySequence(Qt::CTRL | Qt::Key_L); QTest::keySequence(dialogHelper.window(), editPathKeySequence); @@ -356,6 +357,7 @@ void tst_QQuickFolderDialogImpl::changeFolderViaTextEdit() // Enter the path to the folder in the text edit. enterText(dialogHelper.window(), tempSubDir2.path()); QCOMPARE(breadcrumbBar->textField()->text(), tempSubDir2.path()); +#endif // Hit enter to accept. QTest::keyClick(dialogHelper.window(), Qt::Key_Return); @@ -417,9 +419,11 @@ void tst_QQuickFolderDialogImpl::cancelDialogWhileTextEditHasFocus() QVERIFY(dialogHelper.openDialog()); QTRY_VERIFY(dialogHelper.isQuickDialogOpen()); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. const auto editPathKeySequence = QKeySequence(Qt::CTRL | Qt::Key_L); QTest::keySequence(dialogHelper.window(), editPathKeySequence); +#endif auto breadcrumbBar = dialogHelper.quickDialog->findChild<QQuickFolderBreadcrumbBar*>(); QVERIFY(breadcrumbBar); QVERIFY(breadcrumbBar->textField()->isVisible()); @@ -471,6 +475,7 @@ void tst_QQuickFolderDialogImpl::goUp() QTRY_VERIFY(findViewDelegateItem(folderDialogListView, 0, subDirDelegate)); QCOMPARE(subDirDelegate->isHighlighted(), true); +#if QT_CONFIG(shortcut) // Go up a directory via the keyboard shortcut. const auto goUpKeySequence = QKeySequence(Qt::ALT | Qt::Key_Up); QTest::keySequence(dialogHelper.window(), goUpKeySequence); @@ -478,6 +483,7 @@ void tst_QQuickFolderDialogImpl::goUp() QVERIFY(tempParentDir.cdUp()); COMPARE_URL(dialogHelper.dialog->currentFolder(), QUrl::fromLocalFile(tempParentDir.path())); COMPARE_URL(dialogHelper.dialog->selectedFolder(), QUrl::fromLocalFile(tempDir.path())); +#endif } void tst_QQuickFolderDialogImpl::goUpWhileTextEditHasFocus() @@ -610,27 +616,33 @@ void tst_QQuickFolderDialogImpl::keyAndShortcutHandling() QVERIFY(dialogHelper.openDialog()); QTRY_VERIFY(dialogHelper.isQuickDialogOpen()); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. const auto editPathKeySequence = QKeySequence(Qt::CTRL | Qt::Key_L); QTest::keySequence(dialogHelper.window(), editPathKeySequence); +#endif auto breadcrumbBar = dialogHelper.quickDialog->findChild<QQuickFolderBreadcrumbBar*>(); QVERIFY(breadcrumbBar); QVERIFY(breadcrumbBar->textField()->isVisible()); QCOMPARE(breadcrumbBar->textField()->text(), dialogHelper.dialog->currentFolder().toLocalFile()); QCOMPARE(breadcrumbBar->textField()->selectedText(), breadcrumbBar->textField()->text()); +#if QT_CONFIG(shortcut) // Ctrl+L shouldn't hide it. QTest::keySequence(dialogHelper.window(), editPathKeySequence); QVERIFY(breadcrumbBar->textField()->isVisible()); +#endif // Cancel it with the escape key. QTest::keyClick(dialogHelper.window(), Qt::Key_Escape); QVERIFY(!breadcrumbBar->textField()->isVisible()); QVERIFY(dialogHelper.dialog->isVisible()); +#if QT_CONFIG(shortcut) // Make it visible. QTest::keySequence(dialogHelper.window(), editPathKeySequence); QVERIFY(breadcrumbBar->textField()->isVisible()); +#endif // Cancel it with the escape key again. QTest::keyClick(dialogHelper.window(), Qt::Key_Escape); @@ -795,11 +807,13 @@ void tst_QQuickFolderDialogImpl::itemsDisabledWhenNecessary() COMPARE_URL(dialogHelper.dialog->currentFolder(), QUrl::fromLocalFile(tempDir.path())); COMPARE_URL(dialogHelper.quickDialog->currentFolder(), QUrl::fromLocalFile(tempDir.path())); +#if QT_CONFIG(shortcut) // Get the text edit visible with Ctrl+L. The Open button should now be disabled. const auto editPathKeySequence = QKeySequence(Qt::CTRL | Qt::Key_L); QTest::keySequence(dialogHelper.window(), editPathKeySequence); QVERIFY(breadcrumbBar->textField()->isVisible()); QCOMPARE(openButton->isEnabled(), false); +#endif // Hide it with the escape key. The Open button should now be enabled. QTest::keyClick(dialogHelper.window(), Qt::Key_Escape); |