Commit Graph

13647 Commits

Author SHA1 Message Date
Friedemann Kleint
9ddc020246 Stabilize tst_QTabBar::hoverTab()
Port the test to use the QWindow* based overloads of QTest::mouseMove()
and move the cursor away.

Pick-to: 6.3
Task-number: QTBUG-98489
Change-Id: Id1ac0ef176c6f9bf179f989ddd5775877525fc0d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-22 07:55:30 +01:00
Thiago Macieira
5731b83445 tst_qlogging (tst_qmessagehandler): use one line for output and expected
Makes it easier to interpret the output from the test, because of
embedded newlines.

Pick-to: 6.3
Change-Id: Ic15405335d804bdea761fffd16d4f141e09537f4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-20 23:32:26 -08:00
Thiago Macieira
43a171a7d6 tst_qlogging (tst_qmessagehandler): use QProcessEnvironment
Simplifies the code. And removes the unnecessary quote around the
pattern that was there, for some reason.

Pick-to: 6.3
Change-Id: Ic15405335d804bdea761fffd16d4f135edf6993b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-20 23:32:20 -08:00
Mårten Nordheim
db5b8bbea3 Http2: Fix redirect-handling
The redirect handling for http2 was a little simple. E.g. not handling
relative URLs.
Fix this using the redirect response parsing function which the http1
protocol handler already uses.

Fixes: QTBUG-100651
Pick-to: 6.3 6.2 5.15
Change-Id: Ic0cec4cacc92707e7a7fde1f4665f80995a6057e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-20 22:47:25 +01:00
Friedemann Kleint
05428d9b97 Polish tst_QAbstractSpinBox
Introduce modern C++, use static methods, nullptr, auto.

Pick-to: 6.3
Change-Id: I9025c94c063045329ae1a25b387cb2135d588b22
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-18 22:32:18 +01:00
Friedemann Kleint
1af068332b Fix test to pass with QT_FORCE_ASSERTS
Add QT_FORCE_ASSERTS to condition with standard comment.

Pick-to: 6.3 6.2
Change-Id: If493c7cdea8164f010228a755915a211c1cf1b39
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-18 18:55:38 +01:00
Volker Hilsheimer
72e1fc7c0b Simplify failure detection logic in QEventDispatcher test
The test always fails when either the Xcb or UNIX, one of the Windows
event dispatchers is used. So only test for the event dispatcher name,
which then covers all platforms, including QNX and INTEGRITY (which
use the UNIX event dispatcher).

Pick-to: 6.3 6.2
Change-Id: I2e315831b53f823c5496ad0319319df78f064cc1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
2022-02-18 18:55:38 +01:00
Edward Welbourne
795c94658d Expand testing of QDateTime's isNull() and isValid()
Bring out the asymmetry between date and time more clearly; when date
is valid, an invalid time is ignored in favor of QTime(0, 0). At the
same time, eliminate an un-needed variable from the code that
implements this special handling. (Left over from when the QTime was
passed by const ref, rather than by value.)

Change-Id: I81d8a9026cbb7887a8c638a2761b3db54c088af7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-18 17:44:53 +01:00
Edward Welbourne
a2236c7675 Tidy up tst_QTimeZone::specificTransition()
It can now use startOfDay()/endOfDay() for the end-points of its
search range; and it should check transit is not empty before
dereferencing transits.at(0).

