Commit Graph

12858 Commits

Author SHA1 Message Date
Edward Welbourne
6f833eff92 Add QByteArrayView::trimmed()
Unlike simplified(), it just moves the end-points, without needing to
modify contents, so it makes sense (as for QStringView and
QLatin1String) to provide it. Moved QByteArray's trimmed() tests to
tst_QByteArrayApiSymmetry so that QBAV can now share them.

[ChangeLog][QtCore][QByteArrayView] Added trimmed().

Change-Id: Ifd7a752adb5f3d3e2ad0aa8220efa7e7d2d39baa
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-08-11 22:32:42 +02:00
Volker Hilsheimer
761f32ae2a Fix some compiler warnings from deprecated QFont constructor
QFont should be constructed with a list of font families.

Pick-to: 6.2
Change-Id: I61141b25d3f6e25f4fea141acbfa8e164d7af58f
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-11 21:50:51 +02:00
Ievgenii Meshcheriakov
2b4ffe914f QUrl: Fix handling of invalid sequences starting with xn--
Return ASCII sequences that start with xn-- but fail Punycode
decoding as is when converting URLs to Unicode. This is consistent
with handling of sequences that do decode successfully but fail other
validity checks.

This fixes one test in tst_qurlinternal.

Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: I63d7197f25102c96f5dc21d9fecec5e015c531cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-11 19:12:00 +00:00
Ievgenii Meshcheriakov
22bf383519 tst_qurlinternal: Add another Punycode overflow test
The test string "xn--l0902716a" encodes 2**32. Currently
the IDNA code returns an empty string when encoding this
to Unicode instead of expected original string.

Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: I5ce7bcc744c9d5426f66b8a7d0ae76c7c92f552b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-11 21:12:00 +02:00
Ievgenii Meshcheriakov
c859b335b9 tests: Use QT_TESTCASE_SOURCEDIR define
Replace custom SRCDIR define with QT_TESTCASE_SOURCEDIR. The latter is
automatically available to all tests to use and serves the same purpose
but is not terminated by a slash.

Change-Id: I62896d0fd84ac63ac1b74a459ec1646c6bde0a46
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-11 21:03:56 +02:00
Ievgenii Meshcheriakov
58e32ae198 tst_qurlinternal: Use a lambda for bad IDN tests
Use a lambda to simplify testcases for bad IDNs.

Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: Ia4f3a5dbc73c74968628d89bd64d7aa6692b1c46
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-10 23:47:52 +00:00
Edward Welbourne
d055abd195 Assert that special handling of '0' padding does what it should
When formatting numbers, if the fill character used to left-pad to
field widths is '0', the code delegates that padding to the
QLocaleData's ZeroPadded formatting option. Since we want the zeros
before any minus sign, and don't want to subsequently add more zeros
before it, check that this has worked as expected when calling
replaceArgEscapes(), to confirm that it doesn't need to worry about
that.

Add some tests that verify the expected behavior.

In the process, tidy up the code doing this. Rename a local variable
to match our coding style, split a long line.

Pick-to: 6.2
Change-Id: I7cc430c5bceb006cf4e226bca33da16bd2bb1937
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 19:43:03 +02:00
Volker Hilsheimer
33f9591e37 Implement missing support for 'em' and 'ex' lengths in style sheet
The Qt style sheet reference claimed that Length properties can be
specified in 'em' or 'ex' units, but that was never implemented.

Add the missing implementation. Since the sizes depend on the size of
the font of the current element, we cannot convert the units in the CSS
parser, but have to do so in the QRenderRule constructor, where we can
make a decision about which font to use if the style sheet itself doesn't
specify a font. Fall back to the widget font if possible; otherwise it
will be the application default font.

The implementation translates em into QFontMetrics.height, identical to
what is already done in the QCssParser. This is in line with the CSS
specification, but contradicts our previous documentation which stated
that 'em' means "width of M". Fix the documentation.

