From 4b15a8ea8fe0d64b529b859a3dba0de68b92ce85 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 Mar 2021 20:11:59 +0100 Subject: Prospective fix for flaky test tst_QDoubleSpinBox::setReadOnly() The test has been observed to fail with: FAIL! : tst_QDoubleSpinBox::setReadOnly() 'QTest::qWaitForWindowActive(&spin)' returned FALSE. () /Users/qt/work/qt/qtbase/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp(863) : failure location Remove the widget member and use a widget instantiated on the stack instead. Add a check for top level widget leaks in cleanup() and fix leaking task224497_fltMax() by instantiating the widget on the stack. Pick-to: 6.1 Change-Id: Idbbb5d859c0df2d9b9f49fb9f69ef6bb7d1ee150 Reviewed-by: Volker Hilsheimer --- .../widgets/qdoublespinbox/tst_qdoublespinbox.cpp | 56 +++++++++------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index 6b0c353e3b..09fc8343b5 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -134,8 +134,8 @@ public: virtual ~tst_QDoubleSpinBox(); public slots: void initTestCase(); - void cleanupTestCase(); void init(); + void cleanup(); private slots: void germanTest(); @@ -213,7 +213,6 @@ public slots: private: QStringList actualTexts; QList actualValues; - QWidget *testFocusWidget; }; typedef QList DoubleList; @@ -257,25 +256,18 @@ tst_QDoubleSpinBox::~tst_QDoubleSpinBox() void tst_QDoubleSpinBox::initTestCase() { - testFocusWidget = new QWidget(0); - testFocusWidget->resize(200, 100); - testFocusWidget->show(); - if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); - - QVERIFY(QTest::qWaitForWindowActive(testFocusWidget)); } -void tst_QDoubleSpinBox::cleanupTestCase() +void tst_QDoubleSpinBox::init() { - delete testFocusWidget; - testFocusWidget = 0; + QLocale::setDefault(QLocale(QLocale::C)); } -void tst_QDoubleSpinBox::init() +void tst_QDoubleSpinBox::cleanup() { - QLocale::setDefault(QLocale(QLocale::C)); + QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QDoubleSpinBox::setValue_data() @@ -878,15 +870,16 @@ void tst_QDoubleSpinBox::setReadOnly() void tst_QDoubleSpinBox::editingFinished() { - QVBoxLayout *layout = new QVBoxLayout(testFocusWidget); - QDoubleSpinBox *box = new QDoubleSpinBox(testFocusWidget); + QWidget testFocusWidget(nullptr); + QVBoxLayout *layout = new QVBoxLayout(&testFocusWidget); + QDoubleSpinBox *box = new QDoubleSpinBox(&testFocusWidget); layout->addWidget(box); - QDoubleSpinBox *box2 = new QDoubleSpinBox(testFocusWidget); + QDoubleSpinBox *box2 = new QDoubleSpinBox(&testFocusWidget); layout->addWidget(box2); - testFocusWidget->show(); - testFocusWidget->activateWindow(); - QVERIFY(QTest::qWaitForWindowActive(testFocusWidget)); + testFocusWidget.show(); + testFocusWidget.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&testFocusWidget)); box->setFocus(); QTRY_VERIFY(box->hasFocus()); @@ -925,14 +918,9 @@ void tst_QDoubleSpinBox::editingFinished() QTest::keyClick(box2, Qt::Key_Return); QCOMPARE(editingFinishedSpy1.count(), 4); QCOMPARE(editingFinishedSpy2.count(), 3); - testFocusWidget->hide(); + testFocusWidget.hide(); QCOMPARE(editingFinishedSpy1.count(), 4); QCOMPARE(editingFinishedSpy2.count(), 4); - - // On some platforms this is our root window - // we need to show it again otherwise subsequent - // tests will fail - testFocusWidget->show(); } void tst_QDoubleSpinBox::removeAll() @@ -1111,15 +1099,15 @@ public: void tst_QDoubleSpinBox::task224497_fltMax() { - task224497_fltMax_DoubleSpinBox *dspin = new task224497_fltMax_DoubleSpinBox; - dspin->setMinimum(3); - dspin->setMaximum(FLT_MAX); - dspin->show(); - QVERIFY(QTest::qWaitForWindowActive(dspin)); - dspin->lineEdit()->selectAll(); - QTest::keyClick(dspin->lineEdit(), Qt::Key_Delete); - QTest::keyClick(dspin->lineEdit(), Qt::Key_1); - QCOMPARE(dspin->cleanText(), QLatin1String("1")); + task224497_fltMax_DoubleSpinBox dspin; + dspin.setMinimum(3); + dspin.setMaximum(FLT_MAX); + dspin.show(); + QVERIFY(QTest::qWaitForWindowActive(&dspin)); + dspin.lineEdit()->selectAll(); + QTest::keyClick(dspin.lineEdit(), Qt::Key_Delete); + QTest::keyClick(dspin.lineEdit(), Qt::Key_1); + QCOMPARE(dspin.cleanText(), QLatin1String("1")); } void tst_QDoubleSpinBox::task221221() -- cgit v1.2.3 From 65c6fbea242e150d785ea0a7062188fdc090af32 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 3 Mar 2021 08:13:40 +0100 Subject: Stabilize test QMenu::QTBUG_89082_actionTipsHide() on Windows, take 2 Use the QWindow-based overloads of QTest::mouseMove(), which do not move the cursor position. Amends ba139603925453bf79994eca48b566d8f15b2af0, 3f3d5e6716d9130776b3613ccbd5595de7d4af8d. Task-number: QTBUG-89082 Pick-to: 6.0 6.1 5.15 Change-Id: I2cc62e4d1f24e4baebafd0d76fbf0fbdb6f588c7 Reviewed-by: Volker Hilsheimer --- tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 16fd99f44e..db465e9281 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -1376,6 +1376,8 @@ void tst_QMenu::QTBUG_89082_actionTipsHide() QVERIFY(QTest::qWaitForWindowExposed(&widget)); menu->popup(widget.geometry().topRight() + QPoint(50, 0)); QVERIFY(QTest::qWaitForWindowExposed(menu)); + auto menuWindow = menu->windowHandle(); + QVERIFY(menuWindow != nullptr); auto actionZero = menu->actions().at(0); auto actionOne = menu->actions().at(1); @@ -1389,12 +1391,12 @@ void tst_QMenu::QTBUG_89082_actionTipsHide() const QRect submenuRect5 = menu->actionGeometry(actionFive); const QPoint submenuPos5(submenuRect5.topLeft() + QPoint(10, 3)); - QTest::mouseMove(menu, submenuPos1); - QTest::mouseMove(menu, submenuPos0); //show the tip + QTest::mouseMove(menuWindow, submenuPos1); + QTest::mouseMove(menuWindow, submenuPos0); //show the tip QTRY_COMPARE_WITH_TIMEOUT(QToolTip::text(), tipFullName, 1000); //Move to the fifth action without prompting - QTest::mouseMove(menu, submenuPos5); + QTest::mouseMove(menuWindow, submenuPos5); //The previous tip was hidden, but now is a new tip to get text, So there should be no content QTRY_COMPARE_WITH_TIMEOUT(QToolTip::text(), QString(), 1000); } -- cgit v1.2.3 From 5bbd700124d13a292ff8bae6045316112500e230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20K=C3=B6hne?= Date: Wed, 24 Feb 2021 16:07:37 +0100 Subject: Improve support for QT_ADDITIONAL_PACKAGES_PREFIX_PATH Allow to set QT_ADDITIONAL_PACKAGES_PREFIX_PATH as both an env variable and CMake cache variable. Also normalize path and list separators, so that they can be used similar to CMAKE_PREFIX_PATH. The environment variable is intended to be set by the conan virtualenv generator, so that e.g. find_package(Qt6 COMPONENTS NetworkAuth REQUIRED) also works if NetworkAuth is not installed into the Qt prefix. Pick-to: 6.1 Fixes: QTBUG-91142 Change-Id: Ia9f9b9fa2b1b051d33073629139640d0f4c7a843 Reviewed-by: Joerg Bornemann Reviewed-by: Craig Scott --- cmake/QtConfig.cmake.in | 7 ++++++- cmake/QtModuleDependencies.cmake.in | 6 ++++-- cmake/QtPluginDependencies.cmake.in | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in index 57c252091d..00121013b2 100644 --- a/cmake/QtConfig.cmake.in +++ b/cmake/QtConfig.cmake.in @@ -46,6 +46,10 @@ if(APPLE AND (NOT CMAKE_SYSTEM_NAME OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")) list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}/macos") endif() +set(QT_ADDITIONAL_PACKAGES_PREFIX_PATH "" CACHE STRING "Additional directories where find(Qt6 ...) components are searched") +file(TO_CMAKE_PATH "${QT_ADDITIONAL_PACKAGES_PREFIX_PATH}" _qt_additional_packages_prefix_path) +file(TO_CMAKE_PATH "$ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH}" _qt_additional_packages_prefix_path_env) + # Find required dependencies, if any. include(CMakeFindDependencyMacro) if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Dependencies.cmake") @@ -68,7 +72,8 @@ foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS}) ${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_REQUIRED} PATHS ${_qt_cmake_dir} - ${QT_ADDITIONAL_PACKAGES_PREFIX_PATH} + ${_qt_additional_packages_prefix_path} + ${_qt_additional_packages_prefix_path_env} ${QT_EXAMPLES_CMAKE_PREFIX_PATH} ${__qt_use_no_default_path_for_qt_packages} ) diff --git a/cmake/QtModuleDependencies.cmake.in b/cmake/QtModuleDependencies.cmake.in index 8f7960059a..f9a5897676 100644 --- a/cmake/QtModuleDependencies.cmake.in +++ b/cmake/QtModuleDependencies.cmake.in @@ -8,7 +8,8 @@ endif() find_dependency(@INSTALL_CMAKE_NAMESPACE@ @PROJECT_VERSION@ PATHS "${CMAKE_CURRENT_LIST_DIR}/.." - ${QT_ADDITIONAL_PACKAGES_PREFIX_PATH} + ${_qt_additional_packages_prefix_path} + ${_qt_additional_packages_prefix_path_env} ${QT_EXAMPLES_CMAKE_PREFIX_PATH} ${__qt_use_no_default_path_for_qt_packages} ) @@ -86,7 +87,8 @@ foreach(_target_dep ${_target_deps}) find_dependency(${pkg} ${version} PATHS "${CMAKE_CURRENT_LIST_DIR}/.." - ${QT_ADDITIONAL_PACKAGES_PREFIX_PATH} + ${_qt_additional_packages_prefix_path} + ${_qt_additional_packages_prefix_path_env} ${QT_EXAMPLES_CMAKE_PREFIX_PATH} ${__qt_use_no_default_path_for_qt_packages} ) diff --git a/cmake/QtPluginDependencies.cmake.in b/cmake/QtPluginDependencies.cmake.in index 42365b4296..7bd1eef9aa 100644 --- a/cmake/QtPluginDependencies.cmake.in +++ b/cmake/QtPluginDependencies.cmake.in @@ -42,7 +42,8 @@ foreach(_target_dep ${_target_deps}) find_dependency(${pkg} ${version} PATHS @find_dependency_paths@ - ${QT_ADDITIONAL_PACKAGES_PREFIX_PATH} + ${_qt_additional_packages_prefix_path} + ${_qt_additional_packages_prefix_path_env} ${QT_EXAMPLES_CMAKE_PREFIX_PATH} ${__qt_use_no_default_path_for_qt_packages} ) -- cgit v1.2.3