summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs
Commit message (Collapse)AuthorAgeFilesLines
* QTBUG4842_selectFilterWithHideNameFilterDetails remove setActiveWindowFrédéric Lefebvre40 hours1-2/+0
| | | | | | | | | | | 2f6fe3a26843ff68c5d3f9af0a2fc3cce6caac22 has made calls to QApplicationPrivate::setActiveWindow() redundant. Remove redundant calls. Task-number: QTBUG-121488 Change-Id: Ib92cf34d4cd022ccba245508d992ab01099cd97b Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* tst_QFileDialog2::QTBUG6558_showDirsOnly() remove setActiveWindow()Frédéric Lefebvre40 hours1-1/+0
| | | | | | | | | | | 2f6fe3a26843ff68c5d3f9af0a2fc3cce6caac22 has made calls to QApplicationPrivate::setActiveWindow() redundant. Remove redundant calls. Task-number: QTBUG-121488 Change-Id: Ief817a31685e23af57fdcc0909c6e605072d83fd Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* tst_QFileDialog::focus() remove QApplicationPrivate::setActiveWindow()Frédéric Lefebvre40 hours1-1/+0
| | | | | | | | | | | 2f6fe3a26843ff68c5d3f9af0a2fc3cce6caac22 has made calls to QApplicationPrivate::setActiveWindow() redundant. Remove redundant calls. Task-number: QTBUG-121488 Change-Id: Ie48dd98fa8eae796e31de3afc34e09c27e3b78cd Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Tests: check the output of QFile::openGiuseppe D'Angelo2024-03-272-2/+2
| | | | | | | | | | Wrap the call in QVERIFY. tst_QTextStream::read0d0d0a was also faulty as it *never* opened the file because of a broken path. Fix it with QFINDTESTDATA. Change-Id: I61a8f83beddf098d37fda13cb3bfb4aaa4913fc5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove a duplicated call to QFile::openGiuseppe D'Angelo2024-03-261-1/+0
| | | | | | | File was opened on the previous line. Change-Id: I418d616a2f82d9241c37224e4c1a0fb12894eb40 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QMessageBox: Respect explicit accept/reject after closing dialogTor Arne Vestbø2024-03-141-4/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the dialog is closed by pressing a button, the button will be reflected via clickedButton(), and the result() will reflect either the QMessageBox::StandardButton value, or an opaque value for custom buttons. Depending on the role if the buttons, the accepted or rejected signals are emitted. If the user called accept() or rejecct() on a dialog that had already been closed by a button, we would as a result of 1f70c073d4325bc0eb9b0cec5156c3b89ce1b4df emit a signal based on the original button that was clicked, instead of respecting the newly triggered function. It's a questionable use-case, as the clickedButton() is still the original button e.g., but we should still avoid regressing this, so we now emit the signals based on the newly stored result code instead of using the clicked button as the source of truth. To allow this we had to change the opaque result() value for custom buttons to stay out of the QDialog::DialogCode enum, but this should be fine as the documentation explicitly says that this is an opaque value. Fixes: QTBUG-118226 Pick-to: 6.7 6.6 6.5 Change-Id: Ia2966cecc6694efce66493c401854402658332b4 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Change license for tests filesLucie Gérard2024-02-0412-12/+12
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* QDialogButtonBox: Fix focus chain and default button assignmentAxel Spoerl2023-12-201-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDialogButtonBox::layoutButtons() rebuilds the focus chain based on the button layout. It relied on the fact that the last button in the layout would point back to the first button. That is not the case, if - a focus frame gets inserted in the chain, and - the default button is not at the layout's first (=left) position. In that case, the chain stops at the button left of the default button. The default button can not be reached by tabbing forward. Back-tabbing still worked. By not "closing" the focus chain, the focus proxy was set to the first button found in the layout. That is wrong, whenever the default button is not at the first layout position. When the box got focus for the first time, pressing "Enter" could lead to a non-default button being triggered. A Yes/No message box would have No as its default button. On Linux, it would pop up with "No" being highlighted, but "Yes" having focus. Pressing Enter would trigger Yes, instead of No. tst_QMessageBox::staticSourceCompat() heuristically defines the button expected to be triggered by Enter. On Linux/KDE, it would pass, when the wrong button was fired. => Always "close" the focus chain, by linking the last and first buttons. => Make the default button the button box's focus proxy. => Change tst_QMessageBox::staticSourceCompat() to always expect No being fired by Enter in a Yes/No box. [ChangeLog][QtWidgets][QDialogButtonBox] Default button becomes focus proxy of a QDialogButtonBox. This ensures that Enter triggers the default button, instead of the first button in the layout. Fixes: QTBUG-118489 Pick-to: 6.7 6.6 6.5 Change-Id: Ic626d3d0fe7ba8b924c21734332e98532f11c80e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* tst_QMessageBox::staticSourceCompat(): improve diagnostic outputAxel Spoerl2023-12-201-6/+13
| | | | | | | | | | | | | | | The test function casts QMessageBox::StandardButton variables to integers, to pass them as arguments and verify expected buttons. In case of a test failure, this makes it hard to figure out, why a test was failing. Add a local macro to cast int values back to the enum before calling qCompare(). That way the enum keys will be displayed in the logs. Task-number: QTBUG-118489 Pick-to: 6.7 6.6 6.5 Change-Id: I23e766d5026cff3e4775db56e58f808809709e4c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Stabilize tst_QMessageBox::hideNativeByDestruction()Axel Spoerl2023-12-201-1/+1
| | | | | | | | | | | The test was flaky, because of qWaitForWindowActive() after show(). It is not guaranteed, that a window has focus after show(). Use qWaitForWindowExposed() instead. Task-number: QTBUG-118489 Pick-to: 6.7 6.6 6.5 Change-Id: I1eb8a73f2beafec00c4a6f6b34bfd36a8d6e4d93 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove dead code from tst_QMessageBox::staticSourceCompat()Axel Spoerl2023-12-201-12/+0
| | | | | | | | | Remove if (0) clause. Task-number: QTBUG-118489 Pick-to: 6.7 6.6 6.5 Change-Id: Ie1c72e9c7cacb90d9e4d85763cd2f6967a7572cd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Purge empty BLACKLIST files from testsEdward Welbourne2023-11-241-0/+0
| | | | | | | There's no point to the file if it has no content. Change-Id: Ie0deb59a63d5f7a654fcab1218e0a814710072ff Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Preparations to deprecate QItemDelegateChristian Ehrlicher2023-10-052-3/+2
| | | | | | | | | | | | | QItemDelegate was superseded since Qt4 by QStyledItemDelegate but it took until Qt6.7 to remove the last occurrences in qtbase. - remove unused includes / replace with qabstractitemdelegate.h - replace references in the documentation with QStyledItemDelegate - adjust the examples and tests to use QStyledItemDelegate Pick-to: 6.5 6.6 Change-Id: I246755004ce2d01192a726ca0972106c237df0cc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Dialogs: clean up native dialogs when object gets destroyedVolker Hilsheimer2023-09-064-3/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | QWidget::setVisible is virtual, and called via hide() by both the QDialog and the QWidget destructor. A dialog that becomes invisible when getting destroyed will at most execute the QDialog override. Subclassing QDialog and overriding setVisible() to update the state of the native platform dialog will not work, unless we explicitly call hide() in the respective subclass's destructor. Since e0bb9e81ab1a9d71f2893844ea82, QDialogPrivate::setVisible is also virtual, and gets called by QDialog::setVisible. So the clean solution is to move the implementation of the native dialog status update into an override of QDialogPrivate::setVisible. Add test that verifies that the transient parent of the dialog becomes inactive when the (native) dialog shows (and skip if that fails), and then becomes active again when the (native) dialog is closed through the destructor of the Q*Dialog class. The test of QFileDialog has to be skipped on Android for the same reason as the widgetlessNativeDialog. Fixes: QTBUG-116277 Pick-to: 6.6 6.5 Change-Id: Ie3f93980d8653b8d933bf70aac3ef90de606f0ef Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove redundant QPair includesAhmad Samir2023-09-061-1/+0
| | | | | | | | Nothing in those files uses QPair; and a local build finished fine without them. Task-number: QTBUG-115841 Change-Id: I669cfecaa9129bce6b31e464826287f138b159db Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QWizard: port from QSharedPointer to std::shared_ptrMarc Mutz2023-08-141-30/+32
| | | | | | | | | | | | | | | | QSharedPointer is 'meh', see QTBUG-109570 and 18113e22e92a7b8d759fd0f9c9d696ee7e97a849. This is just a textual replacement of - QSharedPointer<(.+)>::create() → std::make_shared<\1>() - QSharedPointer → std::shared_ptr And it compiles and still passes. No non-standard APIs to fix up. Task-number: QTBUG-109570 Change-Id: I827d4a9be0511780c3900bd53ffcbdcb6aacbc3b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QtWidgets tests: port remaining users away from Q_FOREACHMarc Mutz2023-08-141-7/+12
| | | | | | | | | | | | | These are all trivial: all are over (already or newly-made) const local variables. As a drive-by, replace a QList legacy left-shift-based- with initializer_list-construction. Pick-to: 6.6 6.5 Task-number: QTBUG-115803 Change-Id: I453e24272c4c4b7dce5b91a0bd04481d833c50bb Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* tst_QWizard: port away from Q_FOREACH[5/5]: CombinationsTestData ctorMarc Mutz2023-08-071-11/+16
| | | | | | | | | | | | | | | | | | | | | This is iterating over data member containers that are otherwise only touched in the constructor of the same object. Luckily, the initialization of these containers does not require *this, so use NSDMI and mark the containers const, proving they can never be modified and thus the protective copy of Q_FOREACH isn't required. Now that we got rid of Q_FOREACH, we can and do make them arrays for extra measure ("never use dynamically-sized containers for statically-sized data"). Unfortunately, C++ neither allows us to use "flexible array members" nor AAA in NSDMI, so grab the nettle and supply the array size manually (ever so slightly violating DRY, but the compiler will complain if we get it wrong). Task-number: QTBUG-115803 Pick-to: 6.6 6.5 Change-Id: Ibb2ce48b6dcaf2e9d3d1a625602f3865d280c7c6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QWizard: port away from Q_FOREACH[4/5]: TestWizard dtorMarc Mutz2023-08-071-1/+1
| | | | | | | | | | | | | This is iterating over a data member container that's otherwise only touched in the constructor of the same object. The only reason why it's not a const is that the initialization from QWizard::addPage() makes that very cumbersome. So port to a ranged for-loop and apply std::as_const(). Task-number: QTBUG-115803 Pick-to: 6.6 6.5 Change-Id: I033e3725df95b29a8ef295c4e74d746d83234835 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QWizard: port away from Q_FOREACH[3/5]: OptionInfo ctorMarc Mutz2023-08-071-1/+1
| | | | | | | | | | | | | This is iterating over the keys() of a member container we've just filled in the same function. The loop body clearly doesn't modify the container being iterated over. Port to the future-proof ranged for-loop over asKeyValueRange(), using the _-in-SB pattern Christian Ehrlicher showed me to indicate we're not interested in the value. Task-number: QTBUG-115803 Pick-to: 6.6 6.5 Change-Id: I3d86a1de9ea460b7d57fa421ea76e41d2c122f43 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QWizard: port away from Q_FOREACH[2/5]: WizardPages::shown()Marc Mutz2023-08-071-1/+1
| | | | | | | | | | | This is safe to port to a ranged for loop, as it's iterating over a private member container that is not modified under iteration (WizardPage::shown() is just returning a boolean member). Task-number: QTBUG-115803 Pick-to: 6.6 6.5 Change-Id: I50891e4b7509bd64399a128a5ee47d7795374f8e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QWizard: port away from Q_FOREACH[1/5]: TestWizard::applyOperations()Marc Mutz2023-08-071-2/+2
| | | | | | | | | | | | This function is called only from one test function. Mark the function's argument as const in the caller, bringing this use into the const-local category, which is implicitly safe to port 1:1 to ranged-for. Task-number: QTBUG-115803 Pick-to: 6.6 6.5 Change-Id: I9145c1ae2aed5ab3cafc4947dc3eaaf9a27c6a04 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QFileDialog/2: port away from Q_FOREACHMarc Mutz2023-08-072-8/+7
| | | | | | | | | | | | | | | | These are all trivial: all are over (already or newly-made) const local variables. The only noteworthy point here is that, in order to mark it as const, I had to move a container definition to the more narrow scope in which it was actually initialized. There are no references to the container outside the narrow scope that would require it to be defined in the larger scope. Pick-to: 6.6 6.5 Task-number: QTBUG-115803 Change-Id: I20890f48a48ca662679f55fa5db759419d4db8c5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* CMake: Make widgets tests standalone projectsAlexandru Croitor2023-07-0511-0/+66
| | | | | | | | | | | | | | | | | Add the boilerplate standalone test prelude to each test, so that they can be opened with an IDE without the qt-cmake-standalone-test script, but directly with qt-cmake or cmake. Boilerplate was added using the following scripts: https://git.qt.io/alcroito/cmake_refactor Manual adjustments were made where the code was inserted in the wrong location. Task-number: QTBUG-93020 Change-Id: I3c0d1a63c474969e5eaee5fdbb1bb0229482fc5b Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QMessageBox: Respect clients overriding QDialog::done()Tor Arne Vestbø2023-06-291-0/+41
| | | | | | | | | | | | | | As a result of d8bbb5ee0e60d44a70d29306e607a59caf7fe5bc, we were no longer calling QDialog::done(), which users may have overridden. We now pull out the dialog code to determine whether to emit accepted/rejected directly in done(), so that we can go back to calling QDialog::done(). Pick-to: 6.6 6.5 Change-Id: Ie08270123d61d9010acd8c989b66986f71960ad0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Allow disable native messagebox dialogThorbjørn Lund Martsum2023-05-021-0/+17
| | | | | | | | | | | | | | | | | | | | | | The native style may not match the program style and it makes sense to give an option rather than forcing native style. Before it could only be done with setting AA_DontUseNativeDialogs on the app, but it is reasonable to use native file dialogs and Qt styled messageboxes - and it is extremely cumbersome - especially since messageboxes often can start save dialogs. It can look a bit strange that these introduced options has just one option (DontUseNativeDialog) and four functions, but this way it works similar to QColorDialog, QFileDialog and QFontDialog. [ChangeLog][QWidgets][QMessageBox] Added options functionality to QMessagebox. The currently only option available is DontUseNativeDialog. Change-Id: I70282fcfaa66f245f7e679b8897c607bcaff333f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QColorDialog: Support hex rgb values with and without leading #Axel Spoerl2023-03-171-0/+53
| | | | | | | | | | | | | | | | | | QColorDialog supports entering hex rgb values only with a leading #. That makes copy/paste impossible whenever the copy source has plain hex, without the leading #. This patch automatically adds a leading # character, when missing. As a drive-by, QObject::connect statements are altered to PTMF syntax, amending 9eb1b9e86ce3d1004e39e8ab7c7ecb6796d6df1a. The patch also adds an autotest for the new functionality. Fixes: QTBUG-111742 Pick-to: 6.5 Change-Id: I4ced29dc8b543457f411a3fa0ac756b550cdb09f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QThread: add sleep(std::chrono::nanoseconds) overloadAhmad Samir2023-03-131-3/+3
| | | | | | | | | | | | | | All the other overloads are implemented using the new one. Windows change relies on the pre-check in the code review making sure it compiles. [ChangeLog][QtCore][QThread] Added sleep(std::chrono::nanoseconds) overload. Task-number: QTBUG-110059 Change-Id: I9a4f4bf09041788ec9275093b6b8d0386521e286 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QErrorMessage: Reset 'again' check box between each error messageTor Arne Vestbø2023-03-091-2/+1
| | | | | | | | | | | | | | | The choice of whether to show a message again is per message, so when showing a new message we need to reset the check box back to its default checked state, otherwise the user might mistakenly dismiss more than the indented message. [ChangeLog][Widgets] QErrorMessage will now reset the check box for showing a message again for each new message shown, as each individual message has its own suppression state. Pick-to: 6.5 6.5.0 Change-Id: I86d4bb5eabdb5b7a478c03516108a5edf87fcbe3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tests: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-1712-30/+0
| | | | | | | Pick-to: 6.5 Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* macOS: Pick up QWizard background from keyboard assistant via NSBundleTor Arne Vestbø2023-02-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | As of macOS 10.14 the keyboard assistant background is shipped as part of the compiled asset catalog of the app, so looking it up via a URL will fail. Instead we look it up via NSBundle's dedicated image lookup function, which handles both cases. The logic has also been moved to qwizard.cpp, since the additional plumbing via QPlatformNativeInterface was unnecessary. The keyboard assistant itself no longer shows the background image as of macOS 12, so we might consider doing the same, but the design of the assistant has also changed significantly, so as long as our QWizard layout looks like the old keyboard assistant we keep the background as well. Pick-to: 6.5 6.2 Change-Id: I7d42dd79b285f3518837458864bca6bc353b3b6d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Don't override QDialog::setVisible() to implement native dialogsTor Arne Vestbø2023-01-092-0/+19
| | | | | | | | | | | | | | | | | | Clients who called the base-class implementation in QDialog would as a result start hitting the canBeNativeDialog code path at the start of QDialog::setVisible(), which would show the native dialog, but without updating the QWidget visibility state. To keep things 100% compatible, we shuffle the implementation of QDialog::setVisible() into QDialogPrivate, which allows us to override it in QMessageBoxPrivate and QErrorMessagePrivate. The existing subclasses of QDialog that override setVisible have been left as is, to not cause any unintended behavior change. Pick-to: 6.5 Change-Id: Icafe31a7b84a75049365e4e04b80492de08614d2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix QErrorMessage test when using native dialogsTor Arne Vestbø2023-01-092-0/+23
| | | | | | | | | | | | | | | | | When the test is showing the error message over and over, it's not waiting for the native dialog to actually become visible, and as a result, hiding it has no effect and won't result in a call to processResponse, where we got rid of the native dialog. To fix this we explicitly release the native dialog when encountering this corner case. Add logic to QErrorMessage to test both native and non native dialogs. Pick-to: 6.5 Change-Id: I19ac3f463997aed1e66f646fdfcbb4d2459116d1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Add dialog helper for native message boxesTor Arne Vestbø2022-11-151-0/+35
| | | | | | | | | | | | | | | | | The native implementation uses NSAlert, making a best effort to map the QMessageBox properties to the native dialog, falling back to the cross platform non-native dialog if the discrepancy is too big. The initial implementation focuses on the current state of the native dialog helper "protocol", but there's room for improvement here, which would allow even more dialog types and properties to be native. [ChangeLog][macOS] Message boxes such as QMessageBox now follow the platform look and feel by using native dialogs if possible. Change-Id: I4da33f99894194a7b301628cd1fbb44d646ddf18 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Android: Skip/blacklist remaining tests for emulator bump to API 24Samuel Mira2022-11-151-0/+2
| | | | | | | | | | | | Skip on crashing tst_qvulkan test Blacklisted completer_data on qfiledialog (8d76c5af518599800657ab40d56df4dfbc0a0e85 should have been enough but it is still failing) Task-number: QTBUG-108328 Task-number: QTBUG-108329 Change-Id: Iad5573af60cca16d16ba0462293e276186e25653 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Remove unused tst_qfontdialog_mac_helpers.mmTor Arne Vestbø2022-11-111-30/+0
| | | | | | | | The uses of the click_cocoa_button() function was removed in 2012, in ba21ca7b5b4b92996c93a0dc4137ea181c4eb79c. Change-Id: If7abfc56bb307cfbf9f6628cec9c7267a8a1f31f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Android: Fix qfiledialog test for emulator bump to API 24Samuel Mira2022-11-041-7/+3
| | | | | | | | | | The qfiledialog test was failing on completer_data test. The fix available for Android 11 also works in Android 7, so removed the if clause. Task-number: QTBUG-105377 Change-Id: I76a4c1073a754c9b299cfe731f42b80da1a6f8e2 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-038-81/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tests: skip tst_QDialog::showAsTool() on WaylandLiang Qi2022-10-071-0/+4
| | | | | | | | | QWindow::requestActivate() is not supported. Task-number: QTBUG-107153 Pick-to: 6.4 6.2 Change-Id: Id8f9cc1d6a29b4d608a080f5b40a5369d7bd8da9 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-045-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move QMacAutoReleasePool from qglobal.h to qcore_mac_p.hSona Kurazyan2022-09-011-0/+2
| | | | | | | | And include qcore_mac_p.h where needed. Task-number: QTBUG-99313 Change-Id: Idb1b005f1b5938e8cf329ae06ffaf0d249874db2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Deprecate QApplication::setActiveWindow() and mark as internalTor Arne Vestbø2022-08-276-7/+17
| | | | | | | | | | | | | | The function is used the internal window activation machinery and should not be called by user code. Many tests still use this function, and should be ported over to QWidget::activateWindow(). For now they are using the private helper in QApplicationPrivate, so that we can progress with the public API deprecation. Change-Id: I29f1575acf9efdcbae4c005ee9b2eb1bb0c8e5b5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qmessagebox: port away from deprecated methodsIvan Solovev2022-08-241-12/+14
| | | | | | | | | | * Wrap some tests that specifically test deprecated APIs into #ifdefery * Refactor some tests to use available methods Task-number: QTBUG-104858 Change-Id: I03e318004ce1c2718ee574bf11e00df9bc04bcaa Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make QHeaderView restore state from different stream versionsAxel Spoerl2022-08-241-0/+42
| | | | | | | | | | | | | | | | | | | If restoring a QHeaderView state from a data stream with version Qt_5_0, check alignment and resize mode properites for out-of-bound values. If out of bounds, try QDataStream version Qt_6_0, which is used by KDE apps compiled with 5.15.2 or 6.2.3. QFileDialog stores settings in the same settings file across different Qt versions, using different QDataStream versions. That makes QFileDialog vulnerable to the issue (QTBUG-104962). A respective auto test is added with this patch. Fixes: QTBUG-104962 Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-104425 Change-Id: I666207fca7ab837ad27a247e504a40757ee8afab Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-2312-12/+12
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Android: fix Android filedialog and completer testsAssam Boudjelthia2022-08-182-1/+23
| | | | | | | | | | * https://developer.android.com/training/data-storage/use-cases#opt-out- in-production-app Pick-to: 6.4 6.3 6.2 Task-number: QTQAINFRA-4748 Change-Id: If6abb48b730b9b33807f5f6648e1360defc090a6 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Remove network dependency for tests with UNC pathsVolker Hilsheimer2022-08-171-4/+2
| | | | | | | | | | | | | | | | | | | Windows VMs are provisioned with shared folders that are available as \\${COMPUTERNAME}\testshare(writable) so we don't need to access a remote SMB server over network anymore just to test whether our string-parsing code handles UNC paths correctly. Add a QTest::uncServerName() helper function to the shared filesystem.h header and use that instead of QtNetworkSettings::winServerName. The latter is now only used in tst_NetworkSelfTest::smbServer(). Pick-to: 6.4 Change-Id: Id0da66369ad0f4a980d612de2a31a391f1192253 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Test is not flaky any longerDimitrios Apostolou2022-08-101-4/+0
| | | | | | | | | | I can't reproduce the issue after hundreds of iterations on OpenSUSE, and the test hasn't flaked at all in the last 3 months according to our dashboards. Task-number: QTBUG-66371 Change-Id: I9c4daf851e09fbcb47a6ab39418e7b213ccd9dfe Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-0312-0/+36
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-2811-11/+11
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>