Commit Graph

34 Commits

Author SHA1 Message Date
Tor Arne Vestbø 6b9768541c QWidgetBaselineTest: Separate OS version and platform (plugin) name
When reporting and disambiguating results.

Change-Id: I1ea0d38b36deb5cb610a9b0da4c17e9b987375dc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-09-04 13:14:38 +02:00
Tor Arne Vestbø 9768a63b01 QWidgetBaselineTest: Remove style name from appearance ID
It has a dedicated metadata field now.

Change-Id: Ia48b5114f33bfb96a3eae909af07656e979a3941
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-09-04 13:14:38 +02:00
Tor Arne Vestbø 81c71332a6 QWidgetBaselineTest: Propagate name of underlying style in debug style
Change-Id: I58e5db11eacd4eddcb56f3e8944da9619ef718f3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-08-25 14:54:30 +02:00
Tor Arne Vestbø 3a3024e6ea QWidgetBaselineTest: Add style name as client property
Change-Id: I79d4b50025a7360b4aab5982cd431f85289feaf4
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-08-14 00:48:46 +02:00
Tor Arne Vestbø 64c660090b QWidgetBaselineTest; Record debug rects and propagate to server
The baseline server generates client side code that allows toggling
the various debug rects on and off, and draws them with a cosmetic
pen regardless of the zoom level.

Change-Id: I44fcb212cdb95e3c72f884466316f797e44554e2
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-08-14 00:48:46 +02:00
Tor Arne Vestbø a240df70bc widget baseline: Record device pixel ratio as client property
And always use primary screen. The user can choose to use
QT_SCALE_FACTOR to override.

Change-Id: Icad8163d576691645bd90c23156d5c34158a37c6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-08-14 00:48:46 +02:00
Tor Arne Vestbø 387cf8c60c QWidgetBaselineTest: Use 10x10 grid for background checkerboard
Helps to not have to think in octal when looking at pixel differences.

Change-Id: Iea1d560ec03dd7e4b060b528669b1005f156fe37
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-08-13 21:40:11 +02:00
Tor Arne Vestbø 8ac3c88bf9 QWidgetBaselineTest: Fail by throwing, to catch nested QVERIFY
We QVERIFY and QCOMPARE deep in the helper method machinery,
so let's throw to fail, instead of checking for failure at
each call site.

Change-Id: I279b07d0edace775afe34ac497dcbd75e96766c3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-08-09 13:30:42 +02:00
Tor Arne Vestbø 7868bd1698 QWidgetBaselineTest: Report whether liquid glass is enabled or not
Change-Id: I46261b784ca0fc7a47903dbcb15765ff1d9696ba
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-08-09 13:30:41 +02:00
Tor Arne Vestbø 6054f309ac QWidgetBaselineTest: Wait for background element to be shown
Change-Id: I49a6dacc59eb5e7abe0f4faae6257f1edbcec54c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-08-09 13:30:40 +02:00
Tor Arne Vestbø fc5fed5ec4 QWidgetBaselineTest: Wait for window expose after show
For good measure.

Change-Id: Icc94d0b4fd5b7ac9846a95e171e63ef0bec63324
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-07-31 20:48:23 +02:00
Tor Arne Vestbø b9aa8c18eb QWidgetBaselineTest: Speed up animations to avoid snapshot delay
Instead of waiting 250ms between each snapshot, to account for
animations in the styles, let's use the new hook in QUnifiedTimer
to speed up animations.

Brings the tst_Widgets baseline test down from ~200s to ~30s.

The window delay in takeScreenSnapshot has been left alone for now.

Change-Id: I83d4f25d8d6f198c2f00f31af1dbde0f3de5ded0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-07-31 20:48:23 +02:00
Tor Arne Vestbø 0461be4914 QWidgetBaselineTest: Make test widget frameless and no drop shadow
And separate it from the background by making the background a
checkerboard pattern.

Avoids issues with rounded window frames contributing to the
results. Also, by making the window frameless we will not get
a default window background color on macOS, which means that
any issues with transparent rendering will be visible when
running the tests locally, as the checkerboard background
will shine though.

Change-Id: Icd501eeb149d2dbfb184c91e8eac3a531d09408d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-07-31 20:48:22 +02:00
Tor Arne Vestbø 41d0abf4e1 QWidgetBaselineTest: Avoid drop shadow for activation-stealing window
The drop shadow may overlap with the test window, if the activation
stealing window is too close, depending on the shadow size.

