Commit Graph

1652 Commits (d563ec3fba7cc7f435bf75e7569dc253cd95013a)

Author SHA1 Message Date
Giuseppe D'Angelo 27dc042712 Rename qt_saturate to q26::saturate_cast
C++26 adds std::saturate_cast, so follow the established pattern of
other similar "backported" APIs. The old name is left around while
we port other submodules.

While at it, move qt_saturate's tests to the qnumeric test.

Change-Id: I653a2e3d936081378298a9c8e51e7c1a2d438d83
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7447ad503330ed176cf369792ffb33b7e00a58d3)
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-08-25 17:04:32 +00:00
Tim Blechmann 6c8d2e042c Gui/Testlib: fix compilation for FEATURE_qreal
Task-number: QTBUG-118877
Change-Id: I4988f3b8b9ed09d8f01873fe34bf78d8105a25da
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit a74b550e2c38679c329cd40d2119ab440668468e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-25 17:03:41 +00:00
Ivan Solovev 9dfddeb913 Comparison helper macros: drop the check for noexcept
Now when we explicitly have the _NON_NOEXCEPT version of the macros,
and a static_assert() in the "normal" macros, it does not make sense
to have these checks in the helper functions. If the developers choose
the _NON_NOEXCEPT macro, they clearly know what they are doing.

So simply drop the check and get rid of the annoying XFAILs in the
test log.

Change-Id: Id467ae5ad6a852da7c39dd1dbf32ce5838e69ecc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 80bc0152448fbd4a57a4c95147e7b3f067e6a35c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-13 12:56:13 +00:00
Marc Mutz a9f26089ed Enable QT_NO_QSNPRINTF globally
The qsnprintf() function introduces even more platform variability
than std::snprintf(), so from now on, we're using only std::snprintf().

Task-number: QTBUG-127110
Change-Id: Ic81b2a760521d77442cc328d2cfa7659bba8b7e2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit b8a956c2d3f9c158594265eca89185bd2bc671e7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-12 09:43:38 +00:00
Marc Mutz 2e2cdc3c4f qtestcase.cpp: standardize on <cstdio>
As part of the qsnprint() -> std::snprintf() port, we included both
<stdio.h> and <cstdio>. Standardize on the latter; this is a C++
project, after all.

Change-Id: Icd8ef528b94cea75dd0ede18b4105f85b08c3515
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 73d7138c020d0f95ad354c4ec4512a54914e0195)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-07 07:18:06 +00:00
Marc Mutz 33077559a2 QtTest: port from qsnprintf to std::snprintf and mark the module as qsnprintf-free
Drive-by remove an explicit NUL-termination (std::snprintf() does
that) and port a repeated use of printf argument checking to the
protect() idiom.

Change-Id: Ida15940fe9aef0622e9836a229a398c909503a9a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit b5115d1c2fc73feb149a8ee97de011b3c75694fb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-05 18:23:04 +02:00
Marc Mutz 2a72fb6d81 QTest: simplify qPrintDataTags() string building
Use higher-level API (QByteArray::chopped()/operator+()) instead
of new[] and qsnprintf().

methodSignature() already heavily depends on QByteArray concatenation,
therefore trying to avoid using Qt code in QtTest is pointless, at
least here.

Drive-by indent lines so a follow-up port to std::fsprintf() will not
have to re-indent these lines again.

Amends b68bae1132.

Pick-to: 6.7 6.5
Change-Id: I94ec440d7e6d09196cf87cd3dbbfd765e0df69d0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit a15ff49be73228bbbc72989736d32059322c414f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-05 18:22:58 +02:00
Marc Mutz 13ed410121 Make headers QT_NO_QSNPRINTF-clean
Before we roll out QT_NO_QSNPRINTF across Qt, we need to make sure at
least the headers are clean, so downstream modules can port without
being stabbed in the back by unported upstream headers.

Task-number: QTBUG-127110
Change-Id: I7411ff0036482ad68bd5867b624518f68f249228
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 7e2fa57faf230ef8cb505b95c2bc0e70867ac131)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-05 18:22:50 +02:00
Marc Mutz a58abfec1c QtTest: mark more functions as cold
Unit test failure should not happen, so mark failure formatters as
cold (like qFail() itself).

As a drive-by, mark formatFailMessage() overloads file-static, too.

