summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
Commit message (Collapse)AuthorAgeFilesLines
* Make QFutureWatcher::isFinished() consistent with the watched QFutureSona Kurazyan3 days1-25/+50
| | | | | | | | | | | | | | | | | | | | | All the getters of QFutureWatcher are consistent with the getters of the corresponding QFuture, except for the isFinished() method, which returns 'true' only after the finished() signal is delivered. This behavior might be unintuitive for the users. In particular, isFinished() returns 'false', even if it's called immediately after waitForFinished(). [ChangeLog][QtCore][QFutureWatcher][Important Behavior Changes] The QFutureWatcher::isFinished() method now indicates if the related QFuture is finished, instead of indicating if the finished() signal was delivered. This makes it consistent with the future that is being watched. Fixes: QTBUG-91048 Pick-to: 6.1 6.2 Change-Id: I6ae9b882b23e06198a82c95b026491bd480b3bf0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QSet: extend testsIvan Solovev4 days1-5/+172
| | | | | | | | | | | Extend tests to explicitly check the behavior of empty default-constructed container. Also add some missing tests to increase the code coverage. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: Ie57b5d13fad9a846c29c87be4985c87e69bba305 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QString: extend unit testsIvan Solovev4 days1-74/+495
| | | | | | | | | | | | | | | | This patch introduces some test improvements to check the calls of different methods on an empty default-constructed string. Apart from that, some other tests are added to extend code coverage. As a drive-by: * fix int -> qsizetype in the test data * fix int -> enum in the test data Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: I159473b7f5dcbea1bdaf2966979e066296351208 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QFileSelector: Preserve path to root directoryFabian Kosmale5 days1-0/+3
| | | | | | | | | | | | | | | | While QFileSelector is documented to work on files, select accepts arbitrary URLs. Moreover, the QML engine can end up intercepting arbitrary (user provided) URLs, including to directories. Prior to this change, passing "file:///" or "/" to the function would break: We would temporarily get a "//" path, which is invalid, and thus we would return an invalid in the end. Prevent this by only appending a slash to the path when it doesn't have one. Fixes: QTBUG-85410 Pick-to: 6.2 Change-Id: I1d2807a9d225df611c3a5e871e3c1d90a6a25953 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* emit layoutAboutToBeChanged timelyLuca Beldi5 days6-2/+221
| | | | | | | | | | | layoutAboutToBeChanged must be called before persistentIndexList as the user might create persistent indexes as a response to the signal Fixes: QTBUG-93466 Pick-to: 6.2 5.15 Change-Id: I73c24501f536ef9b6092c3374821497f0a8f0de4 Reviewed-by: David Faure <david.faure@kdab.com>
* QHash, QMultiHash: extend testsIvan Solovev6 days1-12/+532
| | | | | | | | | | | | | | Extend tests to explicitly check the behavior of empty default-constructed containers. Also add some missing tests for the existing methods (mostly for QMultiHash) and correct some end()s to cend()s in comparisons. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: Ic9e1b86ef67f6bca2751a65a8589b2f7e0ebb5ea Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Skip tst_qthreadonce test on QEMUSona Kurazyan6 days2-0/+11
| | | | | | | | | | | | The test causes frequent failures in the CI. Couldn't reproduce on actual arm64 hardware, so it's likely to be a QEMU bug. From the available logs it seems that all the test cases are flaky (there's a failure even after cleanupTestCase() is called), so disable all of them. Fixes: QTBUG-94737 Pick-to: 6.1 6.2 Change-Id: I783ec2179ba779a2c8d93351a78e8472a4f7a907 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QList: extend testsIvan Solovev6 days1-13/+428
| | | | | | | | | | | | | | This patch mostly introduces some test improvements to check the calls of different methods on an empty default-constructed container. Apart from that some other tests are added to extend test coverage. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: If2bc96158462292bbdf8504942141af94568c729 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* tst_qlocale: Add tests for parsing Chakma date and time stringsIevgenii Meshcheriakov6 days1-0/+16
| | | | | | | | | | | | Add tests to verify parser behavior with locales that use code points outside of Unicode BMP to represent dates. ccp is used for this because Chakma language uses code points outside of BMP for both letters and digits. QDateTimeParser currently is not able to handle this locale correctly, so the tests are marked as expected failures. Task-number: QTBUG-87111 Change-Id: I1cc6fe7304b47f19950ae0ad3179c4ffa946adb3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use member function instead of template function to resolve native interfaceTor Arne Vestbø9 days1-8/+10
| | | | | | | | | | | | | | The use of a freestanding function is not needed now that the name doesn't alias the nativeInterface accessor function, and was just adding complexity to the machinery. People not familiar with the code will have an easier time following the flow through the helper member function, and we no longer need to declare our own export macros. Pick-to: 6.2 Change-Id: I17530b7e89939cfc19ab8ffaa076b7129ae02dcf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMultiMap: extend unit testsIvan Solovev10 days1-143/+581
| | | | | | | | | | | | | Extend tests to explicitly check the behavior of empty default-constructed container. Also add some missing tests to increase the code coverage. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: Ib3c3f5bcb967cd1031cb24ffceaa77a146212ffd Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Consistent handling of disabled items in QItemSelectionModelAndreas Buhr11 days1-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | In QItemSelectionModel, items which are disabled or marked as not selectable should not be considered as selected. But this was not handled consistently. The following methods considered only items which are enabled and marked selectable: selectedIndexes(), rowIntersectsSelection(), and columnIntersectsSelection(). The following methods considered only items which are marked selectable, but did not check whether they are enabled: selectedRows(), selectedColumns(), isRowSelected(), isColumnSelected(), isSelected(). Finally there is hasSelection(), which did not check for enabled nor for selectable. This patch introduces consistent behavior. All methods check both whether the items are enabled and whether they are selectable now. [ChangeLog][QtCore][QItemSelectionModel][Important Behavior Changes] All methods in QItemSelectionModel now consider only items which are marked as enabled and selectable as part of the selection. Fixes: QTBUG-93829 Pick-to: 6.2 Change-Id: I4725243ea6b0db4f289ce34ada22c7a9d3282713 Reviewed-by: David Faure <david.faure@kdab.com>
* QCryptographicHash: use a std::array to hold result (was: QByteArray)Marc Mutz11 days1-6/+6
| | | | | | | | | | | | | | | | | | | | | | The maximum size for a hash result is 64 atm. Even if, and esp when, we'll get to 128 and 256 bytes in the future, there's no reason to use dynamic memory, because the sizes will always be statically known. So use, essentially, a std::array<char, 64> to hold the result internally. Add a bit of convenience API on top to limit impact on the rest of the code and add a few static_asserts that ensure this is large enough. Then give users access to the internal buffer by adding QByteArrayView resultView() const noexcept. The documentation snippet is taken from QString::data(), suitably adjusted. Use resultView() in a few places instead of result(). [ChangeLog][QtCore][QCryptographicHash] Changed to use a statically-sized buffer internally. Added resultView() to access it. Change-Id: I96c35e55acacbe94529446d720c18325273ffd2f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QCryptographicHash test: remove the moreThan4GiBOfData(SHA512) check from the CIMarc Mutz11 days1-2/+5
| | | | | | | | | | It timed out the other day on the CI. Even the SHA-1 check took 137s (with a 300s timeout). Skip the SHA-512 test on the CI, but keep it for manual runs. Pick-to: 6.1 6.2 Change-Id: I49792ac9bcab6512e1803f66cd986b2830e634c0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Improve error reporting when requesting unsupported native interfaceTor Arne Vestbø11 days1-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By switching out the static_assert for an enable_if we end up producing a clearer error, at the call site: /qt/qtbase/examples/gui/rasterwindow/main.cpp:69:9: error: no matching member function for call to 'nativeInterface' app.nativeInterface<QNativeInterface::QCocoaGLContext>(); ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /qt/qtbase/src/gui/kernel/qguiapplication.h:176:5: note: candidate template ignored: requirement 'NativeInterface<QNativeInterface::QCocoaGLContext>::isCompatibleWith<QGuiApplication>' was not satisfied [with NativeInterface = QNativeInterface::QCocoaGLContext, TypeInfo = QNativeInterface::Private::NativeInterface<QNativeInterface::QCocoaGLContext>, BaseType = QGuiApplication] QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QGuiApplication) ^ By using SFINAE for the TypeInfo we can also ensure that it works for types that are not native interfaces, such as if the user tries to call nativeInterface<QString>(). Since we can no longer use decltype(*this) to resolve the base type we need to change QT_DECLARE_NATIVE_INTERFACE_ACCESSOR to take the type as an argument, as we do for other QT_DECLARE_FOO macros. Pick-to: 6.2 Change-Id: Ie3f7e01ab7c3eb3dcc2ef730834f268bb9e81e0c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add test for native interface machineryTor Arne Vestbø11 days3-0/+129
| | | | | | Pick-to: 6.2 Change-Id: I76acd54039dcc7c662ca7a6e859f21d75dcf4dc4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: Support converting any QFuture<T> to QFuture<void>Arno Rehn11 days1-0/+18
| | | | | | | | | | | | | | | | QMetaType now implicitly knows how to convert any QFuture<T> to QFuture<void> without needing to manually register a converter function. QtWebChannel will make use of this to transparently support QFuture<T> return types. [ChangeLog][QtCore][QMetaType] QMetaType now supports converting any QFuture<T> to QFuture<void>. Task-number: QTBUG-92903 Change-Id: Ied7e71be37c346cc3d2c274ffb0d91a6821ab4d4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMap: extend unit testsIvan Solovev11 days1-4/+301
| | | | | | | | | | | | Extend tests to explicitly check the behavior of empty default-constructed container. Also add some missing tests to increase the code coverage. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: I5b418265fc7cb3e56e44782be7704d642923a8e9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QTranslator: Fix loading of meta catalogs from absolute .qm pathKai Köhne11 days1-0/+14
| | | | | | | | | | | | | | | In case of QTranslator translator; translator.load("somedir/file.qm"); and file.qm being a meta catalog file, the sub-catalogs in somedir couldn't be located, unless "somedir" was set as second argument. Pick-to: 5.15 6.1 6.2 Fixes: QTBUG-95013 Change-Id: I06103244ce2ff9800c2c64cb0c17f9bc7ef0e8de Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* tst_qtranslator: Simplify extraction of test dataKai Köhne11 days4-45/+5
| | | | | | | | | This makes it easier to further extend the test. The overhead this causes is negligible. Pick-to: 5.15 6.1 6.2 Change-Id: I42941879f55337268bb2914e122a5f573ab7e6f9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QDuplicateTracker: accept the number of elements to reserve as a ctor argumentMarc Mutz12 days1-2/+1
| | | | | | | | | | | | This prevents us from first reserve()ing Prealloc elements, and then possibly reserve()ing a larger number, which leaves the first bucket list's memory unused. Consequently, deprecate reserve(). Change-Id: Ifc0a5a021097f4589557e7b5e45d9d0892797ade Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QObject: optimize the common case of findChildren(QString())Marc Mutz13 days1-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Outside tests, all in-tree callers of QObject::findChildren() pass no name to match, and in my experience that is also true for the vast majority of out-of-tree users. Avoid the temporary QString creation in the caller and the repeated QString::isNull() checks in the implementation by overloading findChildren() without a name argument and checking for name.isNull() only once, forking off into separate helper functions. Adjust in-tree callers that used an explicit `QString()` argument in order to pass options, which goes to show that `name` should never have been the first argument of findChilden() in the first place, even though I appreciate the symmetry with findChild() (the use-cases of which, however, are radically different). Change a `findChildren().size() == 0` call found while scanning for findChildren() calls to `!findChild()` as a drive-by. Modernize loops in the various qt_qFindChild{,ren}_helper() overloads to match how the new code looks. [ChangeLog][QtCore][QObject] Added findChildren() overload taking no name (thus optimizing this common case). Change-Id: Ifc56e5438023d079b40c67f11ae274a3e128ad5e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* macOS: Don't mangle QByteArray settings with @ prefix by decoding as UTF-8Tor Arne Vestbø13 days1-0/+4
| | | | | | | | | | | | | | | | | | QSettings encodes QVariants as @Type(data) strings. If that data contains a null-byte, we write the string as UTF-8 encoded CFData. When reading it back we look for a @ prefix, and then pass it as UTF-8 through stringToVariant. The problem arises then the user writes raw QByteArrays with a @ prefix. We can detect this situation by checking the result of stringToVariant, and if it's just a simple conversion of the string into a QVariant, we know that stringToVariant hit its fallback path due to not finding any embedded variants. If that's the case, we return the raw bytes as a QByteArray. Pick-to: 6.2 6.1 5.15 5.12 Change-Id: I4ac5c35d0a6890ebea983b9aca0a3a36b0143de2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CMake: Remove the usage of QT_SOURCE_TREE from testsJoerg Bornemann14 days3-4/+3
| | | | | | | | | | | | | | The ${QT_SOURCE_TREE}/src/network include paths of several tests are apparently not needed anymore. Remove those. tst_qfilesystementry and tst_qfreelist are the only tests that actually need to reference files in qtbase's source tree. Simply use the paths relative to the project file. Task-number: QTBUG-88090 Change-Id: Ic6f341e001338c1b07dce6e58316245bc9560c5e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add QFutureInterfaceBase::get() to retrieve internals of QFutureArno Rehn14 days1-0/+11
| | | | | | | | | | | | For generic interop with other parts of Qt, we need to be able to extract the type-erased internal storage of QFuture<T>. In particular, QtWebChannel needs this to transparently support QFuture<T> as a method return type. Task-number: QTBUG-92903 Change-Id: I763f054656b8810d58720262d364baf42c47eb37 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* tst_QSharedPointer: fix -Wsuggest-override warningsMarc Mutz2021-07-091-7/+7
| | | | | Change-Id: I1aec8d342e8e5e16b39a62c8a0c885e2915feaf9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* tst_QFile: fix GCC -Wignored-qualifiersMarc Mutz2021-07-091-2/+5
| | | | | | | | | | | | The decltype() of a const auto variable will be const T, for some T. GCC warns that in the static_cast, said const is ignored. Fix by not casting, but declaring a variable of fitting type. Add a scope so the next reader doesn't have to go hunting for further uses of 'readResult' or, now, 'expected'. Change-Id: Iebc828a522810c6f2514fb3542d8c76c755ec7a5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix QMultiHash::keys(const T&) overloadIvan Solovev2021-07-081-8/+57
| | | | | | | | | | | | The method was never tested, but it failed to compile after QMultiHash was introduced as a separate class in 6.0. This patch fixes it and adds some unit-tests to cover the case. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: I5dd989d4775efc6a9bb13c5ed1d892e499d95dc2 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QMultiHash::find - prevent detaching shared nullIvan Solovev2021-07-081-0/+15
| | | | | | | | | | | | | Do not detach when find(key, value) is called on an empty QMultiHash. As a drive-by: fix return value for QMultiHash::remove() in case of empty QMultiHash. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: I1e32f359e7ee9ce8403dae79d02e0b88a20ec4a5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_QCryptographicHash: simplify the creation of a large QBAMarc Mutz2021-07-071-4/+1
| | | | | | | | | Use the ctor instead of appending 1'000'000 chars. Introduce C++14 digit separators as a drive-by. Change-Id: Icdbef3173f42d12ae2226b8556f9b1519e594adc Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QProperty: Downgrade assert in noSelfDependencies to warningFabian Kosmale2021-07-071-0/+9
| | | | | | | | | | | | | | | We call evaluateRecursive_inline in setBinding, which in turns runs the noSelfDependecies check. However, creating a binding resuting in a binding loop must not crash, but instead result in the binding entering an error state. To prevent a crash caused by the assert in debug builds of Qt, we replace the assert with a warning for now. A better approach in the future would be to ensure that we only run the check in cases where we are sure that a self-dependency is really a fatal error. Pick-to: 6.2 Change-Id: I58158864ed81fa907132a4e7d6667c9b529e7e64 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* QCryptographicHash: port addData() to QByteArrayViewMarc Mutz2021-07-061-7/+7
| | | | | | | | | | | | | Incl. the static hash() function. Remove the QByteArray versions from the API, but not the ABI. Adapt some callers. [ChangeLog][QtCore][QCryptographicHash] Replaced QByteArray with QByteArrayView in addData() and static hash() functions. Change-Id: Ia0e9bf726276305e05894d323d76a29e985f39eb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QCryptographicHash: don't present the same data over and over againMarc Mutz2021-07-061-0/+84
| | | | | | | | | | | | | | | | | | Need to decrement 'remaining' (check), but also increment data (meep). Testing is a bit complicated, as most algorithms are just too slow to fit into the 5min QTestLib timeout. Picked the fast ones and Sha512 (which completes here in < 17s, with threads), at least. Amends e12577b56396cca0df05f88f8787706a3a12c82d. [ChangeLog][QtCore][QCryptographicHash] Fixed a bug where presenting more than 4GiB in a single addData() call would calculate the wrong result(). Pick-to: 6.1 6.2 Change-Id: Ic72916ebc33ba087d58225af6d8240e46e41f434 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_QCryptographicHash: make hashLength() data-drivenMarc Mutz2021-07-051-3/+12
| | | | | | | Pick-to: 6.1 6.2 Change-Id: I44bf73e15b53b8d93d116f4114bc667c4c94b7b4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Run tst_QIODevice::skip() on random-access deviceAlex Trotsenko2021-07-031-3/+4
| | | | | | | | Due to mistake in data it was missed for testing. Pick-to: 6.2 Change-Id: I4dcd6fd90fd501e4cc941c07efcf9439ba6acf30 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Fix tst_qmessagehandler::formatLogMessage() test on AndroidAssam Boudjelthia2021-07-011-0/+4
| | | | | | | | | This amends 87d8ee755bfdef8e72a122789c2e3ed382881a12. Pick-to: 6.2 Task-number: QTBUG-94708 Change-Id: Iac9b0f896ede76074504f777b65ad572dd8d6377 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* QSemaphore: add <chrono> overload of tryAcquire()Marc Mutz2021-06-301-1/+35
| | | | | | | | | | | | | | | ... and C++20 std::counting_semaphore API compatibility. [ChangeLog][QtCore][QSemaphore] tryAcquire() now optionally takes a <chrono> duration as timeout, not just int milliseconds. [ChangeLog][QtCore][QSemaphore] Added try_acquire{,_for,_until}() for C++20 std::counting_semaphore compatibility. Change-Id: I34b6b4bf57a54745d4b97349903d090c4995338a Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qglobal: fix an uninit'ed variable warningMarc Mutz2021-06-301-1/+1
| | | | | | | | | | GCC can't see through all the foreach code to determine whether the loop will execute at least once, so don't play hardballs with the compiler and initialize the variable. Change-Id: I95756a99eda497a25aa277046df9895f558758c3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qstringapisymmetry: add checks for common overload setsMarc Mutz2021-06-251-0/+106
| | | | | | | | | | | | | - QString/QStringView overloads were designed to be compatible for all possible argument types, so check that it stays that way - QString/QAnyStringView overloads have several known ambiguities that we cannot and don't want to fix, because it would make QAnyStringView less versatile, but at one should at least be able to overload QString and weak-QAnyStringView. Change-Id: I5e5ae3c96060c93bfe070f6c19213328dae9c5f9 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Expand a test that QVariant isn't null even when what it wraps isEdward Welbourne2021-06-241-4/+6
| | | | | | | Match the checks in the constructor test that are similar. Change-Id: Ifb62af09e31aac339f001f44bc30789330c85be6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QString: Respect precision when reading data for %.*s format stringUlf Hermann2021-06-221-0/+30
| | | | | | | | | | | If we disregard the precision we may read a very large string that we subsequently discard. Furthermore, people use this to read non-null-terminated strings, which randomly crashes. Pick-to: 5.15 6.1 6.2 Change-Id: Ifa255dbe71c82d3d4fb46adfef7a9dc74bd40cee Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHash: Fix erase() edge-caseMårten Nordheim2021-06-181-0/+19
| | | | | | | | | | | | | | | | | | | | | When the element you want to erase is the last element AND the next element (element 0), when rehashed, would be relocated to the last element, this leads to the state below. Which is similar to a test in tst_qhash for some seeds. auto it = hash.begin + (hash.size - 1) it = hash.erase(it) it != hash.end By forcing the iterator to increment if we were erasing the last element we always end up with a pointer which is equal to hash.end Befriend the tst_qhash class so we can set the seed to a known-bad one Pick-to: 6.2 6.1 Change-Id: Ie0b175003a2acb175ef5e3ab5a984e010f65d986 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QBindable: Use setter in setValue for QObjectCompatPropertyFabian Kosmale2021-06-171-0/+11
| | | | | | | | | | | | Directly writing to the underlying property storage has the potential of breaking all kinds of internal invariants. As we return QBindable in the public interface, we should not grant callers access to the internals of the object. Pick-to: 6.2 6.1 Change-Id: I737ff293b9d921b7de861da5ae23356c17690b78 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* Universally pass QMetaType by valueUlf Hermann2021-06-171-3/+3
| | | | | | | ... and add Qt7 TODOs where we can't because of BC. Change-Id: Idce8b677ae95231e1690ac4265dc6f06818052e7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Tidy up tst_QString::localeAwareCompare()Edward Welbourne2021-06-161-121/+262
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was suppressed unconditionally (albeit in different places and with different levels of obviousness) almost everywhere, due to inability to set the system locale in use by the implementation. Several test-cases used ISO-8859-1 encoding on Q_OS_MAC, where the tests were all suppressed anyway. A block of no_NO tests was #if 0'd out; and should, in any case, have been nb_NO. Tests of any locale but en_US were skipped on Q_OS_WIN because we can't set the locale (but including the tests of en_US tacitly assumed that's the system locale). If setlocale() failed, for ICU or DARWIN, the test was skipped; but we might as well check for this in the _data() to save repetition. The test was laboriously going through the sign cases; relocate the QString::compare() test's sign() function so that we can use it here, too, and simply QCOMPARE() signs. Introduce a TransientLocale class, copied from tst_QLocale, to take care of setting and restoring the locale using setlocale(). Change the locale name to a QByteArray so that we save having to convert it to one in order to pass it to setlocale(). Since that changed every _data() row, reformat those rows in the process - most of them were long lines. On the systems where we can't set the locale used by the function being tested, condition each block of tests in the _data() on whether LC_COLLATE looks like the locale to be tested, and report how a determined developer at least can (by repeatedly running the test with different locales set) test all the cases; and we'll attempt the ones that we can, when one of the relevant locales is in use. If that leaves us with no tests we can do, QSKIP() in the _data() to avoid an assert failure for "Test data requested, but no testdata available." Change-Id: I75709fda8827dcbe74f80c4136042054da6fcb13 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Apple: Use POSIX IPC instead of System V in sandboxed applicationsTor Arne Vestbø2021-06-161-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | System V semaphores are not supported in sandboxed applications, so when Qt is configured with App Store compliance, or the user requests POSIX IPC explicitly, we use that instead. https://developer.apple.com/library/archive/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW24 As the shared memory name limit on Apple platforms is very low, we have to skip the existing logic for naming, and instead use a truncated hash of the key. This should still be fine for avoiding any collisions in practice. An explicit check for the ENAMETOOLONG error has been added to catch any cases where they key goes beyond the allowed length. Sandboxed applications also have an extra requirement that the key must include an application group identifier. This requirement has been pushed up to the user and documented, as we don't have enough information in Qt to know which identifier to use. Both tst_QSystemSemaphore and tst_QSharedMemory work as before with both sandboxed and non-sandboxed applications, after removing some assumptions in tst_QSharedMemory about System V behavior. Fixes: QTBUG-91130 Change-Id: Iaf1edb36a5d84d69e42ec31471a48d112faa8c6a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLoggingSettingsParser: port setContent() to QStringViewMarc Mutz2021-06-161-15/+15
| | | | | | | | | | | Amends 16f927a4f1ffeff399351b625d73ac3cd7bccd51. At the time the original change was written, QStringTokenizer had not been integrated, yet. Change-Id: I83c31d816199bc48c4baea855d13cbf9eda9aaa2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Turn tst_QString::setRawData()'s QSKIP into QEXPECT_FAIL()sEdward Welbourne2021-06-151-1/+3
| | | | | | | | | | | | | In commit 287ace562ee5ddff22f7dbf4e49ae5f0520f2308, part of this test was suppressed without filing a Jira ticket (or, at least, without recording it in the QSKIP message). Since it's a known failure, it should at least be a QEXPECT_FAIL, not a QSKIP. Since only some of the subsequent parts of the test fail, I used QEXPECT_FAIL(,,Continue) on each of the failing tests. Task-number: QTBUG-94450 Change-Id: Iebc6801210c289b4502e59116e71d5901b71aa46 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Don't use APPLESS testing for QStringEdward Welbourne2021-06-151-1/+2
| | | | | | | | Its collation (and everything locale-related) is only supported during the lifetime of QApplication. Change-Id: Ide97795664d45768e66248d47c3b1da83935b0d6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix and clean up utterly confused (and confusing) transition testsEdward Welbourne2021-06-151-201/+241
| | | | | | | | | | | | | | | | | | | | | | | Various QDateTime tests relating to transitions * used a nomenclature that made them confusing to thing about; and * expected identically-initiallized variables to behave differently. The latter, naturally, lead to "expected fail" tests. Rewrote the tests to get the date-times they want to test at by means that avoid the ambiguities inherent in QDateTime's lack of a way to distinguish the two passes through the repeated hour in a fall-back (QTBUG-79923) and added commented-out tests indicating what should be true once that ambiguity is resolved. Verified the DST status is as expected in the cases where that's the correct distinction between date-times with the same date and time. Renamed various things to (hopefully) make them more intelligible. In the process, purged some leading 0s from numbers in code. Fixes: QTBUG-68936 Change-Id: Id7a348995238b70dcb81a96edb8a3fa5315f86fa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>