summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
Commit message (Collapse)AuthorAgeFilesLines
* QMetaType: Support custom unary converters with optional<To> return typeArno Rehn2022-09-271-14/+53
| | | | | | | | | | | | | | | To indicate success of a conversion, the public API has previously only supported registering member functions of the form To (From::*)(bool *). When adding custom converters for types that cannot be modified, this is usually not a possibility. As an alternative, this patch adds support for std::optional in the UnaryFunction overload of QMetaType::registerConverter. If the returned optional has no value, the conversion is considered failed. Task-number: QTBUG-92902 Change-Id: Ibac52d2cb9b5a2457081b4bebb0def1f03e3c55d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QDebug: Support standard strings and string views directlyVille Voutilainen2022-09-271-0/+256
| | | | | | | | | | [ChangeLog][QtCore][QDebug] QDebug now supports printing std::strings and std::string_views (and their wide, u16, and u32 variants) directly. Task-number: QTBUG-96878 Change-Id: I7baf4fe688bfff50580b1cee9417af13949374cc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Reduce foldCasing of the needle in Boyer-Moore QString searchesØystein Heskestad2022-09-221-1/+24
| | | | | | | | | | | | | | | | | | | | | Before searching, foldCase the first up to 256 characters, and use this buffer to compare against the haystack. If the needle is larger than the buffer, compare the rest of the needle against the rest of the haystack for every potential match. The buffer is placed on the stack and must be refolded for each search, but this change does not break the API. This is faster than the old implementation, except if the needle is long and it is found near the beginning of the haystack, or if the needle is long and it is not found in a short haystack where few comparisons are done and hence few case foldings were needed in the old implementation. Benchmarking using tst_bench_qstringtokenizer tokenize_qstring_qstring shows an improvement for the the total testcase and usually for each individual test. Fixes: QTBUG-100239 Change-Id: Ie61342eb5c19f32de3c1ba0a51dbb0db503bdf3a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QHash: Fix outdated rehash testMårten Nordheim2022-09-221-2/+2
| | | | | | | | | | Inserting the same key repeatedly with QMultiHash will not test rehashing behavior because in Qt6 those entries all end up in a linked list. Pick-to: 6.4 Change-Id: I78c45eed0f35a13af6d6da75d7189a6933750f13 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFuture: fix handling of cancelled continuation chainSona Kurazyan2022-09-211-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support cancellation of continuations attached via the parent future, for each future returned by a continuation we store a pointer to its parent (i.e. future the continuation is attached to). Later, before executing a continuation, we go through chain of parents and check if any of them is cancelled. However, if one of the parents is destroyed while the chain is executing, the next continuations' parent pointers will become invalid. So storing the parent pointers isn't safe. This commit changes the logic of handling the cancelled continuation chain in the following way: - Instead of storing a parent pointer in the continuation future's data, we do the opposite: we store a pointer to continuation's future in the parent. - When a future is cancelled, we mark all continuation futures in the chain with a flag indicating that the chain is cancelled. - To guarantee that the pointers to continuation future's data don't become invalid, we clean the continuation (that stores a copy of its future's data and keeps it alive) only when the associated promise is destructed, instead of cleaning it after the continuation is run. Fixes: QTBUG-105182 Fixes: QTBUG-106083 Pick-to: 6.2 6.3 6.4 Change-Id: I48afa98152672c0fc737112be4ca3b1b42f6ed30 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tst_qprocess: remove unused loop counterJohannes Kauffmann2022-09-201-2/+0
| | | | | Change-Id: I1eece5a676cfa02fff27be01f25b07ddd82c40d6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QFile::setPermissions/Unix: test both chmod() and fchmod()Thiago Macieira2022-09-161-1/+12
| | | | | | | | | | On Unix, we have the fchmod(2) system call that changes the permissions of an open file descriptor. This commit adds a test for that, by not closing the QFile before setPermissions(). Pick-to: 6.4 Change-Id: If5d5ef6220874ae8858efffd171255b9f20ed501 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tst_QFile::setPermissions: add QScopeGuard to remove temporary fileThiago Macieira2022-09-161-2/+3
| | | | | | Pick-to: 6.4 Change-Id: If5d5ef6220874ae8858efffd17125580b5943cc2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFileDevice: clear cached permissions on setPermission()Thiago Macieira2022-09-161-0/+6
| | | | | | | | | | | | In theory, if we succeed, the permissions should be what we set, but let's not make that assumption. And if we failed, it might be because the file disappeared or something else, so re-stat()ing the file is a good idea. Pick-to: 6.4 Fixes: QTBUG-7211 Change-Id: If5d5ef6220874ae8858efffd171255506b7bbee0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove preprocessor conditionals for chrono includeKonrad Kujawa2022-09-163-44/+3
| | | | | | | | | __has_include(<chrono>) is always true, because C++11 chrono include is required since 6.0. Pick-to: 6.4 6.3 6.2 Change-Id: I50cb92571bf4f1f86e2f3f2b5f486dd3c3f30f4a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QLocale: use fenv everywhereMårten Nordheim2022-09-151-25/+3
| | | | | | | | And remove the platform-specific code. fenv is available since c++11. Change-Id: Ia5540be93b54117d4b5e9c7579100039c151dcc5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Disable bad tests relying on wrong behaviorAllan Sandfeld Jensen2022-09-151-20/+10
| | | | | | | | | | | These tested results are all wrong and caused by internal overflows. Note the behavior can not be fixed either as it involves moving an already maximized QRect, which can not be done without overflow. Change-Id: If35db68102889012c56eb149fe49bc48954d3422 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io>
* Tidy up tst_QTimeZoneEdward Welbourne2022-09-141-10/+2
| | | | | | | | | Its debug member can be set where it's declared, making the constructor redundant. Change-Id: Ic1195108766a6a86c3392a5bcf7f197ea31e8068 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QWinRegistryKey: refactorYuhang Zhao2022-09-147-61/+243
| | | | | | | | | | | | | | | | | | | | | | Refactor QWinRegistryKey to make it more modern and more usable from outside. Adjust the test for QWinRegistryKey to test the new functions, merged with the original test. Will port raw registry accessing code in QtBase to use this class in follow-up commits. This change is the first step. The long term goal is to port QSettings registry code to this class instead of using raw Win32 APIs, however, there's much more registry code in QSettings and migrate them to this class needs a large refactor, so jsut leave it for now. Will fix it in some future commit. Change-Id: Iada2adb41b4d58e1b658ff6870a4b31ace479d43 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make time parsing accept zz as equivalent to zEdward Welbourne2022-09-131-3/+9
| | | | | | | | | | | | | | Expand a test to cover millsecond format variants more thoroughly, including a test for the new usage of zz. This applies to parsing the complement to commit 0a36a7c1db173089c25ea09029505a589a1c59e5's change to serialization. Fixed minor glitch in the serialization's doc, too. [ChangeLog][QtCore][QDateTime] When parsing a datetime, the 'zz' format specifier is now equivalent to 'z', as for serialization. Change-Id: I1c5700064738d9c92d5e8ce10bff8050131e190f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCryptographicHash: Add getter for algorithm()Linus Jahn2022-09-121-0/+2
| | | | | | | | | | | | This can be helpful when you calculate multiple hashes, store them in a vector and you want to know which result belongs to which algorithm. [ChangeLog][QtCore][QCryptographicHash] Added getter algorithm(). Change-Id: Ifcf78536f215619a6e2e3035a95598327d0ed733 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Make QCryptographicHash move constructibleLinus Jahn2022-09-121-0/+37
| | | | | | | | | | | | This adds a move constructor, a move assignment operator and a swap function to QCryptographicHash. This can (to name one example) be useful when you want to store multiple hashes in a vector. [ChangeLog][QtCore][QCryptographicHash] Added move constructor, move assignment operator and swap() function. Change-Id: Id54594fa69104ec25ad78581f962a021e85531c2 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Compile guard tests in corelib/kernel that need threading supportMikolaj Boc2022-09-116-0/+20
| | | | | | | | | Some tests in corelib/kernel need threading support, but they are not guarded against compilation if Qt is built without threading. Such tests have been disabled in this case. Change-Id: I2f5dc9582f2a59b6af2a9e56638b045dca06193d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Perform uiLanguages() likely-adjusted processing purely on IDsEdward Welbourne2022-09-071-7/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The collection of translations available to us need not have anything to do with whether CLDR has matching data, so preserve the system UI language list's entries as they are, rather than forcing them through the QLocale constructor's exercise of likely sub-tag rules. Instead, simply parse the given locale tags to QLocaleId instances and use these in the likely-subtag processing to determine what other entries to add to the list in addition to those supplied by the operating system. Since going via QLocale did usually supply a territory, that was included in the BCP 47 name, it's now possible for the given entry to lack the language_territory name, so be sure to add that if missing. This incidentally reduces heap traffic and saves a fair deal of hidden likely-subtag processing in calls to the constructor and bcp47Name(). Expand testing of QLocale::uiLanguages(), both plain and system. In the process, cross-link the two closely-related tests, move a comment on one's _data() to the other's, where it really belongs, and add reporting of the actual lists on failure. Enable MySystemLocale to remember the requested locale's ID, before likely sub-tag processing, so that we can make query() report results for language, script and territory as requested, to ensure the fake system locale really does match what was requested. The new german-britain test failed without it, because there is no de-GB locale in CLDR. Task-number: QTBUG-99531 Change-Id: Ide041577772c442a4413e3b9a590e11140c48f49 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify system locale managementEdward Welbourne2022-09-071-3/+0
| | | | | | | | | | | | Have QSystemLocale manage a stack, so that tests can install an over-ride for the actual system-specific one reliably and restore the system-specific one when finished. Leave the QSystemLocaleSingleton out of the stack, all the same. In the process, mark the QDoc comments for QSystemLocale all as \internal, since this is not public API. Change-Id: I8faed49780215e42f32be10cf936c32bb46105bf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Work round macOS's omission of en_DE from its own uiLanguages()Edward Welbourne2022-09-071-1/+16
| | | | | | | | | | | | | | | | | | | | When the system locale is en_DE, macOS seems to think we should use en_GB as the right translation. While that probably is a sensible choice in the absence of an en_DE translation, we should definitely use the en_DE translation if available, especially if en_GB isn't available (which lead to a fall-back to de_DE, given later entries in macOS's list). So prepend the system locale's own pcp47Name() if it (isn't the C locale and) is missing from what we would otherwise have used for uiLanguages(), after likely sub-tag perturbations. Add a test simulating (some approximation to) what macOS was doing that would have caught this case; and add a scope-guard reporter to the test to report what shows up when lists don't match. Fixes: QTBUG-104930 Pick-to: 6.4 6.4.0 6.3 6.2 5.15 Change-Id: I116234708067e1717d9157aebc84da76e04a9f38 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_qlocale: only restore the fp control masks we changeMårten Nordheim2022-09-071-3/+2
| | | | | | | | | | | Certain masks are not supported outside 32-bit x86, and will assert on x64. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-106000 Change-Id: Ic9f58e5a19c1db3309edeb5ec529e7a78c929665 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Guard windows-specific includes with Q_OS_WINAlexey Edelev2022-09-071-0/+3
| | | | | Change-Id: I0a7c605c55c815c7220024f302f511e302005ab9 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QTextStream: Fix logical error in setEncodingMårten Nordheim2022-09-071-0/+55
| | | | | | | | | | We only want to enable writing BOM if we have _not_ started writing. Fixes: QTBUG-106279 Pick-to: 6.2 6.3.2 6.4 6.4.0 Change-Id: Ibcbc101b931615fddb2507f01307bf9619772d7b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix cmake warnings from using deprecated PUBLIC_LIBRARIESVolker Hilsheimer2022-09-051-1/+1
| | | | | | Pick-to: 6.4 Change-Id: I8d4f0d9e98edc4e06dda9f58e62197572b4cbdbc Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix compiler warning: don't copy in ranged-for loopVolker Hilsheimer2022-09-031-2/+2
| | | | | Change-Id: If21f4e34324f33300009a427fb81e23ab49d4ad0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't batch qmetaobject_compatMikolaj Boc2022-09-021-0/+1
| | | | | | | | | | Batching the tests leads to one of the tests tst_qmetaobject and tst_qmetaobject_compat not being registered in the batch. Attempts to batch those together fail as batch test name is defined per-source, which, in this rare case, is the same across the two targets. Change-Id: I356931feabc004c39ba0b6863b5f64e06d739a58 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QMetaObject: pass the QMetaTypes in variadic invoke/newInstanceThiago Macieira2022-09-013-77/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][Meta Object] QMetaMethod::invoke(), QMetaObject::invokeMethod(), and QMetaObject::newInstance() are no longer limited to 10 arguments. [ChangeLog][QtCore][Meta Object] The use of the Q_ARG macro is no longer necessary when using QMetaMethod::invoke(), QMetaObject::invokeMethod(), and QMetaObject::newInstance(). Types may now be passed directly. Similarly, Q_RETURN_ARG can be replaced by the free function qReturnArg(). [ChangeLog][Potentially Source-Incompatible Changes] QMetaMethod::invoke(), QMetaObject::invokeMethod(), and QMetaObject::newInstance() no longer support passing forward-declared types in the argument list (it was possible to pass them by const-ref). From Qt 6.5 onwards, all types in the argument list must be fully defined. [ChangeLog][Potentially Source-Incompatible Changes] Attempting to use the internal types QArgument, QReturnArgument, QGenericArgument, or QGenericReturnArgument directly with QMetaMethod::invoke(), QMetaObject::invokeMethod() or QMetaObject::newInstance() may fail to compile. Those are internal types that were never meant to be used directly and will be removed in Qt 7. If really necessary, ensure all arguments passed to those functions are directly using those classes and not mixed with Q_ARG and Q_RETURN_ARG. Implementations of bindings to other languages should contact the Qt development mailing list to discuss options. Change-Id: I36b24183fbd041179f2ffffd1701e3e8e47e0fba Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QVariant: fix conversions of Q_ENUM that are QFlags<> to stringEirik Aavitsland2022-09-011-0/+2
| | | | | | | | | | The doc of QMetaEnum::valueToKey() says to use ::valueToKeys() instead for flag types. Pick-to: 6.4 Change-Id: I48e5ba47324137f2ce2710f1d876e93e7c562e9f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QAnyStringView: construct from any T implicitly convertible to ↵Marc Mutz2022-09-011-0/+10
| | | | | | | | | | | | | | | | | | | | | QString/QByteArray This includes QDBusReply, QProperty, and QStringBuilder expressions. The new constructor subsumes the QStringBuilder case without requiring jumping though hoops to delay the definition of the ctor the way we had to for the explicit QStringBuilder constructor, so remove the explicit QStringBuilder one again. [ChangeLog][QtCore][QAnyStringView] Can now be constructed from anything that implicitly converts to either QString or QByteArray. Fixes: QTBUG-105389 Change-Id: I0e584dd3e20d591381609a3329ef47cec7356ecc Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Move qVersion() from qglobal.h to qlibraryinfo.hSona Kurazyan2022-09-012-0/+2
| | | | | | | | | | | | | | | Since qVersion() might be called also from C code, disable the parts of qlibraryinfo.h that are relevant only for C++ code if __cplusplus is not defined. [ChangeLog][Potentially Source-Incompatible Changes] qVersion() is moved from qglobal.h to qlibraryinfo.h, '#include <QtCore/QLibraryInfo>' needs to be added where it's used. Task-number: QTBUG-99313 Change-Id: I3363ef3fa4073114e5151cb3a2a1e8282ad42a4d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Move QMacAutoReleasePool from qglobal.h to qcore_mac_p.hSona Kurazyan2022-09-017-0/+12
| | | | | | | | And include qcore_mac_p.h where needed. Task-number: QTBUG-99313 Change-Id: Idb1b005f1b5938e8cf329ae06ffaf0d249874db2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* RCC: fix zlib compression when --no-zstd was specifiedThiago Macieira2022-08-311-1/+11
| | | | | | | | | | | | | Since we had code to default to zstd as the default algorithm instead of "Best", we ended up not compressing anything. [ChangeLog][rcc] Fixed a bug that caused rcc not to compress files with any compression algorithm if the --no-zstd option was present. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-106012 Change-Id: Ic6547f8247454b47baa8fffd170fddae429f82d2 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* CMake: Fix tst_qlibrary to work on macOS with debug buildsAlexandru Croitor2022-08-312-20/+40
| | | | | | | | | | | | | | | | The test expects the helper libraries to contain the .dylib suffix rather than .so. Replace glob copying of the libraries (which depends on the underlying shell) with manual copy calls. This also ensures the libraries don't contain a _debug postfix in the file name even in a debug build, which would break the tests. Amends f8c1909320313c8a9c03661d8fe77728bde6556a Amends 1dff26dd9539feb40767b7761c5339085ad74dbf Change-Id: I20361c33c4a1b9dd4b5273fcdb8cc79c9f266327 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QMetaObject: add a new, variadic invoke/invokeMethod/newInstanceThiago Macieira2022-08-303-24/+631
| | | | | | | | | | | | | | | | | [ChangeLog][QtCore][Meta Objects] The QMetaObject::invokeMethod() taking a method name by string, QMetaObject::newInstance(), and QMetaMethod::invoke() now support more than 10 arguments. [ChangeLog][QtCore][Meta Objects] The use of the Q_ARG and Q_RETURN_ARG macros is now optional with QMetaObject::invokeMethod(), QMetaObject::newInstance(), and QMetaMethod::invoke(): the type name will be obtained from the C++ type (the same as QMetaType). The function qReturnArg() can be used in place of the Q_RETURN_ARG macro. The macros are still useful in rare conditions where the type was typedef'ed from its original name. Change-Id: I36b24183fbd041179f2ffffd17022a2b48c7639b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Rest of QtBase tests: port away from deprecated methodsIvan Solovev2022-08-301-5/+7
| | | | | | | | | | Small changes to fix builds with QT_DISABLE_DEPRECATED_UP_TO >= 0x060500 Task-number: QTBUG-104858 Change-Id: Ia531a3cee97f13827e36b3d63f28eed879fe9a40 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qobject: port away from deprecated methodsIvan Solovev2022-08-302-29/+17
| | | | | | | | | | | | | | | | | | | | | | The patch includes the following replacements: * QMetaType::type("name") -> QMetaType::fromType<Type>().id() * QMetaProperty::type() -> QMetaProperty::typeId() * QVariant::Type -> QMetaType::Type * qRegisterMetaType<T>("name") -> qResigeterMetaType<T>() * The static QMetaType::{load,save} methods are replaced with non-static versions * Replace QCOMPARE(property.type(), QVariant::UserType) with QCOMPARE_GT(property.typeId(), QMetaType::User), because the deprecated type() method was treating each custom type (id >= QVariant::UserType) as QVariant::UserType, while the typeId() method simply returns the actual id. As a drive-by: remove unneeded QMetaType registration tests as we have tst_QMetaType to check it. Task-number: QTBUG-104858 Change-Id: Ia08e002efdf07ff83366a5193164dba96a956f9a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qvariant: port away from deprecated methodsIvan Solovev2022-08-302-152/+184
| | | | | | | | | | | | | | The most common changes are: * guard the tests for deprecated APIs with QT_DEPRECATED_SINCE * QVariant(QVariant::Type) ctor -> QVariant(QMetaType) ctor * QVariant::type() -> QVariant::typeId() * QVariant::canConvert(int) -> QVariant::canConvert(QMetaType) * QVariant::convert(int) -> QVariant::convert(QMetaType) * QVariant::Type -> QMetaType::Type Task-number: QTBUG-104858 Change-Id: I00584acb24d29b461faa1115f8f8d36a0b443883 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qmetatype: port away from deprecated callsIvan Solovev2022-08-304-156/+304
| | | | | | | | | | | | | | | | | | | | | | | | The most common changes are: * Replace QMetaType::type("name") with QMetaType::fromName("name").id() or QMetaType::fromType<Type>().id() * QMetaType::typeName(int) -> QMetaType(int).name() * QMetaType::typeFlags(int) -> QMetaType(int).flags() * QMetaType::metaObjectForType(int) -> QMetaType(int).metaObject() * The static QMetaType::{load,save} methods are replaced with non-static versions * The static QMetaType::{create,destroy,construct, destruct} methods are guarded by QT_DEPRECATED_SINCE calls. The tests are also extended with non-static calls where they were missing. Fixed potential memory-leaks in these tests. Add separate unit-tests for deprecated APIs and guard them with QT_DEPRECATED_SINCE As a drive-by: use nullptr instead of 0 in some places Task-number: QTBUG-104858 Change-Id: I4b0cdd29bc197c186b835002372240aae3098c33 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qlibrary.cpp: remove extraneous _data functionThiago Macieira2022-08-301-7/+1
| | | | | | | The test function itself is MIA. Change-Id: Ie4bb662dcb274440ab8bfffd170a06fde5c1cd51 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QVariant: fix conversions of string keys to Q_ENUM that are QFlags<>Thiago Macieira2022-08-301-0/+5
| | | | | | | | | | | | | Since Qt 6.0, QMetaType stores the name obtained from the C++ compiler, which means we know a type like Qt::Alignment by its proper, full name of QFlags<Qt::AlignmentFlag>. However, the meta object records only the bare name of the enumeration, not the full flags. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-105932 Fixes: QTBUG-96185 Change-Id: Ic6547f8247454b47baa8fffd170eab977e306377 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add QComHelper class for dealing with COM on WindowsTor Arne Vestbø2022-08-291-9/+2
| | | | | | | | | | | | | | | Unifies our approach to calling CoInitializeEx and CoUninitialize, removing a lot of boilerplate in the process, and also fixes a few bugs where we would incorrectly balance our calls to CoInitializeEx and CoUninitialize. The optimistic approach of qfilesystemengine_win.cpp of calling CoCreateInstance without initializing the COM library explicitly has been removed, as calling CoInitializeEx should be a noop in the situation where it's already been loaded. Change-Id: I9e2ec101678c2ebb9946504b5e8034e58f1bb56a Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* tst_QMap: avoid tripping MSVC debug-mode iterator assertionsThiago Macieira2022-08-281-1/+6
| | | | | | | | | It does a check to ensure you aren't comparing outside the container. Fixes: QTBUG-106001 Pick-to: 6.2 6.3 6.4 Change-Id: Ic6547f8247454b47baa8fffd170eef346b7f4f24 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* tst_qscopedpointer: port away from deprecated APIsIvan Solovev2022-08-271-20/+48
| | | | | | | | | | | | | | | | | The QScopedPointer::take() call in comparison() test was used to avoid a double-deletion error, because the test is creating two QScopedPointer instances referencing the same memory. Avoid the take() call by providing a custom DummyDeleter and managing the memory by the extarnal std::unique_ptr. As the test now has no test-cases for QScopedPointer::take() calls, create a new test for this deprecated API, and guard it with QT_DEPRECATED_SINCE checks. Task-number: QTBUG-104858 Change-Id: Iecc28d44d76c9ce5835e6b1a1df7db30e2a9ca25 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qmap: port away from deprecated APIsIvan Solovev2022-08-271-70/+110
| | | | | | | | | | | | | | The most common changes are: * removing the explicit tests for deprecated APIs * QMultiMap::insertMulti() -> QMultiMap::insert() * QMultiMap::insert(QMultiMap) -> QMultiMap::unite(QMultiMap) Add separate tests for the deprecated APIs, and guard them with QT_DEPRECATED_SINCE() checks. Task-number: QTBUG-104858 Change-Id: Ifb79212d07f20028d93d75f2b32ec3785cc93b22 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qstring: port away from deprecated APIsIvan Solovev2022-08-272-14/+29
| | | | | | | | | | | | | | * QVariant::Type -> QMetaType::Type. * Guard the test for deprecated fromUtf16(const ushort *) overload with QT_DEPRECATED_SINCE check. * Use fromUtf16(const char16_t *) overload in other places. As a drive-by: fix formatting in the affected lines. Task-number: QTBUG-104858 Change-Id: I9fa3a935bca36e97f934f673e2fc07b451c72872 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaObject: fix the consistency check for forward-declared builtinsThiago Macieira2022-08-263-0/+55
| | | | | | | | | | | For those, moc does know their type ID, and yet they may be still forward-declared in the C++ side, so the meta object may have recorded a null pointer in the metatype array. Fixes: QTBUG-105832 Change-Id: Ic6547f8247454b47baa8fffd170dae07c0813dc7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Port tests away from using q{Set}GlobalQHashSeedIvan Solovev2022-08-263-7/+28
| | | | | | | | These functions are marked as deprecated in future Qt releases. Task-number: QTBUG-104858 Change-Id: I25d2932455d8c9e3e2d722b1c48fc2cfa2d1e679 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtBase tests: remove QT_DISABLE_DEPRECATED_UP_TO definesIvan Solovev2022-08-247-14/+0
| | | | | | | | | The value will be propagated from Qt build. Task-number: QTBUG-104858 Change-Id: Iae2c32c3037438f41b92f9ee28004f30eb4e3210 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-23298-298/+298
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>