Fixes: QTBUG-8096
Pick-to: 6.2
Change-Id: I145e2504ae3b19101a0d0dd63653466b6c2cec1d
Done-with: Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-10 19:43:02 +02:00
Tor Arne Vestbø
4632be1b4d testlib: Don't write redundant log message information in JUnit reporter
The separation between <system-out> and <system-err> is sufficient, and
we can't expect consumers to interpret our custom comment format.

The type of the text node has been renamed to more accurately identify
its purpose.

Pick-to: 6.2
Change-Id: I63c8ff17529fc087e1b695698350a6711eb5e68d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
ca15cc0049 testlib: Rename QAbstractTestLogger::QSystem to QCritical
It's used to handle qCritical() messages, and corresponds to QtMsgType's
QtCriticalMsg, so change its name to reflect what it really is.

In the process, reclassify the -maxwarnings overflow message as a warning,
rather than a critical message.

Pick-to: 6.2
Change-Id: I87626117a547ae4498d5dc352b93bd6db8bfb332
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
308280e7a9 testlib: Move stdout/stderr reporting into individual <testcase> elements
The original Ant JUnit reporter only writes <system-err> and <system-out>
to the <testsuite>, but more modern reporters such as Maven Surefire
scopes output to each individual <testcase>.

This is also handled by both the Jenkins JUnit and xUnit plugins, e.g.:

 https://github.com/jenkinsci/junit-plugin/commit/145eb5c98

Pick-to: 6.2
Change-Id: I20c87276004a4e0910fc18e05e6ffa0f5e5a7b7c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
f6c7eb5f0f testlib: Only generate expecations for silent test with plain logger
The -silent option to tests is only supported with the plain text
logger, so we don't need to maintain expectation files for the
others.

Pick-to: 6.2
Change-Id: I0f42bfe90d82b7ce04f550c747d4a80e99621e74
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
825e4291cd testlib: Produce <error> elements on fatal errors in JUnit reporter
Test errors represents unanticipated problems, e.g., an unhandled
exception, or a problem with the implementation of the test.

Pick-to: 6.2
Change-Id: I87219e7ffdea56862278f005de44526ad97545f0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 18:06:36 +02:00
Alexandru Croitor
5161d8d525 CMake: Remove qt6_enable_object_libraries_finalizer_mode
qt6_enable_object_libraries_finalizer_mode is not needed anymore
now that static Qt builds require CMake 3.21 and thus CMake takes
care of placing object library object files at the beginning of
the link line.

Rename qt6_enable_import_plugins_finalizer_mode to a more generic
qt6_set_finalizer_mode that can enable or disable multiple
different modes.

For now the only available mode is "static_plugins" which handles
the behavior of the old function name.

The mode can be enabled by calling

 qt6_set_finalizer_mode(${target} ENABLE MODES "static_plugins")

Note that the function is re-tagged as being in Technical Preview.

Ideally we would not need it at all. But we need to provide some
workaround for the limitations of linking Qt static plugins in CMake
on Linux-y platforms that use bfd ld or ld.gold.

The workaround does not work well with dependencies wrapped in
generator expressions which is why we can't confidently advertise it
as a proper solution.
Our hope is that this can be fixed in future upstream CMake versions
and the function can be removed.
See 6fcc272ac9 for details.

Adjust the tests due to the renamed and removed functions.

Amends 19e789bace
Amends cdbb390c4a
Amends a25027eecb
Amends 6fcc272ac9
Amends a3c430f390

Pick-to: 6.2
Fixes: QTBUG-95169
Task-number: QTBUG-95601
Task-number: QTBUG-95603
Change-Id: I51b85f776ec29fc04fed1a637eba7d1f60609e69
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-10 16:51:53 +02:00
Ievgenii Meshcheriakov
62b5d88b0d tst_qurlinternal: Add tests for punycode overflow
Add two tests for decoding IDNs when they encode values outside Unicode
(> 0x110000).

"xn--5p32g" decodes to "a" (all ASCII) before QTBUG-95577 got fixed.

