aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrolstestutils/controlstestutils.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move qActiveFocusFailureMessage into a Private namespaceMitch Curtis2025-07-121-1/+1
| | | | | | | | | | | | | | Addresses header review feedback: https://codereview.qt-project.org/c/qt/qtdeclarative/+/651782/1/src/qmltest/quicktest.h#86 Amends 386e0851146bdfb24ad841ac388745c3af802673. Task-number: QTBUG-137478 Pick-to: 6.10 Change-Id: Ie16fcac17b29280e47ef9e4362b877f3b4c61b74 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QQuickTest: return QByteArray from qActiveFocusFailureMessage helperVolker Hilsheimer2025-06-301-2/+2
| | | | | | | | | | | | | | The primary use case for this function is to print diagnostics in case of test failure, so don't go through from UTF8 to QString and back, and instead return a QByteArray directly. Amends 386e0851146bdfb24ad841ac388745c3af802673 to address header review comment. Pick-to: 6.10 Task-number: QTBUG-137478 Change-Id: Id5e242be274ef173bc89e281e6e6db5ce758914c Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* MonthGrid: fix dates being incorrect for certain timezonesMitch Curtis2025-06-301-0/+15
| | | | | | | | | | | | | | | | | | | | | | When a QDate is passed to QML, it becomes to a JavaScript Date. As Dates are stored in local time, the QDates we were passing to QML had the potential to be one day off in certain timezones. For example: 00:00 UTC converted to UTC-8 is 20:00 the day before. Fix this by storing and providing dates as QDateTime so that we can give it a time of day that can't possibly result in a different day when converted to local time. It's fine to change the C++ API since it's private, and nothing will change for the type that users see, since they always get a Date. Add a SystemEnvironment singleton to QQuickControlsTestUtils (Qt.test.controls) to allow reading and writing environment variables from QML. Fixes: QTBUG-72208 Pick-to: 6.8 6.9 6.10 Change-Id: Idb4ab26568d8f1eddd5ab4cebe691e38173d02a9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQuickTest: add and use active focus macrosMitch Curtis2025-04-251-0/+13
| | | | | | | | | | | | | Also add support for popups (when controlstestutils_p.h is included). [ChangeLog][Qt Quick Test] Added QVERIFY_ACTIVE_FOCUS and QTRY_VERIFY_ACTIVE_FOCUS macros that can be used to get detailed failure messages for when QQuickItem::hasActiveFocus should be true but isn't. Task-number: QTBUG-133858 Change-Id: I30c67a84ccc16e3969bac5661648d0062bc3d62c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add arePopupWindowsSupported function to QQuickControlsTestUtilsMitch Curtis2025-04-091-0/+9
| | | | | | | | And reduce a few duplicate checks throughout our tests. Pick-to: 6.8 6.9 Change-Id: I31610f07eb548282ade5573af56ffef18d33cd66 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* QQuickControlsTestUtils: add VERIFY_VISUAL_FOCUS and use itMitch Curtis2025-02-241-0/+15
| | | | | | | | | | | | | | | | Adds useful information to diagnose the cause of active focus failures. The failure message will now look like this: FAIL! : tst_QQuickMenu::FluentWinUI3::contextMenuKeyboard(Popup.Window) 'firstItem->hasVisualFocus()' returned FALSE. (control: MenuItem_QMLTYPE_1545(0x5db854767310, name="firstMenuItem", parent=0x5db8549a28d0, geometry=0,0 190x30, z=1) activeFocus: true focusReason: Qt::OtherFocusReason activeFocusItem: "MenuItem_QMLTYPE_1545(0x5db854767310, name=\"firstMenuItem\", parent=0x5db8549a28d0, geometry=0,0 190x30, z=1)") We add both a function and a macro, as this allows the helper to be stepped into while debugging. Task-number: QTBUG-133858 Pick-to: 6.8 6.9 Change-Id: I26014ee93f5f053df1ac19ac6e673876abce1258 Reviewed-by: Doris Verria <doris.verria@qt.io>
* Correct license for Qt Test library filesLucie Gérard2024-04-051-1/+1
| | | | | | | | | | | | | They are licensed as test files. According to QUIP-18 [1], all test files 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: I5bc3e4d40c4d46a5499c9cd19480c5cdf36489f2 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Add StyleInfo singleton to Qt.test.controls helper moduleMitch Curtis2023-02-161-0/+5
| | | | | | | | | | | This allows accessing the current style in QML auto tests, which we need to conditionally skip certain tests after the Material 3 TextField/TextArea changes. Task-number: QTBUG-97993 Pick-to: 6.5 Change-Id: Ife4ca79deb96f17e879353a901e421b03b29ff25 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-2/+2
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), 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', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix warning from ignoring return of [nodiscard] methodVolker Hilsheimer2022-09-181-3/+12
| | | | | | | | | | | | | Compiler warns: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result] Pick-to: 6.4 Change-Id: If10d41fad7dc77b36eecc8725de178b0908f32de Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Drop unnecessary creation contexts from Quick ControlsUlf Hermann2022-09-091-0/+14
| | | | | | | | | | | | | | | Bound components can only be instantiated in the context they're declared in. Adding a context in between before instantiating a component makes it impossible to bind the component. We want to use bound components so that we can safely use IDs of other objects from the same context inside the objects created from the component. Pick-to: 6.4 Fixes: QTBUG-106042 Change-Id: I7a0e1ea3e079ccd0f5fe156f07f8bc62149c6c0a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickApplicationHelper: move initialProperties before qmlImportPathsMitch Curtis2022-06-151-2/+2
| | | | | | | | | | | It's far more common to want to initialize certain properties in the QML file, so this should come before qmlImportPaths so that users of the (private) API do not need to pass an empty QStringList (for qmlImportPaths) each time they want to provide initial properties. Pick-to: 6.2 6.3 6.4 Change-Id: I91ee4f1c1d69c83de3800af2f704c4c8a19d812d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-27/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Consolidate test helpers into private librariesMitch Curtis2021-09-131-0/+182
Previously each test would include and build sources from the shared folder. Now we make those sources a library, build it once, then have each test link to it instead. We also take the opportunity to move some helpers that qtquickcontrols2 had added into the quicktestutils library where it makes sense, and for the helpers that don't make sense to be there, move them into quickcontrolstestutils. We add the libraries to src/ so that they are internal modules built as part of Qt, rather than tests. That way we can use them in a standalone test outside of qtdeclarative. Task-number: QTBUG-95621 Pick-to: 6.2 Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>