summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Add more tests of blacklisting, combined with XPASS and XFAILEdward Welbourne2021-08-278-9/+250
| | | | | | | | | | Include counting of test types, to catch two more cases where totals don't add up. Task-number: QTBUG-95661 Change-Id: I9fe5424bc6652c61a065bf2889333e2ed9437c81 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Include check for the Totals line in testlib's expectedfail selftestEdward Welbourne2021-08-277-1/+71
| | | | | | | | | | | Count how many we expect to pass, fail and be skipped, so we can report that for comparison with the actual totals line: this reveals some double-counting, marked with a FIXME. Task-number: QTBUG-95661 Change-Id: I8b0f13ded5202ed476d8abfee70ed60f9e639bf9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Make clear why QTestLog::addB?XFail() don't add to countersEdward Welbourne2021-08-272-6/+6
| | | | | | | | | | | | | This reverts commit 904617dfb83f39a6a379635b64fea6fcd00f241a and makes clear to future readers why that wouldn't be a sensible change. Update the test's data, eliminating a case of duplicate counting that was caused by the reverted commit. Task-number: QTBUG-95661 Pick-to: 5.12 5.15 6.1 6.2 Change-Id: Ice6d3ab06ca171e0d6eb0fac757f1ab774e229f0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* New QByteArray::toU?LongLong() benchmarkEdward Welbourne2021-08-271-1/+90
| | | | | Change-Id: Ic0581dd5625f9b2750646c73dc80d89741d97a1d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QObject::connect(): fail to connect to a functor if UniqueConnection is passedGiuseppe D'Angelo2021-08-271-2/+3
| | | | | | | | | | | | | | | | | | | | | The connect() documentation makes it clear that UniqueConnection does not work with free functions / function objects and the like; only with actual PMFs. Rather than silently *ignoring* the flag, be vocal about its presence by warning, and make the connection fail (as the user has passed an illegal argument). [ChangeLog][QtCore][QObject] QObject::connect() now will refuse to connect a signal to a free function / function object if UniqueConnection is passed. Note that UniqueConnection has never worked for such connections -- the flag was simply ignored, and they were established multiple times. Now, the flag is not ignored and results in a connection failure (as well as a runtime warning by Qt). Change-Id: I6509667018c74f9bd24910cde0a1b16c5f84f064 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* wasm: add manual tests for main() and exec()Morten Johan Sørvig2021-08-2710-0/+367
| | | | | | | | | Add minimal examples which demonstrates how exec() works on Qt for WebAssembly and how to implement main() without calling QApplication::exec(). Change-Id: I44f1d16af19c538380cc56faf3f0f4cc9d66cf11 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Implement generating of private cpp exportsAlexey Edelev2021-08-272-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Add the generating of private cpp exports for Qt modules. Add the GENERATE_PRIVATE_CPP_EXPORTS option to qt_internal_add_module that is the manual switch for private exports generator. Existing modules in qtbase doesn't follow any strict convention of using private cpp export. So there is no clue how to detect if generating of the private exports is required or not for the module. Use autogenerated private cpp exports in QtNetwork module. CPP_EXPORT_HEADER_NAME argument of the qt_internal_add_module function is replaced by the CPP_EXPORT_HEADER_BASE_NAME and has a different meaning. The provided name is used as a base name for the private and non-private headers that contains cpp exports. Header files suffixes are constant: .h and _p.h for the non-private and private header files accordingly. Pick-to: 6.2 Task-number: QTBUG-90492 Change-Id: Icf11304e00379fb8521a865965c19b974e01e62f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Build a subset of tests when targeting iOS in the CIAlexandru Croitor2021-08-264-3/+99
| | | | | | | | | | | | | | | | | | | | | | | | Add infrastructure to build cmake auto tests in the CI when targeting iOS. Currently the are only CI instructions for qtbase. More work is needed to make it work for other repos. With this change, we will build a single Widgets application targeting the iOS simulator. We can't target the device SDK in the CI because signing fails due to a missing signing certificate and provisioning profile. The Coin instructions will now set a QT_BUILD_ENVIRONMENT=ci env var whose value will be checked in _qt_internal_test_expect_pass, to ensure we build for the simulator SDK when using a universal Qt. Without this, xcodebuild will try to build with the device SDK and fail to build the project. Pick-to: 6.2 Task-number: QTBUG-95839 Change-Id: Ib39c9527b107b2004746ccbdc9d9d1d658f88c76 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Forward touchEvents to children inside QGraphicsProxyWidgetVolker Hilsheimer2021-08-261-0/+168
| | | | | | | | | | | | | | | | | | | | Just sending the event to the embedded widget is not enough, we have to perform hit-testing for the different touch points, and send the event to the child widget under the point. Fortunately, QApplicationPrivate::translateRawTouchEvent provides the logic that generates multiple events for groups of touch points. Since that helper always sent events spontaneously, add an optional parameter to allow sending of non-spontaneous events. Add a test case that simulates touch events to different widget configurations inside a QGraphicsProxyWidget. Fixes: QTBUG-67819 Task-number: QTBUG-45737 Pick-to: 6.2 6.1 5.15 Change-Id: Iffd5c84c64ee2ceadc7e31863675fdf227582c81 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QBA(V)/QS(V)::lastIndexOf: fix the search of 1-char needlesGiuseppe D'Angelo2021-08-262-4/+4
| | | | | | | | | | | | | | | | | | | | When a needle has length 1 (because it's a QChar/char16_t, or because it's a string-like of length 1) then an ad-hoc search algorithm is used. This algorithm had a off-by-one, by not allowing to match at the last position of a haystack (in case `from` was `haystack.size()`). That is inconsistent with the general search of substring needles (and what QByteArray does). Fix that case and amend wrong tests. This in turn unveiled the fact that the algorithm was unable to cope with 0-length haystacks (whops), so fix that as well. Drive-by, add a similar fix for QByteArray. Amends 6cee204d56205e250b0675c9c6d4dd8a2367f3c4. Pick-to: 6.2 Change-Id: I6b3effc4ecd74bcbcd33dd2e550da2df7bf05ae3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qurl{,internal}: Use U+FB01 for normalization to ASCII test casesIevgenii Meshcheriakov2021-08-252-4/+6
| | | | | | | | | | | | Use U+FB01 LATIN SMALL LIGATURE FI instead of U+00DF LATIN SMALL LETTER SHARP S in testcases that need non-ASCII URLs that are normalized to ASCII. The latter is not normalized to ASCII when using UTS #46 nontransitional processing. Task-number: QTBUG-85371 Change-Id: I8c153feb58e556b1d31439018cc84d8e8f1de1a7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qurlinternal: Remove testcases that use U+04CFIevgenii Meshcheriakov2021-08-251-6/+0
| | | | | | | | | | U+04CF CYRILLIC SMALL LETTER PALOCHKA was undefined in Unicode 3.5 used by IDNA2003 but it is allowed in UTS #46. Task-number: QTBUG-85371 Change-Id: I7f5c0f6dc57f1197fd509e98328207d6179f1624 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qurlinternal: Remove nameprep and STD3 rules testsIevgenii Meshcheriakov2021-08-251-325/+0
| | | | | | | | | | | | IDNA 2008/UTS #46 do not use nameprep anymore and have different validity rules. Unexport qt_nameprep() and qt_check_std3rules() because they are not used by any tests anymore. Task-number: QTBUG-85323 Change-Id: I38c0dbae9a6bd108fbcfac350767aa7e757e786f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qurl: Make an invalid URL test compatible with UTS #46Ievgenii Meshcheriakov2021-08-251-3/+4
| | | | | | | | | | | Use U+1F100 DIGIT ZERO FULL STOP instead of U+1F4D9 ORANGE BOOK. The latter is not allowed according to IDNA 2003 rules but is allowed according to UTS #46 rules. The former is disallowed in either case. Task-number: QTBUG-85371 Change-Id: Idc8afef68c26ae0b702a475e5a53592182998a08 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QRegularExpressionMatch: add a way to know if a capturing group capturedGiuseppe D'Angelo2021-08-251-79/+159
| | | | | | | | | | | | | | | | | | | | | | | Relying on the fact that a given capturing group captured a null string doesn't allow users to distinguish whether a capturing group did not capture anything, or captured a null substring (say, from a null subject string). Perl allows for the distinction: the entries in the @- and @+ arrays are set to values in case there is a capture, but they're undef otherwise. PCRE2 gives us the information already in the results "ovector", but it was simply not exposed to QREM users. So, expose it. [ChangeLog][QtCore][QRegularExpressionMatch] Added the hasCaptured() family of functions to know if a given capturing group has captured something. Change-Id: Ic1320933d4554e2e313c0a680be1b1b9dd95af0b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Revive tst_qresourceengineJoerg Bornemann2021-08-245-3/+68
| | | | | | | | | | This test was not ported to CMake yet. Pick-to: 6.2 Fixes: QTBUG-88601 Change-Id: Ied3b1a0e2ddfbcf003cb0d8d01d5f64cb83cf4e7 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fuzzing: Remove .pro-files of libfuzzer testsRobert Löhning2021-08-2413-127/+0
| | | | | | | | | They were replaced by CMake files and oss-fuzz was updated to use the latter. No need to still maintain qmake based builds. Change-Id: If38f39c23ef3a58c33c428341486b62fd0a81888 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QGraphicsProxyWidget: forward Window(De)Activate eventsVolker Hilsheimer2021-08-241-0/+55
| | | | | | | | | | | | | | | | | | The nested widget might be a QGraphicsView as well (documented to be supported), and QGraphicsScene maintains it's own activation status by counting Window(De)Activate events. We need to make sure that the embedded widget is informed about its activation status so that deeper nested children can receive focus. Forward WindowActivate/Deactivate events to the nested widget, which will pass it on to all its children. Add test case, which without this fix fails when verifying the inner scene's isActive state, or later when testing that focusInEvent is delivered to the embedded widget. Fixes: QTBUG-94091 Pick-to: 5.15 6.1 6.2 Change-Id: I4e0ecef50685ed081d15c7f76b6c1a4a40ed2682 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Unicode: fix the grapheme clustering algorithmGiuseppe D'Angelo2021-08-241-0/+101
| | | | | | | | | | | | | | | | | | | An oversight in the code kept the algorithm in the GB11 state, even if the codepoint that is being processed wouldn't allow for that (for instance a sequence of ExtPic, Ext and Any). Refactor the code of GB11/GB12/GB13 to deal with code points that break the sequences (falling back to "normal" handling). Add some manual tests; interestingly enough, the failing cases are not covered by Unicode's tests, as we now pass the entire test suite. Amends a794c5e287381bd056008b20ae55f9b1e0acf138. Fixes: QTBUG-94951 Pick-to: 6.1 5.15 Change-Id: If987d5ccf7c6b13de36d049b1b3d88a3c4b6dd00 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* macOS: Add debug keyboard layout for manual testingTor Arne Vestbø2021-08-232-0/+1446
| | | | | | Pick-to: 6.2 Change-Id: Ie35f7a57c6d54c1cc0a7b79d8fd25d0b056bf5e6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use constexpr for constants and ranged-based for loopsEdward Welbourne2021-08-231-99/+89
| | | | | | | | | In the process, actually use the constants as the size of some arrays, instead of making [1024] arrays and then only using a few entries. Change-Id: I9f36b322840393b8680788190cf8b40a828f4957 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Fix the (currently unbuilt) qdir/tree/ benchmarkEdward Welbourne2021-08-231-20/+19
| | | | | | | | | | | | | | It tried to find its test-data-directory locally, instead of asking FileSystem where it was keeping its files, relative to a temporary directory. Its expected counts didn't match the arcane results of its data file; since this is a benchmark, not a regression test, I'm assuming that's just because it was never right or the rules for QDirIterator's filtering have changed. Tidied up somewhat in the process. Change-Id: Ib2dcd314b11cb0f1a6fc425633afd0e9c39bd036 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Re-add QPropertyAlias functionalityFabian Kosmale2021-08-231-0/+17
| | | | | | | | | | | | | | | | | As QPropertyAlias was public by accident in 6.0, we have to ensure that it still works in 6.2. This re-adds some tests for it, and reimplements the unlinking functionality. To avoid performance regressions in hot-paths, a new unlink_fast function is added, which behaves like the old unlink: It ignores the special handling for QPropertyAlias, so that we can skip the tag check. It is only used in QPropertyObserverNodeProtector and clearDependencyObservers, where we already know the type of the observer. Fixes: QTBUG-95846 Pick-to: 6.2 Change-Id: Ifb405b8327c4d61c673b1a912ed6e169d27c2d8f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tst_QPluginLoader: Simplify creating a fake pointer in fakeplugin.cppMartin Storsjö2021-08-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When assigning multiple variables to a specific section, both GCC and Clang legitimately error out if those variables wouldn't end up in the same section (e.g. if one of them is going to a read-only section while the other one is going to a read-write section). In C++, when a seemingly const variable needs dynamic initialization, it needs to be stored in a read-write section. Clang 13 changed internals for how some constants are materialized. Now, when a variable is initialized with an expression containing plain old fashioned casts, it is considered to be potentially runtime initialized (at the point when section assignment conflicts is evaluated). Therefore, Clang 13 errors out on fakeplugin.cpp with errors like: fakeplugin.cpp:36:39: error: 'message' causes a section type conflict with 'pluginSection' QT_PLUGIN_METADATA_SECTION const char message[] = "QTMETADATA"; ^ fakeplugin.cpp:32:40: note: declared here QT_PLUGIN_METADATA_SECTION void *const pluginSection = (void*)(0xc0ffeec0ffeeL); ^ See https://bugs.llvm.org/show_bug.cgi?id=51442 for discussion on the matter in Clang. To simplify things, just initialize the fake pointers as regular uintptr_t instead, avoiding the whole matter. This produces the exact same contents in the section as before. For what it's worth, the actual manually constructed metadata in fakeplugin.cpp doesn't seem to have any effect on running the QPluginLoader tests on either ELF or MachO right now. Change-Id: Ib84a2ceb20cb8e3a1bb5132a5715538e08049616 Pick-to: 6.2 6.1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QScroller::scrollTo failing in QGraphicsView with movable itemChunLin Wang2021-08-201-0/+30
| | | | | | | | | | | When forcing software scrolling through QScroller::scrollTo, it will start from (0, 0). QGraphicsViewPrivate::canStartScrollingAt should consider the locationof points, not just the flags of item. Fixes: QTBUG-70255 Pick-to: 5.15 6.1 6.2 Change-Id: Iebdd5568baa3bdb41c705204dadb2895cfe9c0e2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Improve lancelot test of dashed line paintingEirik Aavitsland2021-08-203-4/+70
| | | | | | | | | | | Add painting of sets of lines, both connected and unconnected, that go outside the device area. This prepares for fixes & improvements in the painting code. Pick-to: 6.2 6.1 5.15 Change-Id: I9cffc760524e9ade42362c9a04949270ac24180f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* wasm: add cmake build for manual testsMorten Johan Sørvig2021-08-194-0/+37
| | | | | | | The tests can now be built with qt-cmake-standalone-test. Change-Id: I098340a9f755806061de281fbc25cb00c61f33f0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Improve and simplify tst_QByteArray's testsEdward Welbourne2021-08-191-76/+69
| | | | | | | | | | | | Don't go via QString when we don't need to. Put expected after actual, not the other way round. Give tests and test-cases sensible names. Prefer function-style cast over C-style. Change-Id: I0b79534a9cc95f2e312a85394693ac674ff3d1d6 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add benchmark for QByteArray::toPercentEncoding()Edward Welbourne2021-08-191-0/+31
| | | | | Change-Id: If822bb3b9c6623137f27b6624598530432246ed2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix bug with NoFontMerging when font does not support scriptEskil Abrahamsen Blomfeldt2021-08-191-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using NoFontMerging, no fallbacks should be resolved. If the font does not support a specific character in the text, we should display a box instead of merging it with another font. But in practice, Qt would still apply the fallback mechanism for one specific case: If the font itself does not support the script of the text, we would get no match and do a search for a fallback instead. Since NoFontMerging is set, we would then force this as preresolved for *all* scripts in the QFont's private data (logically, the match should only have a single response for NoFontMerging). The end result was that if you set the font family before updating the text, you would get broken rendering. This can happen e.g. in Qt Quick, where you could update the font family of a text label while it contains characters which are not supported by the new font. Qt would then pick a fallback instead. When you subsequently update the text, the fallback would already be preresolved for whatever script this is. If it does not support the updated text, we would then see boxes, even if the requested font actually would have supported it. The fix is simply to do an additional pass if NoFontMerging is set and we were not able to match with the specified script. Since the same family might be available in different foundries, with different writing system support, we still want to do a pass first to see if we can match the exact script of the text. Note that QRawFont::fromFont() exploited the bug by using NoFontMerging for getting the fallback font for a specific writing system. To keep this working without having to rewrite fromFont() and risk introducing regressions, we add an argument to make the findFont() function behave as before. It isn't super-pretty, but since it is private API it is hopefully fine. [ChangeLog][QtGui][Text] Fixed an issue with NoFontMerging and changing font families dynamically, where boxes would be seen in place of the correct text. Pick-to: 5.15 6.1 6.2 Done-with: Andy Shaw Fixes: QTBUG-81770 Change-Id: Ide9a36d7528a1040172c5864fa99e7a82eac4e83 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QString: use the QRegularExpression operations on QStringViewGiuseppe D'Angelo2021-08-191-10/+10
| | | | | | | | | | | | | | | | There's no need of duplicating code all over the place; QString can reuse the implementation of the indexOf/contains/count/lastIndexOf family of functions already existing for QStringView. For simplicity, the warning messages (that our autotests actually check) have been made more generic, rather than introducing some other parameter (as in, "which class is using this functionality so to emit a more precise warning"), which would have just complicated things as the implementation of these functions is exported and used by inline QStringView member functions. Change-Id: I85cd94a31c82b00d61341b3058b954749a2d6c6b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRegularExpression: fix matching over null/empty QString(View)Giuseppe D'Angelo2021-08-191-2/+23
| | | | | | | | | | | | | | | | | | | | | | | An empty QString(View) is allowed to have nullptr as its data pointer (of course, only if its size is 0). This wasn't properly checked in QRegularExpression, which passed such nullptr to PCRE, and that resulted in PCRE raising an error (PCRE_ERROR_NULL). Detect this case and pass a dummy pointer to keep PCRE happy. Fixing and testing this in turn exposed a problem with QStringView support in QRegularExpression when used over a null QString: the code is supposed to use the QStringView(QString) constructor and NOT qToStringViewIgnoringNull. That's because QRE distinguishes null and empty subjects; when using qToStringViewIgnoringNull over a null QString, one gets a non-null QStringView (!). Again, this in turn exposed a problem with a QRegularExpression autotest that assumed that a null match could only mean "no match" (instead, it can happen at position 0 of a null QString(View)). Change-Id: Ifb3cf14dec42ce76fcdbcb07ea1d80784d52ef65 Pick-to: 6.1 6.2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QS(V)/QBA(V)/QL1S::lastIndexOf: fix the offset calculationsGiuseppe D'Angelo2021-08-194-22/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When trying to fix 0-length matches at the end of a QString, be83ff65c424cff1036e7da19d6175826d9f7ed9 actually introduced a regression due to how lastIndexOf interprets its `from` parameter. The "established" (=legacy) interpretation of a negative `from` is that it is supposed to indicate that we want the last match at offset `from + size()`. With the default from of -1, that means we want a match starting at most at position `size() - 1` inclusive, i.e. *at* the last position in the string. The aforementioned commit changed that, by allowing a match at position `size()` instead, and this behavioral change broke code. The problem the commit tried to fix was that empty matches *are* allowed to happen at position size(): the last match of regexp // inside the string "test" is indeed at position 4 (the regexp matches 5 times). Changing the meaning of negative from to include that last position (in general: to include position `from+size()+1` as the last valid matching position, in case of a negative `from`) has unfortunately broken client code. Therefore, we need to revert it. This patch does that, adapting the tests as necessary (drive-by: a broken #undef is removed). Reverting the patch however is not sufficient. What we are facing here is an historical API mistake that forces the default `from` (-1) to *skip* the truly last possible match; the mistake is that thre is simply no way to pass a negative `from` and obtain that match. This means that the revert will now cause code like this: str.lastIndexOf(QRE("")); // `from` defaulted to -1 NOT to return str.size(), which is counter-intuitive and wrong. Other APIs expose this inconsistency: for instance, using QRegularExpressionIterator would actually yield a last match at position str.size(). Similarly, using QString::count would return `str.size()+1`. Note that, in general, it's still possible for clients to call str.lastIndexOf(~~~, str.size()) to get the "truly last" match. This patch also tries to fix this case ("have our cake and eat it"). First and foremost, a couple of bugs in QByteArray and QString code are fixed (when dealing with 0-length needles). Second, a lastIndexOf overload is added. One overload is the "legacy" one, that will honor the pre-existing semantics of negative `from`. The new overload does NOT take a `from` parameter at all, and will actually match from the truly end (by simply calling `lastIndexOf(~~~, size())` internally). These overloads are offered for all the existing lastIndexOf() overloads, not only the ones taking QRE. This means that code simply using `lastIndexOf` without any `from` parameter get the "correct" behavior for 0-length matches, and code that specifies one gets the legacy behavior. Matches of length > 0 are not affected anyways, as they can't match at position size(). [ChangeLog][Important Behavior Changes] A regression in the behavior of the lastIndexOf() function on text-related containers and views (QString, QStringView, QByteArray, QByteArrayView, QLatin1String) has been fixed, and the behavior made consistent and more in line with user expectations. When lastIndexOf() is invoked with a negative `from` position, the last match has now to start at the last character in the container/view (before, it was at the position *past* the last character). This makes a difference when using lastIndexOf() with a needle that has 0 length (for instance an empty string, a regular expression that can match 0 characters, and so on); any other case is unaffected. To retrieve the "truly last" match, one can pass a positive `from` offset to lastIndexOf() (basically, pass `size()` as the `from` parameter). To make calls such as `text.lastIndexOf(~~~);`, that do not pass any `from` parameter, behave properly, a new lastIndexOf() overload has been added to all the text containers/views. This overload does not take a `from` parameter at all, and will search starting from one character past the end of the text, therefore returning a correct result when used with needles that may yield 0-length matches. Client code may need to be recompiled in order to use this new overload. Conversely, client code that needs to skip the "truly last" match now needs to pass -1 as the `from` parameter instead of relying on the default. Change-Id: I5e92bdcf1a57c2c3cca97b6adccf0883d00a92e5 Fixes: QTBUG-94215 Pick-to: 6.2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_QLocale::formatTime(): add some actual locale-dependenceEdward Welbourne2021-08-181-43/+68
| | | | | | | | | | | All the tests were using the C locale, so were equivalent to tests of QTime::toString(). Add a locale column and some test-cases in preparation for a change to am/pm indicators. Task-number: QTBUG-95790 Change-Id: I3ad917b7a6f3d3bfe31d6a5a5da596025f173e81 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Report ImAbsolutePosition for QLineEditTor Arne Vestbø2021-08-181-0/+5
| | | | | | | | | | | ImAbsolutePosition was added in f8dbed12266c42785c1e4758eed05833ec035f33, based on requirements on Android, but without an implementation for QLineEdit. It would seem sensible to fall back to the cursor position in this case, as QLineEdit doesn't support multiple blocks. Pick-to: 6.2 Change-Id: Iff1255270ceef069f03ce457df633d7b675f1a28 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtConcurrent::run: support non default-constructible return typesSona Kurazyan2021-08-182-4/+16
| | | | | | | | | | | | | | The QtConcurrent::RunFunctionTask class keeps a variable to store the result of QtConcurrent::run when it becomes available, so that it can be reported afterwards. This requires the result type to be default-constructible. However there's no need in storing the result, it can be reported immediately after it becomes available. Pick-to: 6.1 6.2 Fixes: QTBUG-95214 Change-Id: I95f3dbff0ab41eaa81b104a8834b37d10a0d193a Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use a scope-guard to take care of process deletion in a testEdward Welbourne2021-08-171-6/+5
| | | | | | | | | | Doing the deletion at the end of the block only works if the test passes. Drive-by: remove spurious braces from single-line bodies of single-line controls. The QTest macros are done properly. Pick-to: 6.2 6.1 5.15 Change-Id: I83002547dba49ab9792f4db44d73151b1c036900 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Attempt to unwedge tst_QThread::wait3_slowDestructor()Edward Welbourne2021-08-171-13/+15
| | | | | | | | | | | | | | | | When the test failed, it never released the blocking slot, so the tested thread remained blocked indefinitely. Blacklisting doesn't rescue that: the test run gets killed by Coin's watchdog. Use a QScopeGuard() to release the clocked slot on failure. replacing the release that was happening only on success. As drive-by clean-up, smarten up the code a little and remove an unused enum. Pick-to: 6.2 6.1 5.15 Change-Id: Ie035dafe6e4b1d82aea5de38ceb31c0f7fcf81d7 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Expand testing of QEXPECT_FAIL()Edward Welbourne2021-08-177-255/+981
| | | | | | | | | Test both Abort and Continue cases. Test more with successive marked as expected failure. Test cases with a QSKIP after the marked check. Unify data functions where practical. Change-Id: I2eade5e4dd0907d23e37137ce3d93cd5ca79f802 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tests: Remove unused SRCDIR definesIevgenii Meshcheriakov2021-08-1719-35/+0
| | | | | | | | | | | Remove SRCDIR defines from tests that don't use them. There is a standard define called QT_TESTCASE_SOURCEDIR that is available to all tests and serves the same purpose. Pick-to: 6.2 Change-Id: I2aa237739c011495e31641cca525dc0eeef3c870 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QString/QByteArray::number(double): Test big numbersMårten Nordheim2021-08-173-3/+42
| | | | | | | | | | | Exhausts the entire buffer which double-conversion is left to work with. Also has a large amount of precision, which apparently we need to store temporarily. Task-number: QTBUG-88484 Change-Id: I87e8c323676465f1b8695e086020df1240d0d0d7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: Improve Punycode overflow handlingIevgenii Meshcheriakov2021-08-161-2/+0
| | | | | | | | | | | | | | | | | | | | Add more overflow checks from the sample code in RFC 3492. Also check if a code point to be inserted into output is in the allowable range for Unicode. Rewrite all overflow checks to use {add,mul}_overflow() functions. Do not try to process any inputs that are too long to be part of a valid domain name label. This fixes a test in tst_qurlinternal. Fixes: QTBUG-95689 Pick-to: 6.2 Change-Id: Ice0b3cd640d8a688b63a791192ef2fa2f13444be Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add benchmark for QMetaEnumMarc Mutz2021-08-163-0/+88
| | | | | Change-Id: If57f00b14713f2083260a00fd833da62d6f1cd57 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QVarLengthArray: add support for emplacementMarc Mutz2021-08-161-0/+19
| | | | | | | | | | | | | Take the rvalue insert() function and turn it into the emplace() function. Reformulate rvalue-insert using emplace(). Lvalue insert() is using a different code path, so leave that alone. This way, we don't need to go overboard with testing. [ChangeLog][QtCore][QVarLengthArray] Added emplace(), emplace_back(). Change-Id: I3e1400820ae0dd1fe87fd4b4c518f7f40be39f8b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QGraphicsProxyWidget: fix propagation of high-precision eventsVolker Hilsheimer2021-08-161-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | In order to fix QTBUG-95552 properly we have to add APIs to QGraphicsSceneWheelEvent that informs QGraphicsProxyWidget about whether the event is a high-precision event where Qt grabs the wheel. If it is, then the wheel grabber will be the QGraphicsView's viewport, and any wheel event sent to any widget will be grabbed by it. This results in infinite recoursion, partly fixed in change I78400ceae8da7a4e22a988c06ed58f99f1a979f4. The proper fix is to re-grab the wheel by the embedded widget if it (or any of its children) accepts the ScrollBegin event (and if not, return the grab to the QGraphicsView). This fixes the scenarios that failed in the test case, so now scrolling through nested widgets and scrolling in nested widgets works as the user would expect. Fixes: QTBUG-95552 Pick-to: 6.2 Change-Id: I3e1f31cbff999c70f8c63c034f77cd2ae567d7e3 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Don't crash in high-precision wheel scrolls on a QGraphicsProxyWidgetVolker Hilsheimer2021-08-161-0/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For high-precision wheel scrolling sequences, the widget that gets the first (typically ScrollBegin) event grabs the wheel. Qt directs all future wheel events within the same sequence (i.e. until ScrollEnd) to that widget. QGraphicsView passes wheel events through to the item under the mouse, and QGraphicsProxyWidget implements wheelEvent to forward a synthesized QWheelEvent to the embedded widget. Since QGraphicsView's viewport has already grabbed the wheel, any forwarded event would end up back in QGraphicsView, resulting in infinite recursion (if the assert doesn't fail first in debug builds). The correct fix requires that QGraphicsProxyWidget knows that this is a high-precision wheel event, allowing it to adjust the wheel grabber temporarily to the embedded widget. However, QGraphicsSceneWheelEvent doesn't provide this information. To fix the infinite recursion, mark the generated event as synthesized by Qt (but still send it spontaneously to enable propagarion within the proxy widget hierarchy). In QApplication's notification routine, interpret such events then to override the wheel grabber. Add a test case for the various scenarios. This 6.1 compatible fix does not pass all situations. A follow up commit that introduces the missing APIs to QGraphicsSceneWheelEvent then fixes those as well. Task-number: QTBUG-95552 Pick-to: 6.1 6.2 Change-Id: I78400ceae8da7a4e22a988c06ed58f99f1a979f4 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Close all popup windows when the screen is rotatedTang Haixiang2021-08-121-0/+16
| | | | | | | | | | | | | Changing the screen orientation will cause the menu position to be displayed incorrectly. When the screen is rotated, the geometry of the application changes. We can refer to the handling of the menu on Android or IOS. Close the popup window when the screen orientation changes. Fixes: QTBUG-95607 Pick-to: 6.2 Change-Id: I55e1cd6a8b89e375c6714a9163dfb1902d52f101 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Add QByteArrayView::trimmed()Edward Welbourne2021-08-113-29/+39
| | | | | | | | | | | | 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>
* Fix some compiler warnings from deprecated QFont constructorVolker Hilsheimer2021-08-112-2/+2
| | | | | | | | 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>
* QUrl: Fix handling of invalid sequences starting with xn--Ievgenii Meshcheriakov2021-08-111-1/+0
| | | | | | | | | | | | | | 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>