Change-Id: I92f5b674a7282f4ebaa9250894a9971a524f4108
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 69c510d6bcc52ac133a82d7a9493ffba037c4521)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-03 11:15:43 +00:00
Marc Mutz f92cab0bee QtTest: Fix format error in _q_compareSequence()
Commit 63295f43e70955a194602a7acf39013f124e14b7 changed the size:
placeholders to %lld, but wrapped only one of the arguments in
qlonglong. This causes 32-bit builds to read past the end of the
expectedSize variable.

Fix by wrapping the other, too.

Pick-to: 6.7 6.5 6.2 5.15
Change-Id: I9c23ab589c8895e8f038fb508e18ac3006fa4f8f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 57eff5b092dbd692594125edc70d3efd898660ea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-03 07:47:17 +00:00
Marc Mutz 0a67a8c3d4 qtestlog.cpp: remove duplicate <vector> include
Amends efb283fb7f.

Pick-to: 6.7 6.5
Change-Id: I92f5b674a7282f4ebaa9250894a9971a524f3096
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 16d085c370a775234ba577461238765c2cf154e5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-02 06:50:02 +00:00
Marc Mutz 9c3ab9a17e QPROPERTY_TEST_COMPARISON_HELPER: fix extra leading \n in failure output
Once we ported the formatting to use formatFailMessage() in
aa8a4be9e9eae82b6c6b8875371114dbfb3ec06a, it became apparent that the
output contained an extra leading newline compared QCOMPARE use of
formatFailMessage(). We kept the newline in the patch that was picked
to older branches. Since this is a stylistic discrepancy, though,
standardize on no leading newline going forward.

Change-Id: I4badf700900a106d835f3f72e92441d8a8912ff7
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 4bc81fe5d1d1e4587075a82a45be9b34825b5233)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-01 15:48:18 +00:00
Marc Mutz e7aa8aa118 QtTest: port approx_wide_len() from std::clamp() to qt_saturate()
The patch that originally added the function used std::clamp() because
qt_saturate() wasn't available in all the branches to which the patch
was backported. This patch modernizes the code for newer branches.

Pick-to: 6.7 6.5
Change-Id: I1b764d303e00ec04858643efed3dcc71f2c7ce4c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit d042c14c9940c6aabaa5b39d3061c0f9e50fff06)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-01 00:43:34 +00:00
Marc Mutz c3e25c61d2 Remove dead code in qtestcase.cpp for Qt 6
This is a clean-up after a previous commit that needed the version
check for cherry-picking to 5.15.

Pick-to: 6.7 6.5 6.2
Change-Id: I914ca6ec184e2d7c376de4c7de6f2f0f7e9ecb22
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 4dd730f99fc95ad1e4c231dda70957b6c01df1b0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-01 00:42:58 +00:00
Marc Mutz d7a8b34d4a QTest::toString(): Fix format specifier for q(u)int64 on Windows
Qt 5 had qint64 as __int64 on Windows, so using I64 was correct, then,
but MinGW was already using long long, so using I64 for all Q_OS_WIN
builds was wrong even then. So exclude Q_CC_GNU from the I64
formatting.

In Qt 6, all platforms always use long long, so no Windows-specific
handling is needed anymore.

Found by adding __attribute__((format(printf))) to qsnprintf().

Pick-to: 6.7 6.5 6.2 5.15
Change-Id: Icfa0afc6f0fe06e5d47684702097ac1d3da6cef1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ab74c1779ec2499758449d41999356a91bb82cf8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-01 00:42:50 +00:00
Marc Mutz 821a8fd523 QPROPERTY_TEST_COMPARISON_HELPER: fix mbstowcs and snprintf usage
The mbstowcs() function is not re-entrant, and while we can probably
rule out that our test macros are being executed concurrently, we
can't rule out that other parts of the test concurrently execute
std::mbstowcs().

To fix, de-inline the code so we can re-use the existing
formatFailMessage() in qtestresult.cpp, which has already been fixed
before.

Amends 930e59b798.

Pick-to: 6.7 6.5 6.2
Change-Id: I61144af13a41ea0b4fba17bd232e660ef33dbd20
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit aa8a4be9e9eae82b6c6b8875371114dbfb3ec06a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-01 00:42:42 +00:00
Marc Mutz 8777e13b5a QTest::formatFailMessage(): fix use of std::mbstowcs()
This function is not re-entrant, and while we can probably rule out
that our test macros are being executed concurrently, we can't rule
out that other parts of the test concurrently execute std::mbstowcs().