Change-Id: Ib1568f4d8d6ce301d601071bb58185be906c631a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-18 17:44:53 +01:00
Tatiana Borisova
8875b5a9a3 Exclude autotest for INTEGRITY
- ICU is not supported by backend.
  System supports only a simple named UTC time zone implementation(see QUtcTimeZonePrivate)

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I4a87fc3d5484d75d55890bf88d012955e5048a0b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-18 13:19:45 +00:00
Fabian Kosmale
8079361852 typeNameForCast: use add_pointer instead of string manipulation
Relying on string manipulation leads to -Wredundant-parens warnings in
the best case, and to non-compiling code (when using typedefs) in the
worst case.
We can avoid both issues by simply generating code that uses
add_pointer, which takes care of reference types (even typedef'd ones),
and creates no warnings about parens (as we don't write any anymore).

Fixes: QTBUG-100915
Pick-to: 6.3 6.2
Change-Id: Ic5b1cbfda20d920d11f51beeb62e9479261d5f00
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-18 13:44:41 +01:00
Mårten Nordheim
9078b41dde QHttp: Move the emission of requestSent
Moved to after the header is actually written, not just generated.
For requests with data (put/post) we may have to wait for a callback
before the data to write is available. Since we then delay writing the
header as well it would be disingenuous to emit requestSent().

Pick-to: 6.3
Change-Id: I76c2d40ca48faaa1f6730ce8b3d5a8a4c3156f8f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-18 13:44:41 +01:00
Ivan Solovev
cd3e3c0dc2 A11Y tests: wrap memory allocations into smart pointers
Some of the UI elements in the a11y tests are allocated dynamically,
which means that if the test fails, the element is not destroyed
properly. As a result, the "hanging" UI elements affect all the
following tests, which leads to more test failures and even hangs.

This patch wraps all such allocations into smart pointers, which
guarantees correct destruction in case of test failure, so that other
tests are not affected, and also prevents memleaks.

As a drive-by:
- use nullptr instead of 0 in constructors;
- create some objects on stack instead of dynamically allocating
  memory for them;
- remove some unneeded 'delete' calls for the objects that belong
  to QObject-hierarchy.

Task-number: QTBUG-87674
Pick-to: 6.3 6.2
Change-Id: I0dcc26990955cd7b240a689a7438880b686985b7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 21:42:23 +01:00
Pasi Petäjäjärvi
17c7af722c tst_qmessagehandler: force QProcess tests to log to stderr
These tests rely on reading output sent to stderr, so make
sure their output does go there.

Pick-to: 6.2 6.3
Change-Id: If62c073101c1d2e3d64f8cb2769d67f3b9fbeefb
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-17 20:00:37 +00:00
Pasi Petäjäjärvi
964c964193 Check if platform has enough RAM for hugeQImage test
The hugeQImage test loads, as its name suggests, a huge image.
At 2.5 GiB it's too big for the hard-coded 1 GiB limit on RAM
that the QNX toolchain hard-codes when it's started in QEMU.

Pick-to: 6.2 6.3
Task-number: QTBUG-100929
Change-Id: I8e8caaff7fd1dd0e648ada5df613c793f72bcf5d
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-17 22:00:37 +02:00
Allan Sandfeld Jensen
65a02da1b5 Make large inputs to qNextPowerOfTwo give undefined output
Fixing documentation and removing tests.

[ChangeLog][Important Behavior Changes] The qNextPowerOfTwo()
functions now have preconditions.

Change-Id: If6d5e8bee66826910e89be7cac388a1f0422ebfd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-17 17:20:34 +00:00
Edward Welbourne
1a693b058f Add spaces round operators and at starts of comment texts
More mindless coding-style conformance. Includes moving & or * to
after the space, not before, in declarations; and spaces after commas.

Change-Id: I221fef1e4de69d6c55d33dfc533aa74e2fd72df0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-17 15:51:31 +01:00
Edward Welbourne
c5645a48d4 Purge stray spaces immediately inside parentheses
With one exception: in a macro-definition with a backslash-newline
immediately following the open-parenthesis.

Change-Id: I0fc8d7492676402636785d571e4667881334af6a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:31 +01:00
Edward Welbourne
426f032119 Invert a condition to save a lot of indentation
Simply if (!condition) QSKIP(...) instead of having a long block
depend on the condition with the QSKIP() in its else block (which
should have had braces, as it was).

While dedenting the code block, tidied up spacing: only include blank
lines where they break up the code into blocks that go together, don't
leave spaces just inside parentheses.

Change-Id: I0196150088be88a7c6073b997a315b8f14d5f392
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:31 +01:00
Edward Welbourne
b3f67d2ba3 tst_QSqlQuery: fix usage of QtTest macros
Use QVERIFY() rather than comparison to true; QVERIFY() the negation
rather comparing to false; prefer QCOMPARE() otherwise for
comparisons, except for a few special cases involving very long
strings. Fix up the phrasing of a few QSKIP()s in the process.

Also, QCOMPARE() can handle an enum as expected value without
int-casting.

Change-Id: I9a1b82e5f4e10df6427bcc184b7757737df7db4f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:31 +01:00
Edward Welbourne
43209d0f0a tst_QSqlQuery coding style: split lots of long lines
In some cases by adjusting where the splits happen within concatenated
strings.

Change-Id: I4cffc41cda4582654151ba45d1478285caee7c81
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:31 +01:00
Edward Welbourne
7e59139f5c tst_QSqlQuery coding style: clean up loops
Prefer pre-decrement over post-decrement, turn a while into a for,
Don't put a while's body on the same line.

Change-Id: I5653a9bcec7901d205a91927c4b08e3dc13e0ca6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
e94b579679 tst_QSqlQuery coding style: clean up comments
Reflowed some over-long ones, fixed some typos, capitalise starts of
sentences (and end them with suitable punctuation). Removed one as
redundant, made another pair redundant by changing the code (use an
overt NaN instead of commenting that it's happening). Prefer C++-style
when single-line. Don't pretend to be QDoc comments, or have other
eccentricities about start-markers.

Change-Id: I5a30e1b22a08866124f09060bb35f5bd27cd443b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
5b7b8e123b tst_QSqlQuery coding style: use vertical spacing to group lines
Much of the test code simply had a blank line after each check. Keep
the ones that separate groups of related statements, but remove the
ones that separated members of such groups. In some cases swap a blank
line and a code line to put the code with things it relates to.

Change-Id: Ie33863080d407898b2b2f044599398980ab9793d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
f8d31aa7de tst_QSqlQuery coding style: clean up declarations
Split some long declarations of two variables in one line into two
separate declarations. Made more things const, made some consts
constexpr. Skip a variable entirely when it's only used once (and not
giving us some other benefit). Moved some declarations closer to their
variables' first uses.

Replace some Capitalised variable names with lower-case ones.

Change-Id: I3b8dac46530ba1c2e6100cb007b5487253304526
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
915469e4de Prefer QLatin1String::arg() over adding more than two strings
It saves the conversion to UTF-16 until the formatting. Split up long
lines, purge spaces just inside parentheses, and otherwise tidy
affected lines. Don't use backslash-newline for line continuation
within string literals; juxtaposition is cleaner.

Change-Id: I9c3d3e33f5ecbdb530538679147f7bc32afbeb05
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
afe23239cb Prefer u"..." and u"..."_qs over QStringLiteral() or QString("...")
It's terser and cleaner to read. Likewise for
QString::fromLatin1(). QCOMPARE() can take a QStringView, hence u"..."
as its expected string; other uses need u"..."_qs.

Change-Id: Iaf96569ff3ce69c890badfb6e40f702a78b100b3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
203f4b93cf Prefer QString::asprintf() over QString::arg when formatting numbers
Marc alleges it is more efficient.
Corrected part of a message to be more accurate in the process.
Save some casting by using suitable format specifiers.

Change-Id: Ic31a4e17b8910d35781a494ec860c7a08f08f33b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
e63b3b48ac Prefer QLatin1String::arg() over QString::arg() for ASCII literals
When the format is an ASCII string, there's no point widening it to
UTF-16 before the actual formatting step. Also, don't construct the
format string using string arithmetic, when passing another parameter
to arg() will do just as well. In the process, restructured
generic_data(), split long lines and conform spacing to Qt coding
style on affected lines. Simplified initialization of two string
fragments by using QL1S instead of QString, too.

Change-Id: Ib101dcf9296cc532291518bcef8e0a8de597b8a0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:29 +01:00
Andreas Buhr
4e77f5ce0a Set version for tst_qguiapplication and tst_qcoreapplication
In tst_qguiapplication and tst_qcoreapplication,
the application version should be set. On Android, this
is done using QT_ANDROID_VERSION_CODE.

Pick-to: 6.2 6.3
Change-Id: I6b473ad25092fb24df9400e0ab8fbb8ea4edbb6a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-17 15:51:29 +01:00
Pasi Petäjäjärvi
963d60ead4 CI: Blacklist updateFocusChainWhenChildDie for QNX
Tests are run for QNX in qemu similar to b2qt currently (using offscreen
plugin and software rendering). So the issue is same.

Pick-to: 6.2 6.3
Task-number: QTBUG-100930
Change-Id: Ie973c6c611ac48703fd7cce53925940b80858bc8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-17 16:08:37 +02:00
Liang Qi
760815599b tests: skip tst_QX11Info on Wayland
Pick-to: 6.3 6.2
Change-Id: I927ee28f61719ff1b67f73dc31dfcae9b73d8329
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-17 00:34:50 +01:00
Liang Qi
ae1197fc56 tests: XFAIL tst_QGuiApplication::genericPluginsAndWindowSystemEvents()
on Wayland

Task-number: QTBUG-100891
Pick-to: 6.3 6.2
Change-Id: Iadf12364ded4549988ad75a9487c7e96e963a956
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-17 00:34:50 +01:00
Liang Qi
c1b6886959 tests: XFAIL 4 tests in tst_QWindow on Wayland
Task-number: QTBUG-66818
Task-number: QTBUG-100887
Task-number: QTBUG-100888
Task-number: QTBUG-100889
Pick-to: 6.3 6.2
Change-Id: I05ba11e54c115380bbbb629fcba5cdd658dd5654
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-17 00:34:50 +01:00
Liang Qi
d55c049c7c tests: XFAIL tst_QScreen::grabWindow() on Wayland
Task-number: QTBUG-100792
Pick-to: 6.3 6.2
Change-Id: I1dc257abdc34c586c4c1eda96a43ea75395b1e4a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-17 00:34:50 +01:00
Liang Qi
ae9fefe3c8 tests: XFAIL tst_QInputDevice::multiSeatDevices() on Wayland
Task-number: QTBUG-100790
Pick-to: 6.3 6.2
Change-Id: Ieec4791e4322286fedeeabacc43b9cb84ea27962
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-17 00:34:50 +01:00
Andreas Buhr
eb628794c7 Repair tst_qtreeview on Android
Scroll tests relied on having a small window. On Android, the
window can not be smaller than the screen.
This patch changes the tests so that the windows have large
enough content so scrolling can happen.

Fixes: QTBUG-87408
Pick-to: 6.2 6.3
Change-Id: I26a444518fd934527089297c594673937f0ecf88
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-16 22:32:56 +01:00
Andreas Buhr
9beca76786 Repair tst_qabstractitemview in case of no cursor
tst_qabstractitemview requires a movable cursor.
This patch skips the test if there is no movable cursor.

Pick-to: 6.2 6.3
Fixes: QTBUG-87400
Change-Id: I4e917b2ad062ce068f23603410aa9209edb9828d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-16 21:09:59 +01:00
Andreas Buhr
e87233fbd8 Repair tst_qfileinfo on Android
Pick-to: 6.2 6.3
Change-Id: I79e0236b90b8a6ca2618d7a9ddac34b26bbd5b5f
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-16 21:09:59 +01:00
Pasi Petäjäjärvi
8aba951d98 Gui: test also depends for clipboard feature
Pick-to: 6.2 6.3 5.15
Change-Id: Id8684b6800bd5659991bc56f8b374ec3989ee590
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-16 21:02:44 +02:00
Axel Spoerl
43b25286ce Update QToolButton texts and add more stylesheets to test with
Adapt QToolButton texts to descriptive versions.
Add dummy stylesheet that will be used for all test functions, and a
specific style sheet to test rendering of QToolButton with a menu button.

Task-number: QTBUG-100401
Pick-to: 6.3 6.2
Change-Id: I5440407ddb3ea5b45124e77a6f0d1013362b4398
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-16 16:41:43 +00:00
Thiago Macieira
8de0493896 QMetaObjectBuilder: fix addProperty() recording of the property type
Issue introduced by commit 465701bb98.

[ChangeLog][QtCore][QMetaObjectBuilder] Fixed a bug that would cause
addProperty() to use the incorrect type for the property if the
property's name matched a valid type registered with QMetaType.

Pick-to: 6.2 6.3
Change-Id: Ic15405335d804bdea761fffd16d402f2c9611f30
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-16 01:47:09 -08:00
Thiago Macieira
01fe59a3b7 QJsonObject::removeAt: stop dividing and multiplying by 2
Change-Id: I89446ea06b5742efb194fffd16bb7d17182c6a2a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
dccd1e87f5 QJsonValueConcreteRef: optimize concrete()
Inline the content to avoid a round-trip through qjsonarray.cpp and
qjsonobject.cpp.

This change revealed an inadviseable unit test check that dereferences
the end() iterator to get its type. I haven't changed it, but have
marked with ###. I also fixed a likely copy&paste mistake in that test.

Change-Id: I89446ea06b5742efb194fffd16bb774f3bfbe5f5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
e99417106f QJsonObject::erase: erase unnecessary and wrong code
Commit 35adb74ddd ("Reimplement JSON
support on top of Cbor") accidentally forgot to multiply by 2 the index
stored in the QJsonObject::iterator. The same mistake was propagated
when QJsonObject::iterator was converted to QJsonValueRef. This had no
ill effects because the o->elements container would always contain more
elements, but it meant the check was ineffective and meant nothing.

So instead of doing nothing when the iterator does not point to this
container, simply assume it does. Bad things will happen if you try to
erase an iterator that points to another container, but that's true for
almost all container/iterator mechanisms.

Drive-by modernization of some of the surrounding lines.

Change-Id: I89446ea06b5742efb194fffd16bb7c322c2fc4f2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
3531f578d3 QCborArray: allow large but in-range keys
The 0x10000 limit should not apply if the key is a valid index in the
array.

Change-Id: I5e52dc5b093c43a3b678fffd16b6a2a5a69acd61
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
800f60657d QJsonObject: use QJsonValueConstRef
Change-Id: I5e52dc5b093c43a3b678fffd16b608f32f8eb4b4
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
04dc959d49 Introduce Q{Json,Cbor}ValueConstRef
I screwed up when I wrote QCborValueRef by not having the ConstRef
type. The code worked, but it wasn't const-correct, allowing you to
write:

  const QCborArray &arr = something();
  *arr.begin() = QCborArray();

This mistake was brought over to QJsonValue in Qt 6.0, so it has to be
fixed for QJsonValue too. The actual fixes are in the next couple of
commits.

This change is believed to be binary-compatible: the Q{Json,Cbor}ValueRef
classes continue to have the exact same size, except that they're now
empty and have a new base class. They weren't trivial before this commit
doesn't change that.

[ChangeLog][Potentially Source-Incompatible Changes] The iterator
classes for Qt's JSON and CBOR containers (array and map/object) had a
const correctness issue which allowed a const_iterator to mutate the
container being iterated on, even if that container was itself const. Qt
6.4 has a fix for this, but will cause compilation issues where
QCborValueRef and QJsonValueRef were used where the correctness could be
violated. To keep code compiling with both 6.3 and 6.4, either change to
non-const iteration or replace the QxxxValueRef with a const QxxxValue
reference. This change is binary-compatible.

Change-Id: I5e52dc5b093c43a3b678fffd16b6063333765ae0
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
9b8f064cd3 QCborValueRef: fix using operator[] to convert an empty array to map
The flag IsContainer was not set, causing the QCborContainerPrivate to
become confused.

This commit also expands and subsumes the existing test for QCborValue
(non-Ref).

Change-Id: I5e52dc5b093c43a3b678fffd16b6a17c6f4a0676
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
3c7b507d1c QCborValueRef: add a test to confirm that its methods reflect QCborValue
This has found several missing const qualifications, a missing
QCborMap::Iterator method, and a missing one in QCborValue too.

The methods "### TEMPORARY" in this commit are actually removed in two
commits.

Change-Id: I5e52dc5b093c43a3b678fffd16b6939f62954dc4
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:02 -08:00
Tatiana Borisova
773362fb68 Fix failures for tst_eventdispatcher on INTEGRITY
- New testcase tst_eventdispatcher added under commit d292f0143f.
  It shows that only glib implementation works correctly.

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I7b861a6207fcb319de362645fc8f00a8ab6cd4b9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-15 18:20:40 +00:00
Edward Welbourne
e5ba838045 tst_qsqlquery coding style: use braces correctly
Single-line bodies of single-line controls don't need braces.
If one block of an if/else chain needs braces, the rest get them too.
One long condition needed a split that forced its body to need braces.

Change-Id: Ic4116b1273e16a586fdec18e6d8228e48a9cb07c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-15 17:32:47 +01:00
Edward Welbourne
1013cf49c7 Prefer QString(count, character) over QString::fill()ing
It lets the string be const, if nothing else.

Change-Id: Iffc1cfe71c5f6030b3f7434f964f2f2c102bf9c0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-15 17:32:47 +01:00
Edward Welbourne
ed0657b5e1 Avoid repeated qTableName() calls by saving in local variables
This saves repetition of the call in the midst of query strings.
This incidentally makes it possible to give informative names.

In the process, build those query strings using QLatin1String::arg(),
instead of implicitly converting ASCII strings to QString in order to
then do arithmetic with them, at least when the arithmetic involves
more than one addition. In one instance, where two branches did the
same thing with different format strings, limit the branching to
selecting which string to use, then do the common thing once.

Change-Id: I60fd7457a727bcc3872d3052d8fd638ebaf36ac2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-15 17:32:47 +01:00
Edward Welbourne
7bac62f8cd Use lists and arrays more gracefully in tst_qsqlquery
Use initializer lists rather than << entries.
Use arrays where we don't need the lists at all.
Make them const when they can be.
Replace foreach with ranged-for.
Use auto rather than naming iterator types and save end() at the start
of the iteration to save re-requesting it each time round the loop.

Reverse arguments to a QCOMPARE() as actual should come first and
expected after, not the other way round. Change some casts from
C-style to type-as-function-style, use QString literals rather than
C-string literals that would need conversion at compile time and
QLatin1String::arg in preference to arithmetic where the same format
is duplicated.

In the process, reworked one test to put its two iterations, one over
good query strings, one over bad ones, into separate blocks using
separate const arrays, instead of reusing a list with an uninformative
name.

Change-Id: I4a272be3eb58e9dca136238277b92379d6ca076d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-15 17:32:47 +01:00
Edward Welbourne
b55f10b2a0 Convert a table iteration to use ranged-for
The loop used an int counter that was initialized from a size_t,
provoking a warning from MSVC. Since the indexing is irrelevant in any
case, use a ranged-for loop. Since the loop was formerly in decreasing
index order, reverse the table being iterated so that entries remain
in their prior order.

Change-Id: I79b93c5a3f39a502b0cae83215b8e3665d0e17f5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-15 15:44:51 +01:00
Marc Mutz
37a25fce94 QDesktopServices: deprecate destroying URL handlers w/o explicit unsetUrlHandler()
[ChangeLog][QtGui][QDesktopServices] URL handlers that have been passed
to setUrlHandler() must now be removed by calling unsetUrlHandler()
before they are destroyed. Relying on the handler's destructor to
implicitly unset it is now deprecated, because it may already be in use
by concurrent openUrl() calls. Support for implicit unsetting will be
removed in 6.6 and, until then, a qWarning() is raised if it is
exercised.

Fixes: QTBUG-100775
Fixes: QTBUG-100779
Pick-to: 6.3 6.2 5.15
Change-Id: I0c4f91b78f847b135fdeb38766babc892bdc1379
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 12:20:16 +00:00
Andreas Buhr
21ce257b6c Repair tst_qcoreapplication to not segfault on Android
tst_qcoreapplication.cpp is used both in tst_qcoreapplication and
tst_qguiapplication. To distinguish these two compilations,
the define QT_GUI_LIB was used. This led to an error on Android,
where Qt::Gui is always linked, because the Qt Android Platform
Plugin needs it.
This patch introduces the preprocessor define QT_QGUIAPPLICATIONTEST
which is to be used only in the compilation of tst_qguiapplication.
This is then used instead of QT_GUI_LIB.

Change-Id: Ifa5bfacb197d68365288c1da85573106515fc6c2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-15 09:10:59 +01:00
Yin Jie
60a67dc41e Position QCompleter popup based on the widget's screen geometry
If adding a QLineEdit to a QGraphicsScene as a QGraphicsProxyWidget, the popup
completion of that QLineEdit is drawn in the wrong location. When the completer
getting the rect of screen, it gets the rect of the QGraphicsScene where
QLineEdit is located rather than the rect of the screen, resulting in an error
in the following calculation.

Note that as long as the completer popup is a toplevel widget not parented
to the target widget, it will not be automatically embedded into the graphics
view via QGraphicsProxyWidget. So with multiple views for a scene, or in views
that use transformations, the geometry will still be off.

Pick-to: 6.3
Task-number: QTBUG-20531
Change-Id: If5d8a707ca35a9e4709117b077978145c6143e46
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-15 01:28:30 +00:00
Andreas Buhr
936771d901 Activate tst_QFutureWatcher for Android
tst_QFutureWatcher was deactivated for Android. This patch activates it.

Fixes: QTBUG-88136
Change-Id: Iead82e22d73eb15c9ecd2756eb33925910bbffc0
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 00:42:29 +01:00
Tatiana Borisova
23fd249b85 Exclude denormal test cases if system doesn't support it
- current INTEGRITY development pack don't support denormals for float and double.
  All values are rounded to 0.

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: Iaaacdc4210c7ac2ec3ec337c61164a1ade0efb01
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 00:48:23 +02:00
Andreas Buhr
d456102962 Make Droid Sans Mono available as fixed font for all Android styles
Fixes: QTBUG-87405
Change-Id: I54ebc06c82c32acd0383ea5fedf78acce4e11977
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-14 16:22:28 +01:00
Marc Mutz
40e2bf3495 QFlatMap: temporarily disable some code
... which implements or assumes something about the
broken^Wnon-STL-compliant insertion behavior.

Once this has integrated into all module dependencies, we can
re-implement these APIs using STL-compatible semantics.

Task-number: QTBUG-100092
Change-Id: I54f4f5ce7addd9543866d2c399f48aff50983b88
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-14 13:20:03 +01:00
Kai Köhne
8275611766 Core: Remove 'properties' feature
Even QtCore alone cannot be built without the properties feature since
Qt 5.5. While fixing this is easy, other modules like dbus,
networking are also using QObject::property() and friends liberally.

All in all I doubt that anybody will miss the feature (otherwise it
would have been fixed in the last decade).

Change-Id: Iaf3cc20bda54ee2ff3b809fac8fa82b94ecc88c0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-14 12:50:59 +01:00
Mårten Nordheim
98de89cc15 tst_QSystemSemaphore: give proper path to test-helper
Amends 29fceed2ff

Pick-to: 5.15 6.2 6.3
Change-Id: Ie386d3af68e4dff84ae893cd24cb96caf2d8e08e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-12 00:01:08 +01:00
Allan Sandfeld Jensen
c0af004d74 Fix build with C++20 on macOS
The macOS standard library doesn't have std::contiguous_iterator yet, and
it doesn't seem like libc++ has it either.
Checking __cpp_lib_concepts for the C++20 official version appears to work.

Pick-to: 6.3 6.2
Change-Id: I8c31cd64de24c03b3a3f37cb393bb2f9b55a834d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-11 22:56:35 +01:00
Alexey Edelev
815bc61626 Cleanup tests that add test data to resources explicitly
Remove Integrity and Android specific code that explicitly adds
test data to the resource files. qt_internal_add_test functions
implicitly adds test data to resources for Android and Integrity
platforms by default.

Change-Id: Ia1d58755b47442e1953462e38606f70fec262368
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-11 21:54:44 +01:00
Alexey Edelev
fdf5d11ff6 CMake: Add BUILTIN_TESTDATA option to qt_internal_add_test
Multiple tests use qt_internal_add_resource that copies the
functionality that is already implemented inside the
qt_internal_add_test function. Simplify these test by replacing
the qt_internal_add_resource call with the new BUILTIN_TESTDATA
option.

Change-Id: I18475b817d6f87264f0de53817d6c26c5ccab4e2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-11 21:54:44 +01:00
Christian Ehrlicher
15f7ef26b8 QMdiSubwindow: respect minimum size of subwidgets when shown maximized
Size a QMdiSubWindow is no real toplevel widget, QLayout::activate() did
not properly set the minimum size based on it's children. Fix this by
treating a QMdiSubWindow as a toplevel widget during the calculation.

Fixes: QTBUG-100494
Change-Id: Ia2e6c519c7214c36383facd244711bd932231d40
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-11 07:03:24 +01:00
Qiang Li
d54bb53247 QPlainTextEdit: fix the visibility of placeholderText
If one calls setPlainText("") before setting a placeholder text,
the placeholder visibility is not updated, and the placeholder is not
visible. Fix it by updating placeholderVisible properly.

Fixes: QTBUG-96212
Pick-to: 5.15 6.2 6.3
Change-Id: I1bd3f0cb4c59973a847bcf3787e35d7c17b6d673
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-11 02:01:03 +01:00
Edward Welbourne
abf4175436 Use function-style casts in preference to C-style ones
In one case, cast an int to qsizetype rather than the other way round,
in order to compare them.

Change-Id: Id8dffe61f9565040f1a5ee24867956397f814a55
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2022-02-10 19:20:59 +01:00
Edward Welbourne
3acaf3160d Convert some if/else-if/else chains into switch()es
Some of the else if lines exceeded 100 characters, so should have been
split; and some lines already were split. So each whole chain should
have had braces on its bodies. Instead make it a switch, as this makes
it more evident what's going on in any case.  Furthermore, as each
branch did the same thing with dbType-specific strings, change to just
setting QLatin1String variables, so that the rest of the code needn't
be duplicated in each branch; it can simply be done once after the
switch, using the string's .arg() to embed fragments. In the process
break up the SQL query strings more gracefully, purge spaces just
inside C++ parentheses.

Change-Id: Ie26166e098ad74720bb6d7c4d9fe47718c33a13c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-10 19:20:59 +01:00
Edward Welbourne
35ec6283dc Convert some QVERIFY2() with useless messages to QVERIFY()
Telling us the condition tested should have been true is what
QVERIFY() does anyway, so don't go to the whole trouble of saying the
same thing - and wrapping it in in a QString() merely in order to then
qPrintable() it back out again, pointlessly converting a C-string to
unicode and back again.

At the same time, skip one other qPrintable(QString("...")) without
.arg() formatting; and change the check it's the message for to use
QL1S::arg() instead of QString::arg().

Change-Id: Ie71a79da8017916d301a38b69fc422e55a5a3649
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-10 19:20:59 +01:00
Edward Welbourne
3253037329 Suppress, and thus verify we do get, two warnings in tst_QSqlQuery
Expected warnings are clutter for anyone reding the output, so
suppress them when they're correct behavior.

Change-Id: Idf47ba4fab8069237067d9b20afef3041e0c2f8c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-10 19:20:59 +01:00
Edward Welbourne
9030ffdffb Use qScopeGuard() to take care of post-test tidy-up
Doing the tidy-up after the last check has the problem that it gets
skipped if any check fails, as the premature return skips the tidy-up.
In the process, added the missing tidy-up to prematureExec().

Repackage the code for one tidy-up as a named lambda so that the
duplicate can share it with the scope guard. Made some existing scope
guards const, while I was about it, so that the one that isn't -
because it gets dismiss()ed - stand out.

Change-Id: I96d6834d5d7675f15018169a7093b0211db6f8a9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-10 19:20:59 +01:00
Andreas Buhr
9e082faf30 Activate tst_QTimeLine on Android
Fixes: QTBUG-88137
Change-Id: I2b66eefd7733198664eaeecf9507daabb3a04e81
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-10 15:14:57 +01:00
Janne Juntunen
9a7e55dcbe tst_qrhi: use OpenGL instead of raster pipeline on webOS
Raster pipeline is not supported on webOS OSE: trying to use it causes
an exit(1).

Fixes: QTBUG-100654
Pick-to: 6.3
Change-Id: I00325fc1330a2d0d4abfdee054343ecfac767309
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-02-10 12:03:36 +02:00
Fabian Kosmale
ae7799a924 qtextstream.h: streamline includes
[ChangeLog][Potentially Source-Incompatible Changes] The qtextstream
header no longer includes <QString>, <QStringEncoder> and
<QStringDecoder>. Code which relied on the implicit inclusion of those
classes might now need to include the headers explicitly.

Task-number: QTBUG-97601
Change-Id: Ifb8c8452026195a772c0588dbbbc53fb51cac548
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-10 04:34:13 +01:00
Alexey Edelev
2201934efa Use 'copy' but not 'copy_if_different' on Windows platforms
Use custom script to copy big Android artifacts on Windows platforms.
The script uses 'copy' but not 'copy_if_different' when source file
size is bigger than 2GB. 'cmake -E copy_if_different' only compares
first 2GB of files because of cmake issue, so this step only
workaround the problem.

Pick-to: 6.2 6.3
Task-number: QTBUG-99491
Change-Id: Id076734700e334dfc3330da412462c2b53829b33
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-10 02:31:05 +01:00
Mårten Nordheim
50c8ec9fa4 QAbstractSocket: Don't pretend pause and resume is a stack
It only stores one layer of state, and pausing twice in a row will just
overwrite the previous state. This doesn't happen often but can happen,
especially on Windows if a certificate needs to be looked up in the system
certificate stores (socket gets paused) and then a recoverable error
occurs in QNAM (socket gets paused again).

Fixes: QTBUG-100362
Fixes: QTBUG-63196
Fixes: QTBUG-98476
Pick-to: 6.3 6.2 5.15
Change-Id: Ie524c48e11b6fa8010b78cc1bf3931efe2ce3351
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-09 22:26:20 +01:00
Edward Welbourne
69e445721c Get rid of empty optional methods in tst_QSqlQuery
No need for a virtual do-nothing destructor in a class that isn't
inherited from. Defining an empty init merely makes QTest go to the
trouble of calling it, which it could just as well skip.

Change-Id: Ifd44c473c05fdeaaa7923d2ccdd0a13c8921b6bd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2022-02-09 21:46:24 +01:00
Edward Welbourne
0828014b44 Fix an inaccurate comment and update a test case
The offset fields for tst_QTimeZone::specificTransition() had a
comment claiming they are in minutes; they are in fact in seconds, so
fix that. At the same time, Moscow hasn't had a time-zone change since
2017, so the end-date for one of the test intervals can be nudged a
little closer to the present without harm.

Change-Id: I66822cb758f7e00d6added801466a6745be3e31a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-09 20:46:24 +00:00
Thiago Macieira
29fceed2ff QProcess/Unix: ensure we don't accidentally execute something from CWD
Unless "." (or the empty string) is in $PATH, we're not supposed to find
executables in the current directory. This is how the Unix shells behave
and we match their behavior. It's also the behavior Qt had prior to 5.9
(commit 28666d167a). On Windows, searching
the current directory is the norm, so we keep that behavior.

This commit does not add an explicit check for an empty return from
QStandardPaths::findExecutable(). Instead, we allow that empty string to
go all the way to execve(2), which will fail with ENOENT. We could catch
it early, before fork(2), but why add code for the error case?

See https://kde.org/info/security/advisory-20220131-1.txt

[ChangeLog][Important Behavior Changes] When passed a simple program
name with no slashes, QProcess on Unix systems will now only search the
current directory if "." is one of the entries in the PATH environment
variable. This bug fix restores the behavior QProcess had before Qt 5.9.
If launching an executable in the directory set by setWorkingDirectory()
or inherited from the parent is intended, pass a program name starting
with "./". For more information and best practices about finding an
executable, see QProcess' documentation.

Pick-to: 5.15 6.2 6.3
Change-Id: I54f205f6b7314351b078fffd16cf7013c97ee9fb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-09 11:26:32 -08:00
Marc Mutz
ec03db7bb3 Fix C++20 ambiguous relational operators between QJsonValue{,Ref}
In C++20, any given relational operator is also considered in its
reversed form, so e.g.

   given op==(X, Y)
   and X x, Y y, then y == x will compile, by using the reversed op(X, Y)

This, unfortunately, makes some existing asymmetric operator overload
sets ambiguous, and instead of applying tie-breaker rules, at least
Clang is warning about these.

For us, this means we need to make our overload set non-ambiguous. The
QJsonValue{,Ref} classes failed this, because they only provide the
following member-operators:

- QJsonValue::op==(const QJsonValue&) const
- QJsonValueRef::op==(const QJsonValue &) const

For member functions, there are no implicit conversions on the LHS. So
in C++17, we have a nice dichotomous overload set:

- LHS is QJsonValue -> use QJsonValue::op==(QJsonValue)
- LHS is QJsonValueRef -> use QJsonValueRef::op==(QJsonValue)

In both of these, it the RHS is a QJsonValueRef, it's implicitly
converted to QJsonValue for the call.

Enter C++20, and the reversed signatures are suddenly available, too,
which is a problem for QJsonValueRef <> QJsonValueRef, which could be
resolved, as in C++17, using

  lhs.QJVR::op==(QJV(rhs))

or it could now be

  rhs.QJVR::op==(QJV(lhs)); // reversed

Says Clang 10:

  tst_qtjson.cpp:990:5: warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'QJsonValueRef' and 'QJsonValueRef') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator]
    CHECK(r0, a0, r1);
    ^     ~~      ~~
  qjsonvalue.h:189:17: note: ambiguity is between a regular call to this operator and a call with the argument order reversed
    inline bool operator==(const QJsonValue &other) const { return toValue() == other; }
                ^

A similar argument makes op!= ambiguous.

Says Clang 10:

  tst_qtjson.cpp:988:5: error: use of overloaded operator '!=' is ambiguous (with operand types 'QJsonValueRef' and 'QJsonValueRef')
    CHECK(r0, r0, r1);
    ^     ~~  ~~
  qjsonvalue.h:190:17: note: candidate function
    inline bool operator!=(const QJsonValue &other) const { return toValue() != other; }
                ^
  qjsonvalue.h:189:17: note: candidate function
    inline bool operator==(const QJsonValue &other) const { return toValue() == other; }
                ^
  qjsonvalue.h:189:17: note: candidate function (with reversed parameter order)

To fix, provide the missing operators as free inline functions (so Qt
6.2 and 5.15 don't get new symbols added) so there's always exactly
one best match.

This is a fix for 6.2 and 5.15. At the time of writing, 6.3 isn't
released, yet, so there, we could QT_REMOVED_SINCE the pre-existing
member operators in favor of hidden friends (as per QTBUG-87973).

Use C++17'isms to prevent an automatic merge to 5.15, which requires

   contains(QT_CONFIG,c++2a):CONFIG += c++2a

added to tst_qtjson.pro.

[ChangeLog][QtCore][QJsonValue] Fixed relational operators to not
cause warnings/ambiguities when compiling in C++20.

Pick-to: 6.3 6.2 5.15
Change-Id: Ic70f3cad9987c87f7346d426c29cc2079d85ad13
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-09 20:26:31 +01:00
Volker Hilsheimer
851143eff1 macOS: Prevent recursion when modifying the edit menu
Amends d42cfeb84f, which would result in
infinite recursion when the Edit menu was populated and added to the
menubar after the menubar has been shown.

Add a macOS-only test case that reproduces the crash without the fix.

Fixes: QTBUG-100441
Pick-to: 6.3
Change-Id: I018a7aa7f01558a3b9732b4d6d96a911dc7fbd19
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-09 18:19:57 +01:00
Axel Spoerl
15caa47e4b Add lineedit and QAbstractItemView widgets in tst_baseline_widgets
Add baseline tests for QListView, QTableView, QTreeView
Add const to reflect number of available standard icons
Add baseline test for QLineEdit

Task-number: QTBUG-99677
Change-Id: I1abaae7f90c9b05c3b3467dc85c5652bc9d0f53b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-09 18:19:57 +01:00
Allan Sandfeld Jensen
23181340ca tst_QContainerApiSymmetry: fix incorrect P1115 detection
The value of __cplusplus has nothing to do with whether the library
implements wg21.link/P1115 (libstdc++ even before C++20) or not
(libc++, even in C++20).

Use the idiomatic check (#if defined(foo) && foo >= x) instead,
fixing the Android build.

Pick-to: 6.3 6.2
Change-Id: I11bcefe455a1f13865c15d4beecbd3fe32115328
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-09 16:22:32 +00:00
Alexey Edelev
ba48e1b809 Add missing implicit dependencies to the tool tests
moc, qmake, rcc, and uic tests execute corresponding tools inside
the test executables. This adds dependencies explicitly, to execute
tests using _check targets, without the need to manually build
dependencies.

Pick-to: 6.3 6.2
Fixes: QTBUG-98576
Change-Id: I8b989276e21199b867591f7b0f6af9204695ac13
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-09 15:33:46 +01:00
Alexey Edelev
1ff8877ea7 Exclude tst_qmake if the build of qmake tool is disabled
Pick-to: 6.2 6.3
Change-Id: I5aadf5250c19d8a8b26c4a890350ff3bf79e31c7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-09 15:33:46 +01:00
Mårten Nordheim
9ec94f31b0 QNetworkInformation: Rename parameter-less load() to loadDefaultBackend
To clarify its purpose and separate it from the others

Pick-to: 6.3
Change-Id: Id9efcf474ac0cd8777393380bb85c83780454005
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-09 15:17:54 +01:00
Pasi Petäjäjärvi
39310a6817 Handle situation when device running test does not have enough RAM
CI tests for QNX are run in QEMU which does not have enough RAM
to run this test successfully.

Pick-to: 6.2 6.3
Change-Id: Idab3e8b6a1e0ae3eddf5aedb82e6784a74ae9a3a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-09 14:17:53 +00:00
Pasi Petäjäjärvi
11fcfd75a0 QNX: Remove expected fail
Pick-to: 6.2 6.3
Change-Id: I66b05685dd1c5c5e083db1ecd9265e1e3c859d45
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Rafael Roquetto <rafael.roquetto@qt.io>
2022-02-09 14:17:53 +00:00
Laszlo Agocs
178c1a6243 rhi: Add the long-pending probe() helper, with backing for Metal
There is a TODO for this in Qt Quick from the 6.0 times. To decide
upfront if Metal can be expected to function, or if a fallback to
OpenGL needs to be triggered (especially important with macOS virtual
machines, where, unlike any real macOS system, Metal may not be
present at all), the scenegraph calls create() and then drops the
result. The idea to make this less wasteful was back then to add a
dedicated probing function which can, possibly, perform the checks in
a more lightweight manner than full initialization. Implement this
now, focusing on Metal.

Brought to attention by QTBUG-100441: printing warnings about not
having an MTLDevice is confusing in a Metal-less macOS VM, because it
is not an actual error, only part of the probing at scenegraph
initialization. We can now avoid printing confusing warnings there.

Change-Id: Ie52c36af9224bedc3f5e4c23edb486d961c9f216
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-02-09 14:02:57 +01:00
Volker Hilsheimer
0a9f3ce3c8 Make time sensitive QScrollBar test fault tolerant
The auto-repeat timer of QScrollBar kicks in after 50ms, so if the test
takes too long and the timer fires during the qWait call or during event
delivery, then we might get multiple valueChanged emissions.

Detect that scenario and allow the test to XFAIL if things take
a significant time (more than 40ms vs the expected 1ms).

Pick-to: 6.3 6.2
Change-Id: Ie90aadc62372397db695fd2b34fe1f5252ce8d37
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-02-09 14:02:57 +01:00
Axel Spoerl
005f3ad625 Update widgets inheriting QAbstractSpinbox in tst_baseline_widgets
Create QAbstractSpinBox test
Update test for QSpinBox
Add tests for QDoubleSpinBox, QDateEdit, QTimeEdit
Add test for QDateTimeEdit incl. calendar popup

Task-number: QTBUG-99677
Change-Id: Ia74686f47a1520ab4c7e878b19fc774e00db88dd
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-09 08:01:46 +01:00
Fabian Kosmale
8b87c6f198 Blacklist tst_qscreen::grabWindow on Windows
Task-number: QTBUG-100412
Pick-to: 6.3
Change-Id: I8497cf31d690bc5fc22d808cba95254b7fedcc49
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-05 16:28:47 +00:00
Shawn Rutledge
6b2c9b81af Deprecate QContextMenuEvent and QMouseEvent ctors without globalPos
As with QHoverEvent, it's better to require globalPos rather than
"initialized to QCursor::pos(), which may not be appropriate" as the
docs have pointed out for many years now. This removes the remaining
calls to QCursor::pos() in event constructors.

Task-number: QTBUG-52430
Task-number: QTBUG-69433
Task-number: QTBUG-100324
Change-Id: I076dae56f37abaad7085cc95dddee453a80a45f3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-05 17:18:35 +01:00
Janne Juntunen
c984a9bf07 tst_qresourceengine: use QFINDTESTDATA() to find correct path
Use alternative method for finding searchPath since
QT_TESTCASE_SOURCEDIR did not point to a correct location on webOS
QEMU test environment.

Fixes: QTBUG-99954
Pick-to: 6.3
Change-Id: I05f95b4aa02027976036d0842ca564a602e01d0e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-04 11:02:07 +02:00
Thiago Macieira
de6ced6692 QCborValue: fix incorrect to{Array,Map} when the value is empty
When QCborValue referred to an empty array or map, toArray() and toMap()
would respectively return the default value instead of the empty object,
as expected.

Pick-to: 6.2 6.3
Change-Id: I5e52dc5b093c43a3b678fffd16b60456d0037ad7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-03 14:45:46 -08:00
Janne Juntunen
5170574532 tst_qlogging: use correct qlogging_helper path on webOS
Switched to use runtime path instead of compile time path for the
helper executable. Some tests cases were failing on webOS because of
wrong path.

Fixes: QTBUG-99846
Pick-to: 6.3
Change-Id: I566bc04bdb96ac6e7dd0a875eadb50685aef8282
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-03 14:24:21 +02:00
Edward Welbourne
06942138d6 Move prematureExec() to the end of tst_qsqlquery's testing
It leaves the system in a state that breaks at least one later test,
so put it last. (This was first seen when picking back to 6.2, but I
am now able to reproduce it on dev.)

Amends commit 78eac57f3d

Pick-to: 6.3
Change-Id: I918cf43cdfc27357329a175518d6f9755747bae5
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-03 12:28:42 +01:00
Shawn Rutledge
0a64a044b6 Add a QHoverEvent ctor taking global mouse position; deprecate the other
The QSinglePointEvent ctor assumes that the given globalPos is correct,
so it was wrong that the QHoverEvent ctor passed along a local position
as global. It's better to require globalPos as an argument; and in fact
it seems that everywhere we construct a QHoverEvent, global position is
available, or possible to get by transformation (which is better than
resorting to QCursor::pos()).

Also, don't convert to QPoint: pointer events have qreal resolution and
there's no reason to truncate them.

Fixes: QTBUG-100324
Change-Id: I919455da36265988d3d149eb97563c9ed0d2c660
Pick-to: 6.3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-03 10:18:43 +01:00
Volker Hilsheimer
5c6f8b2c67 Always wait in the QScreen::grabWindow test
On X11 we already had to wait as window managers might scroll windows
in. On macOS we also waited - albeit a bit shorter - also because
screens scroll in slowly.

We didn't wait on Windows, and on Windows the test is quite flaky.
Attempting to make it run stably by waiting for long enough so that all
paint events are flushed to the screen.

As a drive-by, break some overly long lines.

Task-number: QTBUG-100412
Pick-to: 6.3
Change-Id: I49b1e447aced2fe1af3c5d30b514f8df3cc1813c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-03 04:57:26 +01:00
Giuseppe D'Angelo
e7d627339c QPluginLoader: report the right load hints
A default-constructed QPluginLoader erroneously reports that the
load hints are empty. However, setting a filename would then
automatically set the PreventUnload hint, surprising the user.

Return the correct flags instead.

Amends 494376f980

Change-Id: I7a95964cb680afd3adf2f71ed73d2f93023238f2
Fixes: QTBUG-100416
Pick-to: 5.15 6.2 6.3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-03 03:26:40 +01:00
Axel Spoerl
cb4b29cc2a Extend baseline test for QTabWidget
tabsClosable and documentMode added, merge conflict fixed

Task-number: QTBUG-99773
Pick-to: 6.3
Change-Id: I8eb51b9f434bc97e6e7e55377801c6ee8aec52b0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-03 03:23:53 +01:00
Giuseppe D'Angelo
a605b9297d QPlainTestLogger: do not print "failure location" if there's no failure
When running a test under increased verbosity levels, QTestLib would
print "failure location" for every QTest function (QVERIFY, QCOMPARE,
...), even if there's no failure at all.

Keep the code centralized, but split the formatting of failures and
non-failures (other messages).

Task-number: QTBUG-96844
Change-Id: I3c508653176b68579dc0eb0cffcc153a52da2e2c
Pick-to: 5.15 6.2 6.3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-02 23:08:37 +01:00
Edward Welbourne
830fd1908b Add some more QDate::{start,end}OfDay() tests
While investigating an assertion failure I noticed that the existing
tests didn't even exercise these methods for local time or zone time.
Of course, we can't robustly test these time-specs, due to vagueries
of offset details and zone availability, but we can at least verify
that they return date-times on the specified date. Add a test-case for
the start of 1900, on which the assertions were first seen; it is the
earliest moment representable with tm_year >= 0, after all.

One of these tests fails on 6.2 but the fix for that (as opposed to
the the assertion) requires 6.3's improvements to the handling of
time_t's fuller range - too risky a change to pick back to 6.2.

Pick-to: 6.3
Task-number: QTBUG-99747
Change-Id: I98f5d7850a701972b2d8ea2ce203a2b3e7071354
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-02 19:36:43 +01:00
Alexey Edelev
fd3341a74e Add qt_internal_undefine_global_definition function
qt_internal_undefine_global_definition disables an internal global
definition that is defined by the qt_internal_add_global_definition
function for a specific target.

Remove the ability to set the custom "undefine" flag for the
definitions since it's hard to control it using the introduced
function.

Pick-to: 6.2 6.3
Task-number: QTBUG-100334
Change-Id: Ic1637d97aa51bbdd06c5b191c57a941aa208d4dc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-02 16:45:37 +01:00
Allan Sandfeld Jensen
8bd2e6d0d4 Fix clang-cl build of tst_qobject
Not MSVC, but pretends to be.

Pick-to: 6.3 6.2
Change-Id: I5c201dd917e79a22d6ef15715bf1d3a7010d123e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-02 15:09:22 +01:00
Andreas Buhr
63937ffe6e Fix flags in QFileSystemModel
In 63eea5e5c69434871eaef9d9dc7184d7e54d7276, the
Qt::ItemNeverHasChildren flag was introduced. QFileSystemModel
was modified to use this flag for items which are not directories,
but only if the QFileSystemModel is not read-only and
the directory is writable.
This patch modifies QFileSystemModel to use the ItemNeverHasChildren
flags also if the model is read-only and if the item
is read-only.

Amends 63eea5e5c69434871eaef9d9dc7184d7e54d7276

Change-Id: Ie7f7d58ecf7baade93f9f03d120da84d3c005d42
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2022-02-02 10:28:13 +01:00
Volker Hilsheimer
55433f90af Stylesheet: Fix tab layout when tab has a font and icons
Amends e3b2b12a91, which made the
style sheet calculate the font-dependent text size, but didn't
add the space needed for the close button or a tab icon.

QTabBar's layout code already adds the space needed for icons
and margins to the size; so instead of overwriting that size,
subtract the size needed by the normal font, and then add the
size needed for the font form the style rule, considering both
vertical and horizontal tab bars.

Fix the test case to style only one tab rather than the entire
tab bar, otherwise the font is applied to the entire tab bar,
and not just to a specific tab, which is the style sheet style
code in question.

Pick-to: 6.2 6.3
Task-number: QTBUG-6905
Change-Id: Ieed0ba146a32e81229419adecaf41f467cfd5959
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-02-02 07:10:12 +01:00
Fabian Kosmale
987b896b4e Blacklist putWithServerClosingConnectionImmediately on Windows
Task-number: QTBUG-100362
Change-Id: Ib09aec5ea03867163d476a2c92562bc949fc1b1a
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-02 05:25:06 +01:00
Marc Mutz
9f31f579ec Sequential erase/_if: don't apply predicate twice to element
The code was trying to avoid a detach in the case no element needed to
be removed, by first running find_if() on const_iterators, and then,
after converting its result to (mutable) iterators, start the
remove_if() algorithm where find_if() left off.

But this applies the predicate to the element found by find_if() (if
any) _twice_: first just before we exit the first find_if() and then
just as we enter remove_if(), which will start by running find_if()
again, with the result of the initial find_if as 'first'.

Apart from being needlessly inefficient, this violates the
specification of Uniform Erasure, which defines sequential erase_if()
as being equivalent to remove_if() + container erase(), with the
former being specified to apply the predicate exactly once per
element.

Fix by writing the remove_if() part by hand.

Instead of doing the dance with the loop invariant documentation
twice, simply implement erase() via erase_if() (complicated a bit by
the weird passing of predicates by lvalue reference instead of by
value, as would be idiomatic). This exposes users to:

[ChangeLog][QtCore][Potentially Source-Incompatible Changes] A fix in
the implementation of the erase-like algorithms of sequential Qt
container may re-enable signed/unsigned comparison warnings previously
suppressed by having occurred in std library code. To fix, cast the
value to look for such that it has the same signedness as the
container's elements.

... but the issue would be the same had we inlined std::remove()
instead of passing a lambda to sequential_erase_if(), so it's nothing
we can, nor should, work around.

[ChangeLog][QtCore][Containers] Fixed a bug in the implementation of
most sequential Qt container's erase-like algorithms (member
removeAll()/removeIf() and free erase()/erase_if()) where the equality
operator or the predicate, respectively, was applied to the first
matching element twice. Each element is now tested exactly once.

Pick-to: 6.3 6.2
Change-Id: Ib6d24b01b40866c125406f1cd6042d4cd083ea0d
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-02-02 04:16:59 +00:00
Robert Löhning
27b560373d QImageReader: Check for existing handler in initHandler
Some calling code did this beforehand, other didn't. Now, the function
itself checks for an existing handler before doing anything else.

Change-Id: I8fc43fb8788c9dfe825b15ffa2fa69ee43915cd6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-02-02 04:12:17 +01:00
Axel Spoerl
2628e897fe Add tab close button in QTabBar baseline test
Fixes: QTBUG-99772
Pick-to: 6.3
Change-Id: I01e0fc78880baae12f46005e4a88db41bea89d65
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-02-01 12:47:58 +01:00
Ben Fletcher
9ef702a37b rhi: Add the basic infrastructure for geometry shader support
.. but this will only be supported on Vulkan, OpenGL 3.2+, and Open GL
ES 3.2+ for the time being.

The situation is:

- Vulkan is working.  qsb accepts .geom files already, and QShader has
  existing geometry shader support.

- OpenGL 3.2 and OpenGL ES 3.2 are working.

- D3D11 is not working.  D3D11 supports geometry shaders, but SPIRV-
  Cross does not support translating geometry shaders to HLSL.

- Metal is not working.  Metal does not directly support geometry
  shaders.

Change-Id: Ieb7c44c58b8be5f2e2197bf5133cf6847e6c132d
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-31 08:53:37 -08:00
Ben Fletcher
1c3ae79ad3 rhi: Add support for polygon fill mode
Support for Polygon Mode (Triangle Fill Mode in Metal, Fill Mode in D3D)
in the RHI graphics pipeline.

Options are Fill and Line

Status:
    OpenGL - ok
    Vulkan - ok
    Metal - ok
    D3D11 - ok
    OpenGL ES - does not support glPolygonMode.

Change-Id: I20b7ef416624700c3dc8d1cbe6474f4ca3889db8
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-31 08:52:05 -08:00
Alexey Edelev
1d28fd7a9c Restore missing Qt definitions
Restore the 'QT_NO_JAVA_STYLE_ITERATORS' and
'QT_NO_NARROWING_CONVERSIONS_IN_CONNECT' definitions for Qt
targets.

Add the function that adds global definitions for Qt targets according
to the provided scope and the target property-based switch to disable
the definition for a specific target.

Pick-to: 6.2 6.3
Task-number: QTBUG-100295
Change-Id: I28697e81f9aabc45c48d79aae1e5caea141e04e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-31 17:40:43 +01:00
Sona Kurazyan
f2f5c7d2b7 QtFuture::connect: fix for signals with a single std::tuple argument
If the signal passed to QtFuture::connect() takes multiple arguments,
we need to wrap the arguments in a std::tuple when reporting the result.
To detect this case we were checking if the result type of a QFuture
returned by QtFuture::connect() is a std::tuple, but this was not
correct: the result type could be a std::tuple also if the passed
signal takes a single std::tuple argument. Instead, check if the signal
takes more than one argument.

As a drive-by modified the tst_QFuture::signalConnect to use const
values for tuples used in multiple test-cases, to avoid repetition.

Fixes: QTBUG-100071
Pick-to: 6.2 6.3
Change-Id: I1ce39cf87028f36ef94a9d1a4423b0c51473afd4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-31 17:40:43 +01:00
Ivan Solovev
26fa539ad2 Blacklist tst_QFileSystemWatcher::signalsEmittedAfterFileMoved on all Windows versions
The test was already blacklisted for Windows 10 and Windows 7. Now it
is flaky on Windows 11 as well.
Blacklist it for all windows platforms.

Task-number: QTBUG-98478
Pick-to: 6.2 6.3 5.15
Change-Id: I870fb6ce80cfe244a76d08bf40677fdb6becab97
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
2022-01-31 17:39:33 +01:00
Jani Heikkinen
43dfe13e2c Bump version from 6.2.0 to 6.4.0 in tests as well
Change-Id: I6fbce239f1ce45c921cf3bf1c3970e03d0e520d6
Reviewed-by: Antti Kokko <antti.kokko@qt.io>
2022-01-31 17:20:06 +02:00
Alexandru Croitor
8dce9ee119 rcc: Fix missing IGNORE directive for Qt version in tst_rcc
The IGNORE directive was likely removed as an oversight
in the linked change.

This fixes the test to pass when bumping the Qt version.

Amends 9836dbd6ee

Change-Id: I497325d6d8b8b67cce7b0840bfb9bfa70d85fe73
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-31 16:20:06 +01:00
Mårten Nordheim
8437c27582 QNetworkReply: rename socketConnecting to socketStartedConnecting
From the API review.

Pick-to: 6.3
Change-Id: Ic05737db79327e7811fcd974a70914b837e06601
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-31 14:24:11 +01:00
Oliver Wolff
a3503c8eae Blacklist tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109 for Win
The test also fails on Windows 11

Pick-to: 6.2 6.3
Task-number: QTBUG-98475
Change-Id: Iab079587d743500d222f2272d1145424e079b4a3
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
2022-01-31 12:40:35 +01:00
Samuli Piippo
42221aa84c Catch2: upgrade to 2.13.8
Update Catch2 header to latest released version. Needed
to build correctly with glibc 2.34.

Two patches applied on top of the upstream release. Previously
used Qt specific change extracted to a separate patch file.

Fixes: QTBUG-95842
Pick-to: 6.3 6.2
Change-Id: I67e442bbe756ff00c96a45eabf593f7aecddd628
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-31 09:26:00 +02:00
Marc Mutz
58e8ae5605 QFlatMap: fix is_transparent detection
Add a level of indirection via void_t such that

    struct is_transparent {};

works, and not just

    using is_transparent = <unspecified>;

Pick-to: 6.3
Change-Id: I3ca2af6a07e6989dc95abc10fb2d0078a5269e5b
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-30 10:11:46 +01:00
Marc Mutz
64bc6509c3 QFlatMap: add full is_transparent support [3/3]: add overloads
Now add the missing overloads for mixed-type lookups, supported by
is_transparent Compare objects.

Pick-to: 6.3
Change-Id: Ib588b6a4f733d5d9908c8c7d7c209df6e7bd6674
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-30 04:14:21 +01:00
Tatiana Borisova
d336fdd393 Fix tst_qfloat16 run time error for INTEGRITY (tested on sa8115)
- Bounds::has_denorm returns denorm_indeterminate.
  It is expected behavior for GHS compiler.

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I8402c541093a73623b6dc507012d98e565789cff
Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-01-30 00:02:38 +00:00
Volker Hilsheimer
35e938c2d8 Remove QEXPECT_FAIL for test passing on Android
The test has been XPASS'ing recently on Android.

Reverts 67e209f59f.

Fixes: QTBUG-69216
Change-Id: Ic629cc28936e0ef27277c243717e97226bf01b1c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-01-29 10:47:08 +01:00
Tatiana Borisova
e76d27d3ed Exclude tst_selftests when feature process is disabled
- It should not be built for systems without process feature.

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I71caa59c2168435894c7d1afcc8226e44178439f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-27 21:35:58 +02:00
Axel Spoerl
878aea3645 Add QTabBar test in tst_baseline_widgets
Task-number: QTBUG-99772
Pick-to: 6.3
Change-Id: I501c8e5c8e3ee1a1d3ac2a36b12f51dab90c88c3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-27 02:45:14 +01:00
Volker Hilsheimer
8359e44324 Offscreen: Fix implementation of QScreen::grabWindow
If id == 0, then we should grab the specified rect from the screen.

To do that, find all windows intersecting with the screen geometry, and
compose their backing store images into a screen-size pixmap.

Otherwise, find the respective backing store and grab only that.

Remove the old code respecting the desktop widget, which is no longer a
thing in Qt 6. The code was also wrongly grabbing only the first
containing - not intersecting - window's backing store into the screen
pixmap.

Enable the QScreen::grabImage test for the offscreen platform, where it
now passes.

Task-number: QTBUG-99962
Change-Id: I16eca7b082d65095a62c73624f86a4423e997a7a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-26 17:18:18 +01:00
Axel Spoerl
5d75e9d8b0 Add QScrollBar test in tst_baseline_widgets
Task-number: QTBUG-99882
Pick-to: 6.3
Change-Id: I9e9d3a674c205d26dd008b7de4e4ce31f470bf51
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-26 10:00:23 +01:00
Edward Welbourne
78eac57f3d Check for null driver() before trying to exec()
QSqlQuery::exec() took for granted that it can dereference driver(),
which should be true for all sane usage; however, it should not crash
if used misguidedly. Added regression test, based on bug report's
reproducer, which crashes without the fix.

Fixes: QTBUG-100037
Pick-to: 6.3 6.2 5.15 5.12
Change-Id: I94600bc60f89e82a1121b418144006a683921a38
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2022-01-25 16:18:35 +01:00
Giuseppe D'Angelo
2d95b75345 QByteArray: fix isUpper/isLower
577d698b8e changed QString::isUpper /
isLower behaviors to match Unicode semantics: a string is uppercase
if it's identical to its own toLower/toUpper folding. These semantics
come from Unicode so they're not up for debate.

That commit however left QByteArray untouched. Generally speaking, we
want to move away from QByteArray as "text storage" -- this has
partially happened between Qt 5 and Qt 6, where QByteArray went from
Latin-1 semantics to ASCII semantics. Still, QByteArray offers
toUpper/toLower and isUpper/isLower and all this family of functions
should be consistent in behavior.

Apply the same fix that was applied to QString.

[ChangeLog][Important Behavior Changes] The semantics of
QByteArray::isLower() and QByteArray::isUpper() have been changed. Now
lowercase (resp. uppercase) byte arrays are allowed to contain any
character; a byte array is considered lowercase (resp. uppercase) if
it's equal to its own toLower() (resp. toUpper()) folding. For instance,
the "abc123" byte array is now considered to be lowercase.
Previously, the isLower() (resp. isUpper()) functions checked whether
the byte array only contained ASCII lowercase (resp. uppercase)
characters, and was at least 1 character long. This had the side effect
that byte array containing ASCII non-letters (e.g. numbers, symbols,
etc.) were not lowercase nor uppercase.

[ChangeLog][QtCore][QByteArray] QByteArray::isLower() and
QByteArray::isUpper() now work correctly with empty byte arrays. The
semantics of these functions have been changed.

Pick-to: 6.3 6.2
Fixes: QTBUG-100107
Change-Id: Id56a42f01b2d1af5387bf0e6ccff0f824f757155
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 15:29:20 +01:00
Laszlo Agocs
406bb6ae20 rhi: Make sure pixelSize() to a texture rt is always up to date
This is an issue for QQuickWindow in practice, although it is not hit
by our current tests.

Pick-to: 6.3
Change-Id: Ia73704c1af6a82b2689ce7b844d3b0eb9a17ec18
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-01-25 01:04:07 +01:00
Sona Kurazyan
4cd8eeaf8c Fix memory leak in QtConcurrent::run when called with a NULL QThreadPool
QThreadPool automatically deletes the runnable after it finishes running
the task. In case QThreadPool is nullptr, we should delete the runnable
manually. This amends 87b93c29be.

Pick-to: 6.3 6.2 5.15
Change-Id: Id7e4ed3d4d6de05990edf62e4099852983debc64
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-24 22:40:35 +01:00
Marc Mutz
a8f00bf0ad QByteArray benchmark: fix clang -Wmove-result
Take the argument by value instead of rvalue ref. In C++17, this is as
efficient, and enables the

   return big;

to use the QByteArray move constructor, avoiding the need for a manual
std::move(), which always looks suspicious on a return statement,
because more often than not, it's a pessimization that breaks NRVO.

This code doesn't seem to exist in Qt 6.2, so only

Pick-to: 6.3
Change-Id: I8bf678102f5df1870cfc61090d12f327478d74d1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-24 21:11:22 +01:00
Marc Mutz
6f1821dfa3 benchmarks: fix some (future) -Wunused-result warnings
Clang 10 warns about unused results of relational operators, which is
where this is coming from.

Fix by adding the usual prefix

  [[maybe_unused]] auto r = ~~~;

to silence the warning. Do this elsewhere, too, since [[nodiscard]] is
slowly being rolled out across all our APIs. This is not a complete
sweep, though.

Not picking to 5.15, because this pattern doesn't work there and I
don't want to introduce a new one.

Pick-to: 6.3 6.2
Change-Id: I40dd8ad07496b686979dce533e044cbb486e30f3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-24 21:11:22 +01:00
Marc Mutz
c00e443dcc tst_bench_qlocalsocket: fix Clang 10 warnings about unneeded capture
The timeToTest constant doesn't need to be captured, claims Clang.

Since I don't recall seeing this warning on GCC, be pragmatic and fix
by letting the compiler choose what to capture: [&]. timeToTest is
const, so it doesn't matter whether we capture by reference or value,
the lambda cannot change it either way.

This code doesn't seem to exist in 5.15, so merely

Pick-to: 6.3 6.2
Change-Id: I48d42ab13ed22ac5eb512dc61235b72a19636ea3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-24 21:11:22 +01:00
Marc Mutz
b084c885db QTransform benchmark: measure what was promised
The function name suggests that the *= operator is to be benchmarked,
not simple multiplication.

Use the correct operator.

Pick-to: 6.3 6.2 5.15
Change-Id: I6718e8aea640a153083858b39963199e7bab26e9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-24 21:11:22 +01:00
Sona Kurazyan
d1639da0d5 Mark ResultStoreBase as final
The class is not intended for inheriting from it (see also
e502906305), so we can mark it as final
to explicitly forbid this. The tests were still using it as a base
class to clean the results during destruction, so fix them accordingly.

Task-number: QTBUG-99883
Pick-to: 6.3
Change-Id: I4a7ee3e2b462bd704e4b5a95ed733144805d6e5b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-24 20:54:36 +01:00
Kai Köhne
dfc1728e7b Fix gcc warning in tests
Fixes

/home/qt/work/qt/qtbase/tests/auto/corelib/tools/qcache/tst_qcache.cpp: In function ‘TestNamespace::quint64 qHash(TrivialHashType, size_t)’:
/home/qt/work/qt/qtbase/tests/auto/corelib/tools/qcache/tst_qcache.cpp:491:41: warning: unused parameter ‘seed’ [-Wunused-parameter]
  491 | quint64 qHash(TrivialHashType t, size_t seed = 0)
      |                                  ~~~~~~~^~~~~~~~

Change-Id: I70446d3f53770162ec0b99f53695c11c7aac103f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-24 12:59:37 +00:00
Axel Spoerl
5fa35c4f14 Add layout in QRadioButton baseline test for better visualization
Task-number: QTBUG-99749
Pick-to: 6.3
Change-Id: Iafd097d42b312cc24a60107c00e9c52fc0f3cdff
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-24 05:57:37 +00:00
Marc Mutz
cce7e35253 Q(Static)ByteArrayMatcher: manage indexIn() overloads
Unlike QString and QStringView, QByteArrayView and QByteArray don't
overload well.

Solve the overload issue the usual way: by making the QByteArray one a
Q_WEAK_OVERLOAD. This is trivial for QStaticByteArrayMatcher, which
isn't exported, but require QT_REMOVED_SINCE magic for
QByteArrayMatcher, which is.

The additional const char* overload has shielded us from the worst
fall-out so far, it seems, but it makes for a truly horrible overload
set:

    matcher.indexIn(str, 3);

Q: Is the 3 here the length of the haystack or the value of the from
parameter?

A: It depends on decltype(str)!

If the (const char*, qsizetype, qsizetype=0) overload is the better
match, then 3 limits the haystack's length.

If, otoh, the (QByteArray(View), qsizetype) overload is the better
match, then it's the value of the from parameter.

As if this wasn't bad enough, QByteArray implcitly converts to const
char* by default!

A follow-up patch will therefore deprecate the (ptr, size) overloads,
so we de-inline the QByteArrayView ones to avoid having to touch the
implementation once more.

Found during 6.3 API review.

Pick-to: 6.3
Change-Id: I9640e0bdd298d651511adebcc85f314db9221d34
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-23 09:48:28 +01:00
Marc Mutz
3d3558dc8f QStaticByteArrayMatcher: fix searching in 2+GiB haystacks
Add a test (same techniques as for the 4+GiB check in
tst_qcryptographichash).

Takes ~1s to build the 4GiB test data here, and skips
when RAM is too low:

  $ qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher haystacksWithMoreThan4GiBWork
  [...]
  QDEBUG : tst_QByteArrayMatcher::haystacksWithMoreThan4GiBWork() created dataset in 891 ms
  [...]

  $ (ulimit -v 2000000; qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher haystacksWithMoreThan4GiBWork)
  ********* Start testing of tst_QByteArrayMatcher *********
  [...]
  SKIP   : tst_QByteArrayMatcher::haystacksWithMoreThan4GiBWork() Could not allocate 4GiB plus a couple hundred bytes of RAM.
     Loc: [/home/marc/Qt/qt5/qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp(242)]
  [...]

Found during 6.3 API review.

[ChangeLog][QtCore][QStaticByteArrayMatcher] Fixed searching in
strings with size > 2GiB (on 64-bit platforms).

Fixes: QTBUG-100118
Pick-to: 6.3
Change-Id: I1df420965673b5555fef2b75e785954cc50b654f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-23 01:06:57 +00:00
Edward Welbourne
6db1284de9 Use Q_INT64_C() to express qint64 constants
When int is 32-bit, 0x80000000L is int-min, and (consequently)
negating it makes no difference, so MSVC warns about this. Instead of
using an L suffix, wrap the constant in Q_INT64_C(). Do the same for
similar large constants in the same block.

Pick-to: 6.2 6.3
Change-Id: Ib371b932792f170ab7db2e472a4283df3a205af3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-21 21:45:11 +01:00
Volker Hilsheimer
dd3ea45c23 Remove flaky and duplicate animateClick tests
The animateClick method is a QAbstractButton member, and neither
QCommandLinkButton nor QPushButton override it. The method is tested in
the QAbstractButton test, and 3a9b7d1f18648d7236664d3adfc65c009b01e668
made that test more robust. The previous, flaky version of the test was
almost duplicated here. They add no additional code coverage, so remove
them.

Pick-to: 6.2 6.3
Change-Id: I1fa988c1eabd5054193acb1f5fa1c81d29b3878d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2022-01-21 18:53:34 +01:00
Edward Welbourne
5d80d24d3c Tidy up tst_Warnings: comments and #if-ery
It was missing #if-ery on feature regularexpression for one test that
depends on it. One of its comments had a long line. Added some
annotations to make clear what's going on in messier tests.

Change-Id: I06d8748a134591f93b36029713e52ffd826a24dc
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-21 16:17:48 +01:00
Axel Spoerl
e81e91de85 Add QRadioButton test in tst_baseline_widgets
Task-number: QTBUG-99749
Pick-to: 6.3
Change-Id: I89e759e0943b0d1793728a65bfbae6e6b4d3167a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-21 12:49:35 +01:00