aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktestutils/quick/visualtestutils.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix broken hover in ApplicationWindow's backgroundMitch Curtis2025-04-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8fb643f6d63813a5a8df5e829e4ddeb357e0348d fixed ComboBox not being hoverable by setting QQuickApplicationWindowPrivate::control's hoverEnabled property to true. By doing so, it ensured that only that control and its parent chain could get hover events, breaking hover for e.g. background. The correct fix is to adapt QQuickControlPrivate::calcHoverEnabled to skip the property("hoverEnabled") == true check for QQuickApplicationWindowPrivate::control, resulting in it falling back to the global checks. - Remove code added in 8fb643f6d63813a5a8df5e829e4ddeb357e0348d. - Move QQuickApplicationWindowPrivate declaration into its own header so that code outside the .cpp file (qquickcontrol.cpp, in this case) can use it. - Document behavior of hover flags in void QQuickItem::setAcceptHoverEvents. - Move the check done in tst_QQuickControl::hoverEnabledDefault() into the new tst_QQuickApplicationWindow::hoverInBackground() since they're closely related. - Add initial starting position argument to PointLerper's constructor since it wasn't previously possible to set it. - Remove unused headers in qquickapplicationwindow.cpp. Fixes: QTBUG-133886 Fixes: QTBUG-136031 Pick-to: 6.9 Change-Id: Ic32f902be6433c1c9dc9f4610c5715ce1537e605 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickVisualTestUtils::compareImages: save images on all failuresMitch Curtis2024-11-151-27/+37
| | | | | | | | | | | | I didn't save images on failure for size and format mismatches because I thought it wouldn't be useful, but it turns out it is. Move the image-saving code into a lambda and call it for all failures. Amends 426555aa581ce688538975176cf1c31f6ffddb24. Change-Id: I6b2ccd8fd0a2559c88a8c525e6cd4bad1946e651 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* QQuickVisualTestUtils::compareImages: fail if image depth is not 32Mitch Curtis2024-11-151-0/+4
| | | | | | | | | | | | | | | The function would ignore the depth and read memory that it shouldn't, which can cause hard-to-diagnose failures, and heap-buffer-overflows when ASAN is enabled. Mismatches in depth can happen when optimizing images with optipng, for example, which may convert color images to grayscale. compareImages was added in 7ffea4048321b86402a9ded5255ad16ac74d0518. Pick-to: 6.5 6.8 Change-Id: Id83dcd79ae94088996ff770d90b2c1add910fb1b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Add missing includesFabian Kosmale2024-10-241-0/+1
| | | | | | | | | | ...in preparation of trimming down includes in QQuickItem. As a drive-by, remove the superfluous qqml.h include from quick/items/qquicktextutil_p.h. Change-Id: I7ee0f459bcbfdfe07314d1f63433aaa8639870ac Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Share code between QQuickViewTestUtils and QQuickVisualTestUtilsTor Arne Vestbø2024-09-271-3/+1
| | | | | | | | We don't need two implementations of centerOnScreen(). Pick-to: 6.8 Change-Id: I43fbb00126547e49dad0d7b266948468a358c63e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickVisualTestUtils::compareImages: improve saved image path outputMitch Curtis2024-09-041-1/+1
| | | | | | | | | | Don't double-quote the string, as it makes it harder to copy. Calling noquote() also removes the double backslashes on Windows. Amends 426555aa581ce688538975176cf1c31f6ffddb24. Change-Id: Ieca0f493f42344d3e16a756037db8777414a4606 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix two compile warnings/errorsMatthias Rauter2024-08-161-2/+3
| | | | | | | | | | | On MSVC the implicit construction of QString from char* and the operator+ of char* and QString triggered warnings that were interpreted as errors. This patch works around those warnings. Amends 426555aa581ce688538975176cf1c31f6ffddb24. Pick-to: 6.5 6.7 6.8 Change-Id: Iae02b4e2b2eb0064446245a78ca294e618a4acb1 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QQuickVisualTestUtils::compareImages: save images on failureMitch Curtis2024-08-091-1/+31
| | | | | | | | | Add a qt.quicktestutils.compareimages logging category which saves compared images to the test executable's directory on failure when its debug category is enabled. Change-Id: Ifb5e85d00768fd11336d986a20080e1c16ca78a2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickVisualTestUtils::compareImages: actually check all colorsMitch Curtis2024-08-091-2/+2
| | | | | | | | | | | The function was added in 906d5c5c40183468f9521277c6244a6c46730de6. The tests there don't only use red, so it looks like this bug has existed since 2013. Pick-to: 6.5 6.7 6.8 Change-Id: I4bdf87fe6be0224016baf9a2a80faee6fe61514e Reviewed-by: JiDe Zhang <zhangjide@uniontech.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Correct license for test filesLucie Gérard2024-04-111-1/+1
| | | | | | | | | | | | | 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 Task-number: QTBUG-121787 Pick-to: 6.7 Change-Id: Ib1dea3bf095aeb06e33a64db61a8c01219d12345 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* quicktestutils: document isDelegateVisibleMitch Curtis2024-03-211-0/+6
| | | | | | Pick-to: 6.5 6.6 6.7 Change-Id: I63c5d453a52df49ef0ce4a4d49c23ad5fe682824 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* quicktestutils: rename delegateVisible to isDelegateVisibleMitch Curtis2024-03-211-1/+1
| | | | | | | | Because it's the convention. Pick-to: 6.5 6.6 6.7 Change-Id: I1d3d53f5c051ede0b011c1daa9d1019cad8875f8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add PointLerper to QQuickVisualTestUtilsMitch Curtis2023-06-271-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a convenience class to linearly interpolate between two move points: PointLerper pointLerper(window); // Lerps from {0, 0} to {15, 15}. pointLerper.move(15, 15); QVERIFY(parentButton->isHovered()); // Lerps from {15, 15} to {25, 25}. pointLerper.move(25, 25); QVERIFY(childButton->isHovered()); This allows testing mouse interaction in a more realistic manner, as opposed to immediately moving to a new position with no intermediate move events. More importantly, it fixes flakiness in tst_qquickpopup hover tests. Includes an attempt to stabilize tst_QQuickDrawer::multiple() which seems to crash due to events arriving after window destruction. Task-number: QTBUG-114718 Pick-to: 6.5 6.6 Change-Id: I4b466d820cec4113a9d266685c4575a3692e5202 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Fix build with -no-feature-listview and itemviewsTasuku Suzuki2023-04-131-0/+4
| | | | | | | | | | | | | tested with each/all of below -no-feature-gridview -no-feature-listview -no-feature-pathview -no-feature-tableview -no-feature-treeview Pick-to: 6.5 Change-Id: I90cc7bc45bb9065000bc0fc7eeb8e80f02acb0d0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add coordinate-mapping convenience functions to QQuickVisualTestUtilsMitch Curtis2023-03-311-0/+15
| | | | | | | | | | These make it more convenient to map relative coordinates to the window coordinates expected by QTest functions. Pick-to: 6.5 Change-Id: Ib931af8bda3510209e5ef833e22a0ed3272dde59 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> 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>
* Remove flushFrameSynchronousEvents from qquickwindow_p.hJohan Solbakken2022-07-171-1/+1
| | | | | | Change-Id: Ib1ae19eac2a5a95b71345b80075f871ea82fa928 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickApplicationHelper: move initialProperties before qmlImportPathsMitch Curtis2022-06-151-1/+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>
* QtQuickTest: add API for checking for polish at window levelMitch Curtis2022-06-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a qIsPolishScheduled(QQuickWindow *) overload of qIsPolishScheduled(QQuickItem *) (added in 40d6072bc8a4df0fe1a16025fe30fe653463a446) and deprecates qWaitForItemPolished() (added in 7a3cad0619662b992154e075ec6b840bfc8a46a7) in favor of qWaitForPolish(), which has QQuickItem* and QQuickWindow* overloads. The existing functions that take QQuickItem are useful, but testing Qt Quick applications can be made even easier by allowing users to check if a window has any items that need to be polished. This information is already present (in QQuickWindowPrivate::itemsToPolish), so it's very efficient to check for. This is especially useful now that Qt Quick Layouts using polishing for their layouting, for example, as it's no longer necessary to find individual polishable items in complex hierarchies before proceeding to interact with child items. [ChangeLog][QtQuickTest][QQuickTest] Added QQuickTest::qIsPolishScheduled(QQuickWindow *) and QQuickTest::qWaitForPolish(QQuickWindow *) functions for verifying that updatePolish() was called on one or more items managed by a window. [ChangeLog][QtQuickTest][QQuickTest] Deprecated QQuickTest::qWaitForItemPolished(QQuickItem *). Use the new QQuickTest::qWaitForPolish(QQuickItem *) function instead. Fixes: QTBUG-93757 Change-Id: I95b6e051b3c9fd2fa93604f4d9ccda486bb29f9d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QuickTestUtilsPrivate: includemocsMarc Mutz2022-04-291-0/+2
| | | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102948 Change-Id: I3c9d74e94b0fbbf1e5e9d59522f400485c959cb5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Replace 0 pointer constants with nullptrAllan Sandfeld Jensen2021-10-181-1/+1
| | | | | | | Replaced in most common patterns. Change-Id: Idcaff1f2e915f29922702d3600a2e5f1e2418a7a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Consolidate test helpers into private librariesMitch Curtis2021-09-131-0/+225
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>