Use the re-entrant version and also fix the format string (%* requires
int, not size_t).

Saturation is ok here, because, while std::mbsrtowcs() will happily
return a value > maxMsgLen when dst == nullptr and the string is
longer, we will never actually print more than maxMsgLen of it.

As a drive-by, port to std and adjust the QNX comments to describe the
quirky QNX behavior, if, indeed, still present in the <cwchar>
version, better. This author had to go back in the git history to
figure out what it wanted to tell him.

Amends 2d8028d696 (mbstowcs) and
d040681b6f (%*).

Pick-to: 6.7 6.5 6.2 5.15
Change-Id: I6215713c643647727f73f4e2f2a7ac34204af40d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 1579b18dfa49252318b4a2b3cfa83a4ce325ba0c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-31 15:52:28 +00:00
Marc Mutz e4a03a4001 Fix -Wformat issues in our headers
Before we add __attribute__((format(printf))) to qsnprintf(), we need 
to make sure our code is clean.

Pick-to: 6.7 6.5 6.2 5.15
Task-number: QTBUG-127110
Change-Id: I7411ff0036482ad68bd5867b624518f68f249229
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 63295f43e70955a194602a7acf39013f124e14b7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-31 15:52:12 +00:00
Axel Spoerl 5413d4b460 Minor code cleanup QTestPrivate::parseBlackList()
Constify local variables, where possible.
Remove redundant include.
Bump (c) year to 2024.

Change-Id: If13fb87b306926cb94f75186071a1dff2969a945
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 6de2203fb75e034c1a02478daa13e8ddfcea5d75)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-23 22:52:53 +00:00
Marc Mutz c342496831 QPlainTextLogger: FixedBufString: simplify appendf()
qsnprintf() does not make a difference between lvalue and rvalue
arguments, so the wrapper doesn't need to perfectly forward.

Use decay-copy via by-value arguments to potentially reduce the number
of instantiations required for the existing calls.

Adjust indentation so the continuation line doesn't need to be
re-indented when we'll port qsnprintf() to std::snprintf().

Amends 0e8eb20af4.

Pick-to: 6.7 6.5
Change-Id: Idcaa441517fdbf00fefd952db7928731779123ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit fba67959acb7be39942aa3ce829f6764c46ad3ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-22 21:00:12 +00:00
Marc Mutz 0471e845e4 qtesttostring.h: don't write 32..256B of NULs
qsnprint() is unconditionally called to fill the buffer and is
guaranteed to NUL-terminate, so there's no point in filling the whole
stack buffer with NULs beforehand. Leave it uninitialized.

The code was moved in 4ae6f40b3a, so not
picking further than that.

Change-Id: I34d456ebd2990aa242ccc42693adbbf1f64148de
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4c5b437a3ce84354dfa3bf2c4706e05144ac03a3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-21 15:01:31 +00:00
Marc Mutz 6cda03c5d6 QPROPERTY_TEST_COMPARISON_HELPER: don't write 1KiB of NULs
qsnprint() is unconditionally called to fill the buffer and is
guaranteed to NUL-terminate, so there's no point in filling the whole
1KiB stack buffer with NULs beforehand. Leave it uninitialized.

Amends 930e59b798.

Pick-to: 6.7 6.5 6.2
Change-Id: I7da859d609ad4492c9038cb3e14f2a721b2acbe4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 47c2263e896408e733c9aa466aec388cc4b4a6ad)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-21 10:07:40 +00:00
Allan Sandfeld Jensen 85b7aeaddc Fix source compatibility with existing toString() extensions
Change-Id: I946ebf0f0fa82450105e720489c4da35a77078d8
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7dd2c5f91dd62840d37c5e17cc3f1f5ad46d9366)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-18 11:55:37 +00:00
Edward Welbourne b68eaebc86 Update benchlib's 3rdparty cycle counter to FFTW v3.3.10
Document cycle_p.h's provenance - thanks to Morten Sørvig for digging
that up - and update to its version in the most recent release of
FFTW. Include patches to apply (after purging dangling hspace) for
future updates.