"xn--400595c" decodes to the same value as "xn--097c" after the above
mentioned bug got fixed. This test is currently failing.

Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: Icab55c41e0233b34d57e38232fa90ac42f35a50a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 14:21:58 +02:00
Ievgenii Meshcheriakov
9bd2ab85ac QUrl: Fix Punycode handling for non-BMP codepoints
Iterate over Unicode codepoints instead of UTF-16 characters
when converting to/from Punycode as described in the specification.
Additionally reject strings with invalid surrogate pairs when
encoding to Punycode, reject strings with any encoded surrogates
when decoding.

Remove expected failure marking from the test for this issue
in tst_qurlinternal.

Fixes: QTBUG-95577
Pick-to: 6.2
Change-Id: I3dd68f95ada6d652e2fa5c0c3118dcfa0a5f4c4d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 14:21:58 +02:00
Timur Pocheptsov
33de5f6502 tst_QSslSocket - replace an old certificate
Helped quite a lot with OpenSSL 3 not accepting some old algorithms.

Pick-to: 6.2 6.1 5.15
Task-number: QTBUG-95123
Change-Id: If4894fa86eba7b002465fa661d436ae6ea751989
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 14:21:58 +02:00
Ulf Hermann
6f8ef8c64d QVariant: Tolerate QObject* metatypes without QMetaObject
QMetaType does. QVariant should do the same.

Pick-to: 6.2
Change-Id: I3419276b78b3b5ce8bd144dee92685195797d568
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Daniel Nicoletti <daniel.nicoletti@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-10 13:07:18 +02:00
Thorbjørn Lund Martsum
7502598ef5 QListView: fix AdjustToContents (sizeAdjustPolicy)
Unlike an acceptable effect in QTableView + QTreeView
setAdjustPolicy(QAbstractScrollArea::AdjustToContents)
unfortunately didn't work for QListViews (and QListWidget).

This patch corrects QListViews AdjustToContents
behavior.

[ChangeLog][QtWidgets][QListView] A more correct implementation
of QListView::viewportSizeHint has been made. That
implies that setting the sizeAdjustPolicy to AdjustToContent
on QListView and QListWidget will now cause the view to
size after the contents and avoid scrollbars.

Pick-to: 6.2
Task-number: QTBUG-58749
Change-Id: I1675115f2348e2fcf0b2c39b451ef337e10eb872
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-10 12:00:13 +02:00
Joerg Bornemann
0e92ec9728 Remove dysfunctional -coverage configure argument
The -coverage argument merely added compiler flags for the Qt build.  It
was never properly ported to the CMake build, and it doesn't seem
feasible to have configure arguments for every possible compiler option.

The same can be achieved by passing the needed compiler option to CMake,
for example: CMAKE_CXX_FLAGS=-fsanitize-coverage=trace-pc-guard

Pick-to: 6.2
Fixes: QTBUG-86227
Change-Id: Ieef9acaedc0a839f9fb35b4403395eea28643864
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-10 12:00:13 +02:00
Eirik Aavitsland
84aba80944 Refix for avoiding huge number of tiny dashes
Previous fix hit too widely so some valid horizontal and vertical
lines were affected; the root problem being that such lines have an
empty control point rect (width or height is 0). Fix by caculating in
the pen width.

Pick-to: 6.2 6.1 5.15
Change-Id: I7a436e873f6d485028f6759d0e2c6456f07eebdc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-10 12:00:13 +02:00
Alexandru Croitor
b2f00dfb46 CMake: Rename qt6_add_plugin TYPE option to PLUGIN_TYPE
The intention is to remove TYPE as a keyword completely before 6.2.0
release, but in case if that's not possible due to the large amount
of repositories and examples, just print a deprecation warning for
now and handle both TYPE and PLUGIN_TYPE.

Task-number: QTBUG-95170
Pick-to: 6.2
Change-Id: If0c18345483b9254b0fc21120229fcc2a2fbfbf5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-06 21:08:21 +02:00
Tor Arne Vestbø
eb4fb9fa32 testlib: Don't report blacklisted tests as failures in JUnit reporter
We don't produce <failure> elements for them, so we shouldn't include
them in the total count of failures.

In the future we might produce <skipped> elements instead, but for now
remove the incorrect increment.

