summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.qdoc
Commit message (Collapse)AuthorAgeFilesLines
* QTest: rip out qxp::function_ref from compare_helper()Thiago Macieira2024-04-261-1/+1
| | | | | | | | | | | | | | | | [ChangeLog][QtTest] The QCOMPARE_xx macros can now only find QTest::toString() expansions that are either found via Argument Dependent Lookup on the type in question or are an instatiation of the QTest::toString<T>() template. This matches the behavior of the QCOMPARE() macro. This changes the way how the toString() overloads are selected, so we need to explicilty constraint the main QTest::toString() template in order to pick the free functions when they exist. Change-Id: Ie28eadac333c4bcd8c08fffd17c54e768c5cffd0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QTest: rip out qxp::function_ref from reportResult()Thiago Macieira2024-04-261-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is causing huge code bloat because everything is a local lambda. Instead, pass direct type-erased function and data pointers to the replacement function. Testing with tst_qcborvalue, this reduces the compilation time and the output binary size significantly: Before After Compiler Time Size Time Size GCC 13.2 136.99 s 202.3 MB 13.88 s 14.3 MB GCC 14.0 131.49 s 202.7 MB 14.69 s 14.4 MB Clang 17 77.2 s 146.7 MB 13.62 s 12.2 MB Clang 18 141.9 s 187.1 MB 13.62 s 12.4 MB This causes a difference in how toString() overloads are found. Previously it would match far more overloads because the toString() calls were expanded by the macro. Now, we depend on Argument-Dependent Lookup and associated namespaces, so toString() overloads should not be in the QTest namespace any more. With this patch applied, the testlib testcase of tst_selftest started failing, because nullptr is now handled differently. However, I consider it as a bugfix, because previously it was falling back to a default implementation, and now it is using the QTest::toString(std::nullptr_t) overload, which is a desired behavior. Update the reference files for tst_selftest with the new expected output. Task-number: QTBUG-124272 Change-Id: Ie28eadac333c4bcd8c08fffd17c5484186accdf6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QDoc: Drop default arguments from some \fn documentation stringsPaul Wicking2024-03-131-8/+8
| | | | | | | | | | | | | | | | | | | In the \fn commands for a limited number of methods in the documentation for Testlib and Widgets, `= 0` is passed as default argument instead of `= Qt::KeyboardModifiers()`. Until QDoc with Clang 17, inclusive, QDoc generated the correct signature. However, with Clang 18, QDoc outputs `= 0` in the documentation. While strictly speaking still correct, this change impacts the documentation negatively in terms of readability. Dropping the default argument from the \fn command ensures that QDoc generates the right signature with both Clang 17 and Clang 18. Task-number: QTBUG-123130 Pick-to: 6.7 Change-Id: I94ccec2f2c9a02241095fb5b18feb74aa55f97e1 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QTest: allow passing chrono literal as QTRY_ timeoutMarc Mutz2024-02-071-1/+21
| | | | | | | | | | | | | | | | | | | By wrapping the use of the timeout value in QTRY_IMPL in a lambda that feeds the user input through the std::chrono::milliseconds constructor with std::chrono_literals in-scope, the macros continue to work with raw integral values as well as chrono literals not finer than millisecond granularity. Port all higher-level macros to pass a chrono literal and port some uses in tst_selftests. [ChangeLog][QtTest] The QTRY_*_WITH_TIMEOUT macros now also accept chrono literals (was: int milliseconds). Fixes: QTBUG-121746 Change-Id: Ib38406fc005a0a2c4ae3fd009760f73ad8bed355 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* [docs] Fix C'n'P error in QTRY_VERIFY2 exampleMarc Mutz2024-01-311-1/+1
| | | | | | | | | | | | It's not the _WITH_TIMEOUT variant (the timeout is missing). Amends a change preceding b24bb12f6a93b98e9bc44c99e151b995eb7cea71, the commit that moved all the documentation into qtestcase.qdoc in the first place. I didn't track the change back further than that. Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: I79ccd84a5dbed20012fa1a2d3561945f8a7638d5 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* testlib: Add test function for simulating wheel eventsDoris Verria2023-12-201-0/+11
| | | | | Change-Id: I28fe4dff7db92fb58922948a3eec460df315318c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Remove unneeded toString(QPair) declarationMarc Mutz2023-12-061-7/+0
| | | | | | | | | | | | It's literally the same as the std::pair one that immediately follows it, because QPair these days is just a template alias for std::pair. Wasn't flagged as an error because it's just a declaration, not a definition. Pick-to: 6.6 6.5 Change-Id: I5b47572f6e2a71edb47cbe224801a719ff1e060d Reviewed-by: Jason McDonald <macadder1@gmail.com>
* QTest: simplify toString(tuple)Marc Mutz2023-12-061-6/+0
| | | | | | | | | | | | | | | | | Use C++14's std::index_sequence instead of our home-brewed QtPrivate::IndexList. I used make_index_sequence<sizeof...(Types)> instead of index_sequence_for<Types...> to avoid having to resolve another type-dependent template alias. Remove the helper's vacuous \internal qdoc block. As a drive-by, rename the helper function to prevent it from participating in QTest::toString() overload resolution, and fix spaces around &. Pick-to: 6.6 6.5 Change-Id: I5981a9b1a99fbe741e75820a6954d066ced9573d Reviewed-by: Jason McDonald <macadder1@gmail.com>
* [doc] QBENCHMARK_ONCE: fix typosMarc Mutz2023-11-151-2/+2
| | | | | | | | | ... and remove a prematurely-ending parenthesized remark. Pick-to: 6.6 6.5 6.2 5.15 Change-Id: If0a2f482c45128739ed6cea1d8385ea34f45b094 Reviewed-by: Isak Fyksen <isak.fyksen@qt.io> Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Doc: Fix QTest::createTouchDevice docsMichal Klocek2023-11-011-4/+4
| | | | | | | | | | | | | | After the introduction of QInputDevice class the returned QPointingDevice object from QTest::createTouchDevice() call is no longer automatically deleted when the QCoreApplication is deleted. Moreover, this function does not really go thorough qpa but simply registers the device with QWindowSystemInterface::registerInputDevice() (which is actually also used from qpa plugins when new device is plugged) Pick-to: 6.6 6.5 Change-Id: I3a0400288d76b7c95659d6b6ea260eff3233ebf1 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add QEXPECT_FAIL to tst_QApplication::sendEventsOnProcessEventsTero Heikkinen2023-08-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Test sendEventsOnProcessEvents has been noticed to fail when qgtk3 (Glib) is loaded - Should be fixed in QTBUG-87137 Moving test from blacklist to use QEXPECT_FAIL as it's more recommended until test is fixed in the relevant configurations. QEXPECT_FAIL is selected to use as original investigator reported also some cases when glib is working. Therefore this approach is giving us more insight for further investigation is it always failing with glib or not. It was also reported linkage to zeroTimer test QTBUG-84291, but not sure why removing that has affected to this one. Update to QEXPECT_FAIL documentation to tell in first place that XPASS is not only marking it as XPASS but also failing the test. Same is mentioned in different location but it needs more searching or testing how it works in real test. Task-number: QTBUG-115155 Change-Id: I7fb4ef28dba8adb7009be528f88fc758a12e9006 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTest: Rename QCOMPARE_XX parameters to add meaningMårten Nordheim2023-03-081-48/+48
| | | | | | | | | | | | | | | The parameter names were previously "lhs" and "rhs", which is incredibly abstract for a testing framework. One of the parameters will tend to be a baseline value to compare against while the other is the result of some action we want to test. Thus I suggest they be renamed "computed" and "baseline". This way we can, hopefully, retain the semantic that the 'left'/first argument is the computed ('actual' in QCOMPARE) value while the 'right'/second argument is the baseline ('expected' in QCOMPARE.) Change-Id: I3e0fdce2a3f1faca06fdf7184ef6e0eb9724d990 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Doc: fix links to qFuzzyIsNullVolker Hilsheimer2023-03-031-1/+1
| | | | | | | | The function is in the QtNumeric documentation context. Pick-to: 6.5 6.5.0 Change-Id: Ibc6a8961bc04efd4ab1eb50bb371e6a169d513dc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* testlib: make it possible to test double-clicks with discrete eventsShawn Rutledge2022-10-161-2/+20
| | | | | | | | | | | | | | | | | | | | | | The timestamp will no longer be incremented by 500ms after a mouse release if the delay has been explicitly specified. The default delay is 1 ms since f5010c49a37729375e37e6fe8cea60dd4b880d83 but the running timestamp was unconditionally post-incremented by 500ms after every mouse release, to prevent double-clicks, which were always deemed as unintended (because we have a mouseDClick function for that). Now, we do that 500ms increment only if the user has not provided a delay value in the function argument at all. We have often found it useful in our own tests to generate double-clicks "the hard way", by sending indivdual events, so as to be able to check state in some target object at each step, as shown in the new snippet. [ChangeLog][QtTest] QTest::mouseRelease() and mouseClick() can now be used to test double-clicks, by specifying a realistic timestamp delay. Fixes: QTBUG-102441 Change-Id: I8e8d242061f79efb4c6e02638645e03661a9cd92 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QTest: Support QKeySequence compareLaszlo Papp2022-07-091-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a QTest::toString() override for QKeySequence. This is just calling QKeySequence::toString(). The default format is PortableText, which should be ascii. Deliberately avoided NativeText as it can return unicode, e.g. on Mac. This is necessary to get helpful information for test failures when using QCOMPARE for QKeySequence instances. Currently, the returned output would not only be not helpful, but even misleading: Actual (edit.keySequence()): <null> Expected (QKeySequence()) : <null> After adding the override, the output is neither misleading nor unhelpful: Actual (edit.keySequence()): "" Expected (keySequence) : "Return" Some special characters would be escaped in the output, like the literal double quote: Actual (edit.keySequence()): "Ctrl+N" Expected (QKeySequence("\"")): "\"" Change-Id: Ib4b28fca30f6f2ad86c62530767f94a151332e0a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make it possible to check the accepted state of touch events in testsShawn Rutledge2022-07-081-7/+13
| | | | | | | | | | | | | | | | | | | | | | | QTouchEventSequence simulates a QPA touch event, potentially containing multiple points. (Despite the name, it only calls qt_handleTouchEvent() once, so it cannot really send a sequence of events; however, one event can contain multiple touchpoints.) Delivery is synchronous, and we keep return values through the QWindowSystemInterface::handleTouchEvent() template functions; so the remaining step is to return a bool from qt_handleTouchEvent(), so that we can return a bool from commit(). This allows tests to see the same perspective as a platform plugin can: check whether the event was accepted or not, after delivery is complete. Some tests in Qt Quick need to start doing that, to enforce correct behavior in QQuickDeliveryAgent. [ChangeLog][QtTestLib] QTouchEventSequence::commit() now returns a bool so that tests can check whether the event was accepted during delivery. Pick-to: 6.4 Task-number: QTBUG-104656 Change-Id: I9cf87909a3f847dedbdeca257013e309ac19cf0d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QCOMPARE: Fix a typo in the documentationLaszlo Papp2022-07-011-1/+1
| | | | | Change-Id: If21359397ef7873592b94838647aee121b84b33a Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* QTestLib: improve documentationIvan Solovev2022-06-081-0/+12
| | | | | | | | | | | | Add missing '\since' version numbers. This commit amends cc6d984390dc937b9d8440b6ba7d4f578e22ac0d and 0681a2dd5a8095baddb5905fb21a58ce19b958c5 Pick-to: 6.4 Change-Id: Ia10b991c996fb58f08a17e485c4dfcbfbe8eba0a Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE}_WITH_TIMEOUT()Ivan Solovev2022-06-031-0/+150
| | | | | | | | | | | | [ChangeLog][QTestLib] Add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE}_WITH_TIMEOUT macros that repeatedly execute QCOMPARE_{EQ,NE,LT,LE,GT,GE} until either the comparison returns true or the timeout expires. Also add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE} macros that simply invoke the *_WITH_TIMEOUT versions with the usual timeout of five seconds. Task-number: QTBUG-98873 Change-Id: Ib0d7d1c8c997f442b46acd85da738a8f512cc875 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}()Ivan Solovev2022-06-031-7/+146
| | | | | | | | | | | | | | | | | | | | | [ChangeLog][QTestLib] Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}() macros. These new macros behave similarly to QVERIFY(a op b), where 'op' is ==, !=, <, <=, >, >= respectively, but print a formatted error message with argument values in case of failure. The formatting is done lazily, which means that the strings will be generated only when the comparison fails. Also add a new test for tst_selftest and generate expected output for it. Fixes: QTBUG-98873 Task-number: QTBUG-98874 Change-Id: Ic8074798901d7a469b1f58d5cd28bbf49a3da1db Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-26/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtTestLib: replace remaining uses of QL1String with QL1StringViewSona Kurazyan2022-05-021-1/+1
| | | | | | | | | Remove unneeded \fn qdoc lines as a drive-by. Task-number: QTBUG-98434 Change-Id: Id93ddbb38b97a8f5a6734bfbc82686ccb3a87aa6 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Add \relates command for documented global functions/macrosTopi Reinio2022-03-251-0/+1
| | | | | | | | | | | | | Global functions need an associated header file/class/namespace to make the documentation visible. Remove QDoc comment tag (/*!) for an internal function. Pick-to: 6.3 Task-number: QTBUG-99578 Change-Id: Id390d433d7e081fc90fa57a02097b6c37fa13bee Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Long live QVERIFY_THROWS_NO_EXCEPTION!Marc Mutz2021-11-261-0/+34
| | | | | | | | | Counter-part to QVERIFY_THROWS_EXCEPTION. [ChangeLog][QTest] Added QVERIFY_THROWS_NO_EXCEPTION macro. Change-Id: Ib6a80c8e810d5e2298ff00d608dae04e7a0c3e8f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Long live QVERIFY_THROWS_EXCEPTION!Marc Mutz2021-11-261-4/+20
| | | | | | | | | | | | | Use variable args macros to swallow any extra commas in the expression. To use this, the type of the exception has to be first. Use Eddy's suggestion for a new name to avoid breaking the old macro. [ChangeLog][QtTest] Added QVERIFY_THROWS_EXCEPTION, replacing QVERIFY_EXCEPTION_THROWN, which has therefore been deprecated. Change-Id: I16825c35bae0631c5fad5a9a3ace4d6edc067f83 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QVERIFY_EXCEPTION_THROWN: re-throw unknown exceptionsMarc Mutz2021-11-251-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | | Swallowing unknown exceptions is dangerous business, as the exception might be a pthread cancellation token, the swallowing of which would terminate the program. Instead of returning from the catch-all-clause, therefore, re-throw the unknown exception. Fix tst_verifyexceptionthrown failure cases that use non-std::exception-derived true negative exceptions to not let the exception escape from the test function. As a drive-by, pretty up the macro's docs. [ChangeLog][QtTest][QVERIFY_EXCEPTION_THROWN] Now re-throws unknown exceptions (= not derived from std::exception) (was: swallowed them and returned from the test function), in order to play nice with pthread cancellation. Pick-to: 6.2 5.15 Change-Id: Ic036d4a9ed4b7683fa67e27af8bcbae0eefdd0da Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Clarify documentation of QEXPECT_FAIL()'s modeEdward Welbourne2021-08-111-8/+11
| | | | | | | | | Present behavior is to continue or abort, according to the mode, regardless of whether the condition marked does fail. Change-Id: I2eb5eefbbf173326101d08f3bbb378d214e93e71 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Fix link error to qFuzzyIsNull()Nico Vertriest2021-08-061-4/+5
| | | | | | Pick-to: 6.1 6.2 Change-Id: I17d890d4d61199dd74598ffa4c670ed65894047c Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* testlib: Deprecate QWARN() in favor of qWarning()Tor Arne Vestbø2021-08-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The QtTest best practices documentations recommends using output mechanisms such as qDebug() and qWarning() for diagnostic messages, and this is also what most of our own tests do. The QWARN() macro and corresponding internal QTest::qWarn() function was added when QtTest was first implemented, but was likely meant as an internal implementation detail, like its cousin QTestLog::info(), which does not have any corresponding macro. This theory is backed by our own QtTest self-test (tst_silent) describing the output from QWARN() as "an internal testlib warning". The only difference between QWARN() and qWarning(), besides the much richer feature set of the latter, is that qWarning() will not pass on file and line number information in release mode, but QWARN() will. This is an acceptable loss of functionality, considering that the user can override this behavior by defining QT_MESSAGELOGCONTEXT. [ChangeLog][QtTest] QWARN() has been deprecated in favor of qWarning() Pick-to: 6.2 Change-Id: I5a2431ce48c47392244560dd520953b9fc735c85 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Specify QT_TESTCASE_BUILDDIR for Qt::Test users implicitlyAlexey Edelev2021-04-081-0/+4
| | | | | | | | | | | | | | | | | | | QT_TESTCASE_BUILDDIR was implicitly defined by Qt::Test target for library users in Qt5. By default, this definition will point to CMAKE_CURRENT_BINARY_DIR. This logic works similarly to qmake logic. From user's perspective it might be useful to not rely on standard search paths, but specify own. This can be done by setting the QT_TESTCASE_BUILDDIR property for the user's target. CMake will substute the value of the QT_TESTCASE_BUILDDIR property into the QT_TESTCASE_BUILDDIR definition. The implicit QT_TESTCASE_SOURCEDIR also seems to be useful. According to the current logic, it points to CMAKE_CURRENT_SOURCE_DIR. Fixes: QTBUG-92079 Change-Id: I8a9065f08e859c713b3c8cc08142a9ced0677770 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Doc: Fix link errors qtbaseNico Vertriest2021-04-061-1/+1
| | | | | | Task-number: QTBUG-90662 Change-Id: I17147d149d9f222c142853805443aff94c5a5ff7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: explain how to create a test touch device for use with touchEventMitch Curtis2020-11-201-1/+7
| | | | | | Change-Id: Ib60eb0754449da7c50f8632ebd5228ddbe8389f1 Pick-to: 6.0 6.0.0 5.15 5.12 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix a few qdoc warningsVolker Hilsheimer2020-11-061-1/+2
| | | | | Change-Id: I7cc284ec56f02049d43a23c81659db94bfc3ff42 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Unfix QTest touch API documentationMårten Nordheim2020-11-021-1/+1
| | | | | | | | | Partial revert of 5866b82e240915b9b8d2be7394af560877111ee3. The function is still in the QTest namespace. Change-Id: I5e25b405baf07e61781ca4a527601ef0bf8ce6a4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix documentation for QTest touch APIsVolker Hilsheimer2020-10-291-10/+10
| | | | | Change-Id: Ifd9a3161e8ee422f8b0ce3adba8ae1b029c096d1 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QTestlib: Enable comparing QList against initializer lists/arraysFriedemann Kleint2020-07-211-5/+14
| | | | | | | | | | | | | | | | | | | | | It is unnecessary to create a QList container just for comparison. Split out helpers for comparing sequence sizes and sequences from qCompare(QList) and add a template for an array with a non-type template parameter for the size. One can then write something like: const int expected[] = {10, 12,...}; QCOMPARE(QFontDatabase.pointSizes(...), expected) Unfortunately, any commas in such an array will be misread by macro expansion as macro argument separators, so any expected array with more than one entry needs an extra macro expanding __VA_ARGS__. Change-Id: Ie7c8dc20bf669bbb25f6d7f8562455f8d03968c8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Introduce QInputDevice hierarchy; replace QTouchDeviceShawn Rutledge2020-06-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have seen during the Qt 5 series that QMouseEvent::source() does not provide enough information: if it is synthesized, it could have come from any device for which mouse events are synthesized, not only from a touchscreen. By providing in every QInputEvent as complete information about the actual source device as possible, we will enable very fine-tuned behavior in the object that handles each event. Further, we would like to support multiple keyboards, pointing devices, and named groups of devices that are known as "seats" in Wayland. In Qt 5, QPA plugins registered each touchscreen as it was discovered. Now we extend this pattern to all input devices. This new requirement can be implemented gradually; for now, if a QTWSI input event is received wtihout a device pointer, a default "core" device will be created on-the-fly, and a warning emitted. In Qt 5, QTouchEvent::TouchPoint::id() was forced to be unique even when multiple devices were in use simultaneously. Now that each event identifies the device it came from, this hack is no longer needed. A stub of the new QPointerEvent is added; it will be developed further in subsequent patches. [ChangeLog][QtGui][QInputEvent] Every QInputEvent now carries a pointer to an instance of QInputDevice, or the subclass QPointingDevice in case of mouse, touch and tablet events. Each platform plugin is expected to create the device instances, register them, and provide valid pointers with all input events. If this is not done, warnings are emitted and default devices are created as necessary. When the device has accurate information, it provides the opportunity to fine-tune behavior depending on device type and capabilities: for example if a QMouseEvent is synthesized from a touchscreen, the recipient can see which touchscreen it came from. Each device also has a seatName to distinguish users on multi-user windowing systems. Touchpoint IDs are no longer unique on their own, but the combination of ID and device is. Fixes: QTBUG-46412 Fixes: QTBUG-72167 Task-number: QTBUG-69433 Task-number: QTBUG-52430 Change-Id: I933fb2b86182efa722037b7a33e404c5daf5292a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QCOMPARE: treat values as equal if qFuzzyIsNull(each)Edward Welbourne2020-04-301-11/+10
| | | | | | | | | | | | | | | | | We hope this shall avoid some flaky failures noticed in quick tests, e.g. tst_QQuickMenu::Material::subMenuPosition(cascading,flip) was recently seen failing with 3.88e-11 != 0. This required some revision to test data in the testlib selftest for floats; the resulting expected output differs in details but not in which tests pass or fail. QEMU, naturally, made life difficult, requiring special-case code in the test-driver. [ChangeLog][QtTestLib][QCOMPARE] QCOMPARE() now treats its values as equal when qFuzzyIsNull() is true for both of them. Change-Id: Icc6ad5164b609937eddbe39cc69120f0abf0f3b4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Doc: Make Qt Test snippets compilableNico Vertriest2020-04-031-15/+17
| | | | | | Task-number: QTBUG-81498 Change-Id: I22f07cd539e5e317b6cf15eb369d59915146bd13 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Add best-practice-info for using QVERIFY() and QCOMPARE()Leena Miettinen2019-11-011-26/+82
| | | | | | | | | From https://wiki.qt.io/Writing_Unit_Tests Task-number: QTBUG-63987 Change-Id: I7229ac0712d1207c0c9ebdac868c33bb35dcb0f0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Update info about QSKIP()Leena Miettinen2019-10-311-15/+44
| | | | | | | | Add a section about using QEXPECT_FAIL() to skip known bugs. Change-Id: Icf258b6e20add3b68d62e404fd9ac0db70420bf2 From: https://wiki.qt.io/Writing_Unit_Tests Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Replace \b {Note:} with \noteLeena Miettinen2019-10-211-12/+12
| | | | | Change-Id: I1f6947acec4494c151317e1faf79720dad0da6bb Reviewed-by: Martin Smith <martin.smith@qt.io>
* Doc: Describe initTestCase_data() function and QFETCH_GLOBAL macroLeena Miettinen2019-10-111-3/+30
| | | | | | Fixes: QTBUG-24342 Change-Id: I8f8f3726c5d31e34af9bfe054572c08fc07e01e0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Merge remote-tracking branch 'origin/5.12.1' into 5.12Qt Forward Merge Bot2019-01-231-0/+22
|\ | | | | | | Change-Id: Icebd151eae0cf9d400319a42573290d1a911ce26
| * Doc: Restore documentation for QTest functions in other modulesTopi Reinio2019-01-041-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt Test library sources specific to Core, GUI and Widgets modules were moved around in commit 88867e39b. The new source locations must be referenced in Qt Test documentation configuration. The same sources are excluded in their original doc projects, and the related snippet file is moved over to qttestlib. The commit also fixes the remaining documentation issues for Qt Test. Change-Id: Ibe011aa83639e574d647f12bc9e53e618781bce6 Reviewed-by: Martin Smith <martin.smith@qt.io>
* | Documentation: Add \nullptr macro and use where applicableFriedemann Kleint2019-01-101-1/+1
|/ | | | | | | | | | | | | | | | Qt for Python users reading the documentation assume that int(0) can be passed for pointer parameters. Use the newly introduced \nullptr to disambiguate this. In a follow-up step, the \nullptr macro can be defined as None when generating the Qt for Python documentation. Task-number: PYSIDE-903 Change-Id: I3a45f87175a0668ab5f3f95f0aff409f7e3ef027 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* testlib: Move qtestsystem helpers to their respective modulesTor Arne Vestbø2018-07-161-99/+0
| | | | | | | | | | | | | Having the helpers in each respective module lets us implement the helpers using private APIs without forcing the test to add private dependencies. It also makes it easier to test Qt using a third party testing framework (for running the test suite), while still using the helpers for ensuring tests behave expectedly. Change-Id: I2a6ce24526ed345f3513548f11da05c7804c203f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix typosJarek Kobus2018-02-131-1/+1
| | | | | Change-Id: Id625efea998f2b4dce9970b903830dc3b3efcd3d Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* doc: Fix remaining clang parsing errors in QtTestMartin Smith2018-01-181-2/+53
| | | | | | | | This update also corrects all the remaining qdoc warnings in the mnodule. Change-Id: I1cea2cb1dd515d075a1e49a52ca78fc407c3a324 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qtestmouse: do not qWait for mocked events on macOSGatis Paeglis2017-11-301-4/+0
| | | | | | | | | | | | | | | | | | | | This logic initially was copied from QTest::mouse* widget overload (by d130382776e8b9db491385a0db45a3daaa79890c) which uses QCursor::setPos() to generate mouse move events via the windowing system. The QCursor API was later removed by 1762bf3394219db3a7a9cc99306f4111e6cb8492, but now the redundant qWait logic remained. Later this stray qWait was incorrectly moved to apply for all mouse event types (by 268f41ec70fd70d4aa44a5043d1a4e678df4c5b5), when originally it was needed (arguably) only for mouse move events due to usage of QCursor. This patch also removes the waitForEvents() function as it is not a documented qtestlib API (in qtestlib only the documented functions should be considered public API, no matter what you can find in the header files). Removal does not affect binary compatibility as this is not an exported symbol. And if somebody has used this non public API, updating code is trivial. Change-Id: Id1dec10f5cf276cee1ac0e8c8f8ba2edc493b667 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>