[ChangeLog][Third-Party Code] QtTest's benchlib now uses FFTW
v3.3.10's version of the clock-cycle counter, Cycle.

Task-number: QTBUG-126080
Change-Id: Ib59bc53e5d74cfdc889c03e78f9dd72100168f64
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit 6e7c158152cef6a1ae6a628f08661fcc4b27de90)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-17 10:33:01 +00:00
Edward Welbourne 03a95f5f20 QtTest 3rdparty: update valgrind headers to v23.0
Nothing hugely consequential, although __VALGRIND_MINOR__ was
previously out of step with the version given in qt_attribution.json.

[ChangeLog][Third-Party Code] Updated QtTest's Valgrind headers to
version 3.23.

Fixes: QTBUG-126080
Change-Id: Ie2c9d41d4f35cd497b1dcf9a366cf4b319b361ad
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit efab6e69831c7fc8d35f18e211bda20f854f2f39)
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-07-12 13:45:55 +02:00
Edward Welbourne 35062f6510 Replace a renaming in a third-party file with a #define
Our use of the clock-cycle counter from FFTW involved a rename of its
type ticks to our type CycleCounterTicks. This unnaturally bulks up
the diff from upstream, so undo it and use a simple #define to achieve
the same effect, as seen by our code.

Task-number: QTBUG-126080
Change-Id: Icbe9c413b73dd9213b95f183b71585f4a9c38de1
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
(cherry picked from commit ed7becd9cba582640f19704b5c439e5f6807bc29)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-12 11:45:55 +00:00
Edward Welbourne 1c7c4c5ac9 QtTest 3rdparty: isolate Catch2 part as a 3rdparty component
Move from tests/auto/testlib/selftests/ to
src/testlib/3rdparty/cache2/, so that its path includes a 3rdparty
component and it's isolated from the rest of the selftest files.
Instead, it's now grouped with QtTest's other 3rdparty components, to
make it easier, when doing a 3rdparty update, to see what might need
an update.

In the process, document where in the upstream to find the file to be
copied, if an update is needed. The file is generated, so document its
generator, too, in case its output gets renamed. There is no more
recent release than the 2.13.10 we currently have, so no update will
follow.

Task-number: QTBUG-126080
Change-Id: I371bac233b00318f59d6043fb245ab44b914bf8a
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit 31adb73e289d1bd93276af2b1df9bc356ba14766)
2024-07-12 13:45:55 +02:00
Edward Welbourne 23e0318d24 Reorganise QtTest 3rdparty to separate its various parts
In the process, update the Linux perf_event.h provenance details to
make it possible to find the latest version. Also, remove 3rdparty
headers from the module's CMakeLists.txt (where possible) so that
anything that includes them makes its 3rdparty dependence visible in
the relative path. That can't be applied to cycle_p.h, though, as it's
used by the tests.

Task-number: QTBUG-126080
Change-Id: I3a7099bc123ba7188ad096714cb7ed45ff35a392
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit b14906884c63b3f5f239d7d008eb23aba66836fa)
2024-07-12 13:45:55 +02:00
Christian Ehrlicher 5910dd7fe0 Testlib: remove no longer used function call
QBenchmarkEvent::nativeEventFilter() was changed with Qt6 but the old
Qt5 version was still there and no longer used.

Pick-to: 6.7 6.5
Change-Id: Ia740ce0dc743666c9b3bcbe12d1d310fb9ffcd7b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit ef215fdd8bd36c0312d657e0aafaa766d7c297f7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-03 20:12:03 +00:00
Safiyyah Moosa a02c49f3de Doc: Fix broken links
This commit fixes:
Broken URL (404): 'https://doc.qt.io/qtcreator/creator-autotest.html' from qtest-overview.html
https://doc.qt.io/qtcreator/creator-autotest.html is replaced with
https://doc.qt.io/qtcreator/creator-how-to-build-and-run-tests.html.

Broken URL (404): 'http://www.opengl.org/wiki/Tessellation_Shader' from qopenglshaderprogram.html
'http://www.opengl.org/wiki/Tessellation_Shader' is replaced with
https://www.khronos.org/opengl/wiki/Tessellation