Pick-to: 6.2
Change-Id: Ia89a5cdaf79f6aa2f92be53180112c40ad6da2c6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-06 20:05:15 +02:00
Andrei Golubev
d4e62f2c5a moc: Support BINDABLE for private properties
Hopefully we won't need it but let's have it still at least for
consistency

Change-Id: I72289e65e5e5613174ad4d98cf8d614f9caae8e6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-06 17:25:50 +02:00
Tor Arne Vestbø
a2026e4116 testlib: Write failure details as <failure> content in JUnit reporter
Pick-to: 6.2
Change-Id: Ica48769e7dfcabdc4bc8f0ed058bc22e29a0b632
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 17:00:22 +02:00
Tor Arne Vestbø
0ce70a29b3 testlib: Indent CDATA element in JUnit reporter
The data itself is not indented, as consumers may read it as verbatim
data.

Pick-to: 6.2
Change-Id: Ia934616cea273feadc3a45d7c74726d4f804f0dc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 17:00:22 +02:00
Ievgenii Meshcheriakov
1f20606fa3 tst_qurlinternal: Add a test for Punycode handling of non-BMP codepoints
Use U+102F7 as an example. The current code is not able to handle conversion
of Unicode codepoints outside BMP correctly, so mark the test as expected
failure.

Task-number: QTBUG-95577
Pick-to: 6.2
Change-Id: Ifd50cf306bce4940f84cb412de148eac952e6c09
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 17:00:22 +02:00
Mårten Nordheim
9b860ece42 QString/QByteArray: Fix setNum docs and add tests
Amends 260168d9d7

Task-number: QTBUG-53706
Pick-to: 6.2
Change-Id: I01c8cdc6a3cb46ec8e49e15ad71b6d707c0d272f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 16:49:08 +02:00
Timur Pocheptsov
e7ab17ade1 tst_QSslCertificate::verify - remove QSKIP
And re-generate certificates.

Fixes: QTBUG-95429
Pick-to: 6.2 6.1 5.15 5.12
Change-Id: Id970a0a9315d146d6dd1e66c9cff9b7d75657e2d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-06 16:08:43 +02:00
Fabian Kosmale
87973325f1 Handle even more include in enum cases
The solution in d3ed7dac8a was needlessly
complicated, and broke a valid use case.
The issue of no identifier being available to parse after the include
has been processed can instead be solved by moving the test for the
closing brace after the include processing.

Fixes: QTBUG-94790
Pick-to: 6.2 6.1 5.15
Change-Id: Ieec4b89e1d117637f11479e8bddc4060f93da43d
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-06 11:54:11 +00:00
Tor Arne Vestbø
a71b9c9377 testlib: Clean up tst_blacklist
33d7f76f0e attempted to exercise more
of the blacklisting code, but in doing so didn't account for the
fact that the features it added didn't actually work.

Adding a global blacklisting of * will result in blacklisting
all tests, regardless of any inverse conditions "!*" later on,
such as for the 'pass' test. This would have been evident by
looking at the expectation files, which still showed the test
as a BPASS.

The broken feature should be fixed, but in the meantime let's
clean up the test so it doesn't misrepresent reality.

At the same time we also remove the messages() tests, which was
copied straight out of tst_silent, but doesn't serve any purpose
for the blacklist selftest.

Pick-to: 6.2
Change-Id: I20e4693300aad5e9ff5f17ad22e3dfcb5c49fd0e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
c95d7741b7 testlib: Don't report additional 'pass' test point for blacklisted XFail
Regression after 9906cc57ed.

Pick-to: 6.2
Change-Id: I5566f70c66d248426c7a41b6de1cfb92f104cc64
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
fb16a66b71 testlib: Report skipped tests in JUnit reporter as <skipped> elements
The Apache Ant and Surefire Maven specs document a <skipped> element that
can be used to signify skipped test, with a corresponding total skipped
test attribute on the <testsuite>.

The element includes an optional message attribute, documented in the
Surefire spec, and in the Ant source code, but not yet documented in
the reverse-engineered Ant spec:

 https://github.com/windyroad/JUnit-Schema/pull/11

