summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
Commit message (Collapse)AuthorAgeFilesLines
* Add support for naming JNI functions with the unstringify macroJuha Vuolle2022-07-052-0/+27
| | | | | | | | | | | | | | The manually defined native JNI function tables allow defining a name that may be different from the actual function name; this name is then used from the Java-side. This can be useful to provide also as an option with the new "unstringifying" macros which can help for example in porting code to these new macros. Pick-to: 6.4 Change-Id: Icfebfb351cb8dfb122795d20b37e2eac167a41bf Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Support markdown in QTextEditMimeData; fix pasting trailing newlinesShawn Rutledge2022-06-241-0/+11
| | | | | | | | | | | | | | | | | | | - Since 4edcea762d9ce334c4c1a78234c90c118b81da87 the dropsite example shows markdown if available; and now it shows that when we do DnD of a selection from the richtext example, text/markdown is available. - If we artificially make html unavailable, copying and pasting between widget-based rich text editors uses markdown. In case markdown writer output contains unnecessary backticks due to monospace fonts getting used, the workaround from 1ad456c908467212bc30223a69eb7524b64b86e1 is applied. Pick-to: 6.4 Task-number: QTBUG-76105 Task-number: QTBUG-103484 Change-Id: Ie6ca4dbb450dbc36b3d09fd0df1ae5909aaebca7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* unblacklist passing tests 2022Anna Wojciechowska2022-06-231-4/+0
| | | | | Change-Id: Ifb09a997d39fc2c92503e77cf372d443c13c4c2b Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
* QJsonValue: fix incorrect to{Array,Object} when the value is emptyThiago Macieira2022-06-211-2/+16
| | | | | | | | | | | | This is a repeat of commit de6ced66920600e659dbaa2509526a3bcb0b3360 "QCborValue: fix incorrect to{Array,Map} when the value is empty" (6.4), which fixed the same thing for QCborValue. I've just copied the exact same implementation onto the QJsonValue functions. Pick-to: 6.2 6.3 6.4 5.15 Fixes: QTBUG-104085 Change-Id: I175efddd75f24ae59057fffd16f6b257bf7ed36d Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QPromise: run continuation(s) on destructionSona Kurazyan2022-06-221-0/+20
| | | | | | | | | | | | | | | | | | If the QFuture is canceled because the associated QPromise has been destroyed, we still need to run its continuations (i.e. onCanceled handler, if it's attached), so replaced the cleanContinuation() call inside ~QPromise() with runContinuation(), which will also take care of cleaning the continuation. [ChangeLog][QtCore][Important Behavior Changes] QFuture now runs its continuations when its associated QPromise has been destroyed. Previously, if a QFuture was canceled because the associated QPromise has been destroyed, its continuations were skipped. Fixes: QTBUG-103992 Pick-to: 6.4 6.3 6.2 Change-Id: Ie05bc760c96c349aade8adb8d2fe5263aff8efac Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add QStringDecoder::decoderForHtml()Lars Knoll2022-06-211-20/+64
| | | | | | | | | | | | | | Now that QStringConverter can handle non UTF encodings through ICU, add a way to get a decoder for arbitrary HTML code. Opposed to QStringConverter::encodingForHtml(), this method will try to create a valid string decoder also for non unicode codecs. Pick-to: 6.4 Change-Id: I343584da1b114396c744f482d9b433c9cedcc511 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* function_ref test: Don't take reference of temporariesMårten Nordheim2022-06-201-5/+10
| | | | | | | | | | | | | When assigning the lambdas directly to a function_ref their lifetime is limited to that of the expression. Store them on the stack first to avoid the UB. Fixes: QTBUG-104419 Pick-to: 6.4 Change-Id: I3c85ac683b0bd7768b646dc9d0a1ed4dd173e6f3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Avoid misleading bindingStatusAllan Sandfeld Jensen2022-06-201-1/+37
| | | | | | | | | | | Set it to nullptr on clear, and deal with possibly null bindingStatus. Task-number: QTBUG-101177 Task-number: QTBUG-102403 Pick-to: 6.4 Change-Id: I66cb4d505a4f7b377dc90b45ac13834fca19d399 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qthread: Fix compilation under ubsanFabian Kosmale2022-06-201-4/+4
| | | | | | | | | We missed the terminating ";" in the QSKIP lines. Amends ea4d6b987ae10f1bb910081b523c3b22b11f7b64 Pick-to: 6.3 6.4 Change-Id: Ibda43b8a84230c243dbcc74e157f4c3f8ef3891d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Skip tests that terminate threads under ASANVolker Hilsheimer2022-06-191-0/+16
| | | | | | | | | | | | | | | Thread termination might prevent stack unwinding, which then generates ASAN errors such as ERROR: AddressSanitizer: stack-buffer-underflow on address 0x7f3c1d7858b0 at pc 0x7f3c243d8918 bp 0x7f3c1d7857f0 sp 0x7f3c1d7857e8 Skip such tests so that we can enable blocking CI runs under ASAN. Fixes: QTBUG-104421 Pick-to: 6.4 6.3 Change-Id: I169235a12190e3f72525cddfe1a44a4bee19eca1 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Long live the ICU-based QStringConverter interface!Fabian Kosmale2022-06-193-2/+280
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for additional codecs to QStringConverter when ICU is available. We store the converter in the state (d[0]), and its canonical name in d[1]. We need the name there, as in the clear function we close the UConverter, and set the pointer to null. Consequently, the actual conversion functions might need to re-open the converter again. The advantage of this approach is that clear is used in the destructor of State, and with this approach we properly clean up the state. There is however a disadvantage: The clear function was so far also used for resetting the state when QStringConverter::resetState . Discarding the whole Uconverter for that is however rather costly. For that reason we modify resetState to call a new function, State::reset. For existing converters, it behaves the same as clear; for the ICU based converter, we call the more efficient ucnv_reset. Code compiled against Qt 6.4 can benefit from this more efficient version; code compiled against older Qt versions will continue to work, as the conversion functions can just recretate the converter from the name. We can distinguish between ICU and non-ICU converters by checking if the UsesIcu flag is set. QStringConverter::name is changed to return the name stored in d[1]. The interface of the ICU converter has a dummy name, so code using the old name function from QT < 6.4 still returns something, namely a message asking the user to recompile. The function is moved out of line, as we need to check for the private ICU feature, and want to avoid having that check in the public header. As the QStringConverter ctor taking a name now can allocate memory, it can no longer be noexcept. Removing the noexceptness is safe, as it was only added after Qt 6.3. Note that we cannot extend the API consuming or returning Encoding, as we use Encoding values to index into an array of converter interfaces in inline API. Further API to support getting an ICU converter for HTML will be added in a future commit. Currently, the code depending on ICU is enabled at compile time if ICU is found. However, in the future it could be moved into a plugin to avoid a hard dependency on ICU in Core. [ChangeLog][Corelib][Text] QStringConverter and API using it now supports more text codecs if Qt is compiled with ICU support. Fixes: QTBUG-103375 Change-Id: I7afb92fc68ef994179ebc7a3aa73beebb1386204 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Endian: Remove old special integer bitfieldsUlf Hermann2022-06-161-29/+0
| | | | | | | | | | | | | | The only way to use them was to put them in a union and then write all the members of the union to set the various bit ranges. As only one member of a union can be active at any time, the compiler is free to optimize those writes away, though. This has started happening in the wild now. As we have a replacement, we can remove the old and broken code now. Task-number: QTBUG-99545 Change-Id: I90718ec06662258d1c15220f54da9eed2186c5a5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringConverter: fix use-after-free in the stack in the testThiago Macieira2022-06-151-7/+11
| | | | | | | | | Detected by ASan. Introduced by aef27c5aa2f43e8e34970168dfc517062cc87db8 Pick-to: 6.3 6.4 Fixes: QTBUG-104261 Change-Id: Id0fb9ab0089845ee8843fffd16f88bdeb4f42c7c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Increase timeout of slow test for ASAN-enabled buildDimitrios Apostolou2022-06-151-0/+4
| | | | | Change-Id: I47b6e7e1462c1af7d41677bfe7bb0f78430f72d1 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Increase timeout of slow test for ASAN-enabled buildDimitrios Apostolou2022-06-151-0/+4
| | | | | Change-Id: Iea0802220701501f18822a5eb1f1b0c22f62e705 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-151-1/+1
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Revert "qxp::function_ref: drop use of q23::invoke_r"Marc Mutz2022-06-141-0/+40
| | | | | | | | | | | | | | | | | | | | This reverts commit b9cce12e76796962e5e5ad0d5408370af56af459, which broke function_ref<void(int)> f = [](int i) { return i; }; ie. swallowing of return types. We could maybe implement the same without invoke_r, with the same manual if-constexpr that invoke_r has, but it would be a pointless duplication across the two thunks we have, so just use invoke_r. Add tests. Pick-to: 6.4 Task-number: QTBUG-103739 Change-Id: I6034f05d813c06a25e8058ded5b6b62f3ca858b4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QResourceManager: extend the test to cover open filesMarc Mutz2022-06-141-0/+9
| | | | | | | | | ... when unregistering. Task-number: QTBUG-86088 Change-Id: I11112142ef1d8c4b269089a0a82ca06a5e434f7e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io>
* tst_QAnyStringView: explicitly check the spaceship operatorMarc Mutz2022-06-141-0/+31
| | | | | | | | | | | | | | | We implicitly checked it, because, in C++20 builds, the non-equality relational operators are synthesized from it by the compiler, and we test those, but we didn't check that <=> returns strong_ordering. We now do. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-104108 Change-Id: Ieb19a2d4cb2d600d884f4e2e89e98c6187e23872 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Windows: fix DeferredDelete events processing on QThread::terminate()Vladimir Belyavsky2022-06-101-0/+78
| | | | | | | | | | | | On finishing/terminating a thread, when processing posted events, we need to consider QThread's own data instead of caller thread's data. Otherwise we can get into unexpected situations such as double destruction of an object, premature destruction, etc. Fixes: QTBUG-103922 Pick-to: 6.4 6.3 6.3.1 6.2 5.15 Change-Id: Idf77221ebbaa0b150ee2d0c296b51829ae8dc30e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qfile: skip trash bin test on webOSJanne Juntunen2022-06-071-2/+2
| | | | | | | | | | Skipping moveToTrash() test is needed because WebOS does not implement a trash bin directory. Fixes: QTBUG-104053 Pick-to: 6.4 Change-Id: Id1d1595eb401d8ef3a403c915d95be1cd75368d2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QTestLib: rework QTest::compare_helper()Ivan Solovev2022-06-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QTestLib] QCOMPARE now evaluates toString() on its arguments lazily, speeding up the general case where the comparison doesn't fail. This is true for the QCOMPARE functionality provided by Qt. If you specialized qCompare() for your own types, then you need to change its implementation in line with Qt's own qCompare() specializations in order to enable this feature. [ChangeLog][QTestLib] QCOMPARE calls with nullptr argument(s) will now print the actual and expected values upon failure. Previously it was not like that because of the compareHelper() overload in qtestresult.cpp that treated the presence of nullptr-arguments as a reason to ignore formatFailMessage() call. New implementation does not have this check, and correctly executes formatFailMessage() for all arguments. Note that the qCompare() overloads that call QTestResult::compare() internally were not affected by this patch, because they already defer toString() invocation until the comparison fails. Some numbers, collected against shared release developer build. I checked how this change affects the test execution. The idea was to pick some tests for types that do not have a specific QTestResult::compare overload, so I picked a couple of QByteArray tests. The comparison is done by running a test 10 times and taking the average execution duration, as reported in the log. tst_qbytearrayapisymmetry: Before: 15.6 ms After: 14.2 ms tst_qbytearray: Before: 41 ms After: 36 ms The benefit is around 9% and 12% respectively. Fixes: QTBUG-98874 Change-Id: I7d59ddc760168b15974e7720930f629fb34efa13 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* tst_QStringApiSymmetry: use QCOMPARE_EQ instead of QCOMPAREIvan Solovev2022-06-031-168/+168
| | | | | | | | | | | | | | | | | | | | This allows to defer the toString() invocation until it is really needed, and so allows to speed-up the test execution. I was testing a release shared developer build, running tst_QStringApiSymmetry 10 times before the change, and 10 times after the change, and then taking the average execution duration, as reported in the log. Before the change (using QCOMPARE): 51ms After the change (using QCOMPARE_EQ): 45ms As we see from the results, the benefit is around 10%. Task-number: QTBUG-98873 Task-number: QTBUG-98874 Change-Id: Ifcfbcca1f2c1eaf82c7f1a9098fa1512a269cbf8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* tst_QUrlQuery: improve formatting of lists of pairs of stringsEdward Welbourne2022-06-031-30/+18
| | | | | | | | | | | | | | | | | | The compare() implementation made its actual and expected seem to have different types (using a typedef name for one, when the other was of the type that expands to) and the formatter it used was needlessly clunky. Use modern string literals and package a repeated null-or-quoted representation as a lambda, inline the resulting simplified prettyElement() into prettyPair(), which can now just take a pair rather than an iterator. Short-cut the empty list so that the comma-joined accumulation could initialize with the first entry and loop over the rest, always joining with a comma. Undo commit f776595cc10aaafc7162f382a8fa11afffb0e708's mistaken update to the copyright header and update correctly. Change-Id: I99258dafa01e79f9ec384d9b375a59376eb7fb53 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Endian: Allow special bitfield union fields to cover the whole storageUlf Hermann2022-06-021-1/+11
| | | | | | | | This requires a different computation of the mask since we can't shift out of the storage type. Change-Id: Ife85ca3e0c5ca47f06988a397cc2f8a7e28ad0fe Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Short live qxp::function_ref!Marc Mutz2022-06-024-0/+243
| | | | | | | | | | | | | | | This is an implementation of function_ref, which has been proposed for inclusion into C++23, but has not been accepted, yet, which is why we place it in namespace qxp (for eXPerimental) instead of q23. The implementation is based on wg21.link/P0792r9, which, at the time of writing, is the latest revision of the paper. It will be used in both QTestLib and qmldom. Fixes: QTBUG-103739 Change-Id: I52723eca28f7ac02ce7ce51928361d81ae5c92b1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Long live QAtomicScopedValueRollback (private API)!Marc Mutz2022-05-315-3/+169
| | | | | | | | | | | | | | | | | | | | | | | | | QScopedValueRollback has a few users that apply it on QAtomicInt, which happens to work as QAtomicInt is copy-constructible and its ctors are implicit. But that's of course nonsense. We don't need to store the oldValue in an atomic, nor do we need to pass the new value into the ctor as an atomic. So, add a QAtomicScopedValueRollback which works on std::atomic as well as the Qt atomics, but distinguishes between the reference (which is atomic) and the value (which isn't), and use it in one of the users, tst_QList. Keep it private until we know whether there's an actual need for this. The test is a copy of tst_qscopedvaluefallback, so the occasional oddity (like atomic op*=) should be ignored. Task-number: QTBUG-103835 Change-Id: I3c05b3e51f465698657a02ca5521ed465386e9a6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qglobal.h: use the GCC attribute for nothrow in C modeThiago Macieira2022-05-271-1/+2
| | | | | | | There's exactly one use in Qt: the qVersion() function. Change-Id: Ieb9a2aa1ea914b1b956bfffd16eff4b3b9e2119a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add compile-time generation of JNI class namesVolker Hilsheimer2022-05-273-4/+32
| | | | | | | | | | | | | | | | | | | | | As with method signatures, register class names using template function specialization in the QtJniTypes namespace, and then declare C++ types as JNI classes with a class name string. Such classes implicitly get registered as JNI types as well. Add a QJniObject construct method (since C++ constructors that are templates cannot be explicitly instantiated with a type), and a QJniEnvironment::findClass overload. Add test coverage, also for the recently added macros for native methods. As a drive-by, change the name of the Q_JNI_DECLARE_NATIVE_METHOD macro to Q_DECLARE_JNI_NATIVE_METHOD for consistency. Change-Id: Ic19562d78da726f202b3bdf4e9354e8ad24d8bd9 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QStringConverter: Do not crash if invalidFabian Kosmale2022-05-251-0/+56
| | | | | | | | | | | Attempting to use an invalid QStringConverter would so far have resulted in a crash, as we would dereference the null iface pointer. Fix this by inserting adequate checks, and ensure that hasError returns true if we attempt to en/decode with an invalid converter. Pick-to: 6.2 6.3 Change-Id: Icf74bb88cd8c95685481cc0bd512da99b62f33e6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_qtextboundaryfinder: Remove full copies of data filesIevgenii Meshcheriakov2022-05-243-9541/+0
| | | | | | | | | | There are no commented out test cases remaining, so the normal test vectors are identical to full test vectors. Fixes: QTBUG-97537 Pick-to: 6.3 Change-Id: I987f178f192e1c8e2d998d36499fdce84f237e77 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix line breaking before open parenthesesIevgenii Meshcheriakov2022-05-241-24/+24
| | | | | | | | | | | | | | UAX #14, revision 45 (Unicode 13) has changed rule LB30 to only trigger if the open parentheses is non-wide: (AL | HL | NU) × [OP-[\p{ea=F}\p{ea=W}\p{ea=H}]] This fixes the remaining 24 line break tests. Task-number: QTBUG-97537 Pick-to: 6.3 Change-Id: I9870588c04bf0f6ae0a98289739bef8490f67f69 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix line breaking for potential emojisIevgenii Meshcheriakov2022-05-241-1/+1
| | | | | | | | | | | | | | Implement part of LB30b introduced by UAX #14, revision 47 (Unicode 14.0.0): [\p{Extended_Pictographic}&\p{Cn}] × EM This fixes one line breaking test. Task-number: QTBUG-97537 Pick-to: 6.3 Change-Id: I3fd2372a057b7391d8846e9c146f69a54686ea61 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix interactions of WB3d and WB4 rulesIevgenii Meshcheriakov2022-05-241-1/+1
| | | | | | | | | | | Word breaking rule WB3d should not be affected by WB4. This fixes the remaining word break test. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I99aee831d7c54fafcd2a9d526a3e078b12c5bfad Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Handle WB3c word break ruleIevgenii Meshcheriakov2022-05-241-9/+9
| | | | | | | | | | | | | | | Adjust handling of WB3c rule to UAX #29, revision 33 (Unicode 11.0.0). The rule reads: ZWJ × \p{Extended_Pictographic} This fixes 9 word break tests. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I818d4048828e6663d5c090aa372d83f5099fdffe Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Adjust properties of WSegSpace word break classIevgenii Meshcheriakov2022-05-242-37/+37
| | | | | | | | | | | | | | | | | | Disable break between sequences of WSegSpace characters (rule WB3d, introduced in UAX #29, version 33, Unicode 11.0.0). Also disable breaks between WSegSpace and (Extend | Format | ZWJ) due to rule WB4. Adjust "words4" test to take the above changes into account (space character belongs to WSegSpace). Mention the full class name in a comment inside the word break table. This fixes 34 word break tests. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I7dfe8367e45c86913bb7d7fe2adb053711978487 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix handling of LB22 line break ruleIevgenii Meshcheriakov2022-05-241-28/+28
| | | | | | | | | | | | | | This rule was simplified in version UTS #14 version 45 (Unicode 13.0.0) to read: × IN Re-enabled 28 fixed line break tests. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I1c5565a8c1633428c22379917215d4e424ff0055 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix handling of ZWJ for line breaksIevgenii Meshcheriakov2022-05-241-9/+9
| | | | | | | | | | | | | | | Adjust implementation of rule LB8a of UAX #14. The rule was changed in version 41 (corresponding to Unicode 11.0.0): ZWJ × (ID | EB | EM) ⇒ ZWJ × Fixing this rule fixes 9 line break tests. Those are re-enabled. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I1570719590a46ae28c98ed7d5053e72b12915db7 Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_QStringConverter: roll up independent tests to rows in othersThiago Macieira2022-05-231-59/+6
| | | | | | | | | Simplifies the test a little. Pick-to: 6.3 Change-Id: I77c8221eb2824c369feffffd16f0a7fc44215aaf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_QStringConverter: implement the TODO of testing with flagsThiago Macieira2022-05-231-4/+81
| | | | | | Pick-to: 6.3 Change-Id: I77c8221eb2824c369feffffd16f0a7e428b23fb6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_QStringConverter: improve the char-by-char UTF-8 testingThiago Macieira2022-05-233-63/+168
| | | | | | | | | | | | | | The utf8.txt file was only 21 bytes and contained exactly two non-ASCII characters. It wasn't very good. This commit brings back the UTF-8 test rows that existed before commit 18ec53156ee704fdb4977436fccfdc85333e614b deleted tst_Utf8. There's a lot of overlap with some of the other rows in this test, though. Pick-to: 6.2 6.3 Change-Id: I77c8221eb2824c369feffffd16f094619b69faef Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QStringConverter: use the QUtf8 codec when Windows is using UTF-8Thiago Macieira2022-05-231-14/+50
| | | | | | | | | | | | | | | | | | | | The QLocal8Bit implementation assumes that there's at most one continuation byte -- that is, that all codecs are either Single or Double Byte Character Sets (SBCS or DBCS). It appears to be the case for all Windows default codepages, except for CP_UTF8, which is an opt-in anyway. Instead of fixing our codec, let's just use the optimized UTF-8 implementation. [ChangeLog][Windows] Fixed support for using Qt applications with UTF-8 as the system codepage or by enabling that in the application's manifest. Discussed-on: https://lists.qt-project.org/pipermail/interest/2022-May/038241.html Pick-to: 6.2 6.3 Change-Id: I77c8221eb2824c369feffffd16f0912550a98049 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Android: Enable building of the QLocale test caseVolker Hilsheimer2022-05-231-4/+1
| | | | | | | | | | | Amends 2a893db48017a850044156442b93d935c78e941d, which changed the #ifdef'ery but didn't actually enable the building of the test on Android. Task-number: QTBUG-87414 Pick-to: 6.3 6.2 Change-Id: Id944dd3023da40ecbf4b8a324784409a63f94aec Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Compile-time generate a JNINativeMethod from a C functionVolker Hilsheimer2022-05-231-14/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a template function that allows us to get the method signature string from a free function, which are used as native callbacks methods from Java. Provide a macro that defines a signature object, and a JNINativeMethod object based on it, in an internal namespace so that we don't pollute the namespace with generated names. Add another macro to get the generated JNINativeMethod object based on the free function name. Lastly, add overloads to QJniEnvironment::registerNativeMethods that take a std::initializer_list of JNINativeMethods. We can now declare a free function to be a JNI native method: static bool callbackFromJava(JNIEnv *e, jobject /*thiz*/, jstring p1) { // ... } Q_JNI_DECLARE_NATIVE_METHOD(callbackFromJava); and register it with the JNI environment like this: QJniEnvironment jni; jni.registerNativeMethods(clazz, { Q_JNI_NATIVE_METHOD(callbackFromJava) }); removing a significant amount of boiler plate code. Change-Id: Ie4007b24125879fed3dae1f4d232b4aa95999b44 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QMetaType: disable conversion from smart pointer<const QObject>Giuseppe D'Angelo2022-05-211-0/+17
| | | | | | | | | | | | | | | | | | | | | QMetaType can register a converter from a smart pointer class to QObject *. The code tries to do so even if the smart pointer is actually holding a pointer to a _const_ QObject (e.g. shared_ptr<const QObject>), causing a compile error: ../src/qt5/qtbase/build/include/QtCore/../../../src/corelib/kernel/qmetatype.h:1208:32: error: invalid conversion from ‘const QObject*’ to ‘QObject*’ [-fpermissive] 1208 | return p.operator->(); | ~~~~~~~~~~~~^~ | | | const QObject* Disable the conversion if indeed the source is const qualified. Change-Id: I9e9bc5992f74131e5cfd6ece9b83d4f26d370e92 Fixes: QTBUG-103741 Pick-to: 6.2 6.3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qglobal.h: #include <stdbool.h> in C modeThiago Macieira2022-05-181-9/+0
| | | | | | | It's C99 and we require C11. Change-Id: Ieb9a2aa1ea914b1b956bfffd16eff4556b99f976 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix return value of qGlobalPostedEventsCount()Marc Mutz2022-05-181-11/+6
| | | | | | | | | | | | The unsigned return value was very un-Qt-ish, and, indeed, tst_QCoreApplication just stored the result in ints. Port to qsizetype, being the type of the expression that the function calculates. Task-number: QTBUG-103532 Change-Id: I95a81a686439b0686faad7a430adeaab66dc9e8d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make qGlobalPostedEventsCount() auto-test-exported-onlyMarc Mutz2022-05-182-0/+4
| | | | | | | | The only in-tree user outside QtCore is tst_QCoreApplication, guard the (single) test function there with QT_BUILD_INTERNAL. Change-Id: Ibc87ba76f2135cd8283acd75318f80a95e4b5c45 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove manual declarations of qGlobalPostedEventsCount()Marc Mutz2022-05-182-8/+1
| | | | | | | | | ... in favor of including qabstracteventdispatcher_p.h, where needed. Keeps the code DRY. Change-Id: I5bee2e653cb29ffac2601ff03c952a4b3adbdb9c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Guard the use of QWinEventNotifier in testsAlexey Edelev2022-05-171-0/+2
| | | | | | | | | Add the Q_OS_WIN32 guard for the include of QWinEventNotifier. Change-Id: I7824b2ee236a370c83fd85a2f594a39cf36b36e6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>