Task-number: QTBUG-126281
Fixes: QTBUG-126502
Pick-to: 6.7 6.5
Change-Id: Ifda1258a6500adcfa3fe861135ab98082ed2df10
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
(cherry picked from commit 6e0588225dbe2694de35b7059cf533fe105565ae)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-26 22:52:29 +00:00
Volker Hilsheimer 5cb79f8850 QAccessible: rename AnnouncementPriority to AnnouncementPoliteness
Better name given the value names, as discussed during header review.
Keep AnnouncementPriority as an alias until dependencies are updated.

Change-Id: I7b60c429fb60fc30378a9560da12abb87499225f
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
(cherry picked from commit bb305e63ff856a8c6f9649a27a5eabfb31df8aa7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-18 21:12:18 +00:00
Marc Mutz 2b8cf058f1 Fix misspelled QTEST_THROW_ON_FAILURE
Amends e769cf026e.

Reported-by: Ahmad Samir <a.samirh78@gmail.com>
Task-number: QTBUG-66320
Change-Id: Ib731acf6b7e56c848aa79772488186efdd856c71
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 45e9f5f2e5f0701ad4dffbe532206b791d698953)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-17 23:17:50 +00:00
Alexandru Croitor 699d50bd8f CMake: Annotate some targets with SBOM information
Task-number: QTBUG-122899
Change-Id: I2eb70ca4d52e30c8e15ca7b350df6965d93732f8
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 79f9b490e7f6e2746de36542cc4c7442dabe8315)
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-06-17 15:54:26 +02:00
Alexey Edelev 10b48d59dd Remove GENERATE_CPP_EXPORTS argument
The behavior that argument was enabling is the default one now.

Task-number: QTBUG-90492
Change-Id: I11711d4c794f0b22169abb595b8ffad2eeb1300d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 1ef3bd05eb45d53cdcf92b933603b995283b3432)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-13 14:39:17 +00:00
Friedemann Kleint 0723c6fd05 QAbstractItemModelTester: Enable testing the QtGui roles without linking to QtGui
This enables doing QtGui testing when using QAbstractItemModelTester
in Qt for Python, where the QTestlib binding only links against
QtCore.

Port the code to check against QMetaType constructed from type names.

Task-number: PYSIDE-2772
Change-Id: Ifcd8f1ea4758459d8a178226e3f215e5c2b273b8
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit bb542a55b28dd591709ed2c68e4505ec08fc62b5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-13 08:46:16 +00:00
Tor Arne Vestbø 18375f3bff Promote specific scoping for blacklist-file comments
A standalone comment added before a test case or keyword will
be confusing once more test cases and keywords are added, as
the comment likely doesn't apply to those added lines.

Change-Id: I4e36c1c2ae4547bcffa9df817cd53c64cf66defb
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 2f939540c7a7dac262dd61210351cbd24545ee83)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-07 14:28:47 +00:00
Friedemann Kleint 6333376402 QAbstractItemModelTester: Check size hint role
Returning the wrong data type for Qt::SizeHintRole may lead to a size
of 0,0 and the item disappearing.

Task-number: PYSIDE-2772
Change-Id: I906445f2ed2141da2606774f2b8ad6282662eb17
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit 84f2cd6523081ed8774b2a9fe9ee36d05172ff50)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-05 14:39:58 +00:00
Łukasz Matysiak a092feb71a Add vxworks to the list of keywords used to blacklist tests
Right now vxworks is not on the list of keywords used to blacklist
tests.
Because of that, it's not possible to blacklist a test specifically on
that platform.
Solve the problem by extending the list.

Pick-to: 6.7
Task-number: QTBUG-115777
Change-Id: I04d55eabc27f7554ea9e3fa030ff118a22a624b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 8f9b0891f59dbc59d1295bf8eff361070bd01a9d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-05 13:16:46 +00:00
Marc Mutz aec1edfe40 qtypeinfo.h: move QTypeTraits part to qttypetraits.h
Makes sense to collect the stuff in a similarly-named header, and it's
not like any of the QTypeTraits stuff was needed for QTypeInfo.

Makes #include <qtypeinfo.h> _much_ lighter again, at the expense of
qminmax.h now getting <variant>, <tuple> and <optional> instead, but
qminmax.h is much easier to avoid in Qt headers (just use the std
versions) than qtypeinfo.h.

[ChangeLog][QtCore][Potentially Source-Incompatible Changes] The
qtypeinfo.h header no longer transitively includes <optional>, <tuple>
and <variant>.