Pick-to: 6.2
Task-number: QTBUG-95424
Change-Id: Ib6417a41b9c328836f4017e6ebf7f7e9cd91288d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
58f1c0c146 testlib: Don't report JUnit errors attribute without any <error> elements
The errors attribute on the <testsuite> element represents the number of
<error> elements, but we do not produce any at the moment.

Pick-to: 6.2
Task-number: QTBUG-95424
Change-Id: I7196d622a9a6bbb7e79ed2c2886984d539abb1da
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
973e74399e testlib: Improve JUnit XML conformance
The JUnit test framework did not initially have any XML reporting
facilities built in. Instead, the XML report was generated by the
Apache Ant JUnit task:

 https://github.com/apache/ant/search?q=filename%3AXMLJUnitResultFormatter.java

Many users interacted with these reports via the Jenkins JUnit plugin,
which provided graphical visualization of the test results:

 https://plugins.jenkins.io/junit/

Due to the lack of an official XML schema for the Apache Ant JUnit
report there was some confusion about what the actual format was.
People started documenting the de-facto format, both as produced
by Ant, and as consumed by Jenkins:

 https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
 https://github.com/junit-team/junit5/search?q=filename%3Ajenkins-junit.xsd

The XML produced by the Qt Test JUnit reporter was far from these
schemas, causing issues when importing results into tools such
as Jenkins, Allure2, or Test Center.

The following changes have been made to improve conformance:

  - The 'timestamp' attribute on <testsuite> is is now in ISO
    8601 local time, without any time zone specified
  - The 'hostname' attribute on <testsuite> is now included
  - The 'classname' attribute on <testcase> is now included
  - The non-standard 'result' attribute on <testcase> has
    been removed
  - The non-standard 'result' attribute on <failure> has
    been renamed to 'type'
  - The <system-out> element on <testsuite> is always included,
    even when empty
  - The non-standard 'tag' attribute on <failure> has been
    removed. Data-driven tests are now represented as individual
    <testcase> elements, e.g.:

      <testcase name="someTest(someData X)" ...>
      <testcase name="someTest(someData Y)" ...>
      <testcase name="someTest(someData Z)" ...>

The resulting XML validates against both the de-facto Apache Ant
'JUnit 4' schema and the Jenkins JUnit plugin schema.

Task-number: QTBUG-95424
Change-Id: I6fc9abedbfb319f2545b99b37d059b18c16776ff
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:49 +02:00
Tor Arne Vestbø
177d259782 testlib: Simplify JUnit test logger
- Use the right name for the attribute (AI_Message),
   rather than fixing it up in QTestJUnitStreamer.
 - Don't pretend that we're adding line and file information,
   only to discard it in QTestJUnitStreamer.
 - Don't pretend to add benchmark information,
   only to discard it in QTestJUnitStreamer.

Pick-to: 6.2
Change-Id: Ib6eadc12300157216fe9c6e8bcfebd7eb8a3ea68
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:49 +02:00
Edward Welbourne
2f7d4f478e tst_QByteArray::qUncompressCorruptedData(): MS-Win no longer hangs
Oliver Wolff reports that this test no longer hangs on Windows; and
the other plafroms for which it was skipped are no longer supported,
so remove the #if-ery that skips this test for platfroms on which
uncompressing corrupt data used to hang.

Change-Id: I94a3fd4b83338fe6e3a97ab055fe05e2f15b6b45
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-05 01:07:41 +02:00
Mårten Nordheim
e00928e48c QByteArray::number(double): Extend the test
Move out and share the test data from the QString::number_double() test
and re-use it for this one.