Change-Id: I39bf271d0f1852febd1920e2e7a9fe615ff6594e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-07-31 20:48:22 +02:00
Tor Arne Vestbø 97c87e7868 QWidgetBaselineTest: Grab widget via render() instead of grab()
Going via QWidget::grab() will render to a QPixmap, which on most
platforms is going to be QRasterPlatformPixmap. The format of the
underlying QImage in that case is resolved from the primary screen,
which most platforms report as QImage::Format_RGB32.

This means we will not be able to detect the difference between
black and fully transparent areas in the rendered result, which
has been observed to be a problem for widget styles that wrongly
render their controls using source composition.

To solve this we render via QWidget::render() instead, to an image
with an alpha format.

Change-Id: I078f062b662590598c3597797abc2bfa78eaf86a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-07-31 20:48:22 +02:00
Volker Hilsheimer 3dc28cfae9 Baseline tests: prefer a screen with a DPR of 1.0
Move the windows to a screen with a 1.0 DPR, if the primary screen has a
different ratio. This makes sure that we get reproducible runs also
locally, no matter where e.g. the mouse pointer is (which on macOS
defines which screen the window opens up).

Change-Id: Iab7708c4abc0c97486f00a44a4b0a4c2b9406a62
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2024-12-10 23:45:41 +01:00
Volker Hilsheimer b340fb6982 Baseline tests: disable animations in the vista style
The Vista style uses a dynamic property on each objects to control
animations; respect that dynamic property on the style itself as well
to make it possible to turn off animations.

Do so in the baseline test framework to get rid of some flakiness when
using the Windows Vista style.

Change-Id: I2bad329786f38e37d99f947f121e5cd44f5741c1
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2024-12-10 23:45:41 +01:00
Jonas Karlsson ae9006b72d test: baseline: Call finalizeAndDisconnect
Pick-to: 6.8
Change-Id: I4379b4b982b869ca8d502d2f102ddc3b3858b5c8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2024-11-22 19:21:42 +01:00
Volker Hilsheimer bf2ed62409 Baseline tests: improve focus setting and clearing
Set focus on the test window so that the tested widget doesn't have it.
Remove the "PublicWidget" hack, we have public QWidget APIs to find the
next widget in the focus chain that we can use to transfer focus
reliably. Use TabFocusReason to maintain existing behavior, and to
test that widgets that handle that specifically appear correctly. Clear
the focus on the test widget by setting it back to the window after
taking the "focused" snapshot.

Add QCOMPARE and QVERIFY to assert that the test is in the right state
before taking screenshots.

Pick-to: 6.7
Change-Id: Icef6ce1bb1c63c9f6cde7d0ddca82e693cace420
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-17 21:17:34 +02:00
Volker Hilsheimer a623293a13 Baseline testing: use a full screen background behind the test window
Some tests are flaky on macOS because the background desktop shows
through the rounded corner of the test window. We cannot reliably
control this on each platform, so instead make the test window a
secondary window with a second, fullscreen and frameless window as the
transient parent. This way, we have full control over the background
pixels that might show through (semi-)transparent parts of the test
window.

Pick-to: 6.7
Change-Id: I44b7e834797b46fa8b44d776f6b91c99536a6cc9
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-17 04:37:58 +02:00
Lucie Gérard ff1039c217 Change license for tests files
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>
2024-02-04 09:56:42 +01:00
Volker Hilsheimer b3424c7027 Baseline tests: wait longer before taking a screen snapshot
The recorded images frequently show traces of a fading-out command
prompt window that is opened by the test execution. We evidently have
to wait longer for all window-level effects are finished.

Pick-to: 6.5
Change-Id: I50db54ff33bf4bb1ef7c480a4aede1d5de1618c3
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-04-20 15:17:25 +02:00
Santhosh Kumar f9aaa3e163 Update base line test case for widgets
Added baseline test case for menu (popup), combobox, command link and
lcd number.

New API takeScreenSnapshot() has been added for screen capture and
it serves to capture pop up windows