Task-number: QTBUG-97601
Change-Id: Ied96113f38c1232fef3ec79847ee62f06c68f268
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit b2eb422699118f4ae8370519b4c7bb3fe121beb2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-04 13:42:16 +00:00
Aleix Pol 244964d06a testlib: Integrate the new object type in the unit testing system
It seems like all subclasses of QAccessibleEvent need to be registered
here, otherwise tests explode.

Change-Id: I924961f351bda1f50e2c73d54abe4b51162dc82a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-05-31 05:13:50 +02:00
Jesus Fernandez 7c128f8866 Add -Wweak-vtables to headersclean
This requires some fixes in several classes that are also included
in this patch.

The QTestEvent hierarchy is all-inline and changes layout depending on
QT_GUI_LIB and QT_WIDGETS_LIB, so we can't just export it. Suppress the
warning in that header for now. Created QTBUG-104486 to track a fix for
the real issue.

The QFutureInterface hierarchy is also all-inline, but templates, so
doesn't trigger, except the <void> specialization. Created
QTBUG-125115 to track a fix for the real issue.

Done-with: Marc Mutz <marc.mutz@qt.io>
Task-number: QTBUG-45582
Change-Id: I96b3e109aa989b70e0d4809b90bd53a369e50d55
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-05-19 15:56:17 +00:00
Marc Mutz 672afb13ca QSignalSpy: make sig member const
Previously, the sig member was used to indicate successful
construction of the QSignalSpy (incl. successful connection to the
monitored signal), so it was set only after all other initialization
had taken place, preventing it from being marked as const, which would
indicate that accesses to it need not be protected by the mutex.

Now that we have it, we can instead use the d_ptr's value to indicate
success, and mark sig const.

[ChangeLog][QtTest][Important Behavior Changes][QSignalSpy] The
signal() method no longer necessarily returns an empty byte array when
the connection failed. Use the existing isValid() method to determine
whether a given QSignalSpy object listens to a valid signal on a valid
object.

Change-Id: Ia08fe3b383681f3f203cf1a121c0e1ce08ad268b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-05-16 17:12:14 +02:00
Marc Mutz 46e53117c5 QSignalSpy: make makeArgs() file-static
Now that the private ctor that calls this function is finally
out-of-line, this function need no longer be part of the ABI.

Task-number: QTBUG-123544
Change-Id: Ia4656bf8bfd4d68d6925f93ef150593cd2de6ddf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-05-15 18:22:39 +02:00
Edward Welbourne a2566e139f Extend QTest::failOnWarning() to a no-parameter fail-on-any-warning
Many users (albeit mostly in qtdeclarative) of failOnWarning() are
passing a catch-all regexp, which is only supported when regular
expression support is enabled. Make their lives easier and those
checks independent of the feature by adding a third overload, taking
no parameter, that fails on any (unanticipated) warning.

Implementation is trivial - just put a null QVariant in
failOnWarningList; it won't match either check on the entry that might
exempt a test from failing on a warning, so any warning at all will
trigger failure.

[ChangeLog][QtTest] QTest::failOnWarning() now has a no-parameter
overload to support the common case of fail-on-any-warning, without
needing to construct a match-everything regular expression.

Change-Id: Ic693f1c8619fd6e495543b85737d566134cf9d20
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2024-05-06 20:27:41 +02:00
Andreas Eliasson f8bc0e7c3b Doc: Remove \note that indicates you can access the source code
There used to be an examples page; this is no longer the case. Thus,
remove the \note that indicates you can access the source code.

Fixes: QTBUG-122166
Pick-to: 6.7 6.6 6.5
Change-Id: I1abe88000ae406e8d2cc9cc1deed42664607626b
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2024-04-29 17:38:52 +02:00
Marc Mutz ab0b2a490e QSignalSpy: fix -Wweak-vtable by removing the QObject inheritance
Normally, we'd fix -Wweak-vtable by exporting the class and making at
least one virtual method out-of-line (typically the dtor), thereby
pinning the vtable to exactly one TU.

We can't export QSignalSpy, though, because it also inherits QList,
and we don't want to export QList subclasses to avoid QList API
becoming part of the ABI.