Task-number: QTBUG-88484
Change-Id: I6502d1d360657f6077e5c46636f537ddfdde3a83
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 23:45:47 +02:00
Edward Welbourne
826e1963e3 Rework tst_QString::remove_regexp() and its data table
The test was producing a warning about the invalid test, for which
replace_regexp() had anticipated that warning; do the same in
remove_regexp(). The two tests shared a date() method, but the remove
test was a no-op on the tests with non-empty replacement text; move
the column set-up and data rows with empty replacement to remove's
data() function, from replace's, and reverse the direction of calling
each other between data() functions, so each test gets the cases that
are relevant to it and no spurious PASSes happen for no-op tests. In
the process, give moved test-cases informative names; relocate the
(entirely re-written) remove data function to beside its test; and
eliminate a pointless local variable from both tests (it used to be
needed when testing both QRegExp and QRegularExpression).

Pick-to: 6.2
Change-Id: I93dcfc444f984edf5c029f99306aff6bc95d554a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 22:22:20 +02:00
Edward Welbourne
a13942791d Refine localeAwareCompare() test-case filtering on ICU
The code to work around setlocale() mis-describing en_US as C ensured
that we didn't accept the C test-cases when the locale was really
en_US; but neglected to accept the en_US test-cases when the locale
really was en_US but was misdescribed as C. This lead to no tests
being run when the locale was en_US.

Tweak the logic of the test filtering to compare the wanted locale
against the system locale both when C is wanted and when it isn't.
Make the skip-messages a little more informative.

Pick-to: 6.2 6.1
Change-Id: I4e072e12819144b2941b87a5f486534047d9a579
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 22:22:20 +02:00
Mårten Nordheim
b41d5f6293 QDecompressHelper: Skip double-decompression if download is small
To retain backwards compatibility with some QNetworkReply usage,
namely connecting solely to finished-signal and allocating a buffer to
read into, but without storing the entire decompressed file in memory
until read, we may decompress the file twice.

With this patch users can now avoid this double decompression if the
amount of buffered data stays below 10 MiB. This means any file smaller
than 10 MiB will never need to be decompressed twice to know the size of
it. On top of that, if the data is handled as it arrives (e.g. in
readyRead) and the buffer is kept below 10 MiB it won't need to
decompress twice either.

This is active as long as "countDecompressed" is true, though it
currently always is in QNetworkAccessManger, with a future goal to make
it possible to control with public API. Since it requires the user to
potentially adapt their usage of QNetworkReply.

In this patch we also stop tracking the amount of unhandled uncompressed
bytes (uncompressedBytes) in favor of tracking the total amount of bytes
which has been read() by the user of QDecompressHelper (totalBytesRead),
since we can more intuitively work out the total amount of unread bytes
using this value.

Change-Id: Ie3d8d6e39a18343fcf9b610f45c7fe7e4cd4e474
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-08-04 19:31:52 +02:00
Tor Arne Vestbø
fa8cffa4c9 testlib: Pass on file location on failure, but don't assume we have one
We try our best to pass on the file location of a failure, including for
fatal errors, but the reporting or logging machinery should not assume
there is one.

By passing on nullptr for the file location we allow the logging backends
to decide how to handle the situation, e.g. by not emitting extra fields
for failure location.

This effectively reverts c25687fa0b,
in favor of relying on the backends to cope with null filename,
which they already did.

As qFatal uses QMessageLogger, which by default disables file/line
information in release builds, we need to explicitly enable this in
our self-tests, to get uniform test results. Similarly, we disable
file/line info from testlib itself, as reporting Qt internal file
and line information for user diagnostics is less useful. The odd
one out there is qtestdata.cpp, which still ends up in test output
due to using QTEST_ASSERT instead of qFatal for its diagnostics.
Cleaning up that, and unifying how we report testlib issues to the
user, is left for another day.

Pick-to: 6.2
Change-Id: Ib9451b8eed86fe3ade4a4dcaf0037e1a3450321c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 17:31:51 +00:00
Tor Arne Vestbø
bef57b317f testlib: Deprecate QWARN() in favor of qWarning()
The QtTest best practices documentations recommends using output
mechanisms such as qDebug() and qWarning() for diagnostic messages,
and this is also what most of our own tests do.

The QWARN() macro and corresponding internal QTest::qWarn() function
was added when QtTest was first implemented, but was likely meant as
an internal implementation detail, like its cousin QTestLog::info(),
which does not have any corresponding macro.

This theory is backed by our own QtTest self-test (tst_silent)
describing the output from QWARN() as "an internal testlib warning".

The only difference between QWARN() and qWarning(), besides the much
richer feature set of the latter, is that qWarning() will not pass
on file and line number information in release mode, but QWARN() will.
This is an acceptable loss of functionality, considering that the user
can override this behavior by defining QT_MESSAGELOGCONTEXT.

[ChangeLog][QtTest] QWARN() has been deprecated in favor of qWarning()

Pick-to: 6.2
Change-Id: I5a2431ce48c47392244560dd520953b9fc735c85
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 19:31:51 +02:00
Edward Welbourne
260168d9d7 QByteArray: don't coerce negative to unsigned for any base
This follows up on commit 98666c8afc,
which did the same for QString. If someone wants to get formatting
suitable to an unsigned value, they can cast the value to that
unsigned type and the correct overload shall pick it up.

[ChangeLog][Important Behavior Changes] QByteArray's formatting of
negative whole numbers to bases other than ten now, like QString's
(since Qt 6.0), formats the absolute value and prepends a minus sign.

Task-number: QTBUG-53706
Pick-to: 6.2
Change-Id: I91fee23d25ac0d5d5bcfcbeccbac1386627c004a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-02 23:40:56 +02:00
Laszlo Agocs
b594374ba8 rhi: Be more graceful when one destroys a resource after the QRhi
One is a bad application or library in this case, but nonetheless
we should handle this more gracefully then just crashing due to
the QRhi already having been destroyed. Mainly because in Qt 5 one
could get away with the same: releasing OpenGL objects underneath,
for example, a QSGPlainTexture with no (or wrong) GL context did
not generate any user visible fatal errors. So we should not crash
in Qt 6 either with these code bases.

In debug builds or when QT_RHI_LEAK_CHECK is set, one will get the
unreleased resources warning printed in Qt 6, which is a step
forward compared to Qt 5. So there is still some indication that
something is badly designed, even if the application survives.

Task-number: QTBUG-95394
Pick-to: 6.2
Change-Id: I944f4f425ff126e7363a82aff926b280ccf1dfc3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-08-02 14:35:33 +02:00
Alex Trotsenko
9f092c1077 QIODevice: rework validation policy for read() functions
- avoid calls to private and virtual functions, if the device is not
  open;
- avoid repetitive checks in loops;
- add missing checks in readLine() overloads;
- remove check against unsuccessful resize().

Change-Id: I973d5931163b25db1c09c7c3b66f29ea90bb1b29
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-08-01 10:50:32 +03:00
Alex Trotsenko
21f3ff65b8 QLocalSocket: do not emit aboutToClose() twice
This signal is emitted by the QIODevice itself, so we don't have to
forward it from the internal socket.

Pick-to: 6.1 6.2
Change-Id: I85745f36d7a27d92f339a9184de3b6e5d46f6f34
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-08-01 10:50:15 +03:00
Marc Mutz
615a9cf991 QUuid: port to QAnyStringView
Remove the QString/QStringView/QLatin1String/const char* overloads
from the API, but not the ABI.

As a drive-by, replace a use of QStringView::left() by truncate(), as
suggested by a comment.

[ChangeLog][QtCore][QUuid] The from-string constructor and the
fromString() function now take QAnyStringView (was: overload set with
a subset of QString, QByteArray, const char*, QLatin1String,
QStringView each).

Change-Id: If7fa26cfbef9280480c78b669d9f5f14118995ed
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-30 22:54:28 +02:00
Mårten Nordheim
64368bb527 Add a few more cases to the QString::number(double) test
Formatting using scientific notation with extra precision wasn't tested

Change-Id: I7a89a0f3d6468515604e43e52fc366dedf3c39ea
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-30 12:00:37 +02:00
Tor Arne Vestbø
f9170f56c7 testlib: Regenerate test expectations
After c25687fa0b and
539553a572.

Pick-to: 6.2
Change-Id: I34b436f20b9c480f6948aa97430228936955808e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-07-29 18:46:39 +02:00