Change-Id: I5c1e46df270d94faf5c53431cddbd07532c256ee
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-06 14:51:29 +01:00
Tor Arne Vestbø 2436e259ce Deprecate QApplication::setActiveWindow() and mark as internal
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>
2022-08-27 20:22:29 +02:00
Lucie Gérard 05fc3aef53 Use SPDX license identifiers
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.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00
Volker Hilsheimer 4222d117d2 Baseline tests: slow down cursor blinking
Override the default cursor blink time so that we don't get mismatches
from line edits. We need to set the time to > 0 so that QStyleHints does
not fall back to the platform integration.

Pick-to: 6.3
Change-Id: Ib1d04f7450c01c352c13098886aee032dcb14c72
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-05 16:50:31 +02:00
Volker Hilsheimer dc96d812ec Baseline testing of widget: wait before taking snapshot
Widgets and styles might use fade effects or other asynchronous mechanisms
as part of hovering. This results in mismatches when the snapshot is
taken before those effects are completed.

Since we can't control all such animations from the outside, process
events for some milliseconds before taking the snapshot.

Pick-to: 6.3
Change-Id: I771658300628238552bddcd14a6751c3f6c0c63d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-05 16:50:31 +02:00
Volker Hilsheimer 58a14d9433 Enable tests to turn off Windows Vista animations
Animations in that style depend on the current time, which makes it
impossible to run baseline tests. Introduce a dynamic property that
allows us to set the time that animations use.

This way, tests can turn the animation off, or control which time should
be used.

To keep performance overhead low, check only once whether the dynamic
property is set at all.

Pick-to: 6.3
Change-Id: I9bc57b9867fb0d852e101570eca4c7609e7fe1a8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-16 15:56:17 +01:00
Volker Hilsheimer b2edef557c Baseline: don't compensate for DPRs != 1.0
The resulting blurriness is too significant, and it's hard to see where
the difference comes from. Better to encode the screen DPR into the
appearance ID if it's not 1.0, and warn about the comparison not being
done to the baseline images with a 1.0 DPR.

Pick-to: 6.3
Change-Id: Iceab7b0a4cc50627145bd1267cff22344f7d8e5b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-14 23:38:10 +01:00
Volker Hilsheimer ad333b9b87 Baseline testing: make style name explicit
Mangling it into the checksum makes it hard to navigate the available
images.

Pick-to: 6.3
Change-Id: I54dcab5681e747ce1c5fe1b141ef6c4441d1f7eb
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-14 23:38:09 +01:00
Axel Spoerl fd93c298d6 Prevent takeStandardSnapshots() from stopping on first mismatch
Force takeStandardSnapshots() to take and log all snapshots before
launching QFAIL. Macros QBASELINE_CHECK_DEFERRED and
QBASELINE_CHECK_DEFERRED_SUM have been added in qbaselinetest.h

Task-number: QTBUG-99790
Pick-to: 6.3
Change-Id: Ia015de808f354e842ac4029c5c84be18c4a4e209
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-17 21:24:27 +01:00
Eirik Aavitsland 7719fcea4b Add a couple of utility functions to the baseline test framework
Adds a function for setting the baseline Project name, which selects
the top level server directory and hence config settings.

Also adds a function that lets the client override the server config
setting for the project image keys (ItemPathKeys). This is the list of
properties that will be used to determine which clients are "the
same", i.e. which baseline to compare against. Overriding that is
handy since it allows experimentation and customization of clients
without involving changes in the project config on the baseline
server.

Pick-to: 6.3 6.2
Change-Id: Id3998356494a9a2cb71c009b43593d3dc1b6963a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2022-01-13 14:56:37 +01:00
Eirik Aavitsland 0f051815a0 Remove faulty #include from widgets baseline test
Since there is an actual qwidgetbaselinetest.h header file, one should
not include a .moc file. The build system will take care of it, and
currently warns about this #include.

Pick-to: 6.3
Change-Id: I4fbff9ef75c901fe3db4df54d6f3ff0d9307edce
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-04 05:53:30 +01:00
Volker Hilsheimer 969cd432f5 Share common code for baseline-testing widget UIs
Setting up the baseline tests, creating an appearance identifier,
and basic image-grabbing functionality doesn't need to be reinvented
for each test case that wants to use baseline testing of widget UIs.

As a drive-by, remove unneeded Qt 5 meta tags from .pri file.

Change-Id: I1562e1b377946305cac018e0f0f0175c2c07cd31
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-11-26 22:40:54 +01:00