So remove the vtable, and therefore its being a weak symbol, by moving
the qt_metacall implementation from QSignalSpy into its newly-added
Private, at the cost of an additional memory allocation at
construction (though there was already the wish to make this class
pimpl'ed for extensibility, and this patch accomplishes exactly that).

This class used to be one of few places left that prevents adding
-Wweak-vtable to headersclean, so while this is a breaking change,
QSignalSpy doesn't really model is-a QObject. It uses QObject to
reuse, not to be reused. In fact, no external code should use the
QObject-ness of QSignalSpy, so it should be an acceptable SC break to
drop the inheritance.

We don't need to care about BC here, as we don't promise BC for
QtTest.

This now also allows (and requires) to make the dtor and the private
ctor out-of-line, avoiding the need for the init() hack.

[ChangeLog][QtTest][Potentially Source-Incompatible Changes]
QSignalSpy no longer inherits from QObject. If your code uses the fact
that QSignalSpy is-a QObject, you need to redesign around this now.

Task-number: QTBUG-45582
Fixes: QTBUG-123544
Change-Id: Id93ba0ee6bbb811455d3744a045e38e1b9f9c584
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-04-29 09:23:50 +02:00
Thiago Macieira 15eb9dccae QTest::test*Operators: test reverse order too
There's no need to condition that comparison only for heterogeneous
types. The reverse comparisons will compile if the types are homogeneous
(it's what we had already tested), but this now ensures the results are
also the expected ones.

Change-Id: If1bf59ecbe014b569ba1fffd17c4a2dd756157b2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-04-27 21:35:38 +00:00
Thiago Macieira f7e9bb7783 QTest: replace the majority of the ugly QCOMPARE_xx macro
Using templates to make the code look nicer and be more debuggable.
Previously, if you tried to step into the QCOMPARE_xx, you'd have the
creations of qxp::function_ref from the lambdas before you got to the
actual comparison. And all of this was in-place from macro expansion, so
you couldn't tell what was happening.

Now, if you step into QCOMPARE_xx, you go to qCompareOp. There are 5
frames between that point and the actual comparison (four std::forward()
and the Compare::compare()) and debuggers could step over std::forward.
Even if they can't, both libstdc++ and libc++ implementations are simple
casts, so there's nothing more to step into.

Change-Id: I12a088d1ae424825abd3fffd171dbbf7adb7e7e2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-04-26 18:19:36 +02:00
Thiago Macieira 0756cc1eae QTest: rip out qxp::function_ref from compare_helper()
[ChangeLog][QtTest] The QCOMPARE_xx macros can now only find
QTest::toString() expansions that are either found via Argument
Dependent Lookup on the type in question or are an instatiation of the
QTest::toString<T>() template. This matches the behavior of the
QCOMPARE() macro.

This changes the way how the toString() overloads are selected, so
we need to explicilty constraint the main QTest::toString() template
in order to pick the free functions when they exist.

Change-Id: Ie28eadac333c4bcd8c08fffd17c54e768c5cffd0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-04-26 18:19:36 +02:00
Thiago Macieira c14f399d2a QTest: rip out qxp::function_ref from reportResult()
This is causing huge code bloat because everything is a local lambda.
Instead, pass direct type-erased function and data pointers to the
replacement function. Testing with tst_qcborvalue, this reduces the
compilation time and the output binary size significantly:

                   Before                   After
Compiler        Time      Size          Time     Size
GCC 13.2        136.99 s  202.3 MB      13.88 s  14.3 MB
GCC 14.0        131.49 s  202.7 MB      14.69 s  14.4 MB
Clang 17        77.2 s    146.7 MB      13.62 s  12.2 MB
Clang 18        141.9 s   187.1 MB      13.62 s  12.4 MB

This causes a difference in how toString() overloads are
found. Previously it would match far more overloads because the
toString() calls were expanded by the macro. Now, we depend on
Argument-Dependent Lookup and associated namespaces, so toString()
overloads should not be in the QTest namespace any more.

With this patch applied, the testlib testcase of tst_selftest
started failing, because nullptr is now handled differently.
However, I consider it as a bugfix, because previously it was
falling back to a default implementation, and now it is using
the QTest::toString(std::nullptr_t) overload, which is a
desired behavior. Update the reference files for tst_selftest
with the new expected output.

Task-number: QTBUG-124272
Change-Id: Ie28eadac333c4bcd8c08fffd17c5484186accdf6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-04-26 18:19:36 +02:00