summaryrefslogtreecommitdiffstats
path: root/src/testlib/doc/snippets
Commit message (Collapse)AuthorAgeFilesLines
* Correct doc snippet licenseLucie Gérard2024-02-282-2/+2
| | | | | | | | | | | | | | All file under doc/snippet should be license as Documentation snippets and according to QUIP-18 [1] this is LicenseRef-Qt-Commercial OR BSD-3-Clause [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I76eedfb6b15c4091f726a5652e3530001d7cdaf7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Change license of .qdoc filesLucie Gérard2024-02-011-1/+1
| | | | | | | | | | | According to QUIP-18 [1], all .qdoc files should be LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Change-Id: I4559af21fc9069efa9bf0cbd29c5e86cfdac9082 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Fix warning in recently-added testlib snippetEdward Welbourne2023-07-181-4/+4
| | | | | | | | | | | | Amends commit fa296ee1dcf4c16fb6f242cf08949485e499fec3 to implement MyObject::startup(), mark it void (its return was ignored) and flag its static wrapper as [[maybe_unused]] to calm a compiler warning. As a drive-by, fix indentation of the class definition. Change-Id: I3918bf8a4625a7e2b4e6d4e0cbfa68a337115865 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QTest: add QDeadlineTimer qWaitFor() overloadAhmad Samir2023-06-302-10/+13
| | | | | | | | | | | | For Forever timers, don't check the remaining time. Merge src_corelib_kernel_qtestsupport_core_snippet.cpp and src_corelib_kernel_qtestsupport_core.cpp. [ChangeLog][QtCore][QTest] Added QDeadlineTimer qWaitFor() overload. Change-Id: I74c3f362b77206426136a418e656465e43f45b09 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTest: add qWait(chrono::milliseconds) overloadAhmad Samir2023-06-301-1/+2
| | | | | | | | | | | | | | | | | The code bailed out of the while loop when "remainingTime <= 0", for a QDeadlineTimer::isForever() timer remainingTime() returns -1, whereas remainingTimeAsDuration() returns nanoseconds::max(). I.e. the original code stopped the while loop when the timer isForever() or "expired" (i.e. remaining time is 0). I am not sure the isForever() part was intended that way or not, but it makes sense, if QCoreApplication::processEvents() has already run "forever", there is no point looping again. [ChangeLog][QtCore][QTest] Added qWait(chrono::milliseconds) overload. Change-Id: I871c28b053c6ba4f81a7e2d434aa4fbe03c8c5e7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTest: add qSleep(std::chrono::milliseconds) overloadAhmad Samir2023-06-301-2/+3
| | | | | | | | | Using chrono means one can write 10s instead of 10'000. [ChangeLog][QTest] Added qSleep(std::chrono::milliseconds) overload. Change-Id: Iac1b12a3fc3f692b557e2d459e6f3bc565f20e93 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Use qt_add_executable() not add_executable() in snippetsLeena Miettinen2023-04-261-1/+1
| | | | | | | | | Changes code snippets that are visible in the docs. Task-number: QTBUG-113116 Pick-to: 6.5 Change-Id: If743234bfe6947acf02307bf1144daad4fba5d73 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Remove unused documentation code snippetsFriedemann Kleint2023-04-173-10/+0
| | | | | | | | | | | | | | | | | | | Modules: - Core - Gui - Widgets - Open(Widgets) - PrintSupport - Sql - Network - Concurrent - Testlib Pick-to: 6.5 Change-Id: I63e58c01bec4bd162486020f0085227fdaa83b18 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* testlib: make it possible to test double-clicks with discrete eventsShawn Rutledge2022-10-161-0/+13
| | | | | | | | | | | | | | | | | | | | | | 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>
* Document shell-friendly data tags as best practiceEdward Welbourne2022-09-073-13/+13
| | | | | | | | | Also follow this best practice in testlib's own documentation and examples. Pick-to: 6.4 Change-Id: I8b57dfa8f88835adae8fceeb122a16635708e338 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-232-2/+2
| | | | | | | 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>
* Add license headers to cmake filesLucie Gérard2022-08-032-0/+6
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Doc: Revise Qt Test tutorialAndreas Eliasson2022-06-211-0/+51
| | | | | | | | | | | - Make it explicit that each chapter can be run as a stand-alone test application - Add a CMake section on how to build the executable Task-number: QTBUG-103730 Pick-to: 6.4 6.3 Change-Id: Id4c87c454521f698dcf16cfdc176318dd3e16786 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-1612-588/+24
| | | | | | | | | | | | | 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 QLatin1String uses with _L1/_s/QStringLiteralSona Kurazyan2022-05-021-2/+4
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ie327fd4af1880002e5a1e09b43384f2b709625e7 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Support test-case selection based on global data tagEdward Welbourne2022-04-251-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | In the same ways as for blacklisting. In the process, move reporting of an unrecognised tag outside the global-data loop, as the tag might be, or start with, a global data tag; and also report the global data alongside the test-specific data. Indent the lines reporting tags, as this makes the structure of the lists more evident. Converted the tag argument to QLatin1String() to facilitate searching and matching. Updated documentation, including expanding on the option of specifying the data tags on the command-line. Drive-by: fixed a link in the documentation, removed a snippet that was nowhere used. [ChangeLog][QtTest] When specifying what tests to run on a QtTest command-line, it is now possible to include a global data tag in the same way as a function-specific data tag or in combination with it. Thus if the test reports itself as tst_Class::function(global:local), command-line option function:global:local will select that specific test and function:global will run all data-rows for the function on the given global data tag. Fixes: QTBUG-102269 Change-Id: I7c86d6026933b05f7994bfc3663a2ea6a47f5f38 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Use find_package(Qt6 REQUIRED COMPONENTS ...) idiomKai Köhne2021-12-092-2/+2
| | | | | | | | | | Using REQUIRED as a prefix instead of suffix works better with OPTIONAL_COMPONENTS, and is also the order in the CMake manual. Task-number: QTBUG-98867 Pick-to: 6.2 Change-Id: I1ab68408b95d8edf06272a3b9fceccd8d8e597fc Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Fix MSVC compiler warning in code snippetsKai Köhne2021-06-081-5/+3
| | | | | | | | | Fixes warning C5046: 'testObject::MyTestObject::toString': Symbol involving type with internal linkage not defined Change-Id: I9925eb15e262f29e636c019c87311a6ea2c47505 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Fix warnings about wrong snippet path or missing .pro fileNico Vertriest2021-02-192-0/+14
| | | | | | Task-number: QTBUG-91147 Change-Id: I6a55b2b713dd70cf1cbb0b93a8d4152e175e2c4d Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* CMake: Port the snippet project setup to CMakeVenugopal Shivashankar2021-02-104-8/+86
| | | | | | | | Change-Id: I411e58e94752f3b2d0a3e8aac0ab7c4c2272db89 Fixes: QTBUG-89826 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-074-37/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Replace QtTest headers with QTestDavid Skoland2020-12-224-4/+4
| | | | | | | | | | | 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>
* Doc: Use explicit linkage with target_link_librariesKai Koehne2020-11-301-1/+1
| | | | | | | | | | | | | | The Professional CMake book suggests always using explicit linkage with target_link_libraries, so let's use that. Whether to use PUBLIC or PRIVATE depends on the context. But let's be conservative and advise on using PRIVATE by default. Task-number: QTBUG-88935 Pick-to: 6.0 Change-Id: I12b80ee85be9f6916f1e4dea6b1c9cb29e03c20f Reviewed-by: Craig Scott <craig.scott@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Doc: Fix documentation warnings for Qt TestTopi Reinio2020-11-191-1/+5
| | | | | | Task-number: QTBUG-86295 Change-Id: If3c48bee8c898a228128ade18fbdeaa2b8de8b20 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Prefer versioned CMake library targetsv6.0.0-beta3Kai Koehne2020-11-011-1/+1
| | | | | | | | The non-versioned one's do miss some properties. It's therefore best to not advocate using them. Change-Id: I53645e65ed4de4e0100e59905c024cdfe40be0c5 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Deprecate QVariant::TypeLars Knoll2020-10-231-3/+3
| | | | | | | | | It's been obsolete for a long time already. Make sure the compiler now warns about it and remove all remaining uses in qtbase. Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Update CMake snippets to Qt 6Kai Koehne2020-09-251-2/+2
| | | | | | | Change-Id: I53021781a25c141db5d5fc6771192cd8d6ed732a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix qdoc warning from broken snippetVolker Hilsheimer2020-09-231-1/+1
| | | | | Change-Id: Ieaf7676dd7406363dfd970528dd13e65b9af87c3 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Compile snippets only when running testsPaul Wicking2020-09-102-13/+17
| | | | | | | | | | Turn snippets projects into subdirs with libraries to avoid messy dependencies. Fixes: QTBUG-86497 Pick-to: 5.15 Change-Id: Idb2c43f97d56c9b8d9992617ef716bde40fff5b7 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Doc: Mention no_testcase_installs which can be used to prevent installAndy Shaw2020-08-201-0/+4
| | | | | | | Change-Id: If8044a339cab754d427fd7626dd6813c7cc99e56 Pick-to: 5.15 5.12 Fixes: QTBUG-85827 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix build of testlib doc snippetsTor Arne Vestbø2020-07-291-2/+1
| | | | | | | | The file src_qtestlib_qtestcase was built twice, causing duplicate main symbols Change-Id: I18750b87eee27603d9f56129fd6c30fddf4a4828 Reviewed-by: Nico Vertriest <nico.vertriest@qt.io>
* QTestlib: Enable comparing QList against initializer lists/arraysFriedemann Kleint2020-07-211-0/+20
| | | | | | | | | | | | | | | | | | | | | 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>
* Document how to use CMake for Qt TestLibKai Koehne2020-05-262-1/+9
| | | | | | Task-number: QTBUG-73058 Change-Id: I6e29a83a1346ea0d2f94fcf445e1de9c07072aa6 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Enable warnings-are-errors also for snippetsKai Koehne2020-05-071-0/+2
| | | | | | Pick-to: 5.15 Change-Id: I6b3645924e4f090c7887ce0d6296a71dc8f8159d Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Snippets: Fix dependency issuesKai Koehne2020-05-071-3/+0
| | | | | | | | | | | | | | | | The widget snippet was sometimes ignored, because the printsupport dependency was not explicit in the top-level src.pro file. This lead to a situation that, if printsupport by chance was already built, it was tested, otherwise silently ignored. This shows that having requires(qtHaveModule()) inside src/ is actually harmful, and they are therefore removed from snippets.pro. Also, the dependencies for the snippets projects are now moved to a central place so that the correctness is easier to check. Pick-to: 5.15 Change-Id: Ice051fa04848040e206c78361fbbcf680383c6b2 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Fix compilation of testlib snippets if sql, widgets are missingKai Koehne2020-05-051-0/+3
| | | | | Change-Id: Ibcc872408ba829085809737004d9d3186bd20bab Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Fix compilation issue with QVERIFY2 exampleKai Koehne2020-04-231-1/+1
| | | | | | | | | | | | | Fixes error C2124: divide or mod by zero when compiling the test code (enabled by 713cd83200f3c60eac5d389dfabc44be1446e2ac). Pick-to: 5.15 Change-Id: I2ae39426fc0012f79714ff3d6484d792cab4bd92 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Make Qt Test snippets compilableNico Vertriest2020-04-039-183/+396
| | | | | | Task-number: QTBUG-81498 Change-Id: I22f07cd539e5e317b6cf15eb369d59915146bd13 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Update info about building testsLeena Miettinen2019-12-061-0/+14
| | | | | | | Task-number: QTBUG-63987 Change-Id: I4b6e8f35afc9d3ca10b393a0305bbb51bf81ec26 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Qt Forward Merge Bot2019-11-061-2/+27
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf mkspecs/features/mac/default_post.prf src/corelib/tools/qsimd_p.h src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm util/qfloat16-tables/gen_qfloat16_tables.cpp Change-Id: If48fa8a3bc3c983706b609a6d3822cb67c1352a4
| * Doc: Add best-practice-info for using QVERIFY() and QCOMPARE()Leena Miettinen2019-11-011-2/+27
| | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/5.13' into 5.14Qt Forward Merge Bot2019-10-241-1/+29
|\| | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qstandardpaths_unix.cpp src/corelib/tools/qsharedpointer_impl.h tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp Change-Id: Iae95c5778dc091058f16f6db76f04a0178a9e809
| * Doc: Describe initTestCase_data() function and QFETCH_GLOBAL macroLeena Miettinen2019-10-111-1/+29
| | | | | | | | | | | | Fixes: QTBUG-24342 Change-Id: I8f8f3726c5d31e34af9bfe054572c08fc07e01e0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Introduce QSignalSpy constructor allows to spy on a meta methodVitaly Fanaskov2019-08-131-0/+48
|/ | | | | | | | | This functionality is especially convenient if meta-object system is heavily used in a test. For example, if you need to test a bunch of signals based on their names and/or argument types. Change-Id: I09a4ecbbd3d0859b5fd466d9dde7679804eb7614 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Merge remote-tracking branch 'origin/5.12' into 5.12.1Liang Qi2019-01-081-20/+31
|\ | | | | | | | | | | | | Conflicts: src/widgets/kernel/qtooltip.cpp Change-Id: Ic2f9a425359050eb56b3a4e5162cf5e3447058c8
* | Doc: Restore documentation for QTest functions in other modulesTopi Reinio2019-01-041-0/+52
|/ | | | | | | | | | | | | | 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>
* testlib: Move qtestsystem helpers to their respective modulesTor Arne Vestbø2018-07-161-20/+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>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-02-281-0/+66
|\ | | | | | | Change-Id: Ib21e6b9030b4d5363f440d082ce3df28098d1b95
| * Doc: Add doc for QSKIPNico Vertriest2018-02-281-0/+66
| | | | | | | | | | Change-Id: Ib8cd1b4926652984b41b5a05bf4dbf3214f2856f Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | Improve testlib example a bitFrederik Gladhorn2018-02-131-4/+26
|/ | | | | | | | | | | Assuming this is someone's first contact with testlib, we want to mention QCOMPARE. Make the whole thing a bit more readable instead of squeezing everything into single lines and add a bit more code. Change-Id: I76908003427277670d1199774083a3ee01b8747c Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Nico Vertriest <nico.vertriest@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>