summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QAbstractEventDispatcher: port timer uses to the V2 APIThiago Macieira2024-03-131-40/+65
| | | | | | Change-Id: I83dda2d36c904517b3c0fffd17b52b71739928dc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Change license for tests filesLucie Gérard2024-02-041-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* tst_qeventdispatcher: port to QDeadlineTimerAhmad Samir2023-09-041-8/+9
| | | | | | | Easier logic for these use-cases. Change-Id: I97a18c45d9bd8cfcfee5d379d271366276d5a435 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QEventDispatcher: test with glib disabled tooAhmad Samir2023-08-111-1/+7
| | | | | Change-Id: I05f09e720170c77a567ffea31dfe06a658f1df2b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QThread: add sleep(std::chrono::nanoseconds) overloadAhmad Samir2023-03-131-2/+2
| | | | | | | | | | | | | | All the other overloads are implemented using the new one. Windows change relies on the pre-check in the code review making sure it compiles. [ChangeLog][QtCore][QThread] Added sleep(std::chrono::nanoseconds) overload. Task-number: QTBUG-110059 Change-Id: I9a4f4bf09041788ec9275093b6b8d0386521e286 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-27/+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>
* Make QUnixEventDispatcherQPA XFAIL the testVolker Hilsheimer2022-03-251-1/+1
| | | | | | | | Needed for QNX, don't be overly specific with XcbUnix. Pick-to: 6.3 6.2 Change-Id: I240313bc48d9d81d1f18f27ee11f7c9352e3e452 Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
* Simplify failure detection logic in QEventDispatcher testVolker Hilsheimer2022-02-181-17/+10
| | | | | | | | | | | | The test always fails when either the Xcb or UNIX, one of the Windows event dispatchers is used. So only test for the event dispatcher name, which then covers all platforms, including QNX and INTEGRITY (which use the UNIX event dispatcher). Pick-to: 6.3 6.2 Change-Id: I2e315831b53f823c5496ad0319319df78f064cc1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
* Fix failures for tst_eventdispatcher on INTEGRITYTatiana Borisova2022-02-151-1/+1
| | | | | | | | | | | - New testcase tst_eventdispatcher added under commit d292f0143f0. It shows that only glib implementation works correctly. Task-number: QTBUG-99123 Pick-to: 6.2 6.3 Change-Id: I7b861a6207fcb319de362645fc8f00a8ab6cd4b9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_qeventdispatcher: avoid influence between test functionsAlex Trotsenko2022-01-191-0/+8
| | | | | | | | | | | | | | | | | When some test function fails (even as expected), it can leave the event dispatcher in an inconsistent state where the posted events queue might not be empty. As a result, this may break the internal logic of the next test function that is run. So, calling eventDispatcher->processEvents() after each completed function resets the event dispatcher to its initial state, which fixes the problem. Pick-to: 6.2 6.3 Change-Id: I5a54f892d09a6eca73c8fc82875ce3b9ce4a3242 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Win32: always allow the event loop to be woken up by posted eventsVolker Hilsheimer2022-01-191-3/+0
| | | | | | | | | | | | | | | | | | | We set the wakeUps atomic to prevent multiple WM_QT_SENDPOSTEDEVENTS from being posted. However, this might happen right after the event processing thread cleared the atomic, but before it processed the previous WM_QT_SENDPOSTEDEVENTS message. In that case, we end up with a set atomic and an empty event queue, resulting in the event loop to block even though there are posted QEvents. To prevent that, always reset the atomic when we handle the WM_QT_SENDPOSTEDEVENTS message. In that case, we either call sendPostedEvents, or startPostedEventsTimer. The former already resets wakeUps; reset it in the latter as well. Fixes: QTBUG-99323 Pick-to: 6.2 6.3 5.15 Change-Id: I931c02be9c42b02e8ca20daba5059cd8185f0a37 Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
* Add more tests for event dispatcher waking upVolker Hilsheimer2022-01-191-1/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add two tests for some problematic scenarios where the behavior is not consistent across platforms and depending on which event dispatcher is used: 1) reliably waking up the dispatcher when posting events from a worker thread. That test fails 100% of the time on Windows no matter what type of application is created. It passes reliably on Linux and macOS for both core and gui applications. 2) waking up the dispatcher when we post an event from within an event handler. That test fails 100% of the time on Windows, both with core and GUI event dispatchers. On macOS, the test fails 100% of the time with the core dispatcher, and passes 100% of the time with the GUI dispatcher. On Linux, it passes only if a Glib based event dispatcher is used; the default Unix event dispatcher (which is also the one used on macOS for core applications) fails. Task-number: QTBUG-99323 Pick-to: 6.2 6.3 5.15 Change-Id: I2489533b9f0032488707777be0512bb933669a7d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
* tst_qeventdispatcher: fix UB in single-shot timers activationAlex Trotsenko2022-01-131-6/+6
| | | | | | | | | | | | | | | Any of these timers must be stopped before the corresponding test function completes. Otherwise, functors will operate on dangling pointers, which can lead to failures or unreliability of other tests. Fix this by setting a correct context in the QTimer::singleShot() call. Pick-to: 6.2 6.3 Change-Id: Icd23f6d9a2c6e7f33495d6badc4080a1b10c19f8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QEventDispatcher(Win): Always honor interrupted status to avoid racesMårten Nordheim2021-03-111-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | There may be a race where e.g. thread 'B' is woken up by a queued invoke. At the same time thread 'A' asks 'B' to quit, which will set various atomics (some important ones are 'interrupt' in the dispatcher and 'exit' in the event loop), but it does _not_ try to send another wake since there is already an unhandled wake triggered by 'B' itself. Sadly 'B' reads the 'exit' atomic before 'A' updates it. Then, slightly before, 'B' sets 'interrupt' back to 0, 'A' write 1 to it, meaning 'A's interrupt is ignored. Then, since there is no interrupt, 'B' goes back to waiting for events, leaving the thread alive and running instead of quitting. Maybe this has unforeseen consequences (one consequence is that it will return and re-enter the event dispatcher once more, possible unnecessarily) Fixes: QTBUG-91539 Pick-to: 6.1 6.0 5.15 Change-Id: Ie6f861f42ffddf4817d5c8af2d764abe9d9103c2 Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace QtTest headers with QTestDavid Skoland2020-12-221-1/+3
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove most compiler warnings about missing overridesLars Knoll2020-09-111-2/+2
| | | | | | | | | | | | Remove around 1000 compiler warnings about missing overrides in our auto tests. This significantly reduce the compiler warning noise in our auto tests, so that one can actually better see the real problems inbetween. Change-Id: Id0c04dba43fcaf55d8cd2b5c6697358857c31bf9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Synchronize QEventDispatcherWin32::processEvents() with QCoreApplicationAlex Trotsenko2020-08-261-0/+26
| | | | | | | | | | | | | | | QCoreApplication has a special internal mechanism to control whether the event dispatcher should block after delivering the posted events. To handle queued connections in nested loops properly, we should use that functionality. Pick-to: 5.15 Fixes: QTBUG-85981 Change-Id: I124179a23b26a995cf95ed379e97bfa62c95f42a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Detect double timer during single timeout in registerTimer test, and skipVolker Hilsheimer2020-02-121-5/+17
| | | | | | | | | | | | | | | | We observe this happening on macOS in the CI system, and it might happen if a VM doesn't get CPU cycles for long enough time so that two timers time out. Then event processing will process two timer events, and we overwrite the timerIdFromEvent with the second event. Instead, skip the test when this happens. This is an ammendment to 5c520f4b0ad4b539dc0184c764ca9f12c98730d9 Change-Id: Ibc1169b5458c8dce9d4fe9ce715f49c396e17b86 Fixes: QTBUG-71751 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Discover the conditions under which registerTimer is flaky, and skipVolker Hilsheimer2020-02-071-0/+22
| | | | | | | | | On macOS, the registerTimer test case fails frequently, and blocks valid integrations. With this change we try to detect the condition and skip the test. Change-Id: Id2065f606abfd431971becf63034a4c1f0fdb9e5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QCocoaEventDispatcher: make 'interrupt' workTimur Pocheptsov2019-12-101-0/+45
| | | | | | | | | | | | | | | | | | | even if we are currently inside processEvents (apparently called manually and not from QEventLoop::exec()). A carefully crafted application (see, for example, the linked QTBUG or even updated auto-test) can trigger itself into failing to exit the current (potentially nested) event loop. We can harden our Cocoa event dispatcher to detect such condition and properly propagate 'interrupt' to where it'll do its job, indeed, interrupting the real event loop (aka [NSApp run]). This mainly means we have to undo what bool blocker would erroneously do. Also, long live (as people love to say these days) to another tricky (somewhat) auto-test (surely, it's not flaky!). Fixes: QTBUG-79477 Change-Id: I794f0cda23e24d36be67f2bb63d52b74be057c31 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* tests: Distinguish tst_qeventdispatcher and tst_qguieventdispatcherLiang Qi2018-11-161-0/+1
| | | | | | | | | Both use same source, but link without and with Qt Gui library. Task-number: QTBUG-71751 Change-Id: I5643a07a8067f5fc10fc66f717f19bc3e16a33ab Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Make sure QEventDispatcher::registerTimer() cleans up after itselfUlf Hermann2018-11-151-52/+126
| | | | | | | | | | The test needs to also unregister its timers when it fails. Therefore, wrap the registering and unregistering in an RAII class. Task-number: QTBUG-71773 Change-Id: I6ef44e580880deecb32763b5b0cd71e1c26929be Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Updated license headersJani Heikkinen2016-01-211-17/+12
| | | | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Don't send posted events from QWindowSystemInterface::sendWindowSystemEventsTor Arne Vestbø2013-09-161-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The responsibility of sendWindowSystemEvents() is to process events from the window system. Historially that logic was part of the QPA/QWS event dispatcher, which naturally also sent posted events. Through refactoring, the code at some point ended up in in the QWindowSystemInterface class, still with the posting of events in place. This resulted in QPA event dispatchers adopting a pattern of just calling sendWindowSystemEvents(), as that would cover both posted and window system events. Other event dispatchers would call sendWindowSystemEvents(), and then use a base-class implementation from QtCore for processing events, resulting in two calls to QCoreApplication::sendPostedEvents() per iteration of processEvents(). This breaks the contract that processEvents will only process posted events that has been queued up until then. We fix this entanglement by removing the sendPostedEvents() call from QWindowSystemInterface::sendWindowSystemEvents() and move it to the respective event dispatchers. For some EDs it means an explicit call to sendPostedEvents, while others were already doing sendPostedEvents though a separate source (GLib), or using a base-class (UNIX/BB), and did not need an extra call. We still keep the ordering of the original sendWindowSystemEvents() function of first sending posted events, and then processing any window system events. Task-number: QTBUG-33485 Change-Id: I8b069e76cea1f37875e72a034c11d09bf3fe166a Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
* Don't assume processEvents(WaitForMoreEvents) will process timersTor Arne Vestbø2013-09-051-4/+2
| | | | | | | | | | | | | The WaitForMoreEvents flag only guarantees that we will process _some_ events -- either if they are in the event queue already, or by sleeping and then waking up to process an event. This event might be a system event, not the timer firing, so a single call to processEvents() is not enough to guarantee that the timer has fired. Instead we do a Q_COMPARE with a timeout, where we continiously process events until we see that the timer fired. Change-Id: I5dc04377f04190f3505be22e877af73d11b7547d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Test posted events in tst_QEventDispatcher with various flagsBradley T. Hughes2012-02-101-1/+13
| | | | | | | | | Add QEventLoop::ProcessEventsFlags test data for tst_QEventDispatcher::sendPostedEvents() to test that posted events are sent when waiting for events and when not waiting. Change-Id: I99f9eb121d0b1ded725e19c5233922fc0a6b81e4 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* Run tst_QEventDispatcher with the GUI event dispatchers as wellBradley T. Hughes2012-02-101-1/+16
| | | | | | | | | | | | | Since some GUI event dispatchers are complete reimplementations and do not build on the corelib ones, we want to run the same tests with the other dispatcher. Since this is a GUI test now, we need to make sure to drain system events queued during application startup to make sure we can reliably run the test functions. Change-Id: I4905db70bc8f8584c4ef1f4d767824040281452c Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* Add tst_QEventDispatcher to tests/auto/corelib/kernelBradley T. Hughes2012-02-101-0/+186
This will test the event dispatcher in corelib for proper timer and posted event handling. The test makes sure all of the necessary virtual functions are implemented and working as expected. This test doesn't test socket notifiers or Win32 event notifiers, as these are already covered in existing tests. Change-Id: I5540ffc4e6d7f97bcd6c3725d7e74c0ab